mirror of
https://github.com/GameHackingBook/GameHackingCode
synced 2026-06-08 11:08:54 +00:00
37 lines
1.0 KiB
Lua
37 lines
1.0 KiB
Lua
function _verifyMap(address)
|
|
local parentItem = readInteger(address + 4) or 0
|
|
|
|
local parentLeftItem = readInteger(parentItem + 0) or 0
|
|
local parentRightItem = readInteger(parentItem + 8) or 0
|
|
|
|
local validParent =
|
|
parentLeftItem == address
|
|
or parentRightItem == address
|
|
if (not validParent) then return false end
|
|
|
|
local tries = 0
|
|
local lastChecked = parentItem
|
|
local parentsParent = readInteger(parentItem + 4) or 0
|
|
while (readInteger(parentsParent + 4) ~= lastChecked and tries < 200) do
|
|
tries = tries + 1
|
|
lastChecked = parentsParent
|
|
parentsParent = readInteger(parentsParent + 4) or 0
|
|
end
|
|
|
|
return readInteger(parentsParent + 4) == lastChecked
|
|
end
|
|
|
|
|
|
function isValueInMap(valueAddress)
|
|
for address = valueAddress - 12, valueAddress - 52, -4 do
|
|
if (_verifyMap(address)) then
|
|
return address
|
|
end
|
|
end
|
|
return 0
|
|
end
|
|
|
|
local node = isValueInMap(addressOfSomeValue)
|
|
if (node > 0) then
|
|
print(string.format("Value in map, top of node at 0x0%x", node))
|
|
end |