---- AOBScanModule: Original post by TheyCallMeTim13
---- function AOBScanModule(moduleName, signature, aobSignaturePrivileges, alignmentType, alignmentParam)
---- moduleName: Execueable name
---- signature: aobstring
---- aobSignaturePrivileges: Executable flag: same as aobscan protectionflags. data type is string.
---- X=Executable W=Writable memory C=Copy On Write. Add a + to indicate that flag MUST be set
---- and a - to indicate that that flag MUST NOT be set. (* sets it to don't care)
---- Examples:
---- +W-C = Writable memory exluding copy on write and doesn't care about the Executable flag
---- +X-C-W = Find readonly executable memory
---- +W = Finds all writable memory and don't care about copy on write or execute
---- "" = Find everything (is the same as "*X*C*W" )
---- alignmentType (optional): number :
---- The module to scan for the array of bytes.
---- 0 : No alignment check
---- 1 : Address must be dividable by alignment parameter.
---- 2 : Address must end with alignment parameter.
---- alignmentParam (optional): string :
---- Alignment parameter is a string which either holds the value the addresses must be
---- dividable by or what the last digits of the address must be.
---- Return:
---- userdata : TFoundList :
---- A list of found addresses.
function AOBScanModule(moduleName, signature, aobSignaturePrivileges, alignmentType, alignmentParam)
--checkArgType(moduleName, 1, 'string')
if not signature or not moduleName then return end
index = index or 1
local modStartAddr = getAddress(moduleName)
local modEndAddr = modStartAddr + getModuleSize(moduleName)
local ms = createMemScan()
if type(signature) == 'table' then
local sig = ''
for i, byte in ipairs(signature) do
sig = sig..string.format('%02X', byte)
end
signature = sig
end
ms.firstScan(soExactValue, vtByteArray, nil, signature, nil, modStartAddr, modEndAddr,
aobSignaturePrivileges, alignmentType, alignmentParam, true, true, false, false)
ms.waitTillDone()
local results = createFoundList(ms)
results.initialize()
ms.destroy()
return results
end
registerLuaFunctionHighlight('AOBScanModule')