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 


Injection code problem

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
oLaudix
Expert Cheater
Reputation: 3

Joined: 25 Mar 2010
Posts: 138

PostPosted: Sun Mar 27, 2011 8:28 am    Post subject: Injection code problem Reply with quote

mov [esi+edi*4+00000268],eax <--- this is code responsible for changing ammo in Homefront

I wrote this code

Code:
alloc(newmem,2048) //2kb should be enough
label(returnhere)
label(originalcode)
label(exit)
label(wieksze)
label(mniejsze)

newmem: //this is allocated memory, you have read,write,execute access
cmp [esi+edi*4+00000268],eax
jg wieksze
jmp mniejsze
wieksze:
mov eax,[esi+edi*4+00000268]
mov [esi+edi*4+00000268],eax
jmp exit
mniejsze:
mov [esi+edi*4+00000268],eax

originalcode:
//mov [esi+edi*4+00000268],eax

exit:
jmp returnhere

"HOMEFRONT.exe"+9B3135:
jmp newmem
nop
nop
returnhere:


Is my understanding of this code correct?
Code:
cmp [esi+edi*4+00000268],eax
jg wieksze
jmp mniejsze
wieksze:
mov eax,[esi+edi*4+00000268]
mov [esi+edi*4+00000268],eax
jmp exit
mniejsze:
mov [esi+edi*4+00000268],eax

it should check if [esi+edi*4+00000268] is bigger than eax, if yes i jumpes to wieksze and use only this code
Code:
mov eax,[esi+edi*4+00000268]
mov [esi+edi*4+00000268],eax
jmp exit

if not it use jmp mniejsze and use original code right?
The problem is that it crashes the game and i have no idea why. Any suggestions? (Except shitty coding since im beginer in asembler)
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5627

PostPosted: Sun Mar 27, 2011 10:14 am    Post subject: Reply with quote

Maybe you should try a code like this for example:

Code:
mov eax,#999


To freeze the ammo to a specific value.

Or you can use

Code:
mov [esi+edi*4+00000268],#999


and not change eax register at all.

Also as you use a cmp instruction and you work with flags, you may need to save them at the start of the script with pushfd and load them at the end of the script with popfd.


Code:
alloc(newmem,2048) //2kb should be enough
label(returnhere)
label(originalcode)
label(exit)
label(wieksze)
label(mniejsze)

newmem: //this is allocated memory, you have read,write,execute access
pushfd
cmp [esi+edi*4+00000268],eax
jg wieksze
jmp mniejsze

wieksze:
mov [esi+edi*4+00000268],#999
//or  maybe mov [esi+edi*4+00000268],(int)999
jmp exit

mniejsze:
mov [esi+edi*4+00000268],eax

originalcode:
//mov [esi+edi*4+00000268],eax

exit:
popfd
jmp returnhere

"HOMEFRONT.exe"+9B3135:
jmp newmem
nop
nop
returnhere:

_________________
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
oLaudix
Expert Cheater
Reputation: 3

Joined: 25 Mar 2010
Posts: 138

PostPosted: Sun Mar 27, 2011 11:31 am    Post subject: Reply with quote

Now shooting works, it doesnt decrease ammo while firing but it crashes after reload :/ Asembler is hard >.< Changing quantity of ammo to 999 or eve 5 crashes game immediately.
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5627

PostPosted: Mon Mar 28, 2011 12:08 am    Post subject: Reply with quote

Then probably it is not the script's fault, maybe some kind of protection to avoid changing the value. I don't know because I don't have the game.
_________________
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
kemicza
Newbie cheater
Reputation: 0

Joined: 10 Jan 2011
Posts: 11
Location: Belgium

PostPosted: Mon Mar 28, 2011 4:28 am    Post subject: Reply with quote

This game does have protection against code injection. It checks this during some certain events like reloading/throwing a bomb/loading etc.. I'm not sure if the cracked version has removed the protection, but the original exe does have protection
Back to top
View user's profile Send private message
Geri
Moderator
Reputation: 111

Joined: 05 Feb 2010
Posts: 5627

PostPosted: Mon Mar 28, 2011 4:43 am    Post subject: Reply with quote

Quote:
This game does have protection against code injection. It checks this during some certain events like reloading/throwing a bomb/loading etc.. I'm not sure if the cracked version has removed the protection, but the original exe does have protection.


Thanks, good to know.

@oLaudix

You can try setting a data breakpoint on the code's address and see what is reading it. Like here (though this article is for xlive, probably it will work similarly in your game too):

http://www.szemelyesintegracio.hu/cheats/41-game-hacking-articles/243-xlive

If you have found the function which is reading the memory, you can try to disable it (or change it to "everything is ok" when it is checking the results).

_________________
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 -> General Gamehacking 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