summaryrefslogtreecommitdiffstats
path: root/libirecovery.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2012-07-04 21:08:19 +0200
committerGravatar Nikias Bassen2012-07-04 21:08:19 +0200
commitf2aeb3b87a43ee00c8c512fa132ea79ff02be3e8 (patch)
tree63041f85e21a25f5ac87368faaf383cd3ab6d723 /libirecovery.c
parent6d9cc73e983b5e950b21f172af2a727c8711cba8 (diff)
downloadlibirecovery-f2aeb3b87a43ee00c8c512fa132ea79ff02be3e8.tar.gz
libirecovery-f2aeb3b87a43ee00c8c512fa132ea79ff02be3e8.tar.bz2
win32: workaround for reading serial number
Diffstat (limited to 'libirecovery.c')
-rw-r--r--libirecovery.c34
1 files 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) {