Add compiled function browsing
ExtReMLapin opened this issue · 2 comments
ExtReMLapin commented
Personal notes :
Hook function compilation as runstring/compilestring is a function call on a string
check location name, manually read file provided and it file doesn't exist or match bytecode then it's a runstring/compilestring call
then keep function in a list and assign UID + browse bytecode with glib
ExtReMLapin commented
Pseudosish non-working code I did at work without testing :
local ignored_funcs = {}
local saved_funcs = {}
local settings = {
path = {checkFakePath = false,
compareFilePathBytecode = false
}
}
local function call_wrapper(_)
assert(_ == "call")
local debugInfos = debug.getinfo(2, "flnSu")
local curFunction = debugInfos.func
if ignored_funcs[curFunction] then return end
local source = debugInfos.source -- source might need to be reformated to work with file.Read(source, "LUA")
if source == "=[C]" then goto FAIL_JUMP end
local lineDefined = debugInfos.linedefined
if lineDefined ~= 0 then goto FAIL_JUMP end
if file.Exists(source, "LUA") then
local code = file.Read(source, "LUA")
local bytecode = CompileString(code)
if string.dump(curFunction) == string.dump(bytecode) then
goto FAIL_JUMP
end
end
table.insert(saved_funcs, curFunction)
return
::FAIL_JUMP:: -- could be removed because of `dead code removal` optimization
ignored_funcs[curFunction] = true
end
debug.sethook(call_wrapper, "c")
ExtReMLapin commented
Added in 42c0354