From 1ef64c56b50f0a1f7aa9e169fc41d4365607622a Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Tue, 23 Jan 2018 14:01:41 +0100 Subject: [PATCH] Document the new natives in the include file --- sourcemod/scripting/include/dhooks.inc | 66 ++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/sourcemod/scripting/include/dhooks.inc b/sourcemod/scripting/include/dhooks.inc index 5c9e9c7..bde388c 100644 --- a/sourcemod/scripting/include/dhooks.inc +++ b/sourcemod/scripting/include/dhooks.inc @@ -218,21 +218,69 @@ native bool DHookRemoveEntityListener(ListenType type, ListenCB callback); * @param thistype Type of this pointer or ignore (ignore can be used if not needed) * @param callback Callback function * - * @return Returns setup handle for the hook or INVALID_HANDLE. + * @return Returns setup handle for the hook. + * @error Failed to create hook setup handle. */ native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, DHookCallback callback); -native Handle DHookCreateDetour(Address funcaddr, CallingConvention callConv, ReturnType returntype, ThisPointerType thistype); +/** + * Creates a detour + * + * @param funcaddr The address of the function to detour. + * Can be Address_Null if you want to load the address from gamedata using DHookSetFromConf. + * @param callConv Calling convention of the function. + * @param returnType Type of the return value. + * @param thisType Type of this pointer or ignore (ignore can be used if not needed) + * + * @return Setup handle for the detour. + * @error Failed to create detour setup handle. + */ +native Handle DHookCreateDetour(Address funcaddr, CallingConvention callConv, ReturnType returntype, ThisPointerType thisType); + +/** + * Load details for a vhook or detour from a gamedata file. + * + * @param setup Hook setup handle to set the offset or address on. + * @param gameconf GameConfig handle + * @param source Whether to look in Offsets or Signatures. + * @param name Name of the property to find. + * + * @return True on success, false if nothing was found. + * @error Invalid setup handle. + */ native bool DHookSetFromConf(Handle setup, Handle gameconf, SDKFuncConfSource source, const char[] name); + +/** + * Enable the detour of the function described in the hook setup handle. + * + * @param setup Hook setup handle + * @param post True to make the hook a post hook. (If you need to change the retunr value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) + * @param callback Callback function + * + * @return True if detour was enabled, false otherwise. + * @error Hook handle is not setup for a detour. + */ native bool DHookEnableDetour(Handle setup, bool post, DHookCallback callback); + +/** + * Disable the detour of the function described in the hook setup handle. + * + * @param setup Hook setup handle + * @param post True to disable a post hook. + * @param callback Callback function + * + * @return True if detour was disabled, false otherwise. + * @error Hook handle is not setup for a detour or function is not detoured. + */ native bool DHookDisableDetour(Handle setup, bool post, DHookCallback callback); /* Adds param to a hook setup * - * @param setup Setup handle to add the param to. - * @param type Param type - * @param size Used for Objects (not Object ptr) to define the size of the object. - * @param flag Used to change the pass type. + * @param setup Setup handle to add the param to. + * @param type Param type + * @param size Used for Objects (not Object ptr) to define the size of the object. + * @param flag Used to change the pass type. + * @param custom_register The register this argument is passed in instead of the stack. * * @error Invalid setup handle or too many params added (request upping the max in thread) * @noreturn @@ -244,7 +292,7 @@ native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPa /* Hook entity * * @param setup Setup handle to use to add the hook. - * @param post True to make the hook a post hook. (If you need to change the retunr value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) + * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) * @param entity Entity index to hook on. * @param removalcb Callback for when the hook is removed (Entity hooks are auto-removed on entity destroyed and will call this callback) * @@ -256,7 +304,7 @@ native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB remov /* Hook gamerules * * @param setup Setup handle to use to add the hook. - * @param post True to make the hook a post hook. (If you need to change the retunr value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) + * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) * @param removalcb Callback for when the hook is removed (Game rules hooks are auto-removed on map end and will call this callback) * * @error Invalid setup handle, failing to get gamerules pointer or invalid hook type. @@ -267,7 +315,7 @@ native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVA /* Hook a raw pointer * * @param setup Setup handle to use to add the hook. - * @param post True to make the hook a post hook. (If you need to change the retunr value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) + * @param post True to make the hook a post hook. (If you need to change the return value or need the return value use a post hook! If you need to change params and return use a pre and post hook!) * @param addr This pointer address. * @param removalcb Callback for when the hook is removed (Entity hooks are auto-removed on entity destroyed and will call this callback) *