Skip to content
Thread dispatchOverview

oth.hook

Represents registration of a thread-dispatch callback.

Details#

Installs thread-dispatched interception on a C closure using a Luau callback. The target must be a C closure and the callback a Luau closure; existing oth hooks are replaced. Returns the target, not a saved original. Use oth.get_root_callback inside the handler to call through and oth.unhook for cleanup.

Examples#

Example

Luau
local target = newcclosure(function(n) return n + 1 end)
oth.hook(target, function(n)
    local original = oth.get_root_callback()
    return original(n)
end)
local ok, result = pcall(target, 5)
oth.unhook(target)
print(ok, result)