Is there a way to dump text data in cheatengine?

Anything Cheat Engine related, bugs, suggestions, helping others, etc..
Post Reply
User avatar
eggs
Expert Cheater
Expert Cheater
Posts: 129
Joined: Wed Mar 26, 2025 7:35 pm
Reputation: 169

Is there a way to dump text data in cheatengine?

Post by eggs »

I was looking for a textfield/console-like element where i can dump strings into to creat a log for better debugging. After sifffings through the forum i was not able to find anything too relevant . Is it possible with lua UI, are there working examples for it?

What i want to do:
For the game heroes of hammerwatch II the game mainly runs off angelscript. At this point i wanted to to hook into the angelscript functions to dump the data. For this i prepared angelscript function offsets and inject into them. The final goal is to hook into setArg() and prepare() functions
inside of prepare() i get the the asIScriptFunctionObject pointer which i can than use to call asIScriptFunction::GetName() this all already works.

Spoiler
Image

Code: Select all

{ Game   : HWR2.exe
  Version: 
  Date   : 2025-04-02
  Author : eggs

  Angelscrit SetArgDword https://www.angelcode.com/angelscript/sdk/docs/manual/classas_i_script_context.html#a14cac831c1b419f552ca62a239dfcf45
  Function as follows:
  __int64 __fastcall setArgInt(__int64 engineCtxPtr, unsigned int argnumber, int value)

}

[ENABLE]

aobscanmodule(INJECTint,HWR2.exe,48 89 6C 24 ?? 56 48 83 EC 20 83 79 18 04 41 8B E8 44 8B CA 48 8B F1 74 10 B8 ?? ?? ?? ?? 48 8B 6C 24 ?? 48 83 C4 20 5E C3 48 8B 91 ?? ?? ?? ?? 44 3B 8A ?? ?? ?? ?? 72 17 C7 41 ?? ?? ?? ?? ?? B8 ?? ?? ?? ?? 48 8B 6C 24 ?? 48 83 C4 20 5E C3) // should be unique
alloc(newmem,$1000,INJECTint)

label(code)
label(return)
label(set_r8)

newmem:

  cmp r8,1         // Check if r8 == 1
  je set_r8        
  cmp r8,-1        // Check if r8 == -1
  je set_r8        /
  jmp code         // If neither, continue execution

set_r8:
  mov r8,5         // Set r8 to 5 this is just a small test 
  jmp code         // Continue execution

code:
 // < ========= HERE I WANT TO DUMP R8 (value) and RDX(arguementnumber) somewhere into a console
  mov [rsp+18],rbp
  jmp return

INJECTint:
  jmp newmem
return:
registersymbol(INJECTint)

[DISABLE]

INJECTint:
  db CC 89 6C 24 18

unregistersymbol(INJECTint)
dealloc(newmem)

{
// ORIGINAL CODE - INJECTION POINT: HWR2.asGetLibraryVersion+7A50

HWR2.asGetLibraryVersion+7A43: 48 83 C4 20     - add rsp,20
HWR2.asGetLibraryVersion+7A47: 5F              - pop rdi
HWR2.asGetLibraryVersion+7A48: C3              - ret 
HWR2.asGetLibraryVersion+7A49: CC              - int 3 
HWR2.asGetLibraryVersion+7A4A: CC              - int 3 
HWR2.asGetLibraryVersion+7A4B: CC              - int 3 
HWR2.asGetLibraryVersion+7A4C: CC              - int 3 
HWR2.asGetLibraryVersion+7A4D: CC              - int 3 
HWR2.asGetLibraryVersion+7A4E: CC              - int 3 
HWR2.asGetLibraryVersion+7A4F: CC              - int 3 
// ---------- INJECTING HERE ----------
HWR2.asGetLibraryVersion+7A50: 48 89 6C 24 18  - mov [rsp+18],rbp
// ---------- DONE INJECTING  ----------
HWR2.asGetLibraryVersion+7A55: 56              - push rsi
HWR2.asGetLibraryVersion+7A56: 48 83 EC 20     - sub rsp,20
HWR2.asGetLibraryVersion+7A5A: 83 79 18 04     - cmp dword ptr [rcx+18],04
HWR2.asGetLibraryVersion+7A5E: 41 8B E8        - mov ebp,r8d
HWR2.asGetLibraryVersion+7A61: 44 8B CA        - mov r9d,edx
HWR2.asGetLibraryVersion+7A64: 48 8B F1        - mov rsi,rcx
HWR2.asGetLibraryVersion+7A67: 74 10           - je HWR2.asGetLibraryVersion+7A79
HWR2.asGetLibraryVersion+7A69: B8 FC FF FF FF  - mov eax,FFFFFFFC
HWR2.asGetLibraryVersion+7A6E: 48 8B 6C 24 40  - mov rbp,[rsp+40]
HWR2.asGetLibraryVersion+7A73: 48 83 C4 20     - add rsp,20
}

So at this point, instead of writing and compiling my own cpp console application for debugging is there a best-practise to dump the returned functionnames and than the passed arguements into an console-like ui using just cheatengine?

Frouk
Expert Cheater
Expert Cheater
Posts: 90
Joined: Wed Jun 30, 2021 10:21 am
Reputation: 18

Re: Is there a way to dump text data in cheatengine?

Post by Frouk »

set breakpoint in the Cheat Engine after you enable debugger in that modified code of yours

User avatar
eggs
Expert Cheater
Expert Cheater
Posts: 129
Joined: Wed Mar 26, 2025 7:35 pm
Reputation: 169

Re: Is there a way to dump text data in cheatengine?

Post by eggs »

Frouk wrote:
Wed Apr 02, 2025 9:30 am
set breakpoint in the Cheat Engine after you enable debugger in that modified code of yours
ah im sorry maybe i didnt express myself correctly, I want to dump all the functioncalls (functionname, arguements) made by angelscript while the script is active into "something", without having to pause the game on each functioncall
especially when i want to do an custom functioncall in in prepare() to get the functionname.

Paul44
RCE Fanatics
RCE Fanatics
Posts: 988
Joined: Thu Jul 27, 2017 9:02 am
Reputation: 683

Re: Is there a way to dump text data in cheatengine?

Post by Paul44 »

^ indeed: use a breakpoint, but... then set condition thereby using lua - in your case 'print' for example - via 'complex' option
eg:
local addr = R8
print(string.format('%X',addr))
return (conditon)

TIP: use lua console to test your script first (during a break so you'll see the info). if it returns errrors, CE will ignore the script AND does not report them errors. Iow it will just continue running as if the breakpoint was not there !
TIP2: use 'condition' (0/1) to break explicitly (eg: if R8==0x(specific_address) then condition = 1 end)
TIP3: disable 'focus' in lua engine, so it does not constantly switch back to it...

Post Reply

Who is online

Users browsing this forum: No registered users