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:
@@ -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)
|
||||
|
||||
@@ -98,6 +98,45 @@ enum DHookPassFlag
|
||||
DHookPass_OASSIGNOP = (1<<4), /**< Object has an assignment operator */
|
||||
};
|
||||
|
||||
enum DHookRegister
|
||||
{
|
||||
// Don't change the register and use the default for the calling convention.
|
||||
DHookRegister_Default,
|
||||
|
||||
// 8-bit general purpose registers
|
||||
DHookRegister_AL,
|
||||
DHookRegister_CL,
|
||||
DHookRegister_DL,
|
||||
DHookRegister_BL,
|
||||
DHookRegister_AH,
|
||||
DHookRegister_CH,
|
||||
DHookRegister_DH,
|
||||
DHookRegister_BH,
|
||||
|
||||
// 32-bit general purpose registers
|
||||
DHookRegister_EAX,
|
||||
DHookRegister_ECX,
|
||||
DHookRegister_EDX,
|
||||
DHookRegister_EBX,
|
||||
DHookRegister_ESP,
|
||||
DHookRegister_EBP,
|
||||
DHookRegister_ESI,
|
||||
DHookRegister_EDI,
|
||||
|
||||
// 128-bit XMM registers
|
||||
DHookRegister_XMM0,
|
||||
DHookRegister_XMM1,
|
||||
DHookRegister_XMM2,
|
||||
DHookRegister_XMM3,
|
||||
DHookRegister_XMM4,
|
||||
DHookRegister_XMM5,
|
||||
DHookRegister_XMM6,
|
||||
DHookRegister_XMM7,
|
||||
|
||||
// 80-bit FPU registers
|
||||
DHookRegister_ST0
|
||||
};
|
||||
|
||||
typeset ListenCB
|
||||
{
|
||||
//Deleted
|
||||
@@ -198,7 +237,8 @@ native bool DHookDisableDetour(Handle setup, bool post, DHookCallback callback);
|
||||
* @error Invalid setup handle or too many params added (request upping the max in thread)
|
||||
* @noreturn
|
||||
*/
|
||||
native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPassFlag flag=DHookPass_ByVal);
|
||||
native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPassFlag flag=DHookPass_ByVal, DHookRegister custom_register=DHookRegister_Default);
|
||||
//native void DHookAddParam(Handle setup, HookParamType type, int size=-1, DHookPassFlag flag=DHookPass_ByVal);
|
||||
//native DHookAddParam(Handle:setup, HookParamType:type);
|
||||
|
||||
/* Hook entity
|
||||
|
||||
Reference in New Issue
Block a user