OTH
Install and remove hooks on C closures, fetch the original function beneath any number of layers, and identify hook threads.
OTH ("over the hook") is the low level hooking path for C closures. hookfunction is what you'd normally use, but oth.hook is for when there are already a few hooks stacked on a function and you need the real original under all of them.
Hooking a C closure
local original = oth.hook(game.Close, function(...)
warn("something tried to close the game")
-- Deliberately not calling through.
end)
-- Whatever the bottom of the stack is, regardless of who else hooked.
print(oth.get_root_callback(game.Close))
oth.unhook(game.Close)oth.is_hook_thread and oth.get_original_thread are for when a hook yields. They tell you if you're on the hook's thread and give you the thread that made the original call.