Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Function return value and code cave

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
catshy
How do I cheat?
Reputation: 0

Joined: 01 Feb 2019
Posts: 9

PostPosted: Wed Jul 29, 2020 4:34 am    Post subject: Function return value and code cave Reply with quote

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
View user's profile Send private message
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3327

PostPosted: Wed Jul 29, 2020 9:44 am    Post subject: Reply with quote

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
View user's profile Send private message
catshy
How do I cheat?
Reputation: 0

Joined: 01 Feb 2019
Posts: 9

PostPosted: Wed Jul 29, 2020 1:14 pm    Post subject: Reply with quote

@Csimbi, thanks for answer!

Could u show me example code for point 1. ?
Back to top
View user's profile Send private message
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3327

PostPosted: Thu Jul 30, 2020 4:27 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites