自制反汇编逆向分析工具 迭代第七版本 (一)

继上一版已经时隔差不多一年没有维护,现在继续开发。

当前迭代添加如下功能:

1. 反汇编代码在开展函数逻辑前进行的堆栈保存和扩展,划分出来。

2. 注释输出堆栈扩展区域,用于局部变量使用的空间范围,以rbp为坐标。

3. 注释输出函数中跳转会合点(junction,有相同跳转目标的点)的统计概貌。

4. 注释输出函数返回发生处。

5. 注释输出孤岛(island,只有经由跳转才可以进入的反汇编代码行文)的统计概貌。

6. 划分出反汇编代码中所有孤岛代码片段,在逆向译文时用"if(0) {}"的方式顺序嵌入在逆向C++译文当中。

    这些孤岛片段可以直接内联到跳转处。

 

以函数QuartzCore`+[CALayer defaultValueForKey:]为例。

QuartzCore`+[CALayer defaultValueForKey:]:
     <+0>:    pushq  %rbp
     <+1>:    movq   %rsp, %rbp
     <+4>:    pushq  %r15
     <+6>:    pushq  %r14
     <+8>:    pushq  %r13
     <+10>:   pushq  %r12
     <+12>:   pushq  %rbx
     <+13>:   subq   $0x78, %rsp
     <+17>:   xorl   %ebx, %ebx
     <+19>:   xorl   %esi, %esi
     <+21>:   movq   %rdx, %rdi
     <+24>:   callq  0x1041e107c               ; CAInternAtom
     <+29>:   movl   %eax, %r14d
     <+32>:   leaq   0x804a5(%rip), %r15       ; bool_bits + 16
     <+39>:   cmpl   $0x2d, %r14d
     <+43>:   jg     0x1041a699f               ; <+91>
     <+45>:   cmpl   $0x14, %r14d
     <+49>:   jg     0x1041a6a24               ; <+224>
     <+55>:   cmpl   $0xb, %r14d
     <+59>:   jne    0x1041a6b01               ; <+445>
     <+65>:   leaq   0x6120b(%rip), %rdi       ; "CALAYER_ALLOWS_EDGE_ANTIALIASING"
     <+72>:   leaq   0x8571d(%rip), %r13       ; @"CALayerAllowsEdgeAntialiasing"
     <+79>:   leaq   0x85736(%rip), %rbx       ; @"UIViewEdgeAntialiasing"
     <+86>:   jmp    0x1041a6b20               ; <+476>
     <+91>:   cmpl   $0x187, %r14d
     <+98>:   jg     0x1041a6a86               ; <+322>
     <+104>:  cmpl   $0x126, %r14d
     <+111>:  jg     0x1041a6b4f               ; <+523>
     <+117>:  cmpl   $0x87, %r14d
     <+124>:  jg     0x1041a6c95               ; <+849>
     <+130>:  cmpl   $0x63, %r14d
     <+134>:  jg     0x1041a6ce0               ; <+924>
     <+140>:  cmpl   $0x2e, %r14d
     <+144>:  jne    0x1041a6e32               ; <+1262>
     <+150>:  movq   0x78d0f(%rip), %r13       ; +[CALayer defaultValueForKey:]::defPhase
     <+157>:  testq  %r13, %r13
     <+160>:  jne    0x1041a700f               ; <+1739>
     <+166>:  movq   0x74ec7(%rip), %rdi       ; (void *)0x000000010337f2f0: NSValue
     <+173>:  movq   0x73e50(%rip), %rsi       ; "valueWithSize:"
     <+180>:  movq   0x79839(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+187>:  xorpd  %xmm0, %xmm0
     <+191>:  xorpd  %xmm1, %xmm1
     <+195>:  callq  *%rbx
     <+197>:  movq   0x73818(%rip), %rsi       ; "retain"
     <+204>:  movq   %rax, %rdi
     <+207>:  callq  *%rbx
     <+209>:  movq   %rax, %r13
     <+212>:  movq   %r13, 0x78cd1(%rip)       ; +[CALayer defaultValueForKey:]::defPhase
     <+219>:  jmp    0x1041a700f               ; <+1739>
     <+224>:  cmpl   $0x15, %r14d
     <+228>:  je     0x1041a6e81               ; <+1341>
     <+234>:  cmpl   $0x16, %r14d
     <+238>:  jne    0x1041a6fdd               ; <+1689>
     <+244>:  movq   0x78ca1(%rip), %r13       ; +[CALayer defaultValueForKey:]::defAnchor
     <+251>:  testq  %r13, %r13
     <+254>:  jne    0x1041a700f               ; <+1739>
     <+260>:  movq   0x74e69(%rip), %rdi       ; (void *)0x000000010337f2f0: NSValue
     <+267>:  movq   0x73bfa(%rip), %rsi       ; "valueWithPoint:"
     <+274>:  movq   0x797db(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+281>:  movsd  0x47e23(%rip), %xmm0
     <+289>:  movapd %xmm0, %xmm1
     <+293>:  callq  *%rbx
     <+295>:  movq   0x737b6(%rip), %rsi       ; "retain"
     <+302>:  movq   %rax, %rdi
     <+305>:  callq  *%rbx
     <+307>:  movq   %rax, %r13
     <+310>:  movq   %r13, 0x78c5f(%rip)       ; +[CALayer defaultValueForKey:]::defAnchor
     <+317>:  jmp    0x1041a700f               ; <+1739>
     <+322>:  cmpl   $0x19e, %r14d
     <+329>:  jg     0x1041a6bd7               ; <+659>
     <+335>:  leal   -0x188(%r14), %eax
     <+342>:  cmpl   $0x8, %eax
     <+345>:  ja     0x1041a6fdd               ; <+1689>
     <+351>:  leaq   0x582(%rip), %rcx         ; <+1768>
     <+358>:  movslq (%rcx,%rax,4), %rax
     <+362>:  addq   %rcx, %rax
     <+365>:  jmpq   *%rax
     <+367>:  movq   0x78c1e(%rip), %r13       ; +[CALayer defaultValueForKey:]::defOffset
     <+374>:  testq  %r13, %r13
     <+377>:  jne    0x1041a700f               ; <+1739>
     <+383>:  movq   0x74dee(%rip), %rdi       ; (void *)0x000000010337f2f0: NSValue
     <+390>:  movq   0x73d77(%rip), %rsi       ; "valueWithSize:"
     <+397>:  movq   0x79760(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+404>:  movsd  0x48558(%rip), %xmm1      ; CAPoint3DZero + 184
     <+412>:  xorpd  %xmm0, %xmm0
     <+416>:  callq  *%rbx
     <+418>:  movq   0x7373b(%rip), %rsi       ; "retain"
     <+425>:  movq   %rax, %rdi
     <+428>:  callq  *%rbx
     <+430>:  movq   %rax, %r13
     <+433>:  movq   %r13, 0x78bdc(%rip)       ; +[CALayer defaultValueForKey:]::defOffset
     <+440>:  jmp    0x1041a700f               ; <+1739>
     <+445>:  cmpl   $0xf, %r14d
     <+449>:  jne    0x1041a6fdd               ; <+1689>
     <+455>:  leaq   0x610db(%rip), %rdi       ; "CALAYER_ALLOWS_GROUP_OPACITY"
     <+462>:  leaq   0x855d7(%rip), %r13       ; @"CALayerAllowsGroupOpacity"
     <+469>:  leaq   0x855f0(%rip), %rbx       ; @"UIViewGroupOpacity"
     <+476>:  callq  0x1041ecd2e               ; symbol stub for: getenv
     <+481>:  testq  %rax, %rax
     <+484>:  je     0x1041a6bec               ; <+680>
     <+490>:  movq   %rax, %rdi
     <+493>:  callq  0x1041ecbfc               ; symbol stub for: atoi
     <+498>:  testl  %eax, %eax
     <+500>:  movq   0x795e1(%rip), %rax       ; (void *)0x0000000103d29ca8: kCFBooleanFalse
     <+507>:  cmovneq 0x795e1(%rip), %rax       ; (void *)0x0000000103d29ca0: kCFBooleanTrue
     <+515>:  movq   (%rax), %r13
     <+518>:  jmp    0x1041a700f               ; <+1739>
     <+523>:  cmpl   $0x14a, %r14d
     <+530>:  jg     0x1041a6cc1               ; <+893>
     <+536>:  cmpl   $0x138, %r14d
     <+543>:  jg     0x1041a6d87               ; <+1091>
     <+549>:  cmpl   $0x12c, %r14d
     <+556>:  jg     0x1041a6e74               ; <+1328>
     <+562>:  cmpl   $0x127, %r14d
     <+569>:  je     0x1041a6fd4               ; <+1680>
     <+575>:  cmpl   $0x12b, %r14d
     <+582>:  jne    0x1041a6fdd               ; <+1689>
     <+588>:  movq   0x78b71(%rip), %r13       ; +[CALayer defaultValueForKey:]::corners
     <+595>:  testq  %r13, %r13
     <+598>:  jne    0x1041a700f               ; <+1739>
     <+604>:  movq   0x74ce9(%rip), %rdi       ; (void *)0x000000010337f278: NSNumber
     <+611>:  movq   0x73502(%rip), %rsi       ; "alloc"
     <+618>:  movq   0x79683(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+625>:  callq  *%rbx
     <+627>:  movq   0x7404a(%rip), %rsi       ; "initWithUnsignedInt:"
     <+634>:  movl   $0xf, %edx
     <+639>:  movq   %rax, %rdi
     <+642>:  callq  *%rbx
     <+644>:  movq   %rax, %r13
     <+647>:  movq   %r13, 0x78b36(%rip)       ; +[CALayer defaultValueForKey:]::corners
     <+654>:  jmp    0x1041a700f               ; <+1739>
     <+659>:  leal   -0x19f(%r14), %eax
     <+666>:  cmpl   $0x1, %eax
     <+669>:  jbe    0x1041a6e81               ; <+1341>
     <+675>:  jmp    0x1041a6fdd               ; <+1689>
     <+680>:  movq   %rbx, -0x78(%rbp)
     <+684>:  movq   0x74d51(%rip), %rdi       ; (void *)0x000000010337b380: NSBundle
     <+691>:  movq   0x74012(%rip), %rsi       ; "mainBundle"
     <+698>:  movq   0x79633(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+705>:  callq  *%rbx
     <+707>:  movq   0x7400a(%rip), %rsi       ; "infoDictionary"
     <+714>:  movq   %rax, %rdi
     <+717>:  callq  *%rbx
     <+719>:  movq   %rax, %r12
     <+722>:  movq   0x735e3(%rip), %rsi       ; "objectForKey:"
     <+729>:  movq   %r12, %rdi
     <+732>:  movq   %r13, %rdx
     <+735>:  callq  *%rbx
     <+737>:  movq   %rax, %r13
     <+740>:  testq  %r13, %r13
     <+743>:  jne    0x1041a6c49               ; <+773>
     <+745>:  movq   0x735cc(%rip), %rsi       ; "objectForKey:"
     <+752>:  movq   %r12, %rdi
     <+755>:  movq   -0x78(%rbp), %rdx
     <+759>:  callq  *0x795f7(%rip)            ; (void *)0x000000010357d800: objc_msgSend
     <+765>:  movq   %rax, %r13
     <+768>:  testq  %r13, %r13
     <+771>:  je     0x1041a6c7a               ; <+822>
     <+773>:  movq   0x74c40(%rip), %rdi       ; (void *)0x000000010337f278: NSNumber
     <+780>:  movq   0x73529(%rip), %rsi       ; "class"
     <+787>:  movq   0x795da(%rip), %rax       ; (void *)0x000000010357d800: objc_msgSend
     <+794>:  movq   %rax, %rbx
     <+797>:  callq  *%rbx
     <+799>:  movq   0x735ee(%rip), %rsi       ; "isKindOfClass:"
     <+806>:  movq   %r13, %rdi
     <+809>:  movq   %rax, %rdx
     <+812>:  callq  *%rbx
     <+814>:  testb  %al, %al
     <+816>:  jne    0x1041a700f               ; <+1739>
     <+822>:  xorl   %ebx, %ebx
     <+824>:  cmpl   $0xf, %r14d
     <+828>:  jne    0x1041a6fdd               ; <+1689>
     <+834>:  movq   0x7949b(%rip), %rax       ; (void *)0x0000000103d29ca0: kCFBooleanTrue
     <+841>:  movq   (%rax), %r13
     <+844>:  jmp    0x1041a700f               ; <+1739>
     <+849>:  cmpl   $0x98, %r14d
     <+856>:  jg     0x1041a6dde               ; <+1178>
     <+862>:  cmpl   $0x88, %r14d
     <+869>:  je     0x1041a6e81               ; <+1341>
     <+875>:  cmpl   $0x98, %r14d
     <+882>:  jne    0x1041a6fdd               ; <+1689>
     <+888>:  jmp    0x1041a6d94               ; <+1104>
     <+893>:  cmpl   $0x14b, %r14d
     <+900>:  je     0x1041a6e81               ; <+1341>
     <+906>:  cmpl   $0x16c, %r14d
     <+913>:  je     0x1041a6e81               ; <+1341>
     <+919>:  jmp    0x1041a6fdd               ; <+1689>
     <+924>:  cmpl   $0x72, %r14d
     <+928>:  jg     0x1041a6ec8               ; <+1412>
     <+934>:  leal   -0x64(%r14), %eax
     <+938>:  cmpl   $0x9, %eax
     <+941>:  ja     0x1041a6fdd               ; <+1689>
     <+947>:  leaq   0x85272(%rip), %r13       ; @"resize"
     <+954>:  leaq   0x34b(%rip), %rcx         ; <+1804>
     <+961>:  movslq (%rcx,%rax,4), %rax
     <+965>:  addq   %rcx, %rax
     <+968>:  jmpq   *%rax
     <+970>:  movq   0x789e3(%rip), %r13       ; +[CALayer defaultValueForKey:]::unitRect
     <+977>:  testq  %r13, %r13
     <+980>:  jne    0x1041a700f               ; <+1739>
     <+986>:  movq   0x74b93(%rip), %rdi       ; (void *)0x000000010337f2f0: NSValue
     <+993>:  xorps  %xmm0, %xmm0
     <+996>:  movaps %xmm0, -0x50(%rbp)
     <+1000>: movapd 0x47cec(%rip), %xmm0      ; CA::RectTraits<double>::infinity + 94
     <+1008>: movapd %xmm0, -0x40(%rbp)
     <+1013>: movq   0x73b10(%rip), %rsi       ; "valueWithRect:"
     <+1020>: movq   -0x38(%rbp), %rax
     <+1024>: movq   %rax, 0x18(%rsp)
     <+1029>: movq   -0x40(%rbp), %rax
     <+1033>: movq   %rax, 0x10(%rsp)
     <+1038>: movq   -0x50(%rbp), %rax
     <+1042>: movq   -0x48(%rbp), %rcx
     <+1046>: movq   %rcx, 0x8(%rsp)
     <+1051>: movq   %rax, (%rsp)
     <+1055>: movq   0x794ce(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+1062>: callq  *%rbx
     <+1064>: movq   0x734b5(%rip), %rsi       ; "retain"
     <+1071>: movq   %rax, %rdi
     <+1074>: callq  *%rbx
     <+1076>: movq   %rax, %r13
     <+1079>: movq   %r13, 0x78976(%rip)       ; +[CALayer defaultValueForKey:]::unitRect
     <+1086>: jmp    0x1041a700f               ; <+1739>
     <+1091>: cmpl   $0x139, %r14d
     <+1098>: jne    0x1041a6fdd               ; <+1689>
     <+1104>: movq   0x78935(%rip), %r13       ; +[CALayer defaultValueForKey:]::inf
     <+1111>: testq  %r13, %r13
     <+1114>: jne    0x1041a700f               ; <+1739>
     <+1120>: movq   0x74ae5(%rip), %rdi       ; (void *)0x000000010337f278: NSNumber
     <+1127>: movq   0x732fe(%rip), %rsi       ; "alloc"
     <+1134>: movq   0x7947f(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+1141>: callq  *%rbx
     <+1143>: movq   0x73e3e(%rip), %rsi       ; "initWithDouble:"
     <+1150>: movsd  0x47ade(%rip), %xmm0
     <+1158>: movq   %rax, %rdi
     <+1161>: callq  *%rbx
     <+1163>: movq   %rax, %r13
     <+1166>: movq   %r13, 0x788f7(%rip)       ; +[CALayer defaultValueForKey:]::inf
     <+1173>: jmp    0x1041a700f               ; <+1739>
     <+1178>: cmpl   $0x99, %r14d
     <+1185>: jne    0x1041a6f4d               ; <+1545>
     <+1191>: movq   0x788f6(%rip), %r13       ; +[CALayer defaultValueForKey:]::defEdges
     <+1198>: testq  %r13, %r13
     <+1201>: jne    0x1041a700f               ; <+1739>
     <+1207>: movq   0x74a8e(%rip), %rdi       ; (void *)0x000000010337f278: NSNumber
     <+1214>: movq   0x732a7(%rip), %rsi       ; "alloc"
     <+1221>: movq   0x79428(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+1228>: callq  *%rbx
     <+1230>: movq   0x73def(%rip), %rsi       ; "initWithUnsignedInt:"
     <+1237>: movl   $0xf, %edx
     <+1242>: movq   %rax, %rdi
     <+1245>: callq  *%rbx
     <+1247>: movq   %rax, %r13
     <+1250>: movq   %r13, 0x788bb(%rip)       ; +[CALayer defaultValueForKey:]::defEdges
     <+1257>: jmp    0x1041a700f               ; <+1739>
     <+1262>: cmpl   $0x39, %r14d
     <+1266>: jne    0x1041a6fdd               ; <+1689>
     <+1272>: movq   0x788cd(%rip), %r13       ; +[CALayer defaultValueForKey:]::black
     <+1279>: testq  %r13, %r13
     <+1282>: jne    0x1041a700f               ; <+1739>
     <+1288>: movl   $0x4, %edi
     <+1293>: callq  0x1040ae7d7               ; CAGetColorSpace
     <+1298>: leaq   0x55e53(%rip), %rsi       ; +[CALayer defaultValueForKey:]::values
     <+1305>: movq   %rax, %rdi
     <+1308>: callq  0x1041ec29c               ; symbol stub for: CGColorCreate
     <+1313>: movq   %rax, %r13
     <+1316>: movq   %r13, 0x788a1(%rip)       ; +[CALayer defaultValueForKey:]::black
     <+1323>: jmp    0x1041a700f               ; <+1739>
     <+1328>: cmpl   $0x12d, %r14d
     <+1335>: jne    0x1041a6fcb               ; <+1671>
     <+1341>: movq   0x78838(%rip), %r13       ; +[CALayer defaultValueForKey:]::one
     <+1348>: testq  %r13, %r13
     <+1351>: jne    0x1041a700f               ; <+1739>
     <+1357>: movq   0x749f8(%rip), %rdi       ; (void *)0x000000010337f278: NSNumber
     <+1364>: movq   0x73211(%rip), %rsi       ; "alloc"
     <+1371>: movq   0x79392(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+1378>: callq  *%rbx
     <+1380>: movq   0x736d9(%rip), %rsi       ; "initWithInt:"
     <+1387>: movl   $0x1, %edx
     <+1392>: movq   %rax, %rdi
     <+1395>: callq  *%rbx
     <+1397>: movq   %rax, %r13
     <+1400>: movq   %r13, 0x787fd(%rip)       ; +[CALayer defaultValueForKey:]::one
     <+1407>: jmp    0x1041a700f               ; <+1739>
     <+1412>: cmpl   $0x73, %r14d
     <+1416>: jne    0x1041a6fdd               ; <+1689>
     <+1422>: movq   0x78827(%rip), %r13       ; +[CALayer defaultValueForKey:]::fullRect
     <+1429>: testq  %r13, %r13
     <+1432>: jne    0x1041a700f               ; <+1739>
     <+1438>: movq   0x749cf(%rip), %rdi       ; (void *)0x000000010337f2f0: NSValue
     <+1445>: movapd 0x47f1f(%rip), %xmm0      ; .memset_pattern + 318
     <+1453>: movapd %xmm0, -0x70(%rbp)
     <+1458>: xorpd  %xmm0, %xmm0
     <+1462>: movapd %xmm0, -0x60(%rbp)
     <+1467>: movq   0x7394a(%rip), %rsi       ; "valueWithRect:"
     <+1474>: movq   -0x58(%rbp), %rax
     <+1478>: movq   %rax, 0x18(%rsp)
     <+1483>: movq   -0x60(%rbp), %rax
     <+1487>: movq   %rax, 0x10(%rsp)
     <+1492>: movq   -0x70(%rbp), %rax
     <+1496>: movq   -0x68(%rbp), %rcx
     <+1500>: movq   %rcx, 0x8(%rsp)
     <+1505>: movq   %rax, (%rsp)
     <+1509>: movq   0x79308(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+1516>: callq  *%rbx
     <+1518>: movq   0x732ef(%rip), %rsi       ; "retain"
     <+1525>: movq   %rax, %rdi
     <+1528>: callq  *%rbx
     <+1530>: movq   %rax, %r13
     <+1533>: movq   %r13, 0x787b8(%rip)       ; +[CALayer defaultValueForKey:]::fullRect
     <+1540>: jmp    0x1041a700f               ; <+1739>
     <+1545>: cmpl   $0xb1, %r14d
     <+1552>: jne    0x1041a6fdd               ; <+1689>
     <+1558>: leaq   0x80a4f(%rip), %rax       ; kCAFillModeRemoved
     <+1565>: movq   (%rax), %r13
     <+1568>: jmp    0x1041a700f               ; <+1739>
     <+1573>: movq   0x78758(%rip), %r13       ; +[CALayer defaultValueForKey:]::three
     <+1580>: testq  %r13, %r13
     <+1583>: jne    0x1041a700f               ; <+1739>
     <+1589>: movq   0x74910(%rip), %rdi       ; (void *)0x000000010337f278: NSNumber
     <+1596>: movq   0x73129(%rip), %rsi       ; "alloc"
     <+1603>: movq   0x792aa(%rip), %rbx       ; (void *)0x000000010357d800: objc_msgSend
     <+1610>: callq  *%rbx
     <+1612>: movq   0x735f1(%rip), %rsi       ; "initWithInt:"
     <+1619>: movl   $0x3, %edx
     <+1624>: movq   %rax, %rdi
     <+1627>: callq  *%rbx
     <+1629>: movq   %rax, %r13
     <+1632>: movq   %r13, 0x7871d(%rip)       ; +[CALayer defaultValueForKey:]::three
     <+1639>: jmp    0x1041a700f               ; <+1739>
     <+1641>: movq   0x748dc(%rip), %rdi       ; (void *)0x000000010337f278: NSNumber
     <+1648>: movq   0x73725(%rip), %rsi       ; "numberWithInt:"
     <+1655>: movl   $0x1f4, %edx
     <+1660>: callq  *0x79272(%rip)            ; (void *)0x000000010357d800: objc_msgSend
     <+1666>: movq   %rax, %r13
     <+1669>: jmp    0x1041a700f               ; <+1739>
     <+1671>: cmpl   $0x134, %r14d
     <+1678>: jne    0x1041a6fdd               ; <+1689>
     <+1680>: leaq   0x83515(%rip), %r13       ; @"linear"
     <+1687>: jmp    0x1041a700f               ; <+1739>
     <+1689>: cmpl   %r14d, (%r15)
     <+1692>: je     0x1041a6ff4               ; <+1712>
     <+1694>: incq   %rbx
     <+1697>: addq   $0x20, %r15
     <+1701>: xorl   %r13d, %r13d
     <+1704>: cmpq   $0x1d, %rbx
     <+1708>: jb     0x1041a6fdd               ; <+1689>
     <+1710>: jmp    0x1041a700f               ; <+1739>
     <+1712>: movq   0x79125(%rip), %rax       ; (void *)0x0000000103d29ca8: kCFBooleanFalse
     <+1719>: movl   $0x4920a8, %ecx
     <+1724>: btq    %rbx, %rcx
     <+1728>: cmovbq 0x7911c(%rip), %rax       ; (void *)0x0000000103d29ca0: kCFBooleanTrue
     <+1736>: movq   (%rax), %r13
     <+1739>: movq   %r13, %rax
     <+1742>: addq   $0x78, %rsp
     <+1746>: popq   %rbx
     <+1747>: popq   %r12
     <+1749>: popq   %r13
     <+1751>: popq   %r14
     <+1753>: popq   %r15
     <+1755>: popq   %rbp
     <+1756>: retq   
     <+1757>: leaq   0x84fe8(%rip), %r13       ; @"stretch"
     <+1764>: jmp    0x1041a700f               ; <+1739>
     <+1766>: nop    
     <+1768>: adcb   %bh, %dh
QuartzCore`+[CALayer defaultValueForKey:]: 反汇编代码

 

功能 1-5 如下图:

通过概貌可以大概了解到这个函数的

堆栈使用,-0xa0(%rbp)到-0x30(%rbp)用作局部变量以及函数调用的参数堆栈,-0x28(%rbp)到-08x(%rbp)用作寄存现场保存,0x0(%rbp)是上一栈帧的栈基,0x8(%rbp)是返回地址。

函数返回的地方在1756处,并且有一处跳转的会合点在1739,而且非常多的跳转都跳到这个会合点。这个会合点与返回点非常近,所以可以看到这个函数的逻辑中在多处分支有返回。

这个函数有13个孤岛片段,只能够通过跳转到达,也就是有多处共用了这13个片段,在逆向分析时,可以直接内联到跳转入口。

 

再为看第6个功能点,是这个版本的重点。

当遇到孤岛片段的逆向输出如下:

// 1669
                                                            goto _f1739;
                                                            // ####
                                                            // 1671 island till 1739 {1689island1739,}
                                                            if (0) { //
                                                            _f1671:     // from 1335
                                                                     // 1671 cmpl $0x134, %r14d
                                                                     // 1678 jne 1689
                                                                if (!) { // 1671 (r14d != 0x134)
                                                                _f1680:     // from 569
                                                                         // 1680    r13 = & __cfs("linear");
                                                                         // 1687
                                                                    goto _f1739;
                                                                } // 1689
                                                                  // ####
                                                                  // 1689 island till 1739 {1712island1739,}
                                                                if (0) { //
                                                                _b1689:     // from 1708
                                                                _f1689:     // from 1552
                                                                _f1689:     // from 1416
                                                                _f1689:     // from 1266
                                                                _f1689:     // from 1098
                                                                _f1689:     // from 941
                                                                _f1689:     // from 919
                                                                _f1689:     // from 882
                                                                _f1689:     // from 828
                                                                _f1689:     // from 675
                                                                _f1689:     // from 582
                                                                _f1689:     // from 449
                                                                _f1689:     // from 345
                                                                _f1689:     // from 238
                                                                         // 1689 cmpl %r14d, (%r15)
                                                                         // 1692 je 1712
                                                                    if (!) { // 1689 ((int32_t&)r15->_0 == r14d)
                                                                             // 1694    ++rbx;
                                                                             // 1697    r15 = r15 + 0x20;
                                                                             // 1701    r13d = 0;
                                                                             // 1704 cmpq $0x1d, %rbx
                                                                             // 1708
                                                                        if () // 1704 (rbx < 0x1d)
                                                                            goto _b1689;
                                                                        // 1710
                                                                        goto _f1739;
                                                                    } // 1712
                                                                      // ####
                                                                      // 1712 island till 1739 {}
                                                                    if (0) { //
                                                                             // 1712    rax = (void *)0x0000000103d29ca8: kCFBooleanFalse;
                                                                             // 1719    ecx = 0x4920a8;
                                                                             // 1724 btq %rbx, %rcx
                                                                             // 1728    rax = (0 != (rcx & (1<<rbx))) ? (void *)0x0000000103d29ca0: kCFBooleanTrue : rax;
                                                                             // 1736    r13 = rax->_0;
                                                                    } // 1739 island form 1712
                                                                } // 1739 island form 1689
                                                            } // 1739 island form 1671
片段

我们阅读一个故事,会习惯于按顺序去理清脉络,当你跟着反汇编代码跳转跳几次你就会迷失,不再想看下去,因为我们用了我们不擅长的方式。如果我们知道故事中主干和分支在何处划分的,哪些是插叙,插叙的故事又包含了哪些小故事,哪些小故事被多次引用等等。我们就可以清晰故事的框架,并且有条不紊地还原出整个故事出来。上面的孤岛片段,就像插叙一样。“if(0) {}”表示这里有一个故事或一堆小故事,但是跟你读到的情节发展无关,你可以跳过这一块继续你的情节。控制流也一样,“if(0) {}”是永远不会进入的,如果你想通过这个条件判断进入的话。除此之外,你还可以用goto强制进入这个控制域内的。goto就是主干和分支跟这些零碎的片段的唯一联系,goto指明了这些零碎的片段在主干和分支发生的地点或时间顺序,将它们联系在一起就还原出一整个故事。也就说最后将孤岛片段内联到goto的地方上。

上面的逆向代码显示了这一用途。但是出现了一小点问题,上图的蓝色字描述。孤岛片段不是绝对固定的,而是跟据你选取的角度。如上面的1678处逆向译成

// 1678 jne 1689
if () {// 1671 (r14d != 0x134)
  // gen jmp 1689
  goto _f1689;
} // 1680    r13 = & __cfs("linear");// 1687
goto _f1739;

_b1689:     // from 1708
_f1689:     // from 1678
_f1689:     // from 1416
_f1689:     // from 1266
_f1689:     // from 1098
_f1689:     // from 941
_f1689:     // from 919
_f1689:     // from 882
_f1689:     // from 828
_f1689:     // from 675
_f1689:     // from 582
_f1689:     // from 449
_f1689:     // from 345
_f1689:     // from 238

要进入1689就必须通过跳转。

 

修改BUG后的逆向输出结果是:

// 1669
                                                        goto _f1739;
                                                        // ####
                                                        // 1671 island till 1739 {}
                                                        if (0) { //
                                                        _f1671:     // from 1335
                                                                 // 1671 cmpl $0x134, %r14d
                                                                 // 1678 jne 1689
                                                            if (!) { // 1671 (r14d != 0x134)
                                                            _f1680:     // from 569
                                                                     // 1680    r13 = & __cfs("linear");
                                                                     // 1687
                                                                goto _f1739;
                                                            } // 1689
                                                        _b1689:     // from 1708
                                                        _f1689:     // from 1552
                                                        _f1689:     // from 1416
                                                        _f1689:     // from 1266
                                                        _f1689:     // from 1098
                                                        _f1689:     // from 941
                                                        _f1689:     // from 919
                                                        _f1689:     // from 882
                                                        _f1689:     // from 828
                                                        _f1689:     // from 675
                                                        _f1689:     // from 582
                                                        _f1689:     // from 449
                                                        _f1689:     // from 345
                                                        _f1689:     // from 238
                                                                 // 1689 cmpl %r14d, (%r15)
                                                                 // 1692 je 1712
                                                            if (!) { // 1689 ((int32_t&)r15->_0 == r14d)
                                                                     // 1694    ++rbx;
                                                                     // 1697    r15 = r15 + 0x20;
                                                                     // 1701    r13d = 0;
                                                                     // 1704 cmpq $0x1d, %rbx
                                                                     // 1708
                                                                if () // 1704 (rbx < 0x1d)
                                                                    goto _b1689;
                                                                // 1710
                                                                goto _f1739;
                                                            } // 1712
                                                              // 1712    rax = (void *)0x0000000103d29ca8: kCFBooleanFalse;
                                                              // 1719    ecx = 0x4920a8;
                                                              // 1724 btq %rbx, %rcx
                                                              // 1728    rax = (0 != (rcx & (1<<rbx))) ? (void *)0x0000000103d29ca0: kCFBooleanTrue : rax;
                                                              // 1736    r13 = rax->_0;
                                                        } // 1739 island form 1671
修正BUG后的结果

整个函数的逆向代码,只有分支的版本

// +[CALayer defaultValueForKey:]
void CALayer20_defaultValueForKey3A_(id self, SEL sel, uintptr_t defaultValueForKey)
{
    // local variables location from -0x30(%rbp) to -0xa0(%rbp), total 0x78bytes(, 15 longlongwords) 

    // there are 10 island(s) in total. and the island would be presented in form of "if(0) {}" in sequence.
    // return(s) take(s) palce at 1756.
    // there are 3 junction(s) in total. and they are:
    // . to 1341 from 228, 669, 869, 900, 913, 
    // . to 1689 from 345, 449, 582, 675, 828, 882, 919, 941, 1098, 1266, 1416, 1552, 1678, 1708, 
    // . to 1739 from 160, 219, 254, 317, 377, 440, 518, 598, 654, 816, 844, 980, 1086, 1114, 1173, 1201, 1257, 1282, 1323, 1351, 1407, 1432, 1540, 1568, 1583, 1639, 1669, 1687, 1710, 1764, 
    // 43 jg 91
    if () { // 39 (r14d > 0x2d)
            // gen jmp 91
        goto _f91;
    } // 49 jg 224
    else if () { // 45 (r14d > 0x14)
                 // gen jmp 224
        goto _f224;
    } // 59 jne 445
    else if () { // 55 (r14d != 0xb)
                 // gen jmp 445
        goto _f445;
    }
    else { // 59 next
           // 86
        goto _f476;
    } // 91
_f91:     // from 43
         // 98 jg 322
    if () { // 91 (r14d > 0x187)
            // gen jmp 322
        goto _f322;
    } // 111 jg 523
    else if () { // 104 (r14d > 0x126)
                 // gen jmp 523
        goto _f523;
    } // 124 jg 849
    else if () { // 117 (r14d > 0x87)
                 // gen jmp 849
        goto _f849;
    } // 134 jg 924
    else if () { // 130 (r14d > 0x63)
                 // gen jmp 924
        goto _f924;
    } // 144 jne 1262
    else if () { // 140 (r14d != 0x2e)
                 // gen jmp 1262
        goto _f1262;
    } // 160 jne 1739
    else if () { // 157 (0 != r13)
                 // gen jmp 1739
        goto _f1739;
    }
    else { // 160 next
    } // 219
      // 219
    goto _f1739;
_f224:     // from 49
         // 228 je 1341
    if () { // 224 (r14d == 0x15)
            // gen jmp 1341
        goto _f1341;
    } // 238 jne 1689
    else if () { // 234 (r14d != 0x16)
                 // gen jmp 1689
        goto _f1689;
    } // 254 jne 1739
    else if () { // 251 (0 != r13)
                 // gen jmp 1739
        goto _f1739;
    }
    else { // 254 next
    } // 317
      // 317
    goto _f1739;
_f322:     // from 98
         // 329 jg 659
    if () { // 322 (r14d > 0x19e)
            // gen jmp 659
        goto _f659;
    } // 345 ja 1689
    else if () { // 342 (eax > 0x8)
                 // gen jmp 1689
        goto _f1689;
    } // 377 jne 1739
    else if () { // 374 (0 != r13)
                 // gen jmp 1739
        goto _f1739;
    }
    else { // 377 next
    } // 440
      // 440
    goto _f1739;
_f445:     // from 59
         // 449 jne 1689
    if () { // 445 (r14d != 0xf)
            // gen jmp 1689
        goto _f1689;
    _f476:     // from 86
    } // 484 je 680
    else if () { // 481 (0 == rax)
                 // gen jmp 680
        goto _f680;
    }
    else { // 484 next
    } // 518
      // 518
    goto _f1739;
_f523:     // from 111
         // 530 jg 893
    if () { // 523 (r14d > 0x14a)
            // gen jmp 893
        goto _f893;
    } // 543 jg 1091
    else if () { // 536 (r14d > 0x138)
                 // gen jmp 1091
        goto _f1091;
    } // 556 jg 1328
    else if () { // 549 (r14d > 0x12c)
                 // gen jmp 1328
        goto _f1328;
    } // 569 je 1680
    else if () { // 562 (r14d == 0x127)
                 // gen jmp 1680
        goto _f1680;
    } // 582 jne 1689
    else if () { // 575 (r14d != 0x12b)
                 // gen jmp 1689
        goto _f1689;
    } // 598 jne 1739
    else if () { // 595 (0 != r13)
                 // gen jmp 1739
        goto _f1739;
    }
    else { // 598 next
    } // 654
      // 654
    goto _f1739;
_f659:     // from 329
         // 669 jbe 1341
    if () { // 666 (eax <= 0x1)
            // gen jmp 1341
        goto _f1341;
    }
    else { // 669 next
    } // 675
      // 675
    goto _f1689;
_f680:     // from 484
         // 743 jne 773
    if () { // 740 (0 != r13)
            // gen jmp 773
        goto _f773;
    } // 771 je 822
    else if () { // 768 (0 == r13)
                 // gen jmp 822
        goto _f822;
    }
    else { // 771 next
    } // 773
_f773:     // from 743
         // 816 jne 1739
    if () { // 814 (0 != al)
            // gen jmp 1739
        goto _f1739;
    }
    else { // 816 next
    _f822:     // from 771
             // 828 jne 1689
        if () // 824 (r14d != 0xf)
              // gen jmp 1689
            goto _f1689;
        // 844
        goto _f1739;
        // ####
        // 849 island till 1739 {}
        if (0) { //
        _f849:     // from 124
                 // 856 jg 1178
            if () { // 849 (r14d > 0x98)
                    // gen jmp 1178
                goto _f1178;
            }
            else { // 856 next
                   // 869 je 1341
                if () // 862 (r14d == 0x88)
                      // gen jmp 1341
                    goto _f1341;
                // 882 jne 1689
                if () // 875 (r14d != 0x98)
                      // gen jmp 1689
                    goto _f1689;
                // 888
                goto _f1104;
                // ####
                // 893 island till 1104 {924island1086,}
                if (0) { //
                _f893:     // from 530
                         // 900 je 1341
                    if () // 893 (r14d == 0x14b)
                          // gen jmp 1341
                        goto _f1341;
                    // 913 je 1341
                    if () // 906 (r14d == 0x16c)
                          // gen jmp 1341
                        goto _f1341;
                    // 919
                    goto _f1689;
                    // ####
                    // 924 island till 1086 {}
                    if (0) { //
                    _f924:     // from 134
                             // 928 jg 1412
                        if () {// 924 (r14d > 0x72)
                               // gen jmp 1412
                            goto _f1412;
                        } // 941 ja 1689
                        else if () { // 938 (eax > 0x9)
                                     // gen jmp 1689
                            goto _f1689;
                        } // 980 jne 1739
                        else if () { // 977 (0 != r13)
                                     // gen jmp 1739
                            goto _f1739;
                        }
                        else { // 980 next
                        } // 981 
                    } // 1086 island form 924
                _f1086:     // from 924
                         // 1086
                    goto _f1739;
                _f1091:     // from 543
                         // 1098 jne 1689
                    if () // 1091 (r14d != 0x139)
                          // gen jmp 1689
                        goto _f1689;
                } // 1104 island form 893
            _f1104:     // from 888
            _f1104:     // from 893
                     // 1114 jne 1739
                if () // 1111 (0 != r13)
                      // gen jmp 1739
                    goto _f1739;
                // 1173
                goto _f1739;
            } // 1178
        _f1178:     // from 856
                 // 1185 jne 1545
            if () // 1178 (r14d != 0x99)
                  // gen jmp 1545
                goto _f1545;
            // 1201 jne 1739
            if (!) { // 1198 (0 != r13)
                     // 1257
                goto _f1739;
                // ####
                // 1262 island till 1739 {}
                if (0) { //
                _f1262:     // from 144
                         // 1266 jne 1689
                    if () // 1262 (r14d != 0x39)
                          // gen jmp 1689
                        goto _f1689;
                    // 1282 jne 1739
                    if (!) { // 1279 (0 != r13)
                             // 1323
                        goto _f1739;
                        // ####
                        // 1328 island till 1739 {}
                        if (0) { //
                        _f1328:     // from 556
                                 // 1335 jne 1671
                            if () // 1328 (r14d != 0x12d)
                                  // gen jmp 1671
                                goto _f1671;
                        _f1341:     // from 228
                        _f1341:     // from 869
                        _f1341:     // from 900
                        _f1341:     // from 913
                                 // 1351 jne 1739
                            if (!) { // 1348 (0 != r13)
                                     // 1407
                                goto _f1739;
                                // ####
                                // 1412 island till 1739 {}
                                if (0) { //
                                _f1412:     // from 928
                                         // 1416 jne 1689
                                    if () // 1412 (r14d != 0x73)
                                          // gen jmp 1689
                                        goto _f1689;
                                    // 1432 jne 1739
                                    if (!) { // 1429 (0 != r13)
                                             // 1540
                                        goto _f1739;
                                        // ####
                                        // 1545 island till 1739 {1573island1739,}
                                        if (0) { //
                                        _f1545:     // from 1185
                                                 // 1552 jne 1689
                                            if () // 1545 (r14d != 0xb1)
                                                  // gen jmp 1689
                                                goto _f1689;
                                            // 1568
                                            goto _f1739;
                                            // ####
                                            // 1573 island till 1739 {}
                                            if (0) { //
                                                     // 1583 jne 1739
                                                if (!) { // 1580 (0 != r13)
                                                         // 1639
                                                    goto _f1739;
                                                    // ####
                                                    // 1641 island till 1739 {1671island1739,}
                                                    if (0) { //
                                                             // 1669
                                                        goto _f1739;
                                                        // ####
                                                        // 1671 island till 1739 {}
                                                        if (0) { //
                                                        _f1671:     // from 1335
                                                                 // 1678 jne 1689
                                                            if (!) { // 1671 (r14d != 0x134)
                                                            _f1680:     // from 569
                                                                     // 1687
                                                                goto _f1739;
                                                            } // 1689
                                                        _f1689:     // from 238
                                                        _f1689:     // from 345
                                                        _f1689:     // from 449
                                                        _f1689:     // from 582
                                                        _f1689:     // from 675
                                                        _f1689:     // from 828
                                                        _f1689:     // from 882
                                                        _f1689:     // from 919
                                                        _f1689:     // from 941
                                                        _f1689:     // from 1098
                                                        _f1689:     // from 1266
                                                        _f1689:     // from 1416
                                                        _f1689:     // from 1552
                                                        _b1689:     // from 1708
                                                                 // 1692 je 1712
                                                            if (!) { // 1689 ((int32_t&)r15->_0 == r14d)
                                                                     // 1708
                                                                if () // 1704 (rbx < 0x1d)
                                                                    goto _b1689;
                                                                // 1710
                                                                goto _f1739;
                                                            } // 1712
                                                        } // 1739 island form 1671
                                                    } // 1739 island form 1641
                                                } // 1739
                                            } // 1739 island form 1573
                                        } // 1739 island form 1545
                                    } // 1739
                                } // 1739 island form 1412
                            } // 1739
                        } // 1739 island form 1328
                    } // 1739
                } // 1739 island form 1262
            } // 1739
        } // 1739 island form 849
    } // 1739
_f1739:     // from 160
_f1739:     // from 219
_f1739:     // from 254
_f1739:     // from 317
_f1739:     // from 377
_f1739:     // from 440
_f1739:     // from 518
_f1739:     // from 598
_f1739:     // from 654
_f1739:     // from 816
_f1739:     // from 844
_f1739:     // from 980
_f1739:     // from 1086
_f1739:     // from 1114
_f1739:     // from 1173
_f1739:     // from 1178
_f1739:     // from 1257
_f1739:     // from 1262
_f1739:     // from 1323
_f1739:     // from 1328
_f1739:     // from 1407
_f1739:     // from 1412
_f1739:     // from 1540
_f1739:     // from 1545
_f1739:     // from 1568
_f1739:     // from 1639
_f1739:     // from 1669
_f1739:     // from 1687
_f1739:     // from 1710
_b1739:     // from 1764
         // 1756 ret
    return;
    // 1764
    goto _b1739;
}
+[CALayer defaultValueForKey:] 逆向只有分支

完事的版本

// +[CALayer defaultValueForKey:]
void CALayer20_defaultValueForKey3A_(id self, SEL sel, uintptr_t defaultValueForKey)
{
    // 0 pushq %rbp
    // 1    rbp = rsp;
    // 4 pushq %r15
    // 6 pushq %r14
    // 8 pushq %r13
    // 10 pushq %r12
    // 12 pushq %rbx
    // 13    rsp = rsp - 0x78;
    // there are 3 junction(s) in total. and they are:
    // . to 1341 from 228, 669, 869, 900, 913, 
    // . to 1689 from 345, 449, 582, 675, 828, 882, 919, 941, 1098, 1266, 1416, 1552, 1678, 1708, 
    // . to 1739 from 160, 219, 254, 317, 377, 440, 518, 598, 654, 816, 844, 980, 1086, 1114, 1173, 1201, 1257, 1282, 1323, 1351, 1407, 1432, 1540, 1568, 1583, 1639, 1669, 1687, 1710, 1764, 
    // return(s) take(s) palce at 1756.
    // there are 10 island(s) in total. and the island would be presented in form of "if(0) {}" in sequence.
    // local variables location from -0x30(%rbp) to -0xa0(%rbp), total 0x78bytes(, 15 longlongwords) 

    // 17    ebx = 0;
    // 19    esi = 0;
    // 21    rdi = rdx;
    // 24 call
    CAInternAtom((NSString*)rdx);
    // 29    r14d = eax;
    // 32    r15 = & bool_bits + 16;
    // 39 cmpl $0x2d, %r14d
    // 43 jg 91
    if () { // 39 (r14d > 0x2d)
            // gen jmp 91
        goto _f91;
        // 45 cmpl $0x14, %r14d
    } // 49 jg 224
    else if () { // 45 (r14d > 0x14)
                 // gen jmp 224
        goto _f224;
        // 55 cmpl $0xb, %r14d
    } // 59 jne 445
    else if () { // 55 (r14d != 0xb)
                 // gen jmp 445
        goto _f445;
    }
    else { // 59 next
           // 65    rdi = & "CALAYER_ALLOWS_EDGE_ANTIALIASING";
           // 72    r13 = & __cfs("CALayerAllowsEdgeAntialiasing");
           // 79    rbx = & __cfs("UIViewEdgeAntialiasing");
           // 86
        goto _f476;
    } // 91
_f91:     // from 43
         // 91 cmpl $0x187, %r14d
         // 98 jg 322
    if () { // 91 (r14d > 0x187)
            // gen jmp 322
        goto _f322;
        // 104 cmpl $0x126, %r14d
    } // 111 jg 523
    else if () { // 104 (r14d > 0x126)
                 // gen jmp 523
        goto _f523;
        // 117 cmpl $0x87, %r14d
    } // 124 jg 849
    else if () { // 117 (r14d > 0x87)
                 // gen jmp 849
        goto _f849;
        // 130 cmpl $0x63, %r14d
    } // 134 jg 924
    else if () { // 130 (r14d > 0x63)
                 // gen jmp 924
        goto _f924;
        // 140 cmpl $0x2e, %r14d
    } // 144 jne 1262
    else if () { // 140 (r14d != 0x2e)
                 // gen jmp 1262
        goto _f1262;
        // 150    r13 = +[CALayer defaultValueForKey:]::defPhase;
        // 157 testq %r13, %r13
    } // 160 jne 1739
    else if () { // 157 (0 != r13)
                 // gen jmp 1739
        goto _f1739;
    }
    else { // 160 next
           // 166    rdi = (void *)0x000000010337f2f0: NSValue;
           // 173    rsi = "valueWithSize:";
           // 180    rbx = (void *)0x000000010357d800: objc_msgSend;
           // 187    xmm0 = 0.; ;
           // 191    xmm1 = 0.; ;
           // 195 call
        objc_msgSend(NSValue, "valueWithSize:", ...);
        // 197    rsi = "retain";
        // 204    rdi = rax;
        // 207 call
        objc_msgSend(rax, "retain");
        // 209    r13 = rax;
        // 212     +[CALayer defaultValueForKey:]::defPhase = r13;
    } // 219
      // 219
    goto _f1739;
_f224:     // from 49
         // 224 cmpl $0x15, %r14d
         // 228 je 1341
    if () { // 224 (r14d == 0x15)
            // gen jmp 1341
        goto _f1341;
        // 234 cmpl $0x16, %r14d
    } // 238 jne 1689
    else if () { // 234 (r14d != 0x16)
                 // gen jmp 1689
        goto _f1689;
        // 244    r13 = +[CALayer defaultValueForKey:]::defAnchor;
        // 251 testq %r13, %r13
    } // 254 jne 1739
    else if () { // 251 (0 != r13)
                 // gen jmp 1739
        goto _f1739;
    }
    else { // 254 next
           // 260    rdi = (void *)0x000000010337f2f0: NSValue;
           // 267    rsi = "valueWithPoint:";
           // 274    rbx = (void *)0x000000010357d800: objc_msgSend;
           // 281    xmm0.sd = (double&); ;
           // 289    xmm1.pd[0] = xmm0.pd[0]; xmm1.pd[1] = xmm0.pd[1]; ;
           // 293 call
        objc_msgSend(NSValue, "valueWithPoint:", ...);
        // 295    rsi = "retain";
        // 302    rdi = rax;
        // 305 call
        objc_msgSend(rax, "retain");
        // 307    r13 = rax;
        // 310     +[CALayer defaultValueForKey:]::defAnchor = r13;
    } // 317
      // 317
    goto _f1739;
_f322:     // from 98
         // 322 cmpl $0x19e, %r14d
         // 329 jg 659
    if () { // 322 (r14d > 0x19e)
            // gen jmp 659
        goto _f659;
        // 335    eax = r14 - 0x188;
        // 342 cmpl $0x8, %eax
    } // 345 ja 1689
    else if () { // 342 (eax > 0x8)
                 // gen jmp 1689
        goto _f1689;
        // 351    rcx = & <+1768>;
        // 358    rax = (int64_t)(int32_t&)((int32_t*)rcx)[rax];
        // 362    rax = rax + rcx;
        // 365 jmpq *%rax
        // 367    r13 = +[CALayer defaultValueForKey:]::defOffset;
        // 374 testq %r13, %r13
    } // 377 jne 1739
    else if () { // 374 (0 != r13)
                 // gen jmp 1739
        goto _f1739;
    }
    else { // 377 next
           // 383    rdi = (void *)0x000000010337f2f0: NSValue;
           // 390    rsi = "valueWithSize:";
           // 397    rbx = (void *)0x000000010357d800: objc_msgSend;
           // 404    xmm1.sd = (double&) CAPoint3DZero + 184; ;
           // 412    xmm0 = 0.; ;
           // 416 call
        objc_msgSend(NSValue, "valueWithSize:", ...);
        // 418    rsi = "retain";
        // 425    rdi = rax;
        // 428 call
        objc_msgSend(rax, "retain");
        // 430    r13 = rax;
        // 433     +[CALayer defaultValueForKey:]::defOffset = r13;
    } // 440
      // 440
    goto _f1739;
_f445:     // from 59
         // 445 cmpl $0xf, %r14d
         // 449 jne 1689
    if () { // 445 (r14d != 0xf)
            // gen jmp 1689
        goto _f1689;
        // 455    rdi = & "CALAYER_ALLOWS_GROUP_OPACITY";
        // 462    r13 = & __cfs("CALayerAllowsGroupOpacity");
        // 469    rbx = & __cfs("UIViewGroupOpacity");
    _f476:     // from 86
             // 476 call
        getenv;
        // 481 testq %rax, %rax
    } // 484 je 680
    else if () { // 481 (0 == rax)
                 // gen jmp 680
        goto _f680;
    }
    else { // 484 next
           // 490    rdi = rax;
           // 493 call
        atoi;
        // 498 testl %eax, %eax
        // 500    rax = (void *)0x0000000103d29ca8: kCFBooleanFalse;
        // 507    rax = (0 != eax) ? (void *)0x0000000103d29ca0: kCFBooleanTrue : rax;
        // 515    r13 = rax->_0;
    } // 518
      // 518
    goto _f1739;
_f523:     // from 111
         // 523 cmpl $0x14a, %r14d
         // 530 jg 893
    if () { // 523 (r14d > 0x14a)
            // gen jmp 893
        goto _f893;
        // 536 cmpl $0x138, %r14d
    } // 543 jg 1091
    else if () { // 536 (r14d > 0x138)
                 // gen jmp 1091
        goto _f1091;
        // 549 cmpl $0x12c, %r14d
    } // 556 jg 1328
    else if () { // 549 (r14d > 0x12c)
                 // gen jmp 1328
        goto _f1328;
        // 562 cmpl $0x127, %r14d
    } // 569 je 1680
    else if () { // 562 (r14d == 0x127)
                 // gen jmp 1680
        goto _f1680;
        // 575 cmpl $0x12b, %r14d
    } // 582 jne 1689
    else if () { // 575 (r14d != 0x12b)
                 // gen jmp 1689
        goto _f1689;
        // 588    r13 = +[CALayer defaultValueForKey:]::corners;
        // 595 testq %r13, %r13
    } // 598 jne 1739
    else if () { // 595 (0 != r13)
                 // gen jmp 1739
        goto _f1739;
    }
    else { // 598 next
           // 604    rdi = (void *)0x000000010337f278: NSNumber;
           // 611    rsi = "alloc";
           // 618    rbx = (void *)0x000000010357d800: objc_msgSend;
           // 625 call
        objc_msgSend(NSNumber, "alloc");
        // 627    rsi = "initWithUnsignedInt:";
        // 634    edx = 0xf;
        // 639    rdi = rax;
        // 642 call
        objc_msgSend(rax, "initWithUnsignedInt:", ...);
        // 644    r13 = rax;
        // 647     +[CALayer defaultValueForKey:]::corners = r13;
    } // 654
      // 654
    goto _f1739;
_f659:     // from 329
         // 659    eax = r14 - 0x19f;
         // 666 cmpl $0x1, %eax
         // 669 jbe 1341
    if () { // 666 (eax <= 0x1)
            // gen jmp 1341
        goto _f1341;
    }
    else { // 669 next
    } // 675
      // 675
    goto _f1689;
_f680:     // from 484
         // 680    _78 = rbx;
         // 684    rdi = (void *)0x000000010337b380: NSBundle;
         // 691    rsi = "mainBundle";
         // 698    rbx = (void *)0x000000010357d800: objc_msgSend;
         // 705 call
    objc_msgSend(NSBundle, "mainBundle");
    // 707    rsi = "infoDictionary";
    // 714    rdi = rax;
    // 717 call
    objc_msgSend(rax, "infoDictionary");
    // 719    r12 = rax;
    // 722    rsi = "objectForKey:";
    // 729    rdi = r12;
    // 732    rdx = r13;
    // 735 call
    objc_msgSend(r12, "objectForKey:", ...);
    // 737    r13 = rax;
    // 740 testq %r13, %r13
    // 743 jne 773
    if () { // 740 (0 != r13)
            // gen jmp 773
        goto _f773;
        // 745    rsi = "objectForKey:";
        // 752    rdi = r12;
        // 755    rdx = _78;
        // 759 call
        objc_msgSend(r12, "objectForKey:", ...);
        // 765    r13 = rax;
        // 768 testq %r13, %r13
    } // 771 je 822
    else if () { // 768 (0 == r13)
                 // gen jmp 822
        goto _f822;
    }
    else { // 771 next
    } // 773
_f773:     // from 743
         // 773    rdi = (void *)0x000000010337f278: NSNumber;
         // 780    rsi = "class";
         // 787    rax = (void *)0x000000010357d800: objc_msgSend;
         // 794    rbx = rax;
         // 797 call
    objc_msgSend(NSNumber, "class");
    // 799    rsi = "isKindOfClass:";
    // 806    rdi = r13;
    // 809    rdx = rax;
    // 812 call
    objc_msgSend(r13, "isKindOfClass:", ...);
    // 814 testb %al, %al
    // 816 jne 1739
    if () { // 814 (0 != al)
            // gen jmp 1739
        goto _f1739;
    }
    else { // 816 next
    _f822:     // from 771
             // 822    ebx = 0;
             // 824 cmpl $0xf, %r14d
             // 828 jne 1689
        if () // 824 (r14d != 0xf)
              // gen jmp 1689
            goto _f1689;
        // 834    rax = (void *)0x0000000103d29ca0: kCFBooleanTrue;
        // 841    r13 = rax->_0;
        // 844
        goto _f1739;
        // ####
        // 849 island till 1739 {}
        if (0) { //
        _f849:     // from 124
                 // 849 cmpl $0x98, %r14d
                 // 856 jg 1178
            if () { // 849 (r14d > 0x98)
                    // gen jmp 1178
                goto _f1178;
            }
            else { // 856 next
                   // 862 cmpl $0x88, %r14d
                   // 869 je 1341
                if () // 862 (r14d == 0x88)
                      // gen jmp 1341
                    goto _f1341;
                // 875 cmpl $0x98, %r14d
                // 882 jne 1689
                if () // 875 (r14d != 0x98)
                      // gen jmp 1689
                    goto _f1689;
                // 888
                goto _f1104;
                // ####
                // 893 island till 1104 {924island1086,}
                if (0) { //
                _f893:     // from 530
                         // 893 cmpl $0x14b, %r14d
                         // 900 je 1341
                    if () // 893 (r14d == 0x14b)
                          // gen jmp 1341
                        goto _f1341;
                    // 906 cmpl $0x16c, %r14d
                    // 913 je 1341
                    if () // 906 (r14d == 0x16c)
                          // gen jmp 1341
                        goto _f1341;
                    // 919
                    goto _f1689;
                    // ####
                    // 924 island till 1086 {}
                    if (0) { //
                    _f924:     // from 134
                             // 924 cmpl $0x72, %r14d
                             // 928 jg 1412
                        if () {// 924 (r14d > 0x72)
                               // gen jmp 1412
                            goto _f1412;
                            // 934    eax = r14 - 0x64;
                            // 938 cmpl $0x9, %eax
                        } // 941 ja 1689
                        else if () { // 938 (eax > 0x9)
                                     // gen jmp 1689
                            goto _f1689;
                            // 947    r13 = & __cfs("resize");
                            // 954    rcx = & <+1804>;
                            // 961    rax = (int64_t)(int32_t&)((int32_t*)rcx)[rax];
                            // 965    rax = rax + rcx;
                            // 968 jmpq *%rax
                            // 970    r13 = +[CALayer defaultValueForKey:]::unitRect;
                            // 977 testq %r13, %r13
                        } // 980 jne 1739
                        else if () { // 977 (0 != r13)
                                     // gen jmp 1739
                            goto _f1739;
                        }
                        else { // 980 next
                               // 986    rdi = (void *)0x000000010337f2f0: NSValue;
                               // 993    xmm0 = 0.; ;
                               // 996    ((float*)&_50)[0] = xmm0.ps[0]; ((float*)&_50)[1] = xmm0.ps[1]; ((float*)&_50)[2] = xmm0.ps[2]; ((float*)&_50)[3] = xmm0.ps[3]; ;
                               // 1000    xmm0.pd[0] = ((double*)& CA::RectTraits<double>::infinity + 94)[0]; xmm0.pd[1] = ((double*)& CA::RectTraits<double>::infinity + 94)[1]; ;
                               // 1008    ((double*)&_40)[0] = xmm0.pd[0]; ((double*)&_40)[1] = xmm0.pd[1]; ;
                               // 1013    rsi = "valueWithRect:";
                               // 1020    rax = _38;
                               // 1024    rsp->_18 = rax;
                               // 1029    rax = _40;
                               // 1033    rsp->_10 = rax;
                               // 1038    rax = _50;
                               // 1042    rcx = _48;
                               // 1046    rsp->_8 = rcx;
                               // 1051    rsp->_0 = rax;
                               // 1055    rbx = (void *)0x000000010357d800: objc_msgSend;
                               // 1062 call
                            objc_msgSend(NSValue, "valueWithRect:", ...);
                            // 1064    rsi = "retain";
                            // 1071    rdi = rax;
                            // 1074 call
                            objc_msgSend(rax, "retain");
                            // 1076    r13 = rax;
                            // 1079     +[CALayer defaultValueForKey:]::unitRect = r13;
                        } // 981 
                    } // 1086 island form 924
                      // 1086
                    goto _f1739;
                _f1086:     // from 924
                _f1091:     // from 543
                         // 1091 cmpl $0x139, %r14d
                         // 1098 jne 1689
                    if () // 1091 (r14d != 0x139)
                          // gen jmp 1689
                        goto _f1689;
                } // 1104 island form 893
            _f1104:     // from 893
            _f1104:     // from 888
                     // 1104    r13 = +[CALayer defaultValueForKey:]::inf;
                     // 1111 testq %r13, %r13
                     // 1114 jne 1739
                if () // 1111 (0 != r13)
                      // gen jmp 1739
                    goto _f1739;
                // 1120    rdi = (void *)0x000000010337f278: NSNumber;
                // 1127    rsi = "alloc";
                // 1134    rbx = (void *)0x000000010357d800: objc_msgSend;
                // 1141 call
                objc_msgSend(NSNumber, "alloc");
                // 1143    rsi = "initWithDouble:";
                // 1150    xmm0.sd = (double&); ;
                // 1158    rdi = rax;
                // 1161 call
                objc_msgSend(rax, "initWithDouble:", ...);
                // 1163    r13 = rax;
                // 1166     +[CALayer defaultValueForKey:]::inf = r13;
                // 1173
                goto _f1739;
            } // 1178
        _f1178:     // from 856
                 // 1178 cmpl $0x99, %r14d
                 // 1185 jne 1545
            if () // 1178 (r14d != 0x99)
                  // gen jmp 1545
                goto _f1545;
            // 1191    r13 = +[CALayer defaultValueForKey:]::defEdges;
            // 1198 testq %r13, %r13
            // 1201 jne 1739
            if (!) { // 1198 (0 != r13)
                     // 1207    rdi = (void *)0x000000010337f278: NSNumber;
                     // 1214    rsi = "alloc";
                     // 1221    rbx = (void *)0x000000010357d800: objc_msgSend;
                     // 1228 call
                objc_msgSend(NSNumber, "alloc");
                // 1230    rsi = "initWithUnsignedInt:";
                // 1237    edx = 0xf;
                // 1242    rdi = rax;
                // 1245 call
                objc_msgSend(rax, "initWithUnsignedInt:", ...);
                // 1247    r13 = rax;
                // 1250     +[CALayer defaultValueForKey:]::defEdges = r13;
                // 1257
                goto _f1739;
                // ####
                // 1262 island till 1739 {}
                if (0) { //
                _f1262:     // from 144
                         // 1262 cmpl $0x39, %r14d
                         // 1266 jne 1689
                    if () // 1262 (r14d != 0x39)
                          // gen jmp 1689
                        goto _f1689;
                    // 1272    r13 = +[CALayer defaultValueForKey:]::black;
                    // 1279 testq %r13, %r13
                    // 1282 jne 1739
                    if (!) { // 1279 (0 != r13)
                             // 1288    edi = 0x4;
                             // 1293 call
                        CAGetColorSpace(0x4);
                        // 1298    rsi = & +[CALayer defaultValueForKey:]::values;
                        // 1305    rdi = rax;
                        // 1308 call
                        CGColorCreate;
                        // 1313    r13 = rax;
                        // 1316     +[CALayer defaultValueForKey:]::black = r13;
                        // 1323
                        goto _f1739;
                        // ####
                        // 1328 island till 1739 {}
                        if (0) { //
                        _f1328:     // from 556
                                 // 1328 cmpl $0x12d, %r14d
                                 // 1335 jne 1671
                            if () // 1328 (r14d != 0x12d)
                                  // gen jmp 1671
                                goto _f1671;
                        _f1341:     // from 913
                        _f1341:     // from 900
                        _f1341:     // from 869
                        _f1341:     // from 228
                                 // 1341    r13 = +[CALayer defaultValueForKey:]::one;
                                 // 1348 testq %r13, %r13
                                 // 1351 jne 1739
                            if (!) { // 1348 (0 != r13)
                                     // 1357    rdi = (void *)0x000000010337f278: NSNumber;
                                     // 1364    rsi = "alloc";
                                     // 1371    rbx = (void *)0x000000010357d800: objc_msgSend;
                                     // 1378 call
                                objc_msgSend(NSNumber, "alloc");
                                // 1380    rsi = "initWithInt:";
                                // 1387    edx = 0x1;
                                // 1392    rdi = rax;
                                // 1395 call
                                objc_msgSend(rax, "initWithInt:", ...);
                                // 1397    r13 = rax;
                                // 1400     +[CALayer defaultValueForKey:]::one = r13;
                                // 1407
                                goto _f1739;
                                // ####
                                // 1412 island till 1739 {}
                                if (0) { //
                                _f1412:     // from 928
                                         // 1412 cmpl $0x73, %r14d
                                         // 1416 jne 1689
                                    if () // 1412 (r14d != 0x73)
                                          // gen jmp 1689
                                        goto _f1689;
                                    // 1422    r13 = +[CALayer defaultValueForKey:]::fullRect;
                                    // 1429 testq %r13, %r13
                                    // 1432 jne 1739
                                    if (!) { // 1429 (0 != r13)
                                             // 1438    rdi = (void *)0x000000010337f2f0: NSValue;
                                             // 1445    xmm0.pd[0] = ((double*)& .memset_pattern + 318)[0]; xmm0.pd[1] = ((double*)& .memset_pattern + 318)[1]; ;
                                             // 1453    ((double*)&_70)[0] = xmm0.pd[0]; ((double*)&_70)[1] = xmm0.pd[1]; ;
                                             // 1458    xmm0 = 0.; ;
                                             // 1462    ((double*)&_60)[0] = xmm0.pd[0]; ((double*)&_60)[1] = xmm0.pd[1]; ;
                                             // 1467    rsi = "valueWithRect:";
                                             // 1474    rax = _58;
                                             // 1478    rsp->_18 = rax;
                                             // 1483    rax = _60;
                                             // 1487    rsp->_10 = rax;
                                             // 1492    rax = _70;
                                             // 1496    rcx = _68;
                                             // 1500    rsp->_8 = rcx;
                                             // 1505    rsp->_0 = rax;
                                             // 1509    rbx = (void *)0x000000010357d800: objc_msgSend;
                                             // 1516 call
                                        objc_msgSend(NSValue, "valueWithRect:", ...);
                                        // 1518    rsi = "retain";
                                        // 1525    rdi = rax;
                                        // 1528 call
                                        objc_msgSend(rax, "retain");
                                        // 1530    r13 = rax;
                                        // 1533     +[CALayer defaultValueForKey:]::fullRect = r13;
                                        // 1540
                                        goto _f1739;
                                        // ####
                                        // 1545 island till 1739 {1573island1739,}
                                        if (0) { //
                                        _f1545:     // from 1185
                                                 // 1545 cmpl $0xb1, %r14d
                                                 // 1552 jne 1689
                                            if () // 1545 (r14d != 0xb1)
                                                  // gen jmp 1689
                                                goto _f1689;
                                            // 1558    rax = & kCAFillModeRemoved;
                                            // 1565    r13 = rax->_0;
                                            // 1568
                                            goto _f1739;
                                            // ####
                                            // 1573 island till 1739 {}
                                            if (0) { //
                                                     // 1573    r13 = +[CALayer defaultValueForKey:]::three;
                                                     // 1580 testq %r13, %r13
                                                     // 1583 jne 1739
                                                if (!) { // 1580 (0 != r13)
                                                         // 1589    rdi = (void *)0x000000010337f278: NSNumber;
                                                         // 1596    rsi = "alloc";
                                                         // 1603    rbx = (void *)0x000000010357d800: objc_msgSend;
                                                         // 1610 call
                                                    objc_msgSend(NSNumber, "alloc");
                                                    // 1612    rsi = "initWithInt:";
                                                    // 1619    edx = 0x3;
                                                    // 1624    rdi = rax;
                                                    // 1627 call
                                                    objc_msgSend(rax, "initWithInt:", ...);
                                                    // 1629    r13 = rax;
                                                    // 1632     +[CALayer defaultValueForKey:]::three = r13;
                                                    // 1639
                                                    goto _f1739;
                                                    // ####
                                                    // 1641 island till 1739 {1671island1739,}
                                                    if (0) { //
                                                             // 1641    rdi = (void *)0x000000010337f278: NSNumber;
                                                             // 1648    rsi = "numberWithInt:";
                                                             // 1655    edx = 0x1f4;
                                                             // 1660 call
                                                        objc_msgSend(NSNumber, "numberWithInt:", ...);
                                                        // 1666    r13 = rax;
                                                        // 1669
                                                        goto _f1739;
                                                        // ####
                                                        // 1671 island till 1739 {}
                                                        if (0) { //
                                                        _f1671:     // from 1335
                                                                 // 1671 cmpl $0x134, %r14d
                                                                 // 1678 jne 1689
                                                            if (!) { // 1671 (r14d != 0x134)
                                                            _f1680:     // from 569
                                                                     // 1680    r13 = & __cfs("linear");
                                                                     // 1687
                                                                goto _f1739;
                                                            } // 1689
                                                        _b1689:     // from 1708
                                                        _f1689:     // from 1552
                                                        _f1689:     // from 1416
                                                        _f1689:     // from 1266
                                                        _f1689:     // from 1098
                                                        _f1689:     // from 941
                                                        _f1689:     // from 919
                                                        _f1689:     // from 882
                                                        _f1689:     // from 828
                                                        _f1689:     // from 675
                                                        _f1689:     // from 582
                                                        _f1689:     // from 449
                                                        _f1689:     // from 345
                                                        _f1689:     // from 238
                                                                 // 1689 cmpl %r14d, (%r15)
                                                                 // 1692 je 1712
                                                            if (!) { // 1689 ((int32_t&)r15->_0 == r14d)
                                                                     // 1694    ++rbx;
                                                                     // 1697    r15 = r15 + 0x20;
                                                                     // 1701    r13d = 0;
                                                                     // 1704 cmpq $0x1d, %rbx
                                                                     // 1708
                                                                if () // 1704 (rbx < 0x1d)
                                                                    goto _b1689;
                                                                // 1710
                                                                goto _f1739;
                                                            } // 1712
                                                              // 1712    rax = (void *)0x0000000103d29ca8: kCFBooleanFalse;
                                                              // 1719    ecx = 0x4920a8;
                                                              // 1724 btq %rbx, %rcx
                                                              // 1728    rax = (0 != (rcx & (1<<rbx))) ? (void *)0x0000000103d29ca0: kCFBooleanTrue : rax;
                                                              // 1736    r13 = rax->_0;
                                                        } // 1739 island form 1671
                                                    } // 1739 island form 1641
                                                } // 1739
                                            } // 1739 island form 1573
                                        } // 1739 island form 1545
                                    } // 1739
                                } // 1739 island form 1412
                            } // 1739
                        } // 1739 island form 1328
                    } // 1739
                } // 1739 island form 1262
            } // 1739
        } // 1739 island form 849
    } // 1739
_b1739:     // from 1764
_f1739:     // from 1710
_f1739:     // from 1687
_f1739:     // from 1669
_f1739:     // from 1639
_f1739:     // from 1568
_f1739:     // from 1545
_f1739:     // from 1540
_f1739:     // from 1412
_f1739:     // from 1407
_f1739:     // from 1328
_f1739:     // from 1323
_f1739:     // from 1262
_f1739:     // from 1257
_f1739:     // from 1178
_f1739:     // from 1173
_f1739:     // from 1114
_f1739:     // from 1086
_f1739:     // from 980
_f1739:     // from 844
_f1739:     // from 816
_f1739:     // from 654
_f1739:     // from 598
_f1739:     // from 518
_f1739:     // from 440
_f1739:     // from 377
_f1739:     // from 317
_f1739:     // from 254
_f1739:     // from 219
_f1739:     // from 160
         // 1739    rax = r13;
         // 1742    rsp = rsp + 0x78;
         // 1746 popq %rbx
         // 1747 popq %r12
         // 1749 popq %r13
         // 1751 popq %r14
         // 1753 popq %r15
         // 1755 popq %rbp
         // 1756 ret
    return;
    // 1757    r13 = & __cfs("stretch");
    // 1764
    goto _b1739;
    // 1766 nop
    // 1768    dh = dh + bh + eflags.c;
}
+[CALayer defaultValueForKey:]完整逆向代码

在第七版(二)要完成的事就是,如何代替人手正确地内联孤岛到goto点。

posted on 2017-03-02 19:52  bbqz007  阅读(525)  评论(0编辑  收藏  举报