syn.oth

Functions

hook

function syn.oth.hook(target: function, hook: function)

A secure version of hookfunction for C functions that works by running hook code on separate threads. When a hooked function is called, a new or cached hook thread is resumed with the hook and any passed arguments. The returned callback can be used to execute the original function on the original, calling thread.

In the context of a hook thread, the following functions behave as though being called under the original thread:

  • getnamecallmethod
  • setnamecallmethod
  • checkcaller
  • checkcallstack
  • getcallingscript
  • the debug library (debug.*)
  • TODO

unhook

bool syn.oth.unhook(target: function, hook_or_callback?: function)

Un-hooks a function hooked with syn.oth.hook. The second parameter is not required if the function has only been hooked once. Returns true upon success.

get_root_callback

function syn.oth.get_root_callback()

Returns a function that can be used to call the original function in the context of a hook thread. Useful for when a function is hooked multiple times and the callback you receive from syn.oth.hook executes the next hook in the chain, not the original function.

is_hook_thread

bool syn.oth.is_hook_thread()

Returns true if this thread is a hook thread.

get_original_thread

thread syn.oth.get_original_thread()

Return the original thread this hook comes from, or nil if the current thread is not a hook.