HookDaedalus
Info
Dependencies:
- None
Implementation:
HookDaedalus.d on GitHub
This package allows hooking daedalus functions. The principle is similar HookEngine. We have a function (hooked function) into which we would like to hook another function (hook function).
Tip
Having to hook a Daedalus function should be pretty rare, because you can simply adjust the corresponding function. However, it may become necessary in some contexts.
Initialization
N/A
Functions
HookDaedalusFunc
HookDaedalusFunc
Hooks the function.
var func hooked
Hooked functionvar func hook
Hook function
HookDaedalusFuncF
HookDaedalusFuncF
Alias to the HookDaedalusFunc
function.
var func hooked
Hooked functionvar func hook
Hook function
HookDaedalusFuncI
HookDaedalusFuncI
HookDaedalusFunc
but with function ID.
var int hookedID
ID of hooked functionvar int hookID
ID of hook function
HookDaedalusFuncS
HookDaedalusFuncS
HookDaedalusFunc
but with function name.
var string hookedName
Name of hooked functionvar string hookName
Name of hook function
IsHookD
IsHookD
Checks whether a function is already hooking another. Each function can be hooked any number of times, but each function can only hook one other.
var int funcID
Symbol index of a hook function
Return value
The function returns TRUE
if the function is already hooking another, FALSE
is returned otherwise.
ContinueCall
PassArgumentI
PassArgumentI
Passes an integer as an argument to the original function. Must be called before ContinueCall
.
var int i
Integer argument to forward
PassArgumentS
PassArgumentS
Passes a string as an argument to the original function. Must be called before ContinueCall
.
var string s
String argument to forward
PassArgumentN
PassArgumentN
Passes an instance as an argument to the original function. Must be called before ContinueCall
.
var instance n
Instance argument to forward
Examples
Hook before function
We have a hook:
Hook after function
We have the same hook:
ContinueCall();
is called first: Arguments and return values
If a function to be hooked expects parameters or returns a value, our hooking function should conform to that.
PassArgumentI(i)
to ensure that it is still on top of the stack when the program continues with hooked. Manipulation of arguments and return values
We can also manipulate arguments and return values with our hook.
Multiple hooks
A function can be hooked any number of times, but each function can only hook one. New hooks are always inserted after the previous one. The following example illustrates this quite well.