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 1 hit kill

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
XxSongixX
How do I cheat?
Reputation: 0

Joined: 06 Mar 2022
Posts: 6

PostPosted: Sun Mar 06, 2022 4:13 pm    Post subject: Help with 1 hit kill Reply with quote

Hello, I'm having a bit of a problem with the 1-hit kill code.

The issue is that in the game I manage to drop the life of the enemies to 0 in one hit, but they don't die until they receive the second one, I have tried to solve it on my own, but I can't understand the logic behind it.

I think it's because they activated the death sequence before the life is updated, but I don't know how to fix that.

Code:
[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048,"nioh2.exe"+A30646)
label(returnhere)
label(originalcode)
label(exit)
alloc(ourcode,4,"nioh2.exe"+A30646)

ourcode:
dd (float)9999

newmem: //this is allocated memory, you have read,write,execute access

cmp [rcx+3D4],1
jne originalcode
mov rdx,[ourcode]
mov [rcx+10],rdx
mov rdx,[rcx+28]
jmp exit

originalcode:
mov [rcx+10],rdx
mov rdx,[rcx+28]
mov [rcx+10],0


Thanks for your time.



Mv.png
 Description:
I don't know if this image will help, but I'm attaching it anyway.
 Filesize:  53.51 KB
 Viewed:  2488 Time(s)

Mv.png


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4700

PostPosted: Sun Mar 06, 2022 4:33 pm    Post subject: Reply with quote

Might have something to do with writing 0 to [rcx]. That test rdx,rdx checks if rdx is 0 (which you basically set it to in your injection), and if it is zero, it jumps past writing 0 to rcx. You may want to inject further up to avoid this write and see what happens.

It could also be a check made by the caller. e.g. pseudocode:
Code:
if damageDealt >= healthRemaining then
  kill(...)
else
  damage(...)   // the function you're looking at
end

If you don't know how to read assembly, you're going to have a hard time with this.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Sun Mar 06, 2022 9:13 pm    Post subject: Reply with quote

To supplement ParkourPenguin's advice, You can find the jump pretty easily using break and trace.

Break and trace this instruction once to find the Ret. Follow it, go up one line of code to the call, follow that (This takes you to the start of the current function you are looking at most of the time). Then break and trace from one of the instructions there.

You will perform this last break and trace twice. Once when you are hurting the enemy and once when you are killing the enemy. You will be able to immediately see where the killing branches differently than the hurting. You can change the JE, JNE, JA, JB, etc to a JMP, which means it will always take that branch.

Make sure it does not run for your character or you will be one hit killed, too!
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Sun Mar 06, 2022 11:54 pm    Post subject: Reply with quote

If instruction is accessing health constantly, you can try something like this:

Code:
alloc(newmem,2048,"nioh2.exe"+A30646)
label(returnhere)
label(originalcode)
label(exit)
label(kill)
alloc(ourcode,4,"nioh2.exe"+A30646)

ourcode:
dd (float)9999

newmem: //this is allocated memory, you have read,write,execute access


cmp [rcx+3D4],1
jne kill
mov rdx,[ourcode]
mov [rcx+10],rdx
mov rdx,[rcx+28]
jmp exit

kill:
cmp [rcx+10],0
je originalcode
mov [rcx+10],0
mov rdx,[rcx+28]
jmp exit

originalcode:
mov [rcx+10],rdx
mov rdx,[rcx+28]
jmp exit
Back to top
View user's profile Send private message
XxSongixX
How do I cheat?
Reputation: 0

Joined: 06 Mar 2022
Posts: 6

PostPosted: Tue Mar 08, 2022 6:59 am    Post subject: Reply with quote

++METHOS wrote:
If instruction is accessing health constantly, you can try something like this:

Code:
alloc(newmem,2048,"nioh2.exe"+A30646)
label(returnhere)
label(originalcode)
label(exit)
label(kill)
alloc(ourcode,4,"nioh2.exe"+A30646)

ourcode:
dd (float)9999

newmem: //this is allocated memory, you have read,write,execute access


cmp [rcx+3D4],1
jne kill
mov rdx,[ourcode]
mov [rcx+10],rdx
mov rdx,[rcx+28]
jmp exit

kill:
cmp [rcx+10],0
je originalcode
mov [rcx+10],0
mov rdx,[rcx+28]
jmp exit

originalcode:
mov [rcx+10],rdx
mov rdx,[rcx+28]
jmp exit


The health is not constantly accessing, what happens is that the life reaches 0 but the instructions that make it die are not activated, having to hit again to activate it.

I know I have to inject the code somewhere else, since the time to kill and take life seems to be separate, but I don't know how to find the right place to test. (I hope to make myself understood)
Back to top
View user's profile Send private message
++METHOS
I post too much
Reputation: 92

Joined: 29 Oct 2010
Posts: 4197

PostPosted: Tue Mar 08, 2022 7:15 am    Post subject: Reply with quote

Check to see what accesses and choose an instruction that is accessing constantly. Then try the same approach as posted above and report back.
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
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