| View previous topic :: View next topic |
| Author |
Message |
catshy How do I cheat?
Reputation: 0
Joined: 01 Feb 2019 Posts: 9
|
Posted: Wed Jul 29, 2020 4:34 am Post subject: Function return value and code cave |
|
|
Hello,
I have question about code cave via CE.
If I have function and I know address of this function, for example:
| Code: |
function func(int arg)
{
return arg+1;
}
MessageBox( func(10) );
|
And now:
1. How to get func() return value before this function send it to MessageBox
2. How to change return value before func() send it to MB - like swip.
Thanks!
|
|
| Back to top |
|
 |
Csimbi I post too much
Reputation: 97
Joined: 14 Jul 2007 Posts: 3327
|
Posted: Wed Jul 29, 2020 9:44 am Post subject: |
|
|
1.
allocate a memory for a var.
register the var.
Then store the val into the var before the return.
2.
change it before the return
it is there somewhere in the stack, at esp or esp+04.
|
|
| Back to top |
|
 |
catshy How do I cheat?
Reputation: 0
Joined: 01 Feb 2019 Posts: 9
|
Posted: Wed Jul 29, 2020 1:14 pm Post subject: |
|
|
@Csimbi, thanks for answer!
Could u show me example code for point 1. ?
|
|
| Back to top |
|
 |
Csimbi I post too much
Reputation: 97
Joined: 14 Jul 2007 Posts: 3327
|
Posted: Thu Jul 30, 2020 4:27 am Post subject: |
|
|
I usually allocate a single block, some peeps use globalalloc for each var.
Each have their own benefits.
| Code: | [enable]
alloc(newmem,4096)
label (var)
registersymbol(var)
newmem:
var:
dd 0
[disable]
unregistersymbol(var)
dealloc(newmem)
|
|
|
| Back to top |
|
 |
|