[原]逆向iOS SDK -- +[UIImage imageNamed:] 的实现

汇编代码:

; Dump of assembler code for function +[UIImage imageNamed:]

; R0 = UIImage, R1 = "imageNamed:", R2 = imageFileName

push  {r4, r5, r7, lr} ; 从右向左,依次将这些寄存器压栈

movw  r1, #62936 ;R1(16) = selRef_mainBundle 地址偏移量的低 16 位的 

add   r7, sp, #8 ; R7 = 栈上的值

movt  r1, #3292  ; R1(16) = selRef_mainBundle 地址偏移量的高 16

movw  r0, #44426 ; R0(16) = classRef_NSBundle 偏移量的低 16

movt  r0, #3293  ; R0(16) = classRef_NSBundle 偏移量的高 16

add   r1, pc ; R1 = selRef_mainBundle

add   r0, pc ; R0 = classRef_NSBundle

mov   r4, r2 ; R4 = R2 = imageFileName

ldr   r1, [r1, #0] ; R1 = "mainBundle"

ldr   r0, [r0, #0] ; R0 = NSBundle

blx   0x31f862a4 <dyld_stub_objc_msgSend> ; [NSBundle mainBundle]

mov   r5, r0 ; R5 = R0 = mainBundle

bl    0x31e0abb4 <_UIScreenForce1xScale> ; _UIScreenForce1xScale(),

;判断是否是高清屏:高清屏返回 YES,低分屏返回 NO

mov   r1, r5 ; R1 = R5 = mainBundle

mov   r2, r0 ; R2 = R0 = isRetina

mov   r0, r4 ; R0 = R4 = imageFileName

ldmia.w sp!, {r4, r5, r7, lr} ;

b.w   0x31bc2898 <_UIImageAtPath> ;

;_UIImageAtPath(NSString *imageFileName, NSBundle *mainBundle, BOOL isRetina)

nop

; End of assembler dump.

 

伪代码:

+ (UIImage *)imageNamed:(NSString *)imageFileName {

      NSBundle *mainBundle = [NSBundlemainBundle];

     BOOL isRetina = _UIScreenForce1xScale();

     return_UIImageAtPath(imageFileName, mainBundle, isRetina);

}

 

 

转载于:https://www.cnblogs.com/Proteas/p/3172894.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值