• [原]逆向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);

    }

     

     

  • 相关阅读:
    springAOP源码分析之篇三:代理对象的执行
    springAOP源码分析之篇二:代理对象的生成
    css样式float造成的浮动“塌陷”问题的解决办法
    css font的简写规则
    CSS学习
    工具
    用过的库
    The requested URL ***** was not found on this serve
    修改DeDe标签Pagelist分页样式
    DedeCms autoindex和itemindex使用介绍
  • 原文地址:https://www.cnblogs.com/Proteas/p/3172894.html
Copyright © 2020-2023  润新知