|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
broly7 Advanced Cheater Reputation: 0
Joined: 13 Aug 2015 Posts: 60
|
Posted: Thu Apr 02, 2020 11:52 am Post subject: Get DWORD from Array of Bytes |
|
|
Gonna post here this snippet, credits to DarkByte.
Hope it helps somebody that search from google as much as it helped me:
Code: | function getIntFromTableIndex(t, start)
local r={}
local i
for i=start,start+3 do
r[1+i-start]=t[i]
end
return byteTableToDword(r)
end |
LUA itself doesn't provide a function to do this sadly but DB rekts.
|
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1260
|
|
Back to top |
|
|
Corroder Grandmaster Cheater Supreme Reputation: 75
Joined: 10 Apr 2015 Posts: 1667
|
Posted: Fri Apr 03, 2020 9:48 pm Post subject: |
|
|
This is the explanation:
What @broly7 to do is to get 4 bytes value from a bytes table (AOB) which starts from the table index given on the function. Example:
Code: | local bt = { 0x12, 0x10, 0x90 }
print(getIntFromTableIndex(bt, 1)) -- start from index 1
-- the result is 9441298 -> 4 byte for '12 10 90'
print(getIntFromTableIndex(bt, 2))
-- the result is 36880 -> 4 byte for '10 90'
print(getIntFromTableIndex(bt, 3))
-- the result is 144 4 byte for '90'
|
Now compare with this because:
Quote: | LUA itself doesn't provide a function to do this sadly but DB rekts. |
Code: | local bt = { 0x12, 0x10, 0x90 }
local value = byteTableToDword(bt)
print(string.format('0x%0X', value))
print(value) ---> 0x901012 = 9441298
local bt = { 0x10, 0x90 }
local value = byteTableToDword(bt)
print(string.format('0x%0X', value))
print(value) ---> 0x9010 = 36880
local bt = { 0x90 }
local value = byteTableToDword(bt)
print(string.format('0x%0X', value))
print(value) ---> 0x90 = 144
|
So, where is the special?. The function gives you a chance to change bytes table to 4 bytes value, starting from the given index. That's all.
The questions:
1. How if I have a bytes table more than 1000 indexes?. Should I decide where I need to start to change the values?
2. How if the bytes table pattern like this {'90', '19', 'AE') or like this {'0x9019AE', '0xfffff'} or like this {'90 19 AE', 'FF FF FF'}
3. How if the bytes table contains wild char '??'
Of course, the function will return the result as 0.
The conclusion, get 4 bytes value (DWORD) from a bytes table by give the table pattern manually and use byteTableToDword() is better.
_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 32
Joined: 16 Feb 2017 Posts: 1260
|
Posted: Sat Apr 04, 2020 3:46 am Post subject: |
|
|
Thanks for the explanation @Corroder.
Once again I realized that; I can't understand Lua without a sample.
Probably, while sharing the code to this section (Cheat Engine Extensions or Cheat Engine Tutorials); Code + usage example should also be shared.
_________________
|
|
Back to top |
|
|
|
|
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
|
|