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 


Editing Break and Trace's TreeNode.Data

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

Joined: 27 Dec 2022
Posts: 6

PostPosted: Tue Dec 27, 2022 6:33 pm    Post subject: Editing Break and Trace's TreeNode.Data Reply with quote

I am currently working on an extension to save snapshots of a memory region in Break and Trace instructions and I've run into a bit of a wall.

I wanted to read & modify the data the tracer writes and to my understanding, each TreeNode has a pointer to such data (TfrmTracer.lvTracer.Items[i].Data). However this pointer is to memory belonging to Cheat Engine, not the target process, and thus the read functions return nothing.

Here's an example to show what I'm talking about
Code:
-- Be sure you have a Tracer with items in it before running

function test()
   for i = 0, getFormCount() - 1 do
      local frm = getForm(i)

      if frm.ClassName == "TfrmTracer" then
         local treeView = frm.lvTracer
         local dataPtr = treeView.Items[1].Data
         print("dataPtr: "   .. tostring(dataPtr or "nil"))
         print("firstByte: " .. tostring(readBytes(dataPtr, 1) or "nil"))
         -- dataPtr: 346845872
         -- firstByte: nil
      end
   end
end

test()


Is there any way to access Cheat Engine's memory from another target process?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4289

PostPosted: Tue Dec 27, 2022 7:26 pm    Post subject: Reply with quote

kojocrash wrote:
Is there any way to access Cheat Engine's memory from another target process?
I don't know why you're asking that. You seem to want to access CE's memory from inside of CE itself. Maybe the misunderstanding is that Lua is run inside of CE and not the target process.

There's local read functions. celua.txt:
Quote:
readBytesLocal(address,bytecount, ReturnAsTable) : See readBytes but then it's for Cheat engine's memory
readSmallIntegerLocal(address) : Reads a 16-bit integer from the specified address in CE's memory
readIntegerLocal(address) : Reads a 32-bit integer from the specified address in CE's memory
readQwordLocal(address) : Reads a 64-bit integer from the specified address in CE's memory
readPointerLocal(address) : ReadQwordLocal/ReadIntegerLocal depending on the cheat engine build
readFloatLocal(address) : Reads a single precision floating point value from the specified address in CE's memory
readDoubleLocal(address) : Reads a double precision floating point value from the specified address in CE's memory
readStringLocal(address, maxlength, widechar OPTIONAL)

You'd need to dig through CE's source to figure out what that Data field actually means. Also this could arbitrarily change on any update to CE.

_________________
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
kojocrash
How do I cheat?
Reputation: 0

Joined: 27 Dec 2022
Posts: 6

PostPosted: Tue Dec 27, 2022 7:51 pm    Post subject: Reply with quote

ParkourPenguin wrote:
There's local read functions. celua.txt:


I have no idea how I missed that, you're a life saver!
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 Lua Scripting 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