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 


How to save local variables to memory addresses?(ASM)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Sun Mar 13, 2016 4:30 am    Post subject: How to save local variables to memory addresses?(ASM) Reply with quote

Is it possible for me to permanently store a local variable to a memory address so that I can access that local variable in code injection?

For example, the code below stores a local variable in eax:
Code:

movsx eax,word ptr [esi+28]

How can I allocate a memory address and store the value in eax to such address for later use? Is it possible? Or how can I store the value in "word ptr [esi+28]" for later use? BTW, esi and eax keep changing during the game.
In higher-level programming languages, I just need to create a global variable to store the local variable, or use a table, but how to do it in asm? Thanks.[/code]
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Mar 13, 2016 12:50 pm    Post subject: Reply with quote

Code:
label(myvar)

newmem:
  cmp [myvar],0
  jne code
  movsx eax,word ptr [esi+28]
  mov [myvar],eax
code:
  movsx eax,word ptr [esi+28]
  jmp return

myvar:
  dd 0

INJECT:
  //blahblah

registersymbol(myvar)
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Sun Mar 13, 2016 10:19 pm    Post subject: Reply with quote

Zanzer wrote:
Code:
label(myvar)

newmem:
  cmp [myvar],0
  jne code
  movsx eax,word ptr [esi+28]
  mov [myvar],eax
code:
  movsx eax,word ptr [esi+28]
  jmp return

myvar:
  dd 0

INJECT:
  //blahblah

registersymbol(myvar)


Thanks for the reply. So after using this code, I can use [myvar] as a global variable, right?
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Mon Mar 14, 2016 12:01 pm    Post subject: Reply with quote

Code:


Alloc(MyNewMemory_Variable,32)  // name & how many bytes
Registersymbol(MyNewMemory_Variable)


MyNewMemory_Variable:
dd (float)32

MyNewMemory_Variable+4:

db 45 64 65 23 67





In game global just use MyNewMemory_Variable wherever.

_________________
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Mon Mar 14, 2016 12:44 pm    Post subject: Reply with quote

akumakuja28 wrote:
Code:


Alloc(MyNewMemory_Variable,32)  // name & how many bytes
Registersymbol(MyNewMemory_Variable)


MyNewMemory_Variable:
dd (float)32

MyNewMemory_Variable+4:

db 45 64 65 23 67





In game global just use MyNewMemory_Variable wherever.


Thanks for the reply. So the global variable is "MyNewMemory_Variable" which holds a value of "32", right? Does the memory address of "MyNewMemory_Variable" change? I suppose not?
Back to top
View user's profile Send private message
akumakuja28
Master Cheater
Reputation: 16

Joined: 28 Jun 2015
Posts: 432

PostPosted: Mon Mar 14, 2016 1:03 pm    Post subject: Reply with quote

It will change upon activating and deactivating. This is why the sysmbol gets registered. Use the symbol to load. For instance

Mov eax,[MyNewMemory_Variable]

Add to table with by entering MyNewMemory_Variable as new memory address.

_________________
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Tue Mar 15, 2016 11:53 am    Post subject: Reply with quote

akumakuja28 wrote:
It will change upon activating and deactivating. This is why the sysmbol gets registered. Use the symbol to load. For instance

Mov eax,[MyNewMemory_Variable]

Add to table with by entering MyNewMemory_Variable as new memory address.

Got it, thanks a lot.
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