The iPhone Wiki is no longer updated. Visit this article on The Apple Wiki for current information. |
Difference between revisions of "DFU 0x1227"
m (adding goto (return inbetween) didn't look like an improvement to me, also removed unnecessarily added init of s and removed empty lines) |
|||
Line 1: | Line 1: | ||
− | + | '''DFU 0x1227''' is the protocol used to talk to a device in [[DFU Mode]] or [[WTF]] v2. |
|
− | ==Protocol== |
+ | == Protocol == |
− | + | The protocol is the same as sending a file to a device in [[Recovery Mode (Protocols)|Recovery Mode]] on 2.x. |
|
− | ==Code== |
+ | == Code == |
+ | uint8_t fbuf[FBUF_LENGTH]; |
||
− | hexdump(fbuf, usb_control_msg(idev, 0x80, 6, 0x200, 0, fbuf, 0x100, 1000)); |
||
+ | uint8_t buf[100]; |
||
− | printf("WTF: "); |
||
+ | hexdump(fbuf, usb_control_msg(idev, 0x80, 6, 0x200, 0, fbuf, 0x100, 1000)); |
||
− | fgets(buf, 100, stdin); |
||
+ | printf("WTF: "); |
||
− | buf[strlen(buf) - 1] = 0; |
||
+ | buf[strlen(buf) - 1] = 0; |
||
− | int s; |
||
+ | FILE *f = fopen(buf, "rb"); |
||
− | int c = 0; |
||
+ | int s; |
||
− | if (f > 0) { |
||
+ | int c = 0; |
||
− | do { |
||
+ | if (f > 0) { |
||
− | s = fread(fbuf, 1, 0x800, f); |
||
+ | do { |
||
− | if (usb_control_msg(idev, 0x21, 1, c, 0, fbuf, s, 1000) == s) |
||
− | + | s = fread(fbuf, 1, 0x800, f); |
|
+ | if (usb_control_msg(idev, 0x21, 1, c, 0, fbuf, s, 1000) == s) |
||
− | else |
||
+ | else |
||
− | if (usb_control_msg(idev, 0xA1, 3, 0, 0, fbuf, 6, 1000) != 6|| fbuf[4] != 5) |
||
− | + | printf("x"); |
|
+ | if (usb_control_msg(idev, 0xA1, 3, 0, 0, fbuf, 6, 1000) != 6|| fbuf[4] != 5) |
||
− | c++; |
||
− | + | c++; |
|
+ | } while (s > 0); |
||
− | usb_control_msg(idev, 0xA1, 3, 0, 0, buf, 6, 1000); |
||
− | + | usb_control_msg(idev, 0xA1, 3, 0, 0, buf, 6, 1000); |
|
− | + | hexdump(buf, 6); |
|
+ | usb_control_msg(idev, 0xA1, 3, 0, 0, buf, 6, 1000); |
||
− | usb_reset(idev); |
||
+ | hexdump(buf, 6); |
||
− | fclose(f); |
||
+ | usb_reset(idev); |
||
− | } else |
||
+ | fclose(f); |
||
− | printf("file not found\n"); |
||
+ | } else |
||
− | system("PAUSE"); |
||
+ | printf("file not found\n"); |
||
− | return 0; |
||
− | + | fgets(buf, 100, stdin); |
|
− | + | printf("."); |
|
− | + | printf("%d", fbuf[4]); |
|
− | + | printf("\n"); |
|
+ | system("PAUSE"); |
||
+ | return 0; |
||
} |
} |
||
+ | |||
+ | [[Category:Protocols]] |
Revision as of 23:15, 29 December 2012
DFU 0x1227 is the protocol used to talk to a device in DFU Mode or WTF v2.
Protocol
The protocol is the same as sending a file to a device in Recovery Mode on 2.x.
Code
uint8_t fbuf[FBUF_LENGTH]; uint8_t buf[100]; hexdump(fbuf, usb_control_msg(idev, 0x80, 6, 0x200, 0, fbuf, 0x100, 1000)); printf("WTF: "); fgets(buf, 100, stdin); buf[strlen(buf) - 1] = 0; FILE *f = fopen(buf, "rb"); int s; int c = 0; if (f > 0) { do { s = fread(fbuf, 1, 0x800, f); if (usb_control_msg(idev, 0x21, 1, c, 0, fbuf, s, 1000) == s) printf("."); else printf("x"); if (usb_control_msg(idev, 0xA1, 3, 0, 0, fbuf, 6, 1000) != 6|| fbuf[4] != 5) printf("%d", fbuf[4]); c++; } while (s > 0); printf("\n"); usb_control_msg(idev, 0xA1, 3, 0, 0, buf, 6, 1000); hexdump(buf, 6); usb_control_msg(idev, 0xA1, 3, 0, 0, buf, 6, 1000); hexdump(buf, 6); usb_reset(idev); fclose(f); } else printf("file not found\n"); system("PAUSE"); return 0; }