 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Nessin Advanced Cheater
Reputation: 1
Joined: 29 Oct 2015 Posts: 69
|
Posted: Sat Oct 31, 2015 6:35 pm Post subject: My AOB Injection script crashes game (solved) |
|
|
Hello guys
I was wondering if someone could take a quick peek at my script and see why it could cause the game to instantly crash when activated.
The game I'm working in, is using lua. I am looking for the health address. I was planning to use the descriptor of this address, located at [x+8]+10 (where x is the address containing the health value) to make sure the address found is in fact ... the health address.
If the descriptor of the address is "current_amount", I am sure this is the right address and will store it inside [_HEALTH]
| Code: | [ENABLE]
aobscanmodule(INJECT,speargame.exe,8B 56 FC 83 C2 04) // should be unique
alloc(newmem,$1000)
label(code)
label(return)
label(originalcode)
globalalloc(_HEALTH,4)
newmem:
code:
pushfd
pushad
mov eax, [esi+4] // <--- Game crashes in this block
cmp dword ptr [eax+10],'curr'
jne originalcode
cmp dword ptr [eax+14],'ent_'
jne originalcode
cmp dword ptr [eax+18],'amou'
jne originalcode // <-----
mov [_HEALTH],esi
jmp originalcode
originalcode:
popad
popfd
mov edx,[esi-04]
add edx,04
jmp return
INJECT:
jmp code
nop
return:
registersymbol(INJECT)
[DISABLE]
INJECT:
db 8B 56 FC 83 C2 04
unregistersymbol(INJECT)
dealloc(newmem) |
Last edited by Nessin on Mon Nov 02, 2015 11:18 am; edited 1 time in total |
|
| Back to top |
|
 |
Gniarf Grandmaster Cheater Supreme
Reputation: 43
Joined: 12 Mar 2012 Posts: 1285
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat Oct 31, 2015 7:58 pm Post subject: |
|
|
Are you sure it's crashing on
| Code: | | mov eax, [esi+4] // <--- Game crashes in this block |
Try placing a NOP after it and see if that executes.
It's more likely crashing on
| Code: | | cmp dword ptr [eax+10],'curr' |
Because [esi+4] doesn't contain what you think it does.
|
|
| Back to top |
|
 |
Nessin Advanced Cheater
Reputation: 1
Joined: 29 Oct 2015 Posts: 69
|
Posted: Sun Nov 01, 2015 5:23 am Post subject: |
|
|
Thanks guys, however I don't understand why it crashes
The address for the health is esi-4 (Pretty sure of this one)
The pointer to the descriptor is esi+4
The descriptor (text) is located at [esi+4]+10
However, the part where I injected my code isn't only used to access health. So esi isn't always the health, sometimes its ammo, mana, or something completely different. But I only care about the health. That's why I compare the descriptor with "current_amount".
The game does indeed crash on the compares, but I don't understand why
If [esi+4] doesn't contain what I think it does, the cmp should just return 0, right?
|
|
| Back to top |
|
 |
Zanzer I post too much
Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sun Nov 01, 2015 6:20 am Post subject: |
|
|
Add these two lines before the first CMP.
| Code: | mov eax, [esi+4]
test eax,eax
je originalcode |
|
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Nov 01, 2015 7:49 am Post subject: |
|
|
better:
| Code: | cmp [esi+4],00010000
jb originalcode
mov eax, [esi+4]
|
@Nessin
To be completely sure, do this:
find health address, add to the list, double click address (column 'address') and copy it to the clipboard.
open "structure dissect" (ctrl+m, then ctrl+d)
paste address into editbox and press ctrl+n, then click yes/ok few times.
try to find descriptor (or as I prefer to call it: "a key"), open some nodes. If you find it, do a screenshot and post it here.
Also, do a "find out what accesses..." on that address, there should be few opcodes, find the first one in the "memory browser", do a screenshot, post it here.
_________________
|
|
| Back to top |
|
 |
Nessin Advanced Cheater
Reputation: 1
Joined: 29 Oct 2015 Posts: 69
|
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Sun Nov 01, 2015 8:31 am Post subject: |
|
|
| Nessin wrote: | not sure why it's needed tho  |
Because that piece of code also accesses other things than {key,value} pairs.
About the top part of your picture, I asked for screenshot of "memory browser" (click "show disassembler"). Currently we only see few lines, with more lines (in memory browser) we can tell much more.
_________________
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4709
|
|
| Back to top |
|
 |
Nessin Advanced Cheater
Reputation: 1
Joined: 29 Oct 2015 Posts: 69
|
Posted: Mon Nov 02, 2015 11:15 am Post subject: |
|
|
Thanks, that cleared it up for me
I actually had to resort to isbadreadptr (forum.cheatengine.org/viewtopic.php?t=511049) to completely fix my issue.
| Code: | mov eax, [esi+4]
test eax,eax
je originalcode |
and | Code: | cmp [esi+4],00010000
jb originalcode
mov eax, [esi+4] |
were not enough. Sometimes [esi+4] was still a bad pointer
This is what completely fixed it for me:
| Code: | mov eax, [esi+4]
push 00000004
push eax
call isbadreadptr //make sure [esi+4] points to valid memory
cmp eax,0
jne originalcode |
Kudos to mgr.inz.Player's Don't starve assembly script, teehee
|
|
| Back to top |
|
 |
mgr.inz.Player I post too much
Reputation: 222
Joined: 07 Nov 2008 Posts: 4438 Location: W kraju nad Wisla. UTC+01:00
|
Posted: Mon Nov 02, 2015 12:33 pm Post subject: |
|
|
ehh, I thought you will post a screenshot of memory browser (I asked two times...).
_________________
|
|
| Back to top |
|
 |
Nessin Advanced Cheater
Reputation: 1
Joined: 29 Oct 2015 Posts: 69
|
|
| Back to top |
|
 |
|
|
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
|
|