1

I can get AOB from 4 bytes value (DWORD) using this function on Cheat Engine Lua:

local bt = dwordToByteTable(1075734118)
for i, v in ipairs(bt) do
  print(i, string.format('%02x', v))
end

result = [[
1 66 
2 66 
3 1e 
4 40 
]]

but I want the result as '66 66 1e 40'.

  1. How set the regex for this?.
  2. If I have a table like this:

    cd = { 1075734118, 1075734118, 1075996262, 1076953088, 1076651622, 1076953088, 1076835123 }

How I get AOB for each item on the table with output as no.1?

JoeFern
  • 117
  • 1
  • 8

2 Answers2

0

Found solution:

cd = { 1075734118, 1075734118, 1075996262, 1076953088, 1076651622, 1076953088, 1076835123 }

function byte2aob(b) return type(b)=='number' and b<256 and b>=0 and string.format('%02X',b) or '??' end
function aob2byte(a) a = tonumber(a,16) return type(a)=='number' and a <256 and a>=0 and a or -1 end
function imap(t,f) local s={} for i=1,#t do s[i]=f(t[i]) end return s end
function n2bt(n,t) t=type(t)=='string' and t or 'dword'  return rawget(_G,t..'ToByteTable')(n) end
function t2aob(t,sep) return table.concat(imap(t,byte2aob),type(sep)=='string' and sep or ' ') end
function n2aob(n,t) return t2aob(n2bt(n,t)) end

for i = 1, #cd do
 print(n2aob(cd[i],'dword'))
end

result = [[
66 66 1E 40 
66 66 1E 40 
66 66 22 40 
00 00 31 40 
66 66 2C 40 
00 00 31 40 
33 33 2F 40 
]]
JoeFern
  • 117
  • 1
  • 8
0

Try this code:

print((string.format("%08x",1075734118):reverse():gsub("(.)(.)","%2%1 ")))
lhf
  • 70,581
  • 9
  • 108
  • 149