Correct way to get args in onLeave?
CaledoniaProject opened this issue · 3 comments
CaledoniaProject commented
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))
}
});
FrenchYeti commented
Hi,
Simple by doing :
```
Interceptor.attach(testMethod, {
onEnter: function (args) {
this.data = args[4];
}, onLeave: function (retval){
console.log(Memory.readInt(this.data))
}
});
```
You can also use CPU context to save the value of 4th arg (example with arm64):
```
this.data = this.context.x4;
```
…-------- Message d'origine --------
Le 10 août 2021 à 16:51, CaledoniaProject a écrit :
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))
}
});
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, [view it on GitHub](#65), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/ACCUUQHHC2INIR5AT5H5MV3T4E4GJANCNFSM5B4KXCZQ).
Triage notifications on the go with GitHub Mobile for [iOS](https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675) or [Android](https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email).
CaledoniaProject commented
Thanks!