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 


Adding an Array of Addresses

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Sun Jun 16, 2024 9:51 am    Post subject: Adding an Array of Addresses Reply with quote

Whenever I come across an array I have to either add it manually or make something in C++ to aid me with the burden.

Is there a way I could add addresses starting from the selected address, ending after the defined number of addresses and separated by given bytes?

Basically, a for loop that will add an address after the last added address until the count of addresses is reached.

Thank you
Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1528

PostPosted: Sun Jun 16, 2024 1:34 pm    Post subject: Reply with quote

Here's an example to get you started.
Sometimes ideas are explained better with code examples.

Code:
function aobSrc(search,cn1,b1,b2,b3)
local resTbl = {"Code not found!"}
fHex = function(s) return string.format("%02X", s) end
local aobs1=AOBScan(search)
  if aobs1~=nil then
      print("0 "..aobs1[0]) -- first address..
    for i=0, aobs1.count -1 do
      if i==cn1 then
        resTbl[1] = aobs1[i]
        resTbl[#resTbl + 1] = aobs1[i].."+"..fHex(b3)
        resTbl[#resTbl + 1] = aobs1[i].."+"..fHex(b2)
        resTbl[#resTbl + 1] = aobs1[i].."+"..fHex(b3)
      end
    end
    aobs1.Destroy()
  end
 return resTbl
end

src1 = "E8 03 00 00 ?? ?? 00 00"
findTbl = aobSrc(src1,8,8,8,8)

-- result
 for l,n in pairs(findTbl) do
  print(l,n)
 end


result:

0 0063DDB6 --> first address..

1 02548E90
2 02548E90+08
3 02548E90+08
4 02548E90+08

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Game Hacking Dojo
Master Cheater
Reputation: 1

Joined: 17 Sep 2023
Posts: 250

PostPosted: Sun Jun 16, 2024 3:51 pm    Post subject: Reply with quote

I'm so sorry it means I did a terrible job explaining my issue.
Imagine an address in my cheat table that points to the beginning of the array of items in my inventory. The inventory size can go as much as 200 items (200*(address_size) bytes).
I want to add this much of addresses (entries) to my cheat table starting from the beginning of the array

I think I'm going to use

Code:
getAddressList().getSelectedRecord()
getAddressList().createMemoryRecord()


I'm asking because I'm not sure if that's possible size changing the entries properties requires the use of the GUI
Not sure if there is another way

Quote:
doDescriptionChange() : Will show the GUI window to change the description of the selected entry
doAddressChange() : Will show the GUI window to change the address of the selected entry
doTypeChange() : Will show the GUI window to change the type of the selected entries
doValueChange() : Will show the GUI window to change the value of the selected entries
Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1528

PostPosted: Sun Jun 16, 2024 5:54 pm    Post subject: Reply with quote

Get what you need from the code.

Or let's continue the solution through approximate codes.

Code:
--------------------------------------------------
function getByteString(address, bytecount)
 local bytes = readBytes(address, bytecount, true)
 if bytes then
 local result = ""
 for i = 1, #bytes do
 if #result > 0 then result = result .. "" end
 result = result .. string.format("%02X", bytes[i]) end
 return result end
end

function stringFromHex(aobs)
local fmttext = ""
 for wrd in aobs:gmatch("%x%x") do
   num = tonumber(wrd,16)
   --print("\nFormat byte:\n"..wrd.." to "..num)
    if num~=0 then
      fmttext = fmttext..string.char(tonumber(num))
    else
     fmttext = fmttext..""
    end
 end
return fmttext
end
---------------------------------------------------
local alst = getAddressList()

function addAddres1(adrr,val,desc)
local memRec = alst.createMemoryRecord()
--memRec.CustomTypeName = "Float Big Endian"
memRec.Type = 6 --vtString=6, vtByteArray=8, vtDword=2
--memRec.ShowAsHex = true -- array of byte
memRec.Description = desc
memRec.Address = adrr
memRec.Value = val
end

---------------------------------------------------

function aobSrc(search,cn1,b1,b2,b3)
local resTbl = {"Code not found!"}
fHex = function(s) return string.format("%02X", s) end
local aobs1=AOBScan(search)
  if aobs1~=nil then
      print("0 "..aobs1[0]) -- first address..
    for i=0, aobs1.count -1 do
      if i==cn1 then
        resTbl[1] = aobs1[i]
        resTbl[#resTbl + 1] = aobs1[i].."+"..fHex(b3)
        resTbl[#resTbl + 1] = aobs1[i].."+"..fHex(b2)
        resTbl[#resTbl + 1] = aobs1[i].."+"..fHex(b3)
      end
    end
    aobs1.Destroy()
  end
 return resTbl
end

src1 = "4D 65 6D 73 63 61 6E"
findTbl = aobSrc(src1,8,4,8,12)

-- result
 for l,n in pairs(findTbl) do
  addr1 = n
  desc = "desc"..l
  val = readString(addr1)
  addAddres1(addr1,val,desc)
 end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
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