| View previous topic :: View next topic |
| Author |
Message |
fluckyourusername How do I cheat?
Reputation: 0
Joined: 01 May 2020 Posts: 3
|
Posted: Fri May 01, 2020 5:29 pm Post subject: problem with readmem writing to the wrong address |
|
|
I have the following two injection scripts for a Unity/Mono game:
God Mode - self explanatory
| Code: |
[ENABLE]
alloc(origOpcode, 8)
registersymbol(origOpcode)
origOpcode:
readmem(PlayerHealth:TakeDamage+7, 8)
PlayerHealth:TakeDamage+7: // Right after the prologue
jmp "PlayerHealth:TakeDamage"+1AE // Jump straight to the epilogue
nop
nop
nop
[DISABLE]
PlayerHealth:TakeDamage+7:
readmem(origOpcode, 8)
dealloc(origOpcode)
unregistersymbol(origOpcode)
|
-------------------------------
No Slow Movement - disables the decreased player movement speed when hit by a specific type of monster
| Code: |
[ENABLE]
alloc(origOpcode, 6)
registersymbol(origOpcode)
label(fNewSlowVal)
registersymbol(fNewSlowVal)
origOpcode:
readmem(Player:Slow+6, 6)
fNewSlowVal:
dd (float)0.0
Player:Slow+6:
// fldz could be used instead but I don't want to NOP out
fld dword ptr [fNewSlowVal]
[DISABLE]
Player:Slow+6:
readmem(origOpcode, 6)
dealloc(origOpcode)
unregistersymbol(origOpcode)
unregistersymbol(fNewSlowVal)
|
You can see that I'm using readmem in both scripts to restore the original code once the scripts are disabled since the addresses in opcodes I'm targeting change with each restart. However, I discovered that when I do the following:
- Enable God Mode
- Enable No Slow Movement
- Disable God Mode
...readmem will write the original opcode of Player:Slow+6 into PlayerHealth:TakeDamage+7.
What Am I doing wrong here and how do I fix it? Please see the attached screenshots below.
| Description: |
| The opcode at {PlayerHealth:TakeDamage+7}. This is both the game's original opcode the opcode the 'God Mode' script restores it when it's disabled. |
|
| Filesize: |
5.53 KB |
| Viewed: |
1863 Time(s) |

|
| Description: |
| The injected opcode at {PlayerHealth:TakeDamage+7} when the 'God Mode' script is enabled. |
|
| Filesize: |
6.74 KB |
| Viewed: |
1863 Time(s) |

|
| Description: |
| The opcode at {Player:Slow+6}. This is both the game's original opcode the opcode the 'No Slow Movement' script restores it when it's disabled. |
|
| Filesize: |
2.1 KB |
| Viewed: |
1863 Time(s) |

|
| Description: |
| The injected opcode at {Player:Slow+6} when the 'No Slow Movement' script is enabled. |
|
| Filesize: |
2.15 KB |
| Viewed: |
1863 Time(s) |

|
| Description: |
| The restored opcode of {Player:Slow+6} disastrously written at {PlayerHealth:TakeDamage+7}. |
|
| Filesize: |
5.33 KB |
| Viewed: |
1863 Time(s) |

|
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25840 Location: The netherlands
|
Posted: Fri May 01, 2020 5:49 pm Post subject: |
|
|
use unique names when using registersymbol
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
| Back to top |
|
 |
fluckyourusername How do I cheat?
Reputation: 0
Joined: 01 May 2020 Posts: 3
|
Posted: Fri May 01, 2020 5:58 pm Post subject: |
|
|
| Dark Byte wrote: | | use unique names when using registersymbol |
Well that's embarrassing. Just changed the the symbol names and everything works flawlessly now. Thanks a ton for a quick reply. My stupidity halted my progress for some 20 hours now trying to figure out what went wrong...
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4724
|
Posted: Fri May 01, 2020 6:16 pm Post subject: |
|
|
registersymbol registers a symbol globally. If it's already been defined, it's going to redefine it to point to some new address.
Alloc symbols are saved locally to each script, so simply removing (un)registersymbol(origOpcode) in all scripts could fix the problem.
If you really need it registered, then give the symbols unique names.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
fluckyourusername How do I cheat?
Reputation: 0
Joined: 01 May 2020 Posts: 3
|
Posted: Fri May 01, 2020 7:12 pm Post subject: |
|
|
| ParkourPenguin wrote: | registersymbol registers a symbol globally. If it's already been defined, it's going to redefine it to point to some new address.
Alloc symbols are saved locally to each script, so simply removing (un)registersymbol(origOpcode) in all scripts could fix the problem.
If you really need it registered, then give the symbols unique names. |
Will take note of that. Thanks for taking the time to read and reply.
|
|
| Back to top |
|
 |
|