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 


How to retrieve Register's value to use outside of script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Rexkh
Newbie cheater
Reputation: 0

Joined: 04 Feb 2020
Posts: 18

PostPosted: Mon Feb 10, 2020 1:56 am    Post subject: How to retrieve Register's value to use outside of script Reply with quote

Hi, How can I move value of ESP into a variable and use that variable in Cheat Table.

mov myAddress,ESP then

Add the variable in Cheat Table(Ex. myAddress+18)
Back to top
View user's profile Send private message
DanyDollaro
Master Cheater
Reputation: 3

Joined: 01 Aug 2019
Posts: 334

PostPosted: Mon Feb 10, 2020 11:53 am    Post subject: Reply with quote

You must use the Registersymbol() function.
Code:
[ENABLE]

aobscanmodule(INJECT,devenv.exe,00 00 00 00 00 00)
alloc(newmem,$1000)
alloc(myAddress, 8) // <- Look at this
registersymbol(myAddress) // <- this

label(code)
label(return)

newmem:
  mov [myAddress], esp // <- this

code:
  add [eax],al
  add [eax],al
  add [eax],al
  jmp return

INJECT+03:
  jmp newmem
  nop

return:
registersymbol(INJECT)

[DISABLE]

INJECT+03:
  db 00 00 00 00 00 00

unregistersymbol(INJECT)
unregistersymbol(myAddress) // <- and this
dealloc(newmem)
dealloc(myAddress)


At the end, just add the name of the symbol you used in this case "myAddress" to the cheat table to be able to edit the value ESP was pointing at that moment.

Full cheat table:
Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="29">
  <CheatEntries>
    <CheatEntry>
      <ID>0</ID>
      <Description>"Auto Assemble script"</Description>
      <LastState/>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]

aobscanmodule(INJECT,devenv.exe,00 00 00 00 00 00)
alloc(newmem,$1000)
alloc(myAddress, 8)
registersymbol(myAddress)

label(code)
label(return)

newmem:
  mov [myAddress], esp

code:
  add [eax],al
  add [eax],al
  add [eax],al
  jmp return

INJECT+03:
  jmp newmem
  nop

return:
registersymbol(INJECT)

[DISABLE]

INJECT+03:
  db 00 00 00 00 00 00

unregistersymbol(INJECT)
unregistersymbol(myAddress)
dealloc(newmem)
dealloc(myAddress)
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>1</ID>
      <Description>"Your address"</Description>
      <VariableType>4 Bytes</VariableType>
      <Address>myAddress</Address>
    </CheatEntry>
  </CheatEntries>
  <UserdefinedSymbols/>
</CheatTable>


If you want to add an offset you can use "myAddress + 18"
Back to top
View user's profile Send private message
Rexkh
Newbie cheater
Reputation: 0

Joined: 04 Feb 2020
Posts: 18

PostPosted: Tue Feb 11, 2020 2:06 am    Post subject: Reply with quote

It works as expected. Thanks

On the other hand, I know we can set Data Breakpoint condition on an address. Can we set condition on FPU register? Ex. What opcode write/push (float)160 to ST(0)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Tue Feb 11, 2020 2:15 am    Post subject: Reply with quote

yes, but you have to predeclare a function in lua first for that to work

Code:

function getFP0()
  debug_getContext(true)
  return byteTableToExtended(FP0)
end


then you can use as condition:
Code:

getFP0()==160

_________________
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
Rexkh
Newbie cheater
Reputation: 0

Joined: 04 Feb 2020
Posts: 18

PostPosted: Tue Feb 11, 2020 2:28 am    Post subject: Reply with quote

I'm not sure where to declare this function in Cheat Engine.
Where can I use the condition getFP0()==160?
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