From d506ce912eb7cb3977d1bbcaa54f55125a0dcb61 Mon Sep 17 00:00:00 2001 From: Drifter Date: Fri, 9 Dec 2016 08:22:09 -0500 Subject: [PATCH 1/9] Make sure hooks are entity hooks before removing. --- listeners.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/listeners.cpp b/listeners.cpp index 97b0f17..fecec95 100644 --- a/listeners.cpp +++ b/listeners.cpp @@ -75,7 +75,7 @@ void DHooksEntityListener::OnEntityDestroyed(CBaseEntity *pEntity) for(int i = g_pHooks.length() -1; i >= 0; i--) { DHooksManager *manager = g_pHooks.at(i); - if(manager->callback->entity == entity) + if(manager->callback->hookType == HookType_Entity && manager->callback->entity == entity) { if(g_pRemoveList.length() == 0) { From a26316ba68289e22d904e661baf72bfd0a1b69b1 Mon Sep 17 00:00:00 2001 From: Drifter Date: Tue, 20 Dec 2016 09:48:26 -0500 Subject: [PATCH 2/9] Fix not ending context. --- vhook.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/vhook.cpp b/vhook.cpp index fca8525..fdcdaf0 100644 --- a/vhook.cpp +++ b/vhook.cpp @@ -354,6 +354,7 @@ void *Callback(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; ret = CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); + g_SHPtr->EndContext(NULL); break; case MRES_ChangedOverride: if(dg->returnType != ReturnType_Void) @@ -381,6 +382,7 @@ void *Callback(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); + g_SHPtr->EndContext(NULL); break; case MRES_Override: if(dg->returnType != ReturnType_Void) @@ -434,6 +436,7 @@ void *Callback(DHooksCallback *dg, void **argStack) g_SHPtr->DoRecall(); g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; + g_SHPtr->EndContext(NULL); } break; default: @@ -535,6 +538,7 @@ float Callback_float(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; *(float *)ret = CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); + g_SHPtr->EndContext(NULL); break; case MRES_ChangedOverride: if(dg->returnType != ReturnType_Void) @@ -555,6 +559,7 @@ float Callback_float(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); + g_SHPtr->EndContext(NULL); break; case MRES_Override: if(dg->returnType != ReturnType_Void) @@ -692,6 +697,7 @@ SDKVector *Callback_vector(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; *vec_result = CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); + g_SHPtr->EndContext(NULL); break; case MRES_ChangedOverride: if(dg->returnType != ReturnType_Void) @@ -712,6 +718,7 @@ SDKVector *Callback_vector(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); + g_SHPtr->EndContext(NULL); break; case MRES_Override: if(dg->returnType != ReturnType_Void) @@ -840,6 +847,7 @@ string_t *Callback_stringt(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; *string_result = CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); + g_SHPtr->EndContext(NULL); break; case MRES_ChangedOverride: if(dg->returnType != ReturnType_Void) @@ -860,6 +868,7 @@ string_t *Callback_stringt(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); + g_SHPtr->EndContext(NULL); break; case MRES_Override: if(dg->returnType != ReturnType_Void) From 2591478eada3ee6d16594dc41629efa7cdbc71c4 Mon Sep 17 00:00:00 2001 From: Drifter Date: Tue, 20 Dec 2016 09:48:44 -0500 Subject: [PATCH 3/9] Update version --- buildbot/product.version | 2 +- product.version | 2 +- sdk/smsdk_config.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/buildbot/product.version b/buildbot/product.version index 50aea0e..7c32728 100644 --- a/buildbot/product.version +++ b/buildbot/product.version @@ -1 +1 @@ -2.1.0 \ No newline at end of file +2.1.1 \ No newline at end of file diff --git a/product.version b/product.version index da52462..2e92e60 100644 --- a/product.version +++ b/product.version @@ -1 +1 @@ -2.1.0-dev +2.1.1-dev diff --git a/sdk/smsdk_config.h b/sdk/smsdk_config.h index 90b54bf..3e154f2 100644 --- a/sdk/smsdk_config.h +++ b/sdk/smsdk_config.h @@ -40,7 +40,7 @@ /* Basic information exposed publicly */ #define SMEXT_CONF_NAME "DHooks" #define SMEXT_CONF_DESCRIPTION "Dynamic Hooks" -#define SMEXT_CONF_VERSION "2.1.0" +#define SMEXT_CONF_VERSION "2.1.1" #define SMEXT_CONF_AUTHOR "Dr!fter" #define SMEXT_CONF_URL "http://www.sourcemod.net/" #define SMEXT_CONF_LOGTAG "DHOOKS" From b14f62435cd9b4b4e625df6d7f74c0ec5925dfd7 Mon Sep 17 00:00:00 2001 From: Drifter Date: Sat, 27 Jan 2018 10:08:03 -0500 Subject: [PATCH 4/9] Update test gamedata. --- sourcemod/gamedata/dhooks-test.games.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sourcemod/gamedata/dhooks-test.games.txt b/sourcemod/gamedata/dhooks-test.games.txt index 479beff..168923a 100644 --- a/sourcemod/gamedata/dhooks-test.games.txt +++ b/sourcemod/gamedata/dhooks-test.games.txt @@ -29,18 +29,18 @@ } "GetMaxs" { - "windows" "338" - "linux" "339" + "windows" "339" + "linux" "340" } "CanUse" { - "windows" "259" - "linux" "260" + "windows" "260" + "linux" "261" } "CanHaveAmmo" { - "windows" "97" - "linux" "97" + "windows" "98" + "linux" "98" } "SetModel" { @@ -49,13 +49,13 @@ } "GetMaxPlayerSpeed" { - "windows" "437" - "linux" "438" + "windows" "438" + "linux" "439" } "GiveAmmo" { - "windows" "251" - "linux" "252" + "windows" "252" + "linux" "253" } "OnTakeDamage" { From cd55a5026ec78befc8691dc9f65b89d99b8ac6ad Mon Sep 17 00:00:00 2001 From: Drifter Date: Sat, 27 Jan 2018 10:08:44 -0500 Subject: [PATCH 5/9] Add support for setting callback when hooking instead of on create only. --- natives.cpp | 55 ++++++++++++++++++++------ sourcemod/scripting/dhooks-test.sp | 8 ++-- sourcemod/scripting/include/dhooks.inc | 8 ++-- vhook.cpp | 4 +- vhook.h | 2 +- 5 files changed, 55 insertions(+), 22 deletions(-) diff --git a/natives.cpp b/natives.cpp index cd718d9..03b472f 100644 --- a/natives.cpp +++ b/natives.cpp @@ -18,14 +18,26 @@ bool GetHandleIfValidOrError(HandleType_t type, void **object, IPluginContext *p return true; } +IPluginFunction *GetCallback(IPluginContext *pContext, HookSetup * setup, const cell_t *params, unsigned int callback_index) +{ + IPluginFunction *ret = NULL; + + if (params[0] >= callback_index) + { + ret = pContext->GetFunctionById(params[callback_index]); + } + + if (!ret && setup->callback) + { + ret = setup->callback; + } + + return ret; +} + //native Handle:DHookCreate(offset, HookType:hooktype, ReturnType:returntype, ThisPointerType:thistype, DHookCallback:callback); cell_t Native_CreateHook(IPluginContext *pContext, const cell_t *params) { - if(!pContext->GetFunctionById(params[5])) - { - return pContext->ThrowNativeError("Failed to retrieve function by id"); - } - HookSetup *setup = new HookSetup((ReturnType)params[3], PASSFLAG_BYVAL, (HookType)params[2], (ThisPointerType)params[4], params[1], pContext->GetFunctionById(params[5])); Handle_t hndl = handlesys->CreateHandle(g_HookSetupHandle, setup, pContext->GetIdentity(), myself->GetIdentity(), NULL); @@ -80,7 +92,7 @@ cell_t Native_AddParam(IPluginContext *pContext, const cell_t *params) return 1; } -// native DHookEntity(Handle:setup, bool:post, entity, DHookRemovalCB:removalcb); +// native DHookEntity(Handle:setup, bool:post, entity, DHookRemovalCB:removalcb, DHookCallback:callback); cell_t Native_HookEntity(IPluginContext *pContext, const cell_t *params) { HookSetup *setup; @@ -111,7 +123,14 @@ cell_t Native_HookEntity(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid entity passed %i", params[2]); } - DHooksManager *manager = new DHooksManager(setup, pEnt, pContext->GetFunctionById(params[4]), post); + IPluginFunction *cb = GetCallback(pContext, setup, params, 5); + + if (!cb) + { + pContext->ThrowNativeError("Failed to hook entity %i, no callback provided", params[2]); + } + + DHooksManager *manager = new DHooksManager(setup, pEnt, pContext->GetFunctionById(params[4]), cb, post); if(!manager->hookid) { @@ -123,7 +142,7 @@ cell_t Native_HookEntity(IPluginContext *pContext, const cell_t *params) return manager->hookid; } -// native DHookGamerules(Handle:setup, bool:post, DHookRemovalCB:removalcb); +// native DHookGamerules(Handle:setup, bool:post, DHookRemovalCB:removalcb, DHookCallback:callback); cell_t Native_HookGamerules(IPluginContext *pContext, const cell_t *params) { HookSetup *setup; @@ -156,7 +175,14 @@ cell_t Native_HookGamerules(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Could not get gamerules pointer"); } - DHooksManager *manager = new DHooksManager(setup, rules, pContext->GetFunctionById(params[3]), post); + IPluginFunction *cb = GetCallback(pContext, setup, params, 4); + + if (!cb) + { + pContext->ThrowNativeError("Failed to hook gamerules, no callback provided"); + } + + DHooksManager *manager = new DHooksManager(setup, rules, pContext->GetFunctionById(params[3]), cb, post); if(!manager->hookid) { @@ -168,7 +194,7 @@ cell_t Native_HookGamerules(IPluginContext *pContext, const cell_t *params) return manager->hookid; } -// DHookRaw(Handle:setup, bool:post, Address:addr, DHookRemovalCB:removalcb); +// DHookRaw(Handle:setup, bool:post, Address:addr, DHookRemovalCB:removalcb, DHookCallback:callback); cell_t Native_HookRaw(IPluginContext *pContext, const cell_t *params) { HookSetup *setup; @@ -200,7 +226,14 @@ cell_t Native_HookRaw(IPluginContext *pContext, const cell_t *params) return pContext->ThrowNativeError("Invalid address passed"); } - DHooksManager *manager = new DHooksManager(setup, iface, pContext->GetFunctionById(params[4]), post); + IPluginFunction *cb = GetCallback(pContext, setup, params, 5); + + if (!cb) + { + pContext->ThrowNativeError("Failed to hook address, no callback provided"); + } + + DHooksManager *manager = new DHooksManager(setup, iface, pContext->GetFunctionById(params[4]), cb, post); if(!manager->hookid) { diff --git a/sourcemod/scripting/dhooks-test.sp b/sourcemod/scripting/dhooks-test.sp index da7c434..2c26da4 100644 --- a/sourcemod/scripting/dhooks-test.sp +++ b/sourcemod/scripting/dhooks-test.sp @@ -54,7 +54,7 @@ public OnPluginStart() hGetModelName = DHookCreate(offset, HookType_Entity, ReturnType_String, ThisPointer_CBaseEntity, GetModelName); offset = GameConfGetOffset(temp, "GetMaxs"); - hGetMaxs = DHookCreate(offset, HookType_Entity, ReturnType_Vector, ThisPointer_Ignore, GetMaxsPost); + hGetMaxs = DHookCreate(offset, HookType_Entity, ReturnType_Vector, ThisPointer_Ignore); offset = GameConfGetOffset(temp, "CanUse"); hHookCanUse = DHookCreate(offset, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, CanUsePost); @@ -78,7 +78,7 @@ public OnPluginStart() DHookAddParam(hAcceptInput, HookParamType_Int); offset = GameConfGetOffset(temp, "GetMaxPlayerSpeed"); - hGetSpeed = DHookCreate(offset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, GetMaxPlayerSpeedPost); + hGetSpeed = DHookCreate(offset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity); offset = GameConfGetOffset(temp, "GiveAmmo"); hGiveAmmo = DHookCreate(offset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, GiveAmmo); @@ -161,11 +161,11 @@ public OnClientPutInServer(client) { DHookEntity(hSetModel, false, client, RemovalCB); DHookEntity(hHookCanUse, true, client, RemovalCB); - DHookEntity(hGetSpeed, true, client, RemovalCB); + DHookEntity(hGetSpeed, true, client, RemovalCB, GetMaxPlayerSpeedPost); DHookEntity(hGiveAmmo, false, client); DHookEntity(hGetModelName, true, client); DHookEntity(hTakeDamage, false, client); - DHookEntity(hGetMaxs, true, client, RemovalCB); + DHookEntity(hGetMaxs, true, client, _ , GetMaxsPost); DHookEntity(hBloodColor, true, client); } diff --git a/sourcemod/scripting/include/dhooks.inc b/sourcemod/scripting/include/dhooks.inc index 6bf8211..381e55f 100644 --- a/sourcemod/scripting/include/dhooks.inc +++ b/sourcemod/scripting/include/dhooks.inc @@ -174,7 +174,7 @@ native bool DHookRemoveEntityListener(ListenType type, ListenCB callback); * * @return Returns setup handle for the hook or INVALID_HANDLE. */ -native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, DHookCallback callback); +native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, ThisPointerType thistype, DHookCallback callback=INVALID_FUNCTION); /* Adds param to a hook setup * @@ -199,7 +199,7 @@ native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPa * @error Invalid setup handle, invalid entity or invalid hook type. * @return -1 on fail a hookid on success */ -native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=INVALID_FUNCTION); +native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); /* Hook gamerules * @@ -210,7 +210,7 @@ native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB remov * @error Invalid setup handle, failing to get gamerules pointer or invalid hook type. * @return -1 on fail a hookid on success */ -native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVALID_FUNCTION); +native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); /* Hook a raw pointer * @@ -222,7 +222,7 @@ native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVA * @error Invalid setup handle, invalid address or invalid hook type. * @return -1 on fail a hookid on success */ -native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=INVALID_FUNCTION); +native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); /* Remove hook by hook id * diff --git a/vhook.cpp b/vhook.cpp index fdcdaf0..008b1f2 100644 --- a/vhook.cpp +++ b/vhook.cpp @@ -14,13 +14,13 @@ using namespace SourceHook; #define OBJECT_OFFSET (sizeof(void *)*2) #endif -DHooksManager::DHooksManager(HookSetup *setup, void *iface, IPluginFunction *remove_callback, bool post) +DHooksManager::DHooksManager(HookSetup *setup, void *iface, IPluginFunction *remove_callback, IPluginFunction *plugincb, bool post) { this->callback = MakeHandler(setup->returnType); this->hookid = 0; this->remove_callback = remove_callback; this->callback->offset = setup->offset; - this->callback->plugin_callback = setup->callback; + this->callback->plugin_callback = plugincb; this->callback->returnFlag = setup->returnFlag; this->callback->thisType = setup->thisType; this->callback->post = post; diff --git a/vhook.h b/vhook.h index c4f581c..4d61265 100644 --- a/vhook.h +++ b/vhook.h @@ -309,7 +309,7 @@ public: class DHooksManager { public: - DHooksManager(HookSetup *setup, void *iface, IPluginFunction *remove_callback, bool post); + DHooksManager(HookSetup *setup, void *iface, IPluginFunction *remove_callback, IPluginFunction *plugincb, bool post); ~DHooksManager() { if(this->hookid) From 16aa7900e0c6742893260bcdd540cfe485e27911 Mon Sep 17 00:00:00 2001 From: Drifter Date: Sat, 27 Jan 2018 10:08:56 -0500 Subject: [PATCH 6/9] Update version --- sdk/smsdk_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/smsdk_config.h b/sdk/smsdk_config.h index 3e154f2..6e0a700 100644 --- a/sdk/smsdk_config.h +++ b/sdk/smsdk_config.h @@ -40,7 +40,7 @@ /* Basic information exposed publicly */ #define SMEXT_CONF_NAME "DHooks" #define SMEXT_CONF_DESCRIPTION "Dynamic Hooks" -#define SMEXT_CONF_VERSION "2.1.1" +#define SMEXT_CONF_VERSION "2.2.0" #define SMEXT_CONF_AUTHOR "Dr!fter" #define SMEXT_CONF_URL "http://www.sourcemod.net/" #define SMEXT_CONF_LOGTAG "DHOOKS" From 17332379cb4539ffb063911b583f28a2024f3c9d Mon Sep 17 00:00:00 2001 From: Drifter Date: Mon, 29 Jan 2018 12:36:26 -0500 Subject: [PATCH 7/9] Update documentation. --- natives.cpp | 8 ++++---- sourcemod/scripting/include/dhooks.inc | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/natives.cpp b/natives.cpp index 03b472f..a0beda4 100644 --- a/natives.cpp +++ b/natives.cpp @@ -35,7 +35,7 @@ IPluginFunction *GetCallback(IPluginContext *pContext, HookSetup * setup, const return ret; } -//native Handle:DHookCreate(offset, HookType:hooktype, ReturnType:returntype, ThisPointerType:thistype, DHookCallback:callback); +//native Handle:DHookCreate(offset, HookType:hooktype, ReturnType:returntype, ThisPointerType:thistype, DHookCallback:callback = INVALID_FUNCTION); // Callback is now optional here. cell_t Native_CreateHook(IPluginContext *pContext, const cell_t *params) { HookSetup *setup = new HookSetup((ReturnType)params[3], PASSFLAG_BYVAL, (HookType)params[2], (ThisPointerType)params[4], params[1], pContext->GetFunctionById(params[5])); @@ -92,7 +92,7 @@ cell_t Native_AddParam(IPluginContext *pContext, const cell_t *params) return 1; } -// native DHookEntity(Handle:setup, bool:post, entity, DHookRemovalCB:removalcb, DHookCallback:callback); +// native DHookEntity(Handle:setup, bool:post, entity, DHookRemovalCB:removalcb, DHookCallback:callback = INVALID_FUNCTION); // Both callbacks are optional cell_t Native_HookEntity(IPluginContext *pContext, const cell_t *params) { HookSetup *setup; @@ -142,7 +142,7 @@ cell_t Native_HookEntity(IPluginContext *pContext, const cell_t *params) return manager->hookid; } -// native DHookGamerules(Handle:setup, bool:post, DHookRemovalCB:removalcb, DHookCallback:callback); +// native DHookGamerules(Handle:setup, bool:post, DHookRemovalCB:removalcb, DHookCallback:callback = INVALID_FUNCTION); // Both callbacks are optional cell_t Native_HookGamerules(IPluginContext *pContext, const cell_t *params) { HookSetup *setup; @@ -194,7 +194,7 @@ cell_t Native_HookGamerules(IPluginContext *pContext, const cell_t *params) return manager->hookid; } -// DHookRaw(Handle:setup, bool:post, Address:addr, DHookRemovalCB:removalcb, DHookCallback:callback); +// DHookRaw(Handle:setup, bool:post, Address:addr, DHookRemovalCB:removalcb, DHookCallback:callback = INVALID_FUNCTION); // Both callbacks are optional cell_t Native_HookRaw(IPluginContext *pContext, const cell_t *params) { HookSetup *setup; diff --git a/sourcemod/scripting/include/dhooks.inc b/sourcemod/scripting/include/dhooks.inc index 381e55f..604b186 100644 --- a/sourcemod/scripting/include/dhooks.inc +++ b/sourcemod/scripting/include/dhooks.inc @@ -170,7 +170,7 @@ native bool DHookRemoveEntityListener(ListenType type, ListenCB callback); * @param hooktype Type of hook * @param returntype Type type of return * @param thistype Type of this pointer or ignore (ignore can be used if not needed) - * @param callback Callback function + * @param callback Optional callback function, if not set here must be set when hooking. * * @return Returns setup handle for the hook or INVALID_HANDLE. */ @@ -187,7 +187,6 @@ native Handle DHookCreate(int offset, HookType hooktype, ReturnType returntype, * @noreturn */ native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPassFlag flag=DHookPass_ByVal); -//native DHookAddParam(Handle:setup, HookParamType:type); /* Hook entity * @@ -195,8 +194,9 @@ native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPa * @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 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) + * @param callback Optional callback function, if not set here must be set when creating the hook. * - * @error Invalid setup handle, invalid entity or invalid hook type. + * @error Invalid setup handle, invalid address, invalid hook type or invalid callback. * @return -1 on fail a hookid on success */ native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); @@ -206,8 +206,9 @@ native int DHookEntity(Handle setup, bool post, int entity, DHookRemovalCB remov * @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 removalcb Callback for when the hook is removed (Game rules hooks are auto-removed on map end and will call this callback) + * @param callback Optional callback function, if not set here must be set when creating the hook. * - * @error Invalid setup handle, failing to get gamerules pointer or invalid hook type. + * @error Invalid setup handle, invalid address, invalid hook type or invalid callback. * @return -1 on fail a hookid on success */ native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); @@ -218,8 +219,9 @@ native int DHookGamerules(Handle setup, bool post, DHookRemovalCB removalcb=INVA * @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 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) + * @param callback Optional callback function, if not set here must be set when creating the hook. * - * @error Invalid setup handle, invalid address or invalid hook type. + * @error Invalid setup handle, invalid address, invalid hook type or invalid callback. * @return -1 on fail a hookid on success */ native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB removalcb=INVALID_FUNCTION, DHookCallback callback=INVALID_FUNCTION); From 67b3b54ae1595db6c8f270dec1c1e6702d3fe9d5 Mon Sep 17 00:00:00 2001 From: Drifter Date: Mon, 29 Jan 2018 12:36:43 -0500 Subject: [PATCH 8/9] Fix crash --- vhook.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/vhook.cpp b/vhook.cpp index 008b1f2..b4a4777 100644 --- a/vhook.cpp +++ b/vhook.cpp @@ -354,7 +354,6 @@ void *Callback(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; ret = CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); - g_SHPtr->EndContext(NULL); break; case MRES_ChangedOverride: if(dg->returnType != ReturnType_Void) @@ -382,7 +381,6 @@ void *Callback(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); - g_SHPtr->EndContext(NULL); break; case MRES_Override: if(dg->returnType != ReturnType_Void) @@ -436,7 +434,6 @@ void *Callback(DHooksCallback *dg, void **argStack) g_SHPtr->DoRecall(); g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; - g_SHPtr->EndContext(NULL); } break; default: @@ -538,7 +535,6 @@ float Callback_float(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; *(float *)ret = CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); - g_SHPtr->EndContext(NULL); break; case MRES_ChangedOverride: if(dg->returnType != ReturnType_Void) @@ -559,7 +555,6 @@ float Callback_float(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); - g_SHPtr->EndContext(NULL); break; case MRES_Override: if(dg->returnType != ReturnType_Void) @@ -697,7 +692,6 @@ SDKVector *Callback_vector(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; *vec_result = CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); - g_SHPtr->EndContext(NULL); break; case MRES_ChangedOverride: if(dg->returnType != ReturnType_Void) @@ -718,7 +712,6 @@ SDKVector *Callback_vector(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); - g_SHPtr->EndContext(NULL); break; case MRES_Override: if(dg->returnType != ReturnType_Void) @@ -847,7 +840,6 @@ string_t *Callback_stringt(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; *string_result = CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); - g_SHPtr->EndContext(NULL); break; case MRES_ChangedOverride: if(dg->returnType != ReturnType_Void) @@ -868,7 +860,6 @@ string_t *Callback_stringt(DHooksCallback *dg, void **argStack) g_SHPtr->SetRes(MRES_SUPERCEDE); mres = MRES_SUPERCEDE; CallVFunction(dg, paramStruct, g_SHPtr->GetIfacePtr()); - g_SHPtr->EndContext(NULL); break; case MRES_Override: if(dg->returnType != ReturnType_Void) From ca920d2d96d9a9717246545b3126ea22e5416b04 Mon Sep 17 00:00:00 2001 From: Drifter Date: Tue, 30 Jan 2018 10:09:57 -0500 Subject: [PATCH 9/9] Update version. --- buildbot/product.version | 2 +- product.version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buildbot/product.version b/buildbot/product.version index 7c32728..e3a4f19 100644 --- a/buildbot/product.version +++ b/buildbot/product.version @@ -1 +1 @@ -2.1.1 \ No newline at end of file +2.2.0 \ No newline at end of file diff --git a/product.version b/product.version index 2e92e60..3ea2a8e 100644 --- a/product.version +++ b/product.version @@ -1 +1 @@ -2.1.1-dev +2.2.0-dev