Added lua scripts and fixed a typo in state machine code

This commit is contained in:
Nick Cano
2016-06-06 22:36:51 -07:00
parent 50152ef2c9
commit aceb397307
6 changed files with 131 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
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