From f2aeb3b87a43ee00c8c512fa132ea79ff02be3e8 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 4 Jul 2012 21:08:19 +0200 Subject: win32: workaround for reading serial number --- libirecovery.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/libirecovery.c b/libirecovery.c index e99c16a..aa676a0 100644 --- a/libirecovery.c +++ b/libirecovery.c @@ -193,12 +193,25 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, unsigned long long ec } _client->serial[0] = '\0'; - irecv_get_string_descriptor_ascii(_client, 3, (unsigned char*)_client->serial, 255); - if (_client->serial[0] == '\0') { + if ((sscanf(result, "\\\\?\\usb#vid_%*04x&pid_%*04x#%s#", _client->serial) != 1) || (_client->serial[0] == '\0')) { mobiledevice_closepipes(_client); continue; } + char* p = strchr(_client->serial, '#'); + if (p) { + *p = '\0'; + } + + int j; + for (j = 0; j < strlen(_client->serial); j++) { + if (_client->serial[j] == '_') { + _client->serial[j] = ' '; + } else { + _client->serial[j] = toupper(_client->serial[j]); + } + } + if (ecid != 0) { char* ecid_string = strstr(_client->serial, "ECID:"); if (ecid_string == NULL) { @@ -262,12 +275,25 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, unsigned long long ec } _client->serial[0] = '\0'; - irecv_get_string_descriptor_ascii(_client, 3, (unsigned char*)_client->serial, 255); - if (_client->serial[0] == '\0') { + if ((sscanf(result, "\\\\?\\usb#vid_%*04x&pid_%*04x#%s#", _client->serial) != 1) || (_client->serial[0] == '\0')) { mobiledevice_closepipes(_client); continue; } + char* p = strchr(_client->serial, '#'); + if (p) { + *p = '\0'; + } + + int j; + for (j = 0; j < strlen(_client->serial); j++) { + if (_client->serial[j] == '_') { + _client->serial[j] = ' '; + } else { + _client->serial[j] = toupper(_client->serial[j]); + } + } + if (ecid != 0) { char* ecid_string = strstr(_client->serial, "ECID:"); if (ecid_string == NULL) { -- cgit v1.1-32-gdbae