I have an instruction that looks like this in Ghidra:
100168ff0 e9 13 00 32 orr w9,wzr,#0x1f
Using lldb
I can set a breakpoint on the instruction after this, read w9
to confirm what value it is storing and modify it if needs be.
I am trying to do something similar with Frida with the following script:
var t_module = 'testApp';
var loadAddress = Module.getBaseAddress(t_module);
var instructionOffset = ptr(0x168ff4);
var toAtt = loadAddress.add(instructionOffset);
Interceptor.attach(toAtt, {
onEnter: function(args) {
console.log("[+] Module base address found at " + loadAddress)
console.log("[+] Found instruction at " + toAtt)
console.log("[+] Attempting to read w9: " + this.context.w9)
}
});
however trying to read w9
just returns undefined
. It is defined here so is not that Frida is calling it something else.
I can confirm the right address is being reached using:
Memory.readByteArray(ptr("0x102ab4ff0"),4)
where 0x102ab4ff0
is the address printed by the script, and comparing it to the instruction at the beginning from Ghidra.
I'm not sure if I've misunderstood something about Frida or where I should attach. This is the closest question I could find and that just says to use this.context.eax
.
onEnter
? ( also, you don't need to.add
aptr
, you can just add the offset using.add(0x11)
. there is noeax
in arm64 ) to answer your question please printconsole.log(JSON.stringify(this.context))