how to call pointer function in Frida script

111 Views Asked by At

I'm debugging a macOS app by Frida. here is pseudocode

            rax = [Herlper cfunc];
            rax = *rax;
            rax = (rax)(0x0, 0x0, 0x0);
            rax = [rax retain];
            r13 = rax;
            r12 = [[r13 dataUsingEncoding:0x4] retain];

How do I get r12 results in a script?

Hope you can help, thank you!

i tried using this script

var f = new NativeFunction(ptr(ObjC.classes.Herlper.cfunc()).sign(),'pointer',['uint8','uint8','uint8'])
f(0x0,0x0,0x0)

but it error:

Error: access violation accessing 0x600001931050
    at <eval> (<input>:1)
1

There are 1 best solutions below

0
awalol On

i have solved the question. script:

var stackAddress = ObjC.classes.Herlper.cfunc()
var memoryAddress = Memory.readPointer(stackAddress)
var func = new NativeFunction(memoryAddress,'pointer',['int','int'])
var result = func(0x0,0x0)
Memory.readByteArray(result,100)