Skip to content

Instantly share code, notes, and snippets.

@lukele
Last active December 22, 2016 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukele/152a0f3eb4f51aeb38c12a01e6941bf1 to your computer and use it in GitHub Desktop.
Save lukele/152a0f3eb4f51aeb38c12a01e6941bf1 to your computer and use it in GitHub Desktop.
Disassembly and Pseudo-code differing
Hopper Dissassembly:
00000000000478a4 mov qword [rbp+var_58], rcx ; CODE XREF=-[MCMessageGenerator _newOutgoingMessageFromTopLevelMimePart:topLevelHeaders:withPartData:]+329
00000000000478a8 lea rax, qword [_MCHeaderKeyFrom]
00000000000478af mov rdx, qword [rax]
00000000000478b2 mov rdi, rbx ; argument "instance" for method _objc_msgSend
00000000000478b5 mov qword [rbp+var_88], rbx
00000000000478bc mov rsi, r14 ; argument "selector" for method _objc_msgSend
00000000000478bf call qword [_objc_msgSend_d85c0] ; _objc_msgSend
00000000000478c5 mov rdi, rax ; argument "instance" for method imp___stubs__objc_retainAutoreleasedReturnValue
00000000000478c8 call imp___stubs__objc_retainAutoreleasedReturnValue
00000000000478cd mov r12, rax
00000000000478d0 xor ebx, ebx
00000000000478d2 test r12, r12
00000000000478d5 je loc_47902
00000000000478d7 mov r14, qword [rbp+var_48]
00000000000478db mov rdi, qword [objc_cls_ref_EAEmailAddressParser] ; argument "instance" for method _objc_msgSend
00000000000478e2 mov rsi, qword [0x1063e0] ; @selector(rawAddressFromFullAddress:), argument "selector" for method _objc_msgSend
00000000000478e9 mov rdx, r12
00000000000478ec call qword [_objc_msgSend_d85c0] ; _objc_msgSend
00000000000478f2 mov rdi, rax ; argument "instance" for method imp___stubs__objc_retainAutoreleasedReturnValue
00000000000478f5 call imp___stubs__objc_retainAutoreleasedReturnValue
00000000000478fa mov rbx, rax
00000000000478fd mov r15b, 0x1
0000000000047900 jmp loc_47909
loc_47902:
0000000000047902 mov r14, qword [rbp+var_48] ; CODE XREF=-[MCMessageGenerator _newOutgoingMessageFromTopLevelMimePart:topLevelHeaders:withPartData:]+424
0000000000047906 xor r15d, r15d
loc_47909:
0000000000047909 mov rdi, rbx ; argument "instance" for method _objc_retain, CODE XREF=-[MCMessageGenerator _newOutgoingMessageFromTopLevelMimePart:topLevelHeaders:withPartData:]+467
000000000004790c call qword [_objc_retain_d85d0] ; _objc_retain
0000000000047912 mov r13, rax
0000000000047915 mov rdi, qword [rbp+var_58] ; argument "instance" for method _objc_release
0000000000047919 call qword [_objc_release_d85c8] ; _objc_release
000000000004791f test r15b, r15b
0000000000047922 je loc_4792d
0000000000047924 mov rdi, rbx ; argument "instance" for method _objc_release
0000000000047927 call qword [_objc_release_d85c8] ; _objc_release
loc_4792d:
000000000004792d mov rdi, r12 ; argument "instance" for method _objc_release, CODE XREF=-[MCMessageGenerator _newOutgoingMessageFromTopLevelMimePart:topLevelHeaders:withPartData:]+501
0000000000047930 call qword [_objc_release_d85c8] ; _objc_release
0000000000047936 mov rcx, r13
0000000000047939 mov rbx, qword [rbp+var_88]
0000000000047940 mov qword [rbp+var_48], r14
Hopper Generated Pseudo Code:
var_58 = rcx;
rdx = @"from";
-> var_88 = 0x0; // If I read the assembly correctly, this should be set to rbx which points to a valid object.
-> r12 = [_objc_msgSend(0x0, r14) retain]; // 0x0 should be var_88 in this case.
-> LODWORD(rbx) = 0x0; // Where does this instruction come from
if (r12 != 0x0) {
r14 = var_48;
rbx = [[EAEmailAddressParser rawAddressFromFullAddress:r12] retain];
r15 = 0x1;
}
else {
r14 = var_48;
r15 = 0x0;
}
r13 = [rbx retain];
rax = [var_58 release];
if (r15 != 0x0) {
rax = [rbx release];
}
rax = [r12 release];
rcx = r13;
rbx = var_88;
var_48 = r14;
@lukele
Copy link
Author

lukele commented Dec 22, 2016

Code that in my opinion doesn't match is denoted with "->" and a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment