World Executor · Roblox VM

OTH

Install and remove hooks on C closures, fetch the original function beneath any number of layers, and identify hook threads.

Overview

OTH — "over the hook" — is the low-level hooking path for C closures. Where hookfunction is the everyday tool, oth.hook is what you want when several layers of hook are already stacked on a function and you need the genuine original underneath 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 matter when a hook yields: they tell you whether you are running on the hook's thread and give you the one that made the original call.

Hooking C closures