用IDA查看APP的汇编码的时候,有一段汇编码,一直不清楚具体的运行流程,想写一个相应的伪代码也一直无法正常工作
下面是汇编码:
; Service - (char)request:(struct IMessage *)
; Attributes: bp-based frame
; char __cdecl -[Service request:resHandler:error:](struct Service *self, SEL, struct IMessage *)
__Service_request__
PUSH {R4-R7,LR}
ADD R7, SP, #0xC
PUSH.W {R8,R10,R11}
MOV R10, R0
MOV R6, R2
LDR R1, [R6]
MOV R0, R6
LDR R1, [R1,#0x10]
BLX R1
MOV R11, R0
下面是IMessage的结构:
struct IMessage {
CDUnknownFunctionPointerType *_field1;
};
我对上面汇编码的理解是:
; Service - (char)request:(struct IMessage *)
; Attributes: bp-based frame
; char __cdecl -[Service request:resHandler:error:](struct Service *self, SEL, struct IMessage *)
__Service_request__
PUSH {R4-R7,LR}
ADD R7, SP, #0xC
PUSH.W {R8,R10,R11}
MOV R10, R0
MOV R6, R2 // R2 = (struct IMessage *), R6 = R2
LDR R1, [R6] // R1 = *R6 即 R1 = (struct IMessage) ?
MOV R0, R6
LDR R1, [R1,#0x10] // R1 = *(R1 + 0x10),即 R1 = *(struct IMessage) + 0x10) ?
我自己尝试在tweak 里想关的代码的时候,却一直复原不出来
%hook Service
- (BOOL)request:(struct IMessage *)arg1
{
long addr5 = (intptr_t)&(*arg1); // add5 = (int)& (struct IMessage)即 add5 = &(*R6)
NSLog(@"%lu",addr5);
long * p;
p = (long *)(addr5 + 16); // *p = *(&(*R6) + 0x10)
NSLog(@"%lu",*p);
( *(void *(*)())(*p))(); // *p(), 返回void*;实际运行直接报错退出
请各位高手指定迷津!