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 


What part of code is generating these NOPs?

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

Joined: 02 May 2012
Posts: 82
Location: Flatland

PostPosted: Sun Oct 31, 2021 8:42 am    Post subject: What part of code is generating these NOPs? Reply with quote

Today, while making some cheats, i've encountered a really weird issue, and can't figure it out.
When i enable this script:

Code:

{$STRICT}

// --- check CE version ---

{$lua}
if(getCEVersion() < 7.3) then
  ShowMessage('CE >= v7.3 is required to use this script.')
end

{$asm}
define(orig_god_bytes, orig_bytes)


[ENABLE]

aobscanmodule(god_hook, Game.exe, 48 89 ? ? ? 57 48 83 EC ? 48 8B ? 48 8B ? E8 ? ? ? ? 48 8B)

allocnx(vars, 32)
allocnx(orig_bytes, 32)

alloc(main, 256, god_hook)

registersymbol(vars)
registersymbol(orig_bytes)
registersymbol(god_hook)
registersymbol(godmode)

label(godmode)
label(god_patch)
label(ret_god_hook)

// --- setup variables ---

vars:
  godmode:
    dd 0

// --- save original bytes ---

orig_bytes:
  orig_god_bytes:
    readmem(god_hook, 5)

// --- injection ---

god_hook:
  jmp god_patch
  ret_god_hook:

// --- cave ---

main:
  god_patch:
    cmp [godmode], 1
    je @f
    readmem(god_hook, 5)
    jmp ret_god_hook
    @@:
    ret

[DISABLE]

god_hook:
  readmem(orig_god_bytes, 5)

dealloc(*)
unregistersymbol(*)

instead of patching only 5 bytes (required for this JMP):
Code:

before injection:
7FF7EBF5D870 - 48 89 5C 24 08 - mov [rsp+08],rbx

after injection:
7FF7EBF5D870 - E9 8B279CFF - jmp 7FF7EB920000

CE patches 14 bytes, by inserting this weird 9-byte long NOP slide after the jump:
Code:

7FF7EBF5D870 - E9 8B279CFF - jmp 7FF7EB920000
7FF7EBF5D875 - 66 0F1F 84 00 00000000 - nop word ptr [rax+rax+00000000]

which obviously messes up everything, and crashes the game. Also, the label ret_god_hook inside the allocated code cave points exactly after that NOP slide, at 7FF7EBF5D87E . What is going on here exactly?

_________________
Singularity is nearer.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25793
Location: The netherlands

PostPosted: Sun Oct 31, 2021 9:01 am    Post subject: Reply with quote

do jmp main instead of jmp god_patch as the location of god_patch is unknown at the time the jmp is assembled, but main should be known

or move the god_hook code under main

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Csimbi
I post too much
Reputation: 97

Joined: 14 Jul 2007
Posts: 3324

PostPosted: Sun Oct 31, 2021 11:33 am    Post subject: Reply with quote

In addition to what DB said, you should expect this more and more in x64 titles.
Back to top
View user's profile Send private message
podstanar
Advanced Cheater
Reputation: 4

Joined: 02 May 2012
Posts: 82
Location: Flatland

PostPosted: Mon Nov 01, 2021 7:18 am    Post subject: Reply with quote

Dark Byte wrote:
or move the god_hook code under main


Thanks, this did it. I had no idea AA scripts are parsed in such way, that the order of things could matter. Is there some documentation where i can read what gets parsed when/in which order?

_________________
Singularity is nearer.
Back to top
View user's profile Send private message
STN
I post too much
Reputation: 43

Joined: 09 Nov 2005
Posts: 2676

PostPosted: Mon Nov 01, 2021 2:01 pm    Post subject: Reply with quote

podstanar wrote:
Dark Byte wrote:
or move the god_hook code under main


Thanks, this did it. I had no idea AA scripts are parsed in such way, that the order of things could matter. Is there some documentation where i can read what gets parsed when/in which order?


no but you can look in the source code.

_________________
Cheat Requests/Tables- Fearless Cheat Engine
https://fearlessrevolution.com
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