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 


Help with injecting a code.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Sun Dec 04, 2016 9:26 am    Post subject: Help with injecting a code. Reply with quote

Just having some fun with Hitman Absolution, (i know there's another thread on this with a table) and have found the AOB for health can anyone help me with the code injection please.

The original code is -

code:
fstp dword ptr [esi+00000218]
jmp return

If i remove the 00000218 and add this to newmem like so -

newmem:
fstp dword ptr [esi]

It works, giving god mode but the player has zero health, and if the script is disabled the game eventually crashes after taking damage.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sun Dec 04, 2016 9:35 am    Post subject: Reply with quote

Code:
fstp st(0)
Back to top
View user's profile Send private message
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Sun Dec 04, 2016 9:57 am    Post subject: Reply with quote

@Zanzer Thanks for the reply, it works better than my code, this one doesn't crash after disabling but the health stays at zero and the player remains immortal.

It is working but to reset the script you have first disable it, and then in game either restart or finish a level.

Because this is running in the memory, is it best to make a disable script, or should it disable properly when using the right code.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 223

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 04, 2016 10:03 am    Post subject: Reply with quote

just highlight this instruction "fstp dword ptr [esi+00000218]" in "memory viewer". Then tools->auto assemble, then template->aob injection, then OK, and OK.


replace line
fstp dword ptr [esi+00000218]


with
fstp st(0)



File->assign to current cheat table. Close. Autoassemble window. Close "memory viewer".
In addresslist (bottom part of main CE window) there should be new entry. Change description if you want.
Save your work.

_________________
Back to top
View user's profile Send private message MSN Messenger
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Sun Dec 04, 2016 10:09 am    Post subject: Reply with quote

@mgr.inz.Player thanks for the reply,
Yeah i already had the script, and it is working, but its not disabling instantly.
Here is the script -

[ENABLE]

aobscanmodule(invulnerable,HMA.exe,D9 9E 18 02 00 00 A1) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

newmem:
fstp st(0)

code:
fstp dword ptr [esi+00000218]
jmp return

invulnerable:
jmp newmem
nop
return:
registersymbol(invulnerable)

[DISABLE]

invulnerable:
db D9 9E 18 02 00 00

unregistersymbol(invulnerable)
dealloc(newmem)
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 223

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 04, 2016 10:19 am    Post subject: Reply with quote

You should comment original instruction while using fstp st(0):
Code:
[ENABLE]

aobscanmodule(invulnerable,HMA.exe,D9 9E 18 02 00 00 A1) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

newmem:

code:
//fstp dword ptr [esi+00000218]
fstp st(0)
jmp return

invulnerable:
jmp newmem
nop
return:
registersymbol(invulnerable)

[DISABLE]

invulnerable:
db D9 9E 18 02 00 00

unregistersymbol(invulnerable)
dealloc(newmem)






when someone says: replace this with this. You just do it.

good
Code:
code:
fstp st(0)
jmp return

good (commented original instruction)
Code:
code:
//fstp dword ptr [esi+00000218]
fstp st(0)
jmp return

Code:
code:
fstp st(0)
//fstp dword ptr [esi+00000218]
jmp return

wrong
Code:
code:
fstp dword ptr [esi+00000218]
fstp st(0)
jmp return

Code:
code:
fstp st(0)
fstp dword ptr [esi+00000218]
jmp return

_________________
Back to top
View user's profile Send private message MSN Messenger
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Sun Dec 04, 2016 10:31 am    Post subject: Reply with quote

@mgr.inz.Player Fantastic thanks, it works a treat.

I was under the impression that the new code had to go under the newmem: header, and the original code sat under the code: header, but this works perfect after a quick test. thanks guys.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 223

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 04, 2016 10:57 am    Post subject: Reply with quote

"newmem" and "code" are just labels.

Both sections
- between "newmem:" and "code:"
- between "code:" and "jmp return"

are the "new code". And are placed in freshly allocated memory.


autoassemble commands
new code (new memory) section
overwrite section
CODE wrote:
[ENABLE]
aobscanmodule(invulnerable,HMA.exe,D9 9E 18 02 00 00 A1) // should be unique
alloc(newmem,$1000)

label(code)
label(return)


newmem:

code:
//fstp dword ptr [esi+00000218]
fstp st(0)
jmp return


invulnerable:
jmp newmem
nop
return:

registersymbol(invulnerable)

[DISABLE]

invulnerable:
db D9 9E 18 02 00 00


unregistersymbol(invulnerable)
dealloc(newmem)


About "overwrite section". While enabling cheat it overwrites original instruction(s) with jumpAndNop. While disabling cheat it overwrites jumpAndNop with original instruction(s).

_________________
Back to top
View user's profile Send private message MSN Messenger
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Sun Dec 04, 2016 11:24 am    Post subject: Reply with quote

mgr.inz.Player After reading "The aobscan instruction" by Geri on the tutorials section (which is very informative) one thing i must have misunderstood is where to put the code on the table, to me it suggested the new code had to go under the newmem and original under code, but thanks for enlightening me.

"Both sections
- between "newmem:" and "code:"
- between "code:" and "jmp return"

are the "new code". And are placed in freshly allocated memory."

Could you please explain why the layout of my original table only partially worked and wouldn't disable properly, all the code needed was within the "new code area"

newmem:
fstp st(0)

code:
fstp dword ptr [esi+00000218]
jmp return
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 223

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 04, 2016 11:32 am    Post subject: Reply with quote

In "overwrite section" you have "jmp newmem"
So, injected user code starts at newmem.


Code:
newmem:
fstp st(0)

code:
fstp dword ptr [esi+00000218]
jmp return



CPU will execute those, one-by-one:
- fstp st(0)
- fstp dword ptr [esi+00000218]
- jmp return

So, it is the same as this:
Code:
newmem:
fstp st(0)
fstp dword ptr [esi+00000218]
jmp return







Why "AOB" template has "code" label? Because trainer creators often do this:
Code:
newmem:
// some checks, to be 100% sure it is player health and not enemy
cmp [registerhere+offsethere],specialvaluehereonlyplayerhas
jne code // jump is taken if not equal

//player health
fstp st(0)
jmp return

code:
fstp dword ptr [esi+00000218]
jmp return




PS: it is not nice to quote post when you are still on the same page.

_________________
Back to top
View user's profile Send private message MSN Messenger
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Sun Dec 04, 2016 11:44 am    Post subject: Reply with quote

@mgr.inz.Player When i tried the code like this -

newmem:
fstp st(0)

code:
fstp dword ptr [esi+00000218]
jmp return

It didn't work properly, is it because all the code needs to be together, whether under newmem or code. So the above code has issues in regards to disabling it, but this would work -

newmem:
fstp st(0)
fstp dword ptr [esi+00000218]
jmp return

And this does work (tested) -

code:
//fstp dword ptr [esi+00000218]
fstp st(0)
jmp return
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 223

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sun Dec 04, 2016 11:53 am    Post subject: Reply with quote

for disabling, you need this:
Code:
[DISABLE]

invulnerable:
db D9 9E 18 02 00 00

unregistersymbol(invulnerable)
dealloc(newmem)






Enabling part, "new code (new memory) section"

This is wrong:
Code:
newmem:
fstp st(0)

code:
fstp dword ptr [esi+00000218]
jmp return

and this is also wrong:
Code:
newmem:
fstp st(0)
fstp dword ptr [esi+00000218]
jmp return



good:
Code:
newmem:
fstp st(0)
//fstp dword ptr [esi+00000218]

code:
jmp return

Code:
newmem:
//fstp dword ptr [esi+00000218]
fstp st(0)

code:
jmp return

Code:
newmem:

code:
fstp st(0)
//fstp dword ptr [esi+00000218]
jmp return

Code:
newmem:

code:
//fstp dword ptr [esi+00000218]
fstp st(0)
jmp return

Code:
newmem:
fstp st(0)

code:
//fstp dword ptr [esi+00000218]
jmp return

Code:
newmem:
fstp st(0)
//fstp dword ptr [esi+00000218]
jmp return

Code:
newmem:
//fstp dword ptr [esi+00000218]
fstp st(0)
jmp return



Code:
newmem:
fstp st(0)

code:
jmp return

Code:
newmem:

code:
fstp st(0)
jmp return

Code:
newmem:
fstp st(0)
jmp return




The point is. Fstp instruction, you can not remove it, you have to replace it. And you better not replace one FSTP instruction with two FSTP instructions.



With other instructions, such as "mov [eax+10],edx", you can remove it,
or replace it with "mov [eax+10],(float)100".


 

_________________


Last edited by mgr.inz.Player on Sun Dec 04, 2016 12:10 pm; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
Flux.
Advanced Cheater
Reputation: 0

Joined: 10 Nov 2016
Posts: 88
Location: Another World - N5X2 106311411+2123518

PostPosted: Sun Dec 04, 2016 12:10 pm    Post subject: Reply with quote

@mgr.inz.Player
Thanks for all your help, it is really appreciated.

So the reason the original didn't work was because it needed //, and without the // it was executing the original code.
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