AOBScanModule

A forum dedicated to use and support LUA for Cheat Engine.


Post Reply
User avatar
bbfox
Table Master
Table Master
Journeyman Hacker
Journeyman Hacker
Posts: 368
Joined: Sat Jul 23, 2022 8:59 am
Answers: 0
x 777

AOBScanModule

Post by bbfox »

By TheyCallMeTim13 posted in .org forum
pastebin data was gone. here is altered version.

Code: Select all

-- AOBScanModule関数
local debugMode = false
if not AOBScanModule then
    function AOBScanModule(moduleName, signature, scanOptions)
        local baseAddr = nil
        local maxAddr = 0
        local modList

    synchronize(function()
        modList = enumModules()
    end)

    for _, mod in ipairs(modList) do
        if string.lower(mod.Name) == string.lower(moduleName) then
            baseAddr = mod.Address
            maxAddr = baseAddr + mod.Size
            break
        end
    end

    if not baseAddr then
        if debugMode then print("Error: Module " .. moduleName .. " not found!") end
        return nil
    end

    if debugMode then
        print(string.format("%s Base Address: 0x%X", moduleName, baseAddr))
        print(string.format("Scanning Range: 0x%X - 0x%X", baseAddr, maxAddr))
    end

    local ms = createMemScan()

    synchronize(function()
        ms.firstScan(
            soExactValue,
            vtByteArray,
            nil,
            signature,
            nil,
            baseAddr,
            maxAddr,
            scanOptions or "+X+R",
            fsmNotAligned,
            "1",
            true,
            true,
            false,
            false
        )
    end)

    ms.waitTillDone()

    local results = createFoundList(ms)
    results.initialize()

    local addr
    synchronize(function()
        if results.getCount() > 0 then
            addr = results[0]
        end
    end)

    if addr then
        if debugMode then print("AOB found at: 0x" .. addr) end
    else
        if debugMode then print("AOB not found in " .. moduleName) end
    end

    results.destroy()
    ms.destroy()
    return addr
end
end

registerLuaFunctionHighlight('AOBScanModule')

--[[
test AOBScanModule()
local aob_addr_str = AOBScanModule("???.exe", "48 8B 05 ?? ?? ?? ?? 33 ED 48 8B 88", "+X+R")
if aob_addr_str then
    print("Final AOB Address: 0x" .. aob_addr_str)
else
    print("AOB not found in ???.exe")
end
]]--

Post Reply