How to add WAIT function? Is this possible at all?

Memory scanning, code injection, debugger internals and other gamemodding related discussion
Post Reply
marek1957
Expert Cheater
Expert Cheater
Posts: 155
Joined: Sat Dec 16, 2017 4:46 pm
Reputation: 4

How to add WAIT function? Is this possible at all?

Post by marek1957 »

Hello,
I made a script and I have one problem. When I activate it, its ok, its working perfectly - but now I don't know how to write a code to deactivate it.

This is my script:

Code: Select all

[ENABLE]

aobscanmodule(no_hud_and_no_icons,Asphalt8.exe,FF 50 0C 83 7F 14 02 75 25 83 BF C8 05 00 00 01) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

newmem:
  cmp [edi+14],C
  jb nohudnoicons

code:
  cmp dword ptr [edi+14],02
  jne Asphalt8.exe+2C8F51
  jmp return

nohudnoicons:
  push edi
  mov [edi+14],2
  pop edi
  jmp code

no_hud_and_no_icons+3:
  jmp newmem
  nop
return:
registersymbol(no_hud_and_no_icons)

[DISABLE]


"Asphalt8.exe"+2C8F26:
mov [edi+14],1

no_hud_and_no_icons:
db FF 50 0C 83 7F 14 02 75 25 83 BF C8 05 00 00 01

unregistersymbol(no_hud_and_no_icons)
dealloc(newmem)
Like we can see that the main function which I am hacking is cmp dword ptr [edi+14],02. I am injecting value in edi+14. On this moment is everything good. But when I want to disable this function, I must first: inject a function: mov [edi+14],1 and then change this function to original: cmp dword ptr [edi+14],02 - this is the only way to disable it. I can do it manually but injecting once a nr 1 code, then nr 2 code, but I want all of this operation made by one script. Like you can see in my script, I was trying to write manually injection but i don't know any WAIT function so my script when disabled is writing ONLY original function: cmp dword ptr [edi+14],02 which is not disabling the script at all! Is in CHEAT ENGINE function WAIT or something like that? Then when I deactivate the script, first will inject one code, then wait and inject another code?

I am waiting for your advices.

Thank you.

TimFun13
Expert Cheater
Expert Cheater
Posts: 1354
Joined: Fri Mar 03, 2017 12:31 am
Reputation: 6

Re: How to add WAIT function? Is this possible at all?

Post by TimFun13 »

There really isn't a wait comand, there is "sleep" api, but with what you want to do I would use "readMem" or a "luaCall". For either one you will need to store the address/base to use later, but this assumes that only the one address is accessed by the instruction.

Code: Select all

[ENABLE]

aobscanmodule(no_hud_and_no_icons,Asphalt8.exe,FF 50 0C 83 7F 14 02 75 25 83 BF C8 05 00 00 01) // should be unique
alloc(newmem,$1000)

label(code)
label(return)

label(storedAddress)
registersymbol(storedAddress)

newmem:
  mov [storedAddress],edi
  cmp [edi+14],C
  jb nohudnoicons

code:
  cmp dword ptr [edi+14],02
  jne Asphalt8.exe+2C8F51
  jmp return
  storedAddress:
    dd 0

nohudnoicons:
  // push edi // I don't think you need to push/pop, as edi is not changed
  mov [edi+14],2
 //  pop edi //  I don't think you need these
  jmp code

no_hud_and_no_icons+3:
  jmp newmem
  nop
return:
registersymbol(no_hud_and_no_icons)

[DISABLE]
luaCall(writeInteger('[storedAddress]+14', 1))

no_hud_and_no_icons:
db FF 50 0C 83 7F 14 02 75 25 83 BF C8 05 00 00 01

unregistersymbol(no_hud_and_no_icons)
unregistersymbol(storedAddress)
dealloc(newmem)
[Link]
[Link]
Similar to the "luaCall":
[Link]

marek1957
Expert Cheater
Expert Cheater
Posts: 155
Joined: Sat Dec 16, 2017 4:46 pm
Reputation: 4

Re: How to add WAIT function? Is this possible at all?

Post by marek1957 »

Thanks, all working great, I add my other options and all is working perfectly now, thank you once again!

Code: Select all

[ENABLE]
aobscanmodule(no_hud_and_no_icons,Asphalt8.exe,FF 50 0C 83 7F 14 02 75 25 83 BF C8 05 00 00 01)
alloc(newmem,$1000)
label(code)
label(return)
label(storedAddress)
registersymbol(storedAddress)
newmem:
  mov [storedAddress],edi
  cmp [edi+14],C
  jb nohudnoicons
code:
  cmp dword ptr [edi+14],02
  jne Asphalt8.exe+2C8F51
  jmp return
  storedAddress:
    dd 0
nohudnoicons:
    mov [edi+14],2
   jmp code
no_hud_and_no_icons+3:
  jmp newmem
  nop
return:
registersymbol(no_hud_and_no_icons)
aobscanmodule(no_hud,Asphalt8.exe,96 DF FF 8A 87 F4 04 00 00 88 87 30 75 00 00)
alloc(newmem2,$1000)
label(code2)
label(return2)
newmem2:
code2:
  mov [edi+00007530],01
  jmp return2
no_hud+09:
  jmp newmem2
  nop
return2:
registersymbol(no_hud)
[DISABLE]
luaCall(writeInteger('[storedAddress]+14', 1))
no_hud_and_no_icons:
db FF 50 0C 83 7F 14 02 75 25 83 BF C8 05 00 00 01
unregistersymbol(no_hud_and_no_icons)
unregistersymbol(storedAddress)
dealloc(newmem)
no_hud+09:
  db 88 87 30 75 00 00
unregistersymbol(no_hud)
dealloc(newmem2)

Post Reply

Who is online

Users browsing this forum: No registered users