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 


Push/Pop causing crash?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Sat May 02, 2015 6:05 pm    Post subject: Push/Pop causing crash? Reply with quote

So I'm working on my inventory editor for State Of Decay: Year One and I ran into a problem. I was able to write a script to modify the inventory, and that works great, but the thing is when I add things into my inventory, it pops up with a quantity of 0, which kinda means it doesn't REALLY exist. So I've found the instruction that controls the quantity, great, I basically try to do a copy and paste of the inventory editor since it is kinda the same thing. Here's the gist of the inventory editor, this script is meant to retrieve the current inventory so when you modify it, you won't lose what you had.
Code:
mov eax,[ebp+10] <--Original Code
mov esi,[eax+edi*4] <--Original Code
push [eax]
pop [inv_slot1]
Now this works flawlessly, so I try and do the same with the quantity editor, like so
Code:
mov eax,[ebp+14] <--Original Code
movzx eax,byte ptr [eax+ebx] <--Original Code
push [eax]
pop [iqe_slot1]
this crashes, any idea why? Also, this raises another question for me, what exactly is "byte ptr"?
Back to top
View user's profile Send private message
justa_dude
Grandmaster Cheater
Reputation: 23

Joined: 29 Jun 2010
Posts: 893

PostPosted: Sat May 02, 2015 6:52 pm    Post subject: Reply with quote

Most instructions will infer 32-bit operands when operating on 32-bit registers. The byte ptr tells the assembler that you're working with a one-byte value.

Not sure why you're crashing, but it's weird that you're pushing and popping instead of just moving from register to mem.

_________________
A nagy kapu mellett, mindig van egy kis kapu.
----------------------
Come on...
Back to top
View user's profile Send private message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Sat May 02, 2015 6:57 pm    Post subject: Reply with quote

you mean like "mov iqe_slot1,[eax]"? I get a compile error. Maybe I'm doing it wrong? How is it suppose to be done?
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5627

PostPosted: Sat May 02, 2015 7:42 pm    Post subject: Reply with quote

Probably an access violation, because

movzx eax,byte ptr [eax+ebx]

You have moved the value to eax and then you do

push [eax]

At that point, eax is not an address, but a value from 0 to 255 and that will obviously crash the game.


When you have no idea why is your code crashing, use break and trace to debug it and check the trace log to see what went wrong.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Sat May 02, 2015 7:46 pm    Post subject: Reply with quote

I thought "mov" simply copied the value from the second operand to the first? Anyhow, how would I fix this?
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5627

PostPosted: Sat May 02, 2015 7:52 pm    Post subject: Reply with quote

Yes, it does, and that code is overwriting eax with [eax+ebx].

Eg

mov eax,[eax]

is a valid code and it's overwriting eax with [eax].

Just store [eax+ebx] before it's overwritten. Right before the movzx eax,byte ptr [eax+ebx] instruction.

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Sat May 02, 2015 7:57 pm    Post subject: Reply with quote

hmm tried it, still crashing Rolling Eyes time to go fishing...
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5627

PostPosted: Sat May 02, 2015 8:00 pm    Post subject: Reply with quote

Ok, then do the trace and see what happens. Even if the game will crash, the trace log will be available with every data and you can see what happened.
_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat May 02, 2015 8:44 pm    Post subject: Reply with quote

Are you trying to store the actual quantity value?
Or the game address containing the quantity?
Also, did you declare iqe_slot1 as a 1 byte field?

Are you sure what you want isn't:
Code:
mov byte ptr [inv_slot1],eax
Back to top
View user's profile Send private message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Sat May 02, 2015 9:00 pm    Post subject: Reply with quote

I want to store the value, I originally declared iqe_slot1 with "dd", switched it to "db" and still crashed, and with your piece of code above I get this

Just out of curiosity, what can I do by storing the address?
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat May 02, 2015 9:03 pm    Post subject: Reply with quote

Sounds like you didn't register the variable name... or alloc it.
Back to top
View user's profile Send private message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Sat May 02, 2015 9:13 pm    Post subject: Reply with quote

nope, its definitely registered... here it is in all its non-working glory
Code:
[Enable]

alloc(iqe_1,32,StateOfDecay.exe) //Inventory Quantity Editor
aobscanmodule(iqe_aob1,StateOfDecay.exe,8B 45 14 0F B6 04 18)
registersymbol(iqe_aob1)
label(returnhere_iqe_1)

label(iqe_slot1)
registersymbol(iqe_slot1)

//--------------------------------------------------//
iqe_1:
mov eax,[ebp+14]
movzx eax,byte ptr [eax+ebx]
push [eax]
pop [iqe_slot1]
jmp returnhere_iqe_1

iqe_slot1:
dd 0
//--------------------------------------------------//

iqe_aob1:
jmp iqe_1
nop
nop
returnhere_iqe_1:

[Disable]

iqe_aob1:
db 8B 45 14 0F B6 04 18
unregistersymbol(iqe_aob1)
dealloc(iqe_1)

unregistersymbol(iqe_slot1)
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5627

PostPosted: Sat May 02, 2015 9:20 pm    Post subject: Reply with quote

eax is a 32-bit register. byte ptr is not working if you are trying to read eax. You have to use an 8-bit register for it:

http://www.sandpile.org/x86/gpr.htm

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.


Last edited by Geri on Sat May 02, 2015 9:26 pm; edited 2 times in total
Back to top
View user's profile Send private message
vng21092
Grandmaster Cheater
Reputation: 15

Joined: 05 Apr 2013
Posts: 644

PostPosted: Sat May 02, 2015 9:21 pm    Post subject: Reply with quote

Code:
mov eax,[ebp+14]
movzx eax,byte ptr [eax+ebx]
is the original code, unless I'm missing your point... Embarassed
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5627

PostPosted: Sat May 02, 2015 9:26 pm    Post subject: This post has 1 review(s) Reply with quote

If you want to store the value, you just have to do this:


mov eax,[ebp+14]
movzx eax,byte ptr [eax+ebx]
mov [iqe_slot1],eax
jmp returnhere_iqe_1

_________________
My trainers can be found here: http://www.szemelyesintegracio.hu/cheats

If you are interested in any of my crappy articles/tutorials about CE and game hacking, you can find them here:
http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles

Don't request cheats or updates.
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
Goto page 1, 2  Next
Page 1 of 2

 
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