oth.unhook
Removes a hook created with oth.hook.
Syntax
oth.unhook(target: function) -> booleanParameters
| Parameter | Type | Description |
|---|---|---|
target | function | The hooked function to remove |
Returns
| Type | Description |
|---|---|
boolean | True if the hook was successfully removed |
Description
oth.unhook removes a hook from a function that was created with oth.hook. The function is restored to its original behavior.
Example
-- Hook a function
local originalFunc = oth.hook(someCFunction, function(...)
print("Hooked:", ...)
return originalFunc(...)
end)
-- Later, remove the hook
local success = oth.unhook(someCFunction)
if success then
print("Hook removed successfully")
endCheck Hook Status
local originalFunc = oth.hook(print, function(...)
print("[HOOKED]", ...)
end)
-- Remove hook
if oth.unhook(print) then
print("Hook removed")
else
print("No hook to remove")
endNotes
- Only works on functions hooked with
oth.hook - Returns
falseif the function wasn't hooked or hook removal failed - The original function reference from
oth.hookremains valid after unhooking
Related Functions
oth.hook- Create a hookoth.get_root_callback- Get original function