Help! Hook script in libtool

tvhieu

Platinian
HI guys, im trying to hook a function to copy or inspect the parameter. but i alway got crash when ever try to print the parameter
:( can any1 give me an example code or docs about the script in libtool.
Code:
TrophiesManager = Class.fromName("Managers.Trophies.TrophiesManager")
MethodHook = TrophiesManager.KFJBHDHFFFD

hook {
    method = MethodHook,

    after = function(...)
        local argc = select("#", ...)

        print("argc =", argc)

        for i = 1, argc do
            local v = select(i, ...)
            print(i, type(v))
        end
    end
}
 
TrophiesManager = Class.fromName("Managers.Trophies.TrophiesManager")
MethodHook = TrophiesManager.KFJBHDHFFFD

hook {
method = MethodHook,
after = function(...)
local argc = select("#", ...)
print("--- Hook Triggered (after) ---")
print("Argument Count (argc) =", argc)

for i = 1, argc do
local v = select(i, ...)

local success, err = pcall(function()
if v == nil then
print(string.format("[%d] Nil", i))
elseif type(v) == "userdata" or type(v) == "table" then
print(string.format("[%d] Type: %s, Value: %s", i, type(v), tostring(v)))
else
print(string.format("[%d] Type: %s, Value: %s", i, type(v), v))
end
end)

if not success then
print(string.format("[%d] Error (Potential Pointer): %s", i, tostring(err)))
end
end
end
}
 
Back
Top Bottom