diff options
| author | 2012-07-04 21:08:19 +0200 | |
|---|---|---|
| committer | 2012-07-04 21:08:19 +0200 | |
| commit | f2aeb3b87a43ee00c8c512fa132ea79ff02be3e8 (patch) | |
| tree | 63041f85e21a25f5ac87368faaf383cd3ab6d723 | |
| parent | 6d9cc73e983b5e950b21f172af2a727c8711cba8 (diff) | |
| download | libirecovery-f2aeb3b87a43ee00c8c512fa132ea79ff02be3e8.tar.gz libirecovery-f2aeb3b87a43ee00c8c512fa132ea79ff02be3e8.tar.bz2 | |
win32: workaround for reading serial number
| -rw-r--r-- | libirecovery.c | 34 |
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 | |||
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | _client->serial[0] = '\0'; | 195 | _client->serial[0] = '\0'; |
| 196 | irecv_get_string_descriptor_ascii(_client, 3, (unsigned char*)_client->serial, 255); | 196 | if ((sscanf(result, "\\\\?\\usb#vid_%*04x&pid_%*04x#%s#", _client->serial) != 1) || (_client->serial[0] == '\0')) { |
| 197 | if (_client->serial[0] == '\0') { | ||
| 198 | mobiledevice_closepipes(_client); | 197 | mobiledevice_closepipes(_client); |
| 199 | continue; | 198 | continue; |
| 200 | } | 199 | } |
| 201 | 200 | ||
| 201 | char* p = strchr(_client->serial, '#'); | ||
| 202 | if (p) { | ||
| 203 | *p = '\0'; | ||
| 204 | } | ||
| 205 | |||
| 206 | int j; | ||
| 207 | for (j = 0; j < strlen(_client->serial); j++) { | ||
| 208 | if (_client->serial[j] == '_') { | ||
| 209 | _client->serial[j] = ' '; | ||
| 210 | } else { | ||
| 211 | _client->serial[j] = toupper(_client->serial[j]); | ||
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 202 | if (ecid != 0) { | 215 | if (ecid != 0) { |
| 203 | char* ecid_string = strstr(_client->serial, "ECID:"); | 216 | char* ecid_string = strstr(_client->serial, "ECID:"); |
| 204 | if (ecid_string == NULL) { | 217 | if (ecid_string == NULL) { |
| @@ -262,12 +275,25 @@ irecv_error_t mobiledevice_connect(irecv_client_t* client, unsigned long long ec | |||
| 262 | } | 275 | } |
| 263 | 276 | ||
| 264 | _client->serial[0] = '\0'; | 277 | _client->serial[0] = '\0'; |
| 265 | irecv_get_string_descriptor_ascii(_client, 3, (unsigned char*)_client->serial, 255); | 278 | if ((sscanf(result, "\\\\?\\usb#vid_%*04x&pid_%*04x#%s#", _client->serial) != 1) || (_client->serial[0] == '\0')) { |
| 266 | if (_client->serial[0] == '\0') { | ||
| 267 | mobiledevice_closepipes(_client); | 279 | mobiledevice_closepipes(_client); |
| 268 | continue; | 280 | continue; |
| 269 | } | 281 | } |
| 270 | 282 | ||
| 283 | char* p = strchr(_client->serial, '#'); | ||
| 284 | if (p) { | ||
| 285 | *p = '\0'; | ||
| 286 | } | ||
| 287 | |||
| 288 | int j; | ||
| 289 | for (j = 0; j < strlen(_client->serial); j++) { | ||
| 290 | if (_client->serial[j] == '_') { | ||
| 291 | _client->serial[j] = ' '; | ||
| 292 | } else { | ||
| 293 | _client->serial[j] = toupper(_client->serial[j]); | ||
| 294 | } | ||
| 295 | } | ||
| 296 | |||
| 271 | if (ecid != 0) { | 297 | if (ecid != 0) { |
| 272 | char* ecid_string = strstr(_client->serial, "ECID:"); | 298 | char* ecid_string = strstr(_client->serial, "ECID:"); |
| 273 | if (ecid_string == NULL) { | 299 | if (ecid_string == NULL) { |
