frida/frida-node

Correct way to get args in onLeave?

CaledoniaProject opened this issue · 3 comments

The testMethod has a pointer argument which will be modified in the method. I need to read its value in onLeave. Right now I had to store the variable in onEnter then read it in onLeave.

I'm wondering if there's a better way to do that? It's not healthy for multithread programs.

    let data = null
    Interceptor.attach(testMethod, {
        onEnter: function (args) {
            data = args[4]
        },
        onLeave: function (retval) {
            console.log(Memory.readInt(data))           
        }
    });

Also some useful hints here.

Thanks!