ShyTwig16 wrote: ↑Mon Aug 02, 2021 11:03 pm
Not that there was anything wrong with the script, but with these changes you can use the description or ID. Plus I think it makes it a tiny bit more readable, and makes use of the "AddressList" variable CE makes available.
And this post/topic might be better suited in the tools section, or maybe the tutorials section; I think tools is more fitting though. It would help keep it from just getting buried here. Let me know if you would like it moved.
I actually think it would be better to use the getAddressList() to preserve compatibility since I think AddressList is a feature that is only in v7.2+.
Also I like the idea of this going to tools so we can turn it into a repository of helper functions in lua.
Here are some of my contributions:
Simple function for disabling all your scripts at once.
Code: Select all
function disableScripts()
local addList = getAddressList()
for i = 0,addList.Count - 1 do
if addList[i].Type == vtAutoAssembler and addList[i].Description ~= 'Enable' then addList[i].Active = false end
end
end
Just returns the Base and Size of a module which you can use in search limits.
Code: Select all
function getModuleLimits(moduleName)
local modList = enumModules()
local moduleTemp = nil
local params = nil
for i = 1,#modList do
if moduleName == modList[i].Name then
moduleTemp = modList[i]
end
end
if moduleTemp then
params = {moduleTemp.Address,getModuleSize(moduleName)}
end
return params
end
Function for getting the address or parameter from an opcode. Useful for getting base addresses within a module or making sure your offsets are always correct when you have an AOB with wildcards.
Code: Select all
function getParamFromOpcode(opAddr)
local disassembler = createDisassembler()
disassembler.disassemble(opAddr)
local disTable = disassembler.getLastDisassembleData()
local modrm = disTable.modrmValue
local param = disTable.parameterValue
if modrm and modrm ~= 0 then return modrm
elseif param and param ~= 0 then return param end
return nil
end
Simple timer creation function to keep things organized:
Code: Select all
function createMyTimer(func,params,interval)
if func == nil then return nil end
local timer = createTimer()
timer.Interval = interval
timer.OnTimer = function() func(params) end
return timer
end
Functions for quickly adding/removing records or headers to your table:
Code: Select all
function createRecord(base,desc,vType,topRec)
local addList = getAddressList()
local newRec = addList.createMemoryRecord()
newRec.Address = base
newRec.Description = desc
newRec.Type = vType
if topRec then newRec.appendToEntry(topRec) end
end
For the headers keep in mind that the offset list must be in descending order (top to bottom).
Code: Select all
function createHeader(base,desc,offList,topRec)
local addList = getAddressList()
local header = addList.createMemoryRecord()
header.Address = base
header.OffsetCount = #offList
for i = 0,#offList - 1 do
header.Offset[i] = offList[i+1]
end
header.Description = desc
header.IsAddressGroupHeader = true
header.options = '[moHideChildren]'
if topRec then header.appendToEntry(topRec) end
return header
end
Code: Select all
function removeRecords(mainRec)
if mainRec ~= nil then
while mainRec.Count > 0 do
mainRec.Child[0]:Delete()
end
end
end