Skip to content

Commit

Permalink
Add pre-hook so DHooks tracks pushed args
Browse files Browse the repository at this point in the history
  • Loading branch information
nosoop committed May 5, 2020
1 parent f8bc6b9 commit 4000ba3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scripting/tf_ontakedamage.sp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include <stocksoup/memory>

#define PLUGIN_VERSION "1.1.0"
#define PLUGIN_VERSION "1.1.1-pre"
public Plugin myinfo = {
name = "[TF2] OnTakeDamage Hooks",
author = "nosoop",
Expand Down Expand Up @@ -95,6 +95,7 @@ public void OnPluginStart() {

Handle dtModifyRules = DHookCreateFromConf(hGameConf,
"CTFGameRules::ApplyOnDamageModifyRules()");
DHookEnableDetour(dtModifyRules, false, OnDamageModifyRulesWindowsHack);
DHookEnableDetour(dtModifyRules, true, OnDamageModifyRules);

delete hGameConf;
Expand Down Expand Up @@ -133,6 +134,17 @@ public MRESReturn Internal_OnTakeDamage(int victim, Handle hReturn, Handle hPara
return MRES_Ignored;
}

/**
* dumb hack to preserve argument values on windows
*
* we don't actually need to do anything in this hook, we just need to add a prehook for dhooks
* to preserve the input params
*/
public MRESReturn OnDamageModifyRulesWindowsHack(Address pGameRules, Handle hReturn,
Handle hParams) {
return MRES_Ignored;
}

public MRESReturn OnDamageModifyRules(Address pGameRules, Handle hReturn, Handle hParams) {
if (DHookGetReturn(hReturn) == true) {
Address pTakeDamageInfo = DHookGetParam(hParams, 1);
Expand Down

0 comments on commit 4000ba3

Please sign in to comment.