7
"My Script"
Auto Assembler Script
{$lua}
local function hex(a, c)
if a == nil then
return "(nil)"
end
local fmt = "%X"
if type(c) == "number" then
fmt = "%0"..c.."X"
end
return string.format(fmt, a)
end
local function pointerSize()
if targetIs64Bit() then
return 8
end
return 4
end
local function readSignedInteger(a)
local v = readInteger(a)
if v ~= nil then
if v > 0x7FFFFFFF then
v = -(0x100000000 - v)
end
end
return v
end
local function findRecord(parent, desc)
if parent == nil and memrec ~= nil then
parent = memrec
end
local found
if parent ~= nil and parent.Count > 0 then
local i
for i = 0, parent.Count-1 do
if parent.Child[i].Description == desc then
found = parent.Child[i]
end
end
end
return found
end
local function updateRecord(parent, desc, type, addr, offsets)
if parent == nil and memrec ~= nil then
parent = memrec
end
local rec = findRecord(parent,desc)
if rec == nil then
rec = getAddressList().createMemoryRecord()
rec.Description = desc
rec.VarType = type
if addr ~= nil then
rec.setAddress(addr, offsets)
end
if parent ~= nil then
rec.appendToEntry(parent)
end
else
local a = rec.Address
if addr ~= a then
rec.setAddress(addr, offsets)
end
end
return rec
end
local cached = {}
local function updatePath(path, desc, type, addr, offsets)
if memrec == nil then
return nil
end
local fullpath = ""
if path ~= nil and path ~= "" then
fullpath = path.."\\"..desc
else
fullpath = desc
end
local rec
if cached[fullpath] == nil or cached[fullpath].Parent == nil then
local i
local arr = {}
local parent
for i in string.gmatch(path, "[^\\]+") do
table.insert(arr, i)
end
if #arr > 0 then
local item = table.remove(arr)
parent = updatePath(table.concat(arr, '\\'), item, "vtCustom", 0, {})
else
parent = memrec
end
rec = getAddressList().createMemoryRecord()
rec.Description = desc
rec.VarType = type
rec.setAddress(addr, offsets)
rec.appendToEntry(parent)
if type == "vtCustom" then
rec.IsGroupHeader = true
end
cached[fullpath] = rec
else
rec = cached[fullpath]
local a = rec.Address
if addr ~= a then
rec.setAddress(addr, offsets)
end
end
return cached[fullpath]
end
local function removePath(path)
if cached[path] ~= nil then
if cached[path].getAddress() ~= "" then
cached[path]:Delete()
end
cached[path] = nil
end
end
local function cleanupPath(path, list)
local pathlist = {}
local i,v
for i,v in pairs(list) do
table.insert(pathlist, path.."\\"..i)
end
for i,v in pairs(cached) do
if string.sub(i,1,string.len(path)+1) == path.."\\" then
local r,z
local found = false
for r,z in ipairs(pathlist) do
if i == z or string.sub(i,1,string.len(z)+1) == z.."\\" then
found = true
break
end
end
if not found then
removePath(i)
end
end
end
end
local function getHeader(parent, desc)
if parent == nil and memrec ~= nil then
parent = memrec
end
local rec = findRecord(parent,desc)
if rec == nil then
rec = getAddressList().createMemoryRecord()
rec.Description = desc
rec.IsGroupHeader = true
if parent ~= nil then
rec.appendToEntry(parent)
end
end
return rec
end
local function getFlag(desc)
local result = false
if memrec ~= nil then
local rec = findRecord(memrec, desc)
if rec == nil then
rec = getAddressList().createMemoryRecord()
rec.Description = desc
rec.IsGroupHeader = true
rec.appendToEntry(memrec)
end
result = rec.Active
end
return result
end
local function getCodeOffset(addr, off)
if addr == nil or addr == 0 then
return nil
end
local o = readSignedInteger(addr + off)
if o ~= nil then
return addr + o + off + 4
end
return nil
end
local function followAddress(addr, offs, debug)
local i
for i = 1,#offs do
if addr ~= nil then
local ot = type(offs[i])
if ot == "table" then
if type(offs[i]["offset"]) ~= "number" then
return nil
end
if offs[i]["rc"] == true then
addr = getCodeOffset(addr, offs[i]["offset"])
elseif offs[i]["r32"] == true then
addr = readInteger(addr + offs[i]["offset"])
else
addr = readPointer(addr + offs[i]["offset"])
end
elseif ot == "number" then
addr = readPointer(addr + offs[i])
else
return nil
end
if debug then
print(" "..hex(addr))
end
end
end
return addr
end
if timers == nil then
timers = {}
end
if aobscans == nil then
aobscans = {}
end
local function getTimer()
if memrec ~= nil then
local id = memrec.id
if timers[id] == nil then
timers[id] = createTimer()
timers[id].Enabled = false
timers[id].Interval = getFreezeTimer().Interval
end
return timers[id]
end
return nil
end
local function killTimer()
if memrec ~= nil then
local id = memrec.id
if timers[id] ~= nil then
timers[id]:Destroy()
timers[id] = nil
end
end
end
local function setScan(name, opts)
if memrec == nil then
return false
end
if aobscans[memrec.id] ~= nil then
aobscans[memrec.id][name] = nil
end
if opts["bytes"] == nil then
return false
end
local perm = opts["perm"]
if perm == nil then
perm = "-C-W+X" -- Not CopyOnWrite, Not Writable, but executable by default
end
local startaddress = 0
local endaddress = 0x7FFFFFFFFFFFFFFF
if opts["module"] ~= nil then
startaddress = getAddress(opts["module"])
endaddress = startaddress + getModuleSize(opts["module"])
end
local bytes = opts["bytes"]
local ms = createMemScan()
local success = false
if aobscans[memrec.id] == nil then
aobscans[memrec.id] = {}
end
if ms ~= nil then
ms.firstScan(soExactValue, vtByteArray, 0, bytes, "", startaddress, endaddress, perm, fsmNotAligned, "1", true, false, false, false)
ms.waitTillDone()
local fl = createFoundList(ms)
if fl ~= nil then
fl.initialize()
if fl.Count > 0 then
aobscans[memrec.id][name] = {}
local i
for i=0,fl.Count-1 do
table.insert(aobscans[memrec.id][name], tonumber("0x"..fl.Address[i]))
end
end
fl:Destroy()
end
ms:Destroy()
if success then
return true
end
end
return false
end
local function setScans(list, perm)
local k,v
for k,v in pairs(list) do
setScan(k, v, perm)
end
end
local function getScan(name)
if memrec ~= nil then
local id = memrec.id
if aobscans[id] ~= nil then
if aobscans[id][name] ~= nil then
return aobscans[id][name]
end
end
end
return nil
end
local function forEach(startaddress, toaddress, itemsize, func)
if startaddress < toaddress then
local addr = startaddress
while addr < toaddress do
local r = func(addr)
if r == false then
break
end
addr = addr + itemsize
end
end
end
if syntaxcheck then
return
end
[ENABLE]
--[[
-- For Debugging
local le = getLuaEngine()
le.mOutput.Lines:Clear()
le.cbShowOnPrint.Checked = false
le:Show()
]]--
-- AOBScans here
setScans({
main = {
bytes = "48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 49 8B 06",
module = "ELEX.exe"
},
jetpack = {
bytes = "48 8B 15 ?? ?? ?? ?? 8B C8 2B 8A",
module = "ELEX.exe"
}
})
local function Run()
-- Refresh code here
local freezehp = getFlag("Freeze Health")
local freezestamina = getFlag("Freeze Stamina")
local freezejp = getFlag("Freeze Jet Pack")
local freezesm = getFlag("Freeze Special Meter")
local mainscan = getScan("main")
local jscan = getScan("jetpack")
if jscan ~= nil then
local jaddr = followAddress(jscan[1], { { offset=0x3, rc=true }, 0x0 })
if jaddr ~= nil then
updatePath("", "Jet Pack", "vtSingle", hex(jaddr + 0x1E0), {})
updatePath("", "Max Jet Pack", "vtSingle", hex(jaddr + 0x1E4), {})
if freezejp then
writeInteger(jaddr + 0x1E0, readInteger(jaddr + 0x1E4))
end
end
end
if mainscan ~= nil then
local raddr = followAddress(mainscan[1], { { offset=0x3, rc=true }, 0x60, 0x0, 0x30 })
if raddr ~= nil then
local off = readBytes(raddr + 0x67 + 1)
local maddr = followAddress(mainscan[1], { { offset=0x3, rc=true }, 0x60, 0x0, 0x38, off * 8, 0x218, 0x0, 0x8 })
if maddr ~= nil then
updatePath("Position", "X", "vtDouble", hex(maddr + 0x1D0), {})
updatePath("Position", "Z", "vtDouble", hex(maddr + 0x1D8), {})
updatePath("Position", "Y", "vtDouble", hex(maddr + 0x1E0), {})
end
local off = readBytes(raddr + 0x4D + 1)
local maddr = followAddress(mainscan[1], { { offset=0x3, rc=true }, 0x60, 0x0, 0x38, off * 8 })
if maddr ~= nil then
updatePath("", "Strength", "vtDword", hex(maddr + 0x1*4 + 0x20), {})
updatePath("", "Constitution", "vtDword", hex(maddr + 0x2*4 + 0x20), {})
updatePath("", "Dexterity", "vtDword", hex(maddr + 0x3*4 + 0x20), {})
updatePath("", "Intelligence", "vtDword", hex(maddr + 0x4*4 + 0x20), {})
updatePath("", "Cunning", "vtDword", hex(maddr + 0x5*4 + 0x20), {})
updatePath("", "XP", "vtDword", hex(maddr + 0x6*4 + 0x20), {})
updatePath("", "Cold", "vtDword", hex(maddr + 0x7*4 + 0x20), {})
updatePath("", "Learning Points", "vtDword", hex(maddr + 0x8*4 + 0x20), {})
updatePath("", "Attribute Points", "vtDword", hex(maddr + 0x9*4 + 0x20), {})
updatePath("Abilities", "Melee Weapons", "vtDword", hex(maddr + 0x21*4 + 0x20), {})
updatePath("Abilities", "Ranged Weapons", "vtDword", hex(maddr + 0x22*4 + 0x20), {})
updatePath("Abilities", "Heavy Weapons", "vtDword", hex(maddr + 0x23*4 + 0x20), {})
updatePath("Abilities", "Attack Strength", "vtDword", hex(maddr + 0x24*4 + 0x20), {})
updatePath("Abilities", "Parry Strength", "vtDword", hex(maddr + 0x25*4 + 0x20), {})
updatePath("Abilities", "Heavy Punch", "vtDword", hex(maddr + 0x26*4 + 0x20), {})
updatePath("Abilities", "Grenades", "vtDword", hex(maddr + 0x27*4 + 0x20), {})
updatePath("Abilities", "Jet Pack Attack", "vtDword", hex(maddr + 0x28*4 + 0x20), {})
updatePath("Abilities", "Mutant Killer", "vtDword", hex(maddr + 0x29*4 + 0x20), {})
updatePath("Abilities", "Machine Killer", "vtDword", hex(maddr + 0x2A*4 + 0x20), {})
updatePath("Abilities", "Radiation Resistance", "vtDword", hex(maddr + 0x2B*4 + 0x20), {})
updatePath("Abilities", "Fire Resistance", "vtDword", hex(maddr + 0x2C*4 + 0x20), {})
updatePath("Abilities", "Frost Resistance", "vtDword", hex(maddr + 0x2D*4 + 0x20), {})
updatePath("Abilities", "Poison Resistance", "vtDword", hex(maddr + 0x2E*4 + 0x20), {})
updatePath("Abilities", "Armor", "vtDword", hex(maddr + 0x2F*4 + 0x20), {})
updatePath("Abilities", "Animal Trophies", "vtDword", hex(maddr + 0x30*4 + 0x20), {})
updatePath("Abilities", "Good Eater", "vtDword", hex(maddr + 0x31*4 + 0x20), {})
updatePath("Abilities", "Adventurer", "vtDword", hex(maddr + 0x32*4 + 0x20), {})
updatePath("Abilities", "Sixth Sense", "vtDword", hex(maddr + 0x33*4 + 0x20), {})
updatePath("Abilities", "Extra Hitpoints", "vtDword", hex(maddr + 0x34*4 + 0x20), {})
updatePath("Abilities", "Stamina", "vtDword", hex(maddr + 0x35*4 + 0x20), {})
updatePath("Abilities", "Lock Picking", "vtDword", hex(maddr + 0x36*4 + 0x20), {})
updatePath("Abilities", "Locksmith", "vtDword", hex(maddr + 0x37*4 + 0x20), {})
updatePath("Abilities", "Pickpocket", "vtDword", hex(maddr + 0x38*4 + 0x20), {})
updatePath("Abilities", "You Only Steal Twice", "vtDword", hex(maddr + 0x39*4 + 0x20), {})
updatePath("Abilities", "Modify Weapons", "vtDword", hex(maddr + 0x3A*4 + 0x20), {})
updatePath("Abilities", "Goldsmith", "vtDword", hex(maddr + 0x3B*4 + 0x20), {})
updatePath("Abilities", "Gemstone Socket", "vtDword", hex(maddr + 0x3C*4 + 0x20), {})
updatePath("Abilities", "Chemistry", "vtDword", hex(maddr + 0x3D*4 + 0x20), {})
updatePath("Abilities", "Hack", "vtDword", hex(maddr + 0x3E*4 + 0x20), {})
updatePath("Abilities", "Professional Hacker", "vtDword", hex(maddr + 0x3F*4 + 0x20), {})
updatePath("Abilities", "Hold Your Horses", "vtDword", hex(maddr + 0x40*4 + 0x20), {})
updatePath("Abilities", "Mining", "vtDword", hex(maddr + 0x41*4 + 0x20), {})
updatePath("Abilities", "Attribute Points", "vtDword", hex(maddr + 0x42*4 + 0x20), {})
updatePath("Abilities", "Experienced Hunter", "vtDword", hex(maddr + 0x43*4 + 0x20), {})
updatePath("Abilities", "Bookworm", "vtDword", hex(maddr + 0x44*4 + 0x20), {})
updatePath("Abilities", "Practioner", "vtDword", hex(maddr + 0x45*4 + 0x20), {})
updatePath("Abilities", "Haggler", "vtDword", hex(maddr + 0x46*4 + 0x20), {})
updatePath("Abilities", "Combat Skills", "vtDword", hex(maddr + 0x47*4 + 0x20), {})
updatePath("Abilities", "Survival Skills", "vtDword", hex(maddr + 0x48*4 + 0x20), {})
updatePath("Abilities", "Crafting Skills", "vtDword", hex(maddr + 0x49*4 + 0x20), {})
updatePath("Abilities", "Personality Skills", "vtDword", hex(maddr + 0x4A*4 + 0x20), {})
updatePath("Abilities", "Group", "vtDword", hex(maddr + 0x4B*4 + 0x20), {})
updatePath("Abilities", "Advocate", "vtDword", hex(maddr + 0x4C*4 + 0x20), {})
updatePath("Abilities", "Friend of Beasts", "vtDword", hex(maddr + 0x4D*4 + 0x20), {})
updatePath("Abilities", "Attribute", "vtDword", hex(maddr + 0x4E*4 + 0x20), {})
updatePath("Abilities", "Emotional", "vtDword", hex(maddr + 0x4F*4 + 0x20), {})
updatePath("Abilities", "Balanced", "vtDword", hex(maddr + 0x50*4 + 0x20), {})
updatePath("Abilities", "Synthetic", "vtDword", hex(maddr + 0x51*4 + 0x20), {})
updatePath("Abilities", "Berserker", "vtDword", hex(maddr + 0x52*4 + 0x20), {})
updatePath("Abilities", "Magic", "vtDword", hex(maddr + 0x53*4 + 0x20), {})
updatePath("Abilities", "Mana", "vtDword", hex(maddr + 0x54*4 + 0x20), {})
updatePath("Abilities", "Enchant Weapon", "vtDword", hex(maddr + 0x55*4 + 0x20), {})
updatePath("Abilities", "Scatter Shot", "vtDword", hex(maddr + 0x56*4 + 0x20), {})
updatePath("Abilities", "Seeker Shot", "vtDword", hex(maddr + 0x57*4 + 0x20), {})
updatePath("Abilities", "Camouflage Spell", "vtDword", hex(maddr + 0x58*4 + 0x20), {})
updatePath("Abilities", "Leather Skin Spell", "vtDword", hex(maddr + 0x59*4 + 0x20), {})
updatePath("Abilities", "Aspect of the Warrior Spell", "vtDword", hex(maddr + 0x5A*4 + 0x20), {})
updatePath("Abilities", "Blood Transfer Spell", "vtDword", hex(maddr + 0x5B*4 + 0x20), {})
updatePath("Abilities", "Spirit Wolf Spell", "vtDword", hex(maddr + 0x5C*4 + 0x20), {})
updatePath("Abilities", "Sense Life Spell", "vtDword", hex(maddr + 0x5D*4 + 0x20), {})
updatePath("Abilities", "Poisonous Aura Spell", "vtDword", hex(maddr + 0x5E*4 + 0x20), {})
updatePath("Abilities", "Healing Spell", "vtDword", hex(maddr + 0x5F*4 + 0x20), {})
updatePath("Abilities", "Clerics", "vtDword", hex(maddr + 0x60*4 + 0x20), {})
updatePath("Abilities", "PSI", "vtDword", hex(maddr + 0x61*4 + 0x20), {})
updatePath("Abilities", "Battery", "vtDword", hex(maddr + 0x62*4 + 0x20), {})
updatePath("Abilities", "High-Tech Weaponsmith", "vtDword", hex(maddr + 0x63*4 + 0x20), {})
updatePath("Abilities", "One Man Army", "vtDword", hex(maddr + 0x64*4 + 0x20), {})
updatePath("Abilities", "Suggestion", "vtDword", hex(maddr + 0x65*4 + 0x20), {})
updatePath("Abilities", "Technophile", "vtDword", hex(maddr + 0x66*4 + 0x20), {})
updatePath("Abilities", "Cleansing Ability", "vtDword", hex(maddr + 0x67*4 + 0x20), {})
updatePath("Abilities", "Power Shield", "vtDword", hex(maddr + 0x68*4 + 0x20), {})
updatePath("Abilities", "One with the Weapon Ability", "vtDword", hex(maddr + 0x69*4 + 0x20), {})
updatePath("Abilities", "Phasing Ability", "vtDword", hex(maddr + 0x6A*4 + 0x20), {})
updatePath("Abilities", "Power Wave Ability", "vtDword", hex(maddr + 0x6B*4 + 0x20), {})
updatePath("Abilities", "The Last Stand Ability", "vtDword", hex(maddr + 0x6C*4 + 0x20), {})
updatePath("Abilities", "Perception Ability", "vtDword", hex(maddr + 0x6D*4 + 0x20), {})
updatePath("Abilities", "Outlaw", "vtDword", hex(maddr + 0x6E*4 + 0x20), {})
updatePath("Abilities", "Unscrew", "vtDword", hex(maddr + 0x6F*4 + 0x20), {})
updatePath("Abilities", "Create Ammunition", "vtDword", hex(maddr + 0x70*4 + 0x20), {})
updatePath("Abilities", "Body Chemistry", "vtDword", hex(maddr + 0x71*4 + 0x20), {})
updatePath("Abilities", "Low-Tech Weaponsmith", "vtDword", hex(maddr + 0x72*4 + 0x20), {})
updatePath("Abilities", "Chem Capacity", "vtDword", hex(maddr + 0x73*4 + 0x20), {})
updatePath("Abilities", "Overdrive Stim", "vtDword", hex(maddr + 0x74*4 + 0x20), {})
updatePath("Abilities", "Steel Skim Chem", "vtDword", hex(maddr + 0x75*4 + 0x20), {})
updatePath("Abilities", "Pick-me-up Stim", "vtDword", hex(maddr + 0x76*4 + 0x20), {})
updatePath("Abilities", "Scrap Scanner Chem", "vtDword", hex(maddr + 0x77*4 + 0x20), {})
updatePath("Abilities", "Immune Booster Chem", "vtDword", hex(maddr + 0x78*4 + 0x20), {})
updatePath("Abilities", "Tough Guy Chem", "vtDword", hex(maddr + 0x79*4 + 0x20), {})
updatePath("Abilities", "Mind Charger Stim", "vtDword", hex(maddr + 0x7A*4 + 0x20), {})
updatePath("Abilities", "Animal Lover Chem", "vtDword", hex(maddr + 0x7B*4 + 0x20), {})
updatePath("", "Charisma", "vtDword", hex(maddr + 0x81 * 4 + 0x20), {})
updatePath("", "Max Health", "vtDword", hex(maddr + 0x85*4 + 0x20), {})
updatePath("", "Health", "vtDword", hex(maddr + 0x86*4 + 0x20), {})
updatePath("", "Max Stamina", "vtDword", hex(maddr + 0x89*4 + 0x20), {})
updatePath("", "Level", "vtDword", hex(maddr + 0x8A*4 + 0x20), {})
if freezehp then
writeInteger(maddr + 0x86*4 + 0x20, readInteger(maddr + 0x85*4 + 0x20))
end
end
local off = readBytes(raddr + 0x57 + 1)
local faddr = followAddress(mainscan[1], { { offset=0x3, rc=true }, 0x60, 0x0, 0x38, off * 8 })
if faddr ~= nil then
local saddr = followAddress(faddr, { 0x98 })
if saddr ~= nil then
updatePath("", "Stamina", "vtSingle", hex(saddr + 0x280), {})
updatePath("", "Special Meter", "vtSingle", hex(saddr + 0x2C8), {})
if freezestamina then
writeFloat(saddr + 0x280, readInteger(maddr + 0x89*4 + 0x20))
end
if freezesm then
writeFloat(saddr + 0x2C8, 100)
end
end
end
end
end
collectgarbage()
collectgarbage()
end
if memrec ~= nil then
local t = getTimer()
t.OnTimer = Run
Run()
t.Enabled = true -- Enable timer ONLY after first run in case of error
end
[DISABLE]
if memrec ~= nil then
killTimer()
while memrec.Count > 0 do
memrec.Child[0]:Delete()
end
end
cached = {}
collectgarbage()
collectgarbage()
10
"Inventory"
Auto Assembler Script
{$lua}
local function hex(a, c)
if a == nil then
return "(nil)"
end
local fmt = "%X"
if type(c) == "number" then
fmt = "%0"..c.."X"
end
return string.format(fmt, a)
end
local function pointerSize()
if targetIs64Bit() then
return 8
end
return 4
end
local function readSignedInteger(a)
local v = readInteger(a)
if v ~= nil then
if v > 0x7FFFFFFF then
v = -(0x100000000 - v)
end
end
return v
end
local function findRecord(parent, desc)
if parent == nil and memrec ~= nil then
parent = memrec
end
local found
if parent ~= nil and parent.Count > 0 then
local i
for i = 0, parent.Count-1 do
if parent.Child[i].Description == desc then
found = parent.Child[i]
end
end
end
return found
end
local function updateRecord(parent, desc, type, addr, offsets)
if parent == nil and memrec ~= nil then
parent = memrec
end
local rec = findRecord(parent,desc)
if rec == nil then
rec = getAddressList().createMemoryRecord()
rec.Description = desc
rec.VarType = type
if addr ~= nil then
rec.setAddress(addr, offsets)
end
if parent ~= nil then
rec.appendToEntry(parent)
end
else
local a = rec.Address
if addr ~= a then
rec.setAddress(addr, offsets)
end
end
return rec
end
local cached = {}
local function updatePath(path, desc, type, addr, offsets)
if memrec == nil then
return nil
end
local fullpath = ""
if path ~= nil and path ~= "" then
fullpath = path.."\\"..desc
else
fullpath = desc
end
local rec
if cached[fullpath] == nil or cached[fullpath].Parent == nil then
local i
local arr = {}
local parent
for i in string.gmatch(path, "[^\\]+") do
table.insert(arr, i)
end
if #arr > 0 then
local item = table.remove(arr)
parent = updatePath(table.concat(arr, '\\'), item, "vtCustom", 0, {})
else
parent = memrec
end
rec = getAddressList().createMemoryRecord()
rec.Description = desc
rec.VarType = type
rec.setAddress(addr, offsets)
rec.appendToEntry(parent)
if type == "vtCustom" then
rec.IsGroupHeader = true
end
cached[fullpath] = rec
else
rec = cached[fullpath]
local a = rec.Address
if addr ~= a then
rec.setAddress(addr, offsets)
end
end
return cached[fullpath]
end
local function removePath(path)
if cached[path] ~= nil then
if cached[path].getAddress() ~= "" then
cached[path]:Delete()
end
cached[path] = nil
end
end
local function cleanupPath(path, list)
local pathlist = {}
local i,v
for i,v in pairs(list) do
table.insert(pathlist, path.."\\"..i)
end
for i,v in pairs(cached) do
if string.sub(i,1,string.len(path)+1) == path.."\\" then
local r,z
local found = false
for r,z in ipairs(pathlist) do
if i == z or string.sub(i,1,string.len(z)+1) == z.."\\" then
found = true
break
end
end
if not found then
removePath(i)
end
end
end
end
local function getHeader(parent, desc)
if parent == nil and memrec ~= nil then
parent = memrec
end
local rec = findRecord(parent,desc)
if rec == nil then
rec = getAddressList().createMemoryRecord()
rec.Description = desc
rec.IsGroupHeader = true
if parent ~= nil then
rec.appendToEntry(parent)
end
end
return rec
end
local function getFlag(desc)
local result = false
if memrec ~= nil then
local rec = findRecord(memrec, desc)
if rec == nil then
rec = getAddressList().createMemoryRecord()
rec.Description = desc
rec.IsGroupHeader = true
rec.appendToEntry(memrec)
end
result = rec.Active
end
return result
end
local function getCodeOffset(addr, off)
if addr == nil or addr == 0 then
return nil
end
local o = readSignedInteger(addr + off)
if o ~= nil then
return addr + o + off + 4
end
return nil
end
local function followAddress(addr, offs, debug)
local i
for i = 1,#offs do
if addr ~= nil then
local ot = type(offs[i])
if ot == "table" then
if type(offs[i]["offset"]) ~= "number" then
return nil
end
if offs[i]["rc"] == true then
addr = getCodeOffset(addr, offs[i]["offset"])
elseif offs[i]["r32"] == true then
addr = readInteger(addr + offs[i]["offset"])
else
addr = readPointer(addr + offs[i]["offset"])
end
elseif ot == "number" then
addr = readPointer(addr + offs[i])
else
return nil
end
if debug then
print(" "..hex(addr))
end
end
end
return addr
end
if timers == nil then
timers = {}
end
if aobscans == nil then
aobscans = {}
end
local function getTimer()
if memrec ~= nil then
local id = memrec.id
if timers[id] == nil then
timers[id] = createTimer()
timers[id].Enabled = false
timers[id].Interval = getFreezeTimer().Interval
end
return timers[id]
end
return nil
end
local function killTimer()
if memrec ~= nil then
local id = memrec.id
if timers[id] ~= nil then
timers[id]:Destroy()
timers[id] = nil
end
end
end
local function setScan(name, opts)
if memrec == nil then
return false
end
if aobscans[memrec.id] ~= nil then
aobscans[memrec.id][name] = nil
end
if opts["bytes"] == nil then
return false
end
local perm = opts["perm"]
if perm == nil then
perm = "-C-W+X" -- Not CopyOnWrite, Not Writable, but executable by default
end
local startaddress = 0
local endaddress = 0x7FFFFFFFFFFFFFFF
if opts["module"] ~= nil then
startaddress = getAddress(opts["module"])
endaddress = startaddress + getModuleSize(opts["module"])
end
local bytes = opts["bytes"]
local ms = createMemScan()
local success = false
if aobscans[memrec.id] == nil then
aobscans[memrec.id] = {}
end
if ms ~= nil then
ms.firstScan(soExactValue, vtByteArray, 0, bytes, "", startaddress, endaddress, perm, fsmNotAligned, "1", true, false, false, false)
ms.waitTillDone()
local fl = createFoundList(ms)
if fl ~= nil then
fl.initialize()
if fl.Count > 0 then
aobscans[memrec.id][name] = {}
local i
for i=0,fl.Count-1 do
table.insert(aobscans[memrec.id][name], tonumber("0x"..fl.Address[i]))
end
end
fl:Destroy()
end
ms:Destroy()
if success then
return true
end
end
return false
end
local function setScans(list, perm)
local k,v
for k,v in pairs(list) do
setScan(k, v, perm)
end
end
local function getScan(name)
if memrec ~= nil then
local id = memrec.id
if aobscans[id] ~= nil then
if aobscans[id][name] ~= nil then
return aobscans[id][name]
end
end
end
return nil
end
local function forEach(startaddress, toaddress, itemsize, func)
if startaddress < toaddress then
local addr = startaddress
while addr < toaddress do
local r = func(addr)
if r == false then
break
end
addr = addr + itemsize
end
end
end
if syntaxcheck then
return
end
[ENABLE]
-- For Debugging
--[[
local le = getLuaEngine()
le.mOutput.Lines:Clear()
le.cbShowOnPrint.Checked = false
le:Show()
]]--
-- AOBScans here
setScans({
main = {
bytes = "48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 49 8B 06",
module = "ELEX.exe"
},
lookup = {
bytes = "48 8D 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B 10 EB 07 48 8D 15 ?? ?? ?? ?? 48 8B 03",
module = "ELEX.exe"
},
})
local damageoffset = {
[0x01] = 0x188,
[0x02] = 0x188,
[0x03] = 0x188,
[0x12] = 0x198
}
local stattoname = {
[0x12] = "Fire Resistance",
[0x1B] = "Penalty Enemy Resistance",
[0x1C] = "Bonus Resistance",
[0x85] = "Max Health",
[0x86] = "Health",
[0x88] = "Energy",
[0x89] = "Max Stamina",
[0x8C] = "Parrying Power",
[0x8D] = "Armor",
[0x8F] = "Resistance to Frost",
[0x90] = "Resistance to Poison",
}
local function Run()
-- Refresh code here
local mainscan = getScan("main")
local lookupaddr
local lookupsize
local lscan = getScan("lookup")
if lscan ~= nil then
lookupaddr = followAddress(lscan[1], { { offset=0x3, rc=true }, 0x18 })
end
if mainscan ~= nil then
local raddr = followAddress(mainscan[1], { { offset=0x3, rc=true }, 0x60, 0x0, 0x30 })
if raddr ~= nil then
local off = readBytes(raddr + 0x19 + 1)
local maddr = followAddress(mainscan[1], { { offset=0x3, rc=true }, 0x60, 0x0, 0x38, off * 8 })
if maddr ~= nil then
local cnt = readInteger(maddr + 0x60)
local iaddr = followAddress(maddr, { 0x58 })
if iaddr ~= nil then
local i
for i=0,cnt-1 do
local itemaddr = iaddr + i * 0x48
local v = readInteger(itemaddr + 0x44)
local r = followAddress(itemaddr, { 0x8, 0x0 })
if r ~= nil then
local off = readInteger(r+0x20)
local straddr = followAddress(lookupaddr, { off * 0x18 })
if straddr ~= nil then
local str = readString(straddr, 200)
--print("-------------------------------------------")
--print(hex(itemaddr).." -- " ..str)
local imr = updatePath("Inventory", str, "vtDword", hex(itemaddr + 0x44), {})
local daddr = followAddress(r, {0x30})
if imr.Count == 0 and daddr ~= nil then
local doff = readBytes(daddr + 0x20 + 1)
local daddr = followAddress(r, {0x38, doff * 8})
if daddr ~= nil then
local type = readInteger(daddr + 0xE0)
--print(hex(daddr).." -- " .. hex(type))
updatePath("Inventory\\"..str, "Price", "vtDword", hex(daddr + 0x28), {})
updatePath("Inventory\\"..str, "Type ID", "vtDword", hex(daddr + 0xE0), {})
if damageoffset[type] ~= nil then
updatePath("Inventory\\"..str, "Min Damage", "vtDword", hex(daddr + damageoffset[type]), {})
updatePath("Inventory\\"..str, "Max Damage", "vtDword", hex(daddr + damageoffset[type] + 4), {})
end
local cnt = readInteger(daddr + 0xC8)
local aaddr = followAddress(daddr, { 0xC0 })
local i
if cnt > 0 and cnt<20 then
for i=0,cnt-1 do
local a1addr = aaddr + 0x20 * i
local sid = readInteger(a1addr + 0x8)
if stattoname[sid] ~= nil then
updatePath("Inventory\\"..str, stattoname[sid], "vtDword", hex(a1addr+0x10),{})
else
--print(hex(a1addr).." -- UNKNOWN.." ..hex(sid))
end
end
end
end
end
end
end
end
end
end
end
end
collectgarbage()
collectgarbage()
end
if memrec ~= nil then
local t = getTimer()
t.OnTimer = Run
Run()
t.Inteval = 15000
t.Enabled = true -- Enable timer ONLY after first run in case of error
end
[DISABLE]
if memrec ~= nil then
killTimer()
while memrec.Count > 0 do
memrec.Child[0]:Delete()
end
end
cached = {}
collectgarbage()
collectgarbage()