Add support for custom calling convention passing arguments in registers

If the compiler decided to pass an argument in a register on an internal function instead of pushing it on the stack to save time, allow us to specify the register the parameter is going to be in.

DHookAddParam received another parameter to set the register.
This commit is contained in:
Peace-Maker
2018-01-23 03:15:03 +01:00
parent 5d21350e9e
commit 1b9fa3743f
17 changed files with 555 additions and 36 deletions
+4 -4
View File
@@ -6,7 +6,7 @@
Handle hFlashbangDetonateDetour;
Handle hFlashbangDeafen;
Handle hPercentageOfFlashForPlayer;
//Handle hPercentageOfFlashForPlayer;
public void OnPluginStart()
{
@@ -40,7 +40,7 @@ public void OnPluginStart()
if (!DHookSetFromConf(hFlashbangDeafen, temp, SDKConf_Signature, "Deafen"))
SetFailState("Failed to load Deafen signature from gamedata");
DHookAddParam(hFlashbangDeafen, HookParamType_Float);
DHookAddParam(hFlashbangDeafen, HookParamType_Float, .custom_register=DHookRegister_XMM1);
if (!DHookEnableDetour(hFlashbangDeafen, false, Detour_OnDeafen))
SetFailState("Failed to detour Deafen.");
@@ -51,7 +51,7 @@ public void OnPluginStart()
PrintToServer("CCSPlayer::Deafen detoured!");
hPercentageOfFlashForPlayer = DHookCreateDetour(Address_Null, CallConv_CDECL, ReturnType_Float, ThisPointer_Ignore);
/*hPercentageOfFlashForPlayer = DHookCreateDetour(Address_Null, CallConv_CDECL, ReturnType_Float, ThisPointer_Ignore);
if (!hPercentageOfFlashForPlayer)
SetFailState("Failed to setup detour for PercentageOfFlashForPlayer");
@@ -68,7 +68,7 @@ public void OnPluginStart()
if (!DHookEnableDetour(hPercentageOfFlashForPlayer, true, Detour_OnPercentageOfFlashForPlayer_Post))
SetFailState("Failed to detour PercentageOfFlashForPlayer post.");
PrintToServer("PercentageOfFlashForPlayer detoured!");
PrintToServer("PercentageOfFlashForPlayer detoured!");*/
}
public MRESReturn Detour_OnFlashbangDetonate(int pThis)