Oth Library
The oth (Off-Thread-Hook) library provides advanced function hooking capabilities. It is available both under the Volcano.oth namespace and as the global oth table.
WARNING
This is an advanced API. For most use cases, prefer hookfunction from the Hooking page. The oth library is designed for scenarios that require fine-grained control over hook behavior and thread management.
Original Thread Functions
The following functions automatically run on the original thread when called inside an oth hook. You do not need to manually retrieve the original thread to use them:
- All
debugfunctions that accept a stack level (debug.getstack,debug.setstack,debug.getinfo, etc.) getnamecallmethod()andsetnamecallmethod()getcallingscript()checkcaller()debug.getfenv()— use this instead ofgetfenvinsideothhooks (when a level is provided, it uses the original thread)
oth.hook
Creates an advanced hook on a function. Unlike hookfunction, this provides access to the original thread, branching capabilities, and root callback access.
oth.hook(target: function, callback: function) -> void| Parameter | Type | Description |
|---|---|---|
target | function | The function to hook |
callback | function | The hook callback function |
Example
oth.hook(game.FindFirstChild, function(self, ...)
local caller = getcallingscript() -- runs on original thread automatically
if caller then
print("Called from:", caller:GetFullName())
end
-- Call original via root callback
return oth.get_root_callback()(self, ...)
end)oth.unhook
Removes a previously installed oth hook, restoring the original function behavior.
oth.unhook(target: function) -> void| Parameter | Type | Description |
|---|---|---|
target | function | The hooked function to restore |
Example
-- Hook a function
oth.hook(game.FindFirstChild, function(self, ...)
return oth.get_root_callback()(self, ...)
end)
-- Later, remove the hook
oth.unhook(game.FindFirstChild)oth.is_hook_thread
Returns true if the current thread is an oth hook thread. Use this inside hook callbacks to determine context.
oth.is_hook_thread() -> booleanExample
oth.hook(some_function, function(...)
if oth.is_hook_thread() then
print("Running inside oth hook thread")
end
return oth.get_root_callback()(...)
end)oth.get_root_callback
Returns the root (original) callback function. This is especially useful when the hook has a branch — calling the root callback invokes the original function without triggering any existing hook branches.
oth.get_root_callback() -> functionINFO
If oth.has_branch() returns true, using oth.get_root_callback() will bypass all branch hooks and call the original function directly.
Example
oth.hook(game.FindFirstChild, function(self, name, ...)
-- Intercept specific calls
if name == "HiddenPart" then
return nil
end
-- Forward everything else to the original (bypasses any branches)
return oth.get_root_callback()(self, name, ...)
end)oth.get_original_thread
Returns the original thread that initiated the call before it was intercepted by the hook. Useful for inspecting the caller's context.
oth.get_original_thread() -> threadTIP
Most common use cases (getting the caller script, checking identity, etc.) are covered by the original thread functions which run on the original thread automatically. Use oth.get_original_thread() only when you need direct access to the thread object itself.
Example
oth.hook(some_function, function(...)
local caller_thread = oth.get_original_thread()
local script = getscriptfromthread(caller_thread)
if script then
print("Called from:", script:GetFullName())
end
return oth.get_root_callback()(...)
end)oth.has_branch
Returns true if the current hook has a branch (an additional hook layer). When a branch exists, oth.get_root_callback() can be used to call the original function while bypassing the branch.
oth.has_branch(target: function) -> boolean| Parameter | Type | Description |
|---|---|---|
target | function | The hooked function |
Example
local old;
old = oth.hook(some_function, function(...)
if oth.has_branch(some_function) then
print("This hook has a branch, calling root to bypass it")
return oth.get_root_callback()(...)
end
return old(...)
end)Full Example
A complete example demonstrating oth hook usage to intercept and log FindFirstChild calls:
-- Advanced hook on FindFirstChild
oth.hook(game.FindFirstChild, function(self, name, ...)
-- getcallingscript runs on original thread automatically
local caller = getcallingscript()
-- Use debug.getfenv inside oth hooks (not getfenv)
-- When given a level, debug.getfenv uses the original thread
local env = debug.getfenv(1)
print(env.script)
-- Log the call
print(string.format(
"[OTH] FindFirstChild('%s') called from %s",
tostring(name),
caller and caller:GetFullName() or "unknown"
))
-- Block access to specific children
if name == "AntiCheat" then
return nil
end
-- Forward to original
return oth.get_root_callback()(self, name, ...)
end)
-- Clean up when done
task.wait(30)
oth.unhook(game.FindFirstChild)