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 


Script that checks every memory address accessed by function

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

Joined: 26 May 2024
Posts: 2

PostPosted: Sun Jun 30, 2024 3:44 am    Post subject: Script that checks every memory address accessed by function Reply with quote

I want to make a script where I pick a function call and get every memory addressed that's being either written or read from until the function returns. Honestly I feel like this should've been a feature with break and trace but I just don't know how to do it, it would really save a lot of headache. Thanks in advance
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 462

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

PostPosted: Sun Jun 30, 2024 7:43 am    Post subject: Reply with quote

Normally such a list will be so huge it's not useful

but you could use this lua script:
Code:

function cleanList()
  list={}
end

function parse(address)
  if list[address]==nil then
    list[address]=1
  else
    list[address]=list[address]+1
  end

  return false --make search continue
end

function printlist()
  local r={}
  for k,v in pairs(list) do
    local e={}
    e.address=k
    e.count=v
    table.insert(r,e)
  end
  table.sort(r,function(a,b) return a.address<b.address end)

  for i=1,#r do
    printf("%x = %d",r[i].address, r[i].count)
  end
end

cleanList()


then search the break and trace at the start for
Code:

parse(referencedAddress)


and then when done execute lua command printlist()

when doing it again, execute cleanList() first

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

Joined: 04 Jul 2024
Posts: 10

PostPosted: Fri Jul 05, 2024 1:55 pm    Post subject: Reply with quote

Thank you for the script! It works well for tracking memory addresses.

I noticed that the list can still become quite large and I find myself unable to manage. To make the output perhaps useful, I added a filter to only include addresses that are accessed more than a certain number of times.

I hope this helps if you are a newbie like me Smile

function cleanList()
list = {}
end

function parse(address)
if list[address] == nil then
list[address] = 1
else
list[address] = list[address] + 1
end

return false -- make search continue
end

function printlist(minCount)
local r = {}
for k, v in pairs(list) do
if v > minCount then
local e = {}
e.address = k
e.count = v
table.insert(r, e)
end
end
table.sort(r, function(a, b) return a.address < b.address end)

for i = 1, #r do
printf("%x = %d", r[i].address, r[i].count)
end
end

cleanList()


what I am struggling with is when not dealing with smaller functions. e.g. a fairly complex function that accesses a large number of memory addresses, and then list gets quite overwhelming.

Any recommendation on how to manage this, is quite appreciated.

I am thinking of a few modifications to filter out addresses that are accessed less frequently (a specified number of times).

Please let me know if my thinking is on the right track
Back to top
View user's profile Send private message
Csimbi
I post too much
Reputation: 96

Joined: 14 Jul 2007
Posts: 3179

PostPosted: Mon Jul 08, 2024 5:27 am    Post subject: Reply with quote

To me, it'd more interesting to track variables through a function.
For example, I could say, here, the value is in edx before the call.
Tell me what happened with the value in edx.
(added, subtracted, XORed, converted, put into the stack, used as a multiplier, etc.)
Sort of an AI buddy that can follow something for you.
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