| View previous topic :: View next topic |
| Author |
Message |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Sun Mar 13, 2016 4:30 am Post subject: How to save local variables to memory addresses?(ASM) |
|
|
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 |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Mar 13, 2016 12:50 pm Post subject: |
|
|
| 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 |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Sun Mar 13, 2016 10:19 pm Post subject: |
|
|
| 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 |
|
 |
akumakuja28 Master Cheater
Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Mon Mar 14, 2016 12:01 pm Post subject: |
|
|
| 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 |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Mon Mar 14, 2016 12:44 pm Post subject: |
|
|
| 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 |
|
 |
akumakuja28 Master Cheater
Reputation: 16
Joined: 28 Jun 2015 Posts: 432
|
Posted: Mon Mar 14, 2016 1:03 pm Post subject: |
|
|
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 |
|
 |
Dr.Disrespect Grandmaster Cheater
Reputation: 3
Joined: 17 Feb 2016 Posts: 526
|
Posted: Tue Mar 15, 2016 11:53 am Post subject: |
|
|
| 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 |
|
 |
|