Created
February 21, 2013 01:45
-
-
Save numist/5001256 to your computer and use it in GitHub Desktop.
Annotated disassembly of NSFastEnumeration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function _MyEnumerator { | |
stackGuard = **__stack_chk_guard; | |
rax = objc_retain(); | |
collection = rax; | |
memset(&fastEnumerationState, 0x0, 0x40); | |
rax = [collection retain]; | |
collection = rax; | |
rax = [rax countByEnumeratingWithState:&fastEnumerationState objects:&stackbuf count:0x10]; | |
initialStackbufCount = rax; | |
if (rax != 0x0) { | |
mutations = *mutationsPtr; | |
mutationsPtrPtr = &fastEnumerationState + 0x10; | |
stackbufIndex_2 = 0x0; | |
stackbufCount = initialStackbufCount; | |
do { | |
do { | |
stackbufIndex = stackbufIndex_2; | |
stackbufCount_2 = stackbufCount; | |
if (**mutationsPtrPtr != mutations) { | |
objc_enumerationMutation(collection); | |
} | |
rdx = stackbufIndex; | |
rcx = *(stackbufPtr + rdx * 0x8); | |
member = rcx; | |
NSLog(@"%@", member, rdx, rcx); | |
rax = stackbufIndex + 0x1; | |
rcx = stackbufCount_2; | |
stackbufCount = rcx; | |
stackbufIndex_2 = rax; | |
} while (rax < rcx); | |
zero = 0x0; | |
rax = [collection countByEnumeratingWithState:&fastEnumerationState objects:&stackbuf count:0x10]; | |
stackbufIndex_2 = zero; | |
stackbufCount = rax; | |
} while (rax != 0x0); | |
} | |
[collection release]; | |
rax = [collection release]; | |
if (**__stack_chk_guard == stackGuard) { | |
return rax; | |
} | |
else { | |
rax = __stack_chk_fail(); | |
} | |
return rax; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Basic Block Input Regs: <nothing> - Killed Regs: rax rcx rdx rbp rsi rdi r8 | |
_MyEnumerator: | |
0000000100001720 55 push rbp ; XREF=0x100001af9 | |
0000000100001721 4889E5 mov rbp, rsp | |
0000000100001724 4881EC20010000 sub rsp, 0x120 | |
000000010000172b 488B05DE080000 mov rax, qword [ds:imp___got____stack_chk_guard] | |
0000000100001732 488B00 mov rax, qword [ds:rax] | |
0000000100001735 488945F8 mov qword [ss:rbp-0x120+stackGuard], rax | |
0000000100001739 E8BA040000 call imp___stubs__objc_retain | |
000000010000173e BE00000000 mov esi, 0x0 | |
0000000100001743 48BA4000000000000000 mov rdx, 0x40 | |
000000010000174d 488D7DA8 lea rdi, qword [ss:rbp-0x120+fastEnumerationState] | |
0000000100001751 488945F0 mov qword [ss:rbp-0x120+collection], rax | |
0000000100001755 E8BC040000 call imp___stubs__memset | |
000000010000175a 488B7DF0 mov rdi, qword [ss:rbp-0x120+collection] | |
000000010000175e E895040000 call imp___stubs__objc_retain | |
0000000100001763 488D55A8 lea rdx, qword [ss:rbp-0x120+fastEnumerationState] | |
0000000100001767 488D8D28FFFFFF lea rcx, qword [ss:rbp-0x120+stackbuf] | |
000000010000176e 49B81000000000000000 mov r8, 0x10 | |
0000000100001778 488B35C90A0000 mov rsi, qword [ds:objc_sel_countByEnumeratingWithState_objects_count_] ; @selector(countByEnumeratingWithState:objects:count:) | |
000000010000177f 4889C7 mov rdi, rax | |
0000000100001782 48898520FFFFFF mov qword [ss:rbp-0x120+collection], rax | |
0000000100001789 E858040000 call imp___stubs__objc_msgSend | |
000000010000178e 483D00000000 cmp rax, 0x0 | |
0000000100001794 48898518FFFFFF mov qword [ss:rbp-0x120+initialStackbufCount], rax | |
000000010000179b 0F842E010000 je 0x1000018cf | |
; Basic Block Input Regs: rbp - Killed Regs: rax rcx rdx rbp rsi | |
00000001000017a1 48B80000000000000000 mov rax, 0x0 | |
00000001000017ab 488D4DA8 lea rcx, qword [ss:rbp-0x120+fastEnumerationState] | |
00000001000017af 4881C110000000 add rcx, 0x10 | |
00000001000017b6 488B55B8 mov rdx, qword [ss:rbp-0x120+mutationsPtr] | |
00000001000017ba 488B12 mov rdx, qword [ds:rdx] | |
00000001000017bd 488BB518FFFFFF mov rsi, qword [ss:rbp-0x120+initialStackbufCount] | |
00000001000017c4 48899510FFFFFF mov qword [ss:rbp-0x120+mutations], rdx | |
00000001000017cb 48898D08FFFFFF mov qword [ss:rbp-0x120+mutationsPtrPtr], rcx | |
00000001000017d2 48898500FFFFFF mov qword [ss:rbp-0x120+stackbufIndex_2], rax | |
00000001000017d9 4889B5F8FEFFFF mov qword [ss:rbp-0x120+stackbufCount], rsi | |
; Basic Block Input Regs: rbp - Killed Regs: rax rcx rdx rbp rsi rdi | |
00000001000017e0 488B8500FFFFFF mov rax, qword [ss:rbp-0x120+stackbufIndex_2] ; XREF=0x10000186f, 0x1000018c9 | |
00000001000017e7 488B8DF8FEFFFF mov rcx, qword [ss:rbp-0x120+stackbufCount] | |
00000001000017ee 488B9508FFFFFF mov rdx, qword [ss:rbp-0x120+mutationsPtrPtr] | |
00000001000017f5 488B32 mov rsi, qword [ds:rdx] | |
00000001000017f8 488BBD10FFFFFF mov rdi, qword [ss:rbp-0x120+mutations] | |
00000001000017ff 48393E cmp qword [ds:rsi], rdi | |
0000000100001802 488985F0FEFFFF mov qword [ss:rbp-0x120+stackbufIndex], rax | |
0000000100001809 48898DE8FEFFFF mov qword [ss:rbp-0x120+stackbufCount_2], rcx | |
0000000100001810 0F840C000000 je 0x100001822 | |
; Basic Block Input Regs: rbp - Killed Regs: rdi | |
0000000100001816 488BBD20FFFFFF mov rdi, qword [ss:rbp-0x120+collection] | |
000000010000181d E8B8030000 call imp___stubs__objc_enumerationMutation | |
; Basic Block Input Regs: rbp - Killed Regs: rax rcx rdx rbp rsi rdi | |
0000000100001822 488D050F0B0000 lea rax, qword [ds:cfstring___] ; @"%@" XREF=0x100001810 | |
0000000100001829 488B4DB0 mov rcx, qword [ss:rbp-0x120+stackbufPtr] | |
000000010000182d 488B95F0FEFFFF mov rdx, qword [ss:rbp-0x120+stackbufIndex] | |
0000000100001834 488B0CD1 mov rcx, qword [ds:rcx+rdx*8] | |
0000000100001838 48894DE8 mov qword [ss:rbp-0x120+member], rcx | |
000000010000183c 488B75E8 mov rsi, qword [ss:rbp-0x120+member] | |
0000000100001840 4889C7 mov rdi, rax | |
0000000100001843 B000 mov al, 0x0 | |
0000000100001845 E878030000 call imp___stubs__NSLog | |
000000010000184a 488B85F0FEFFFF mov rax, qword [ss:rbp-0x120+stackbufIndex] | |
0000000100001851 480501000000 add rax, 0x1 | |
0000000100001857 488B8DE8FEFFFF mov rcx, qword [ss:rbp-0x120+stackbufCount_2] | |
000000010000185e 4839C8 cmp rax, rcx | |
0000000100001861 48898DF8FEFFFF mov qword [ss:rbp-0x120+stackbufCount], rcx | |
0000000100001868 48898500FFFFFF mov qword [ss:rbp-0x120+stackbufIndex_2], rax | |
000000010000186f 0F826BFFFFFF jc 0x1000017e0 | |
; Basic Block Input Regs: rbp - Killed Regs: rax rcx rdx rbp rsi rdi r8 | |
0000000100001875 48B80000000000000000 mov rax, 0x0 | |
000000010000187f 488D55A8 lea rdx, qword [ss:rbp-0x120+fastEnumerationState] | |
0000000100001883 488D8D28FFFFFF lea rcx, qword [ss:rbp-0x120+stackbuf] | |
000000010000188a 49B81000000000000000 mov r8, 0x10 | |
0000000100001894 488B35AD090000 mov rsi, qword [ds:objc_sel_countByEnumeratingWithState_objects_count_] ; @selector(countByEnumeratingWithState:objects:count:) | |
000000010000189b 488BBD20FFFFFF mov rdi, qword [ss:rbp-0x120+collection] | |
00000001000018a2 488985E0FEFFFF mov qword [ss:rbp-0x120+zero], rax | |
00000001000018a9 E838030000 call imp___stubs__objc_msgSend | |
00000001000018ae 483D00000000 cmp rax, 0x0 | |
00000001000018b4 488B8DE0FEFFFF mov rcx, qword [ss:rbp-0x120+zero] | |
00000001000018bb 48898D00FFFFFF mov qword [ss:rbp-0x120+stackbufIndex_2], rcx | |
00000001000018c2 488985F8FEFFFF mov qword [ss:rbp-0x120+stackbufCount], rax | |
00000001000018c9 0F8511FFFFFF jne 0x1000017e0 | |
; Basic Block Input Regs: rbp - Killed Regs: rax rdi | |
00000001000018cf 488BBD20FFFFFF mov rdi, qword [ss:rbp-0x120+collection] ; XREF=0x10000179b | |
00000001000018d6 E817030000 call imp___stubs__objc_release | |
00000001000018db 488B7DF0 mov rdi, qword [ss:rbp-0x120+collection] | |
00000001000018df E80E030000 call imp___stubs__objc_release | |
00000001000018e4 488B3D25070000 mov rdi, qword [ds:imp___got____stack_chk_guard] | |
00000001000018eb 488B3F mov rdi, qword [ds:rdi] | |
00000001000018ee 488B45F8 mov rax, qword [ss:rbp-0x120+stackGuard] | |
00000001000018f2 4839C7 cmp rdi, rax | |
00000001000018f5 0F8509000000 jne 0x100001904 | |
; Basic Block Input Regs: <nothing> - Killed Regs: rsp rbp | |
00000001000018fb 4881C420010000 add rsp, 0x120 | |
0000000100001902 5D pop rbp | |
0000000100001903 C3 ret | |
; Basic Block Input Regs: <nothing> - Killed Regs: <nothing> | |
0000000100001904 E807030000 call imp___stubs____stack_chk_fail ; XREF=0x1000018f5 | |
; endp | |
0000000100001909 0F1F8000000000 nop dword [ds:rax+0x0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment