Enable check for calling convention

This commit is contained in:
A1mDev 2024-12-31 00:51:23 +07:00
parent 88024a71fc
commit 6eb540a761
3 changed files with 12 additions and 40 deletions

View File

@ -532,6 +532,7 @@ CDynamicHooksSourcePawn::CDynamicHooksSourcePawn(HookSetup *setup, CHook *pDetou
this->hookType = setup->hookType; this->hookType = setup->hookType;
this->m_pDetour = pDetour; this->m_pDetour = pDetour;
this->callConv = setup->callConv; this->callConv = setup->callConv;
this->thisFuncCallConv = setup->callConv;
} }
HookReturnStruct *CDynamicHooksSourcePawn::GetReturnStruct() HookReturnStruct *CDynamicHooksSourcePawn::GetReturnStruct()

View File

@ -1117,16 +1117,10 @@ cell_t Native_GetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param
} }
else else
{ {
/*HookSetup* setup; if(paramStruct->dg->thisFuncCallConv != CallConv_THISCALL)
if(!GetHandleIfValidOrError(g_HookSetupHandle, (void **)&setup, pContext, params[1]))
{
return pContext->ThrowNativeError("Cannot determine calling convention type, parameter 'this' is only available in member functions");
}
if(setup->callConv != CallConv_THISCALL)
{ {
return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'"); return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'");
}*/ }
if(paramStruct->dg->thisType != ThisPointer_Address && paramStruct->dg->thisType != ThisPointer_CBaseEntity) if(paramStruct->dg->thisType != ThisPointer_Address && paramStruct->dg->thisType != ThisPointer_CBaseEntity)
{ {
@ -1213,16 +1207,10 @@ cell_t Native_SetParamObjectPtrVar(IPluginContext *pContext, const cell_t *param
} }
else else
{ {
/*HookSetup* setup; if(paramStruct->dg->thisFuncCallConv != CallConv_THISCALL)
if(!GetHandleIfValidOrError(g_HookSetupHandle, (void **)&setup, pContext, params[1]))
{
return pContext->ThrowNativeError("Cannot determine calling convention type, parameter 'this' is only available in member functions");
}
if(setup->callConv != CallConv_THISCALL)
{ {
return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'"); return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'");
}*/ }
if(paramStruct->dg->thisType != ThisPointer_Address && paramStruct->dg->thisType != ThisPointer_CBaseEntity) if(paramStruct->dg->thisType != ThisPointer_Address && paramStruct->dg->thisType != ThisPointer_CBaseEntity)
{ {
@ -1323,16 +1311,10 @@ cell_t Native_GetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t
} }
else else
{ {
/*HookSetup* setup; if(paramStruct->dg->thisFuncCallConv != CallConv_THISCALL)
if(!GetHandleIfValidOrError(g_HookSetupHandle, (void **)&setup, pContext, params[1]))
{
return pContext->ThrowNativeError("Cannot determine calling convention type, parameter 'this' is only available in member functions");
}
if(setup->callConv != CallConv_THISCALL)
{ {
return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'"); return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'");
}*/ }
if(paramStruct->dg->thisType != ThisPointer_Address && paramStruct->dg->thisType != ThisPointer_CBaseEntity) if(paramStruct->dg->thisType != ThisPointer_Address && paramStruct->dg->thisType != ThisPointer_CBaseEntity)
{ {
@ -1402,16 +1384,10 @@ cell_t Native_SetParamObjectPtrVarVector(IPluginContext *pContext, const cell_t
} }
else else
{ {
/*HookSetup* setup; if(paramStruct->dg->thisFuncCallConv != CallConv_THISCALL)
if(!GetHandleIfValidOrError(g_HookSetupHandle, (void **)&setup, pContext, params[1]))
{
return pContext->ThrowNativeError("Cannot determine calling convention type, parameter 'this' is only available in member functions");
}
if(setup->callConv != CallConv_THISCALL)
{ {
return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'"); return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'");
}*/ }
if(paramStruct->dg->thisType != ThisPointer_Address && paramStruct->dg->thisType != ThisPointer_CBaseEntity) if(paramStruct->dg->thisType != ThisPointer_Address && paramStruct->dg->thisType != ThisPointer_CBaseEntity)
{ {
@ -1480,16 +1456,10 @@ cell_t Native_GetParamObjectPtrString(IPluginContext *pContext, const cell_t *pa
} }
else else
{ {
/*HookSetup* setup; if(paramStruct->dg->thisFuncCallConv != CallConv_THISCALL)
if(!GetHandleIfValidOrError(g_HookSetupHandle, (void **)&setup, pContext, params[1]))
{
return pContext->ThrowNativeError("Cannot determine calling convention type, parameter 'this' is only available in member functions");
}
if(setup->callConv != CallConv_THISCALL)
{ {
return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'"); return pContext->ThrowNativeError("Parameter 'this' is only available in member functions, specify the calling convention type 'thiscall'");
}*/ }
if(paramStruct->dg->thisType != ThisPointer_Address && paramStruct->dg->thisType != ThisPointer_CBaseEntity) if(paramStruct->dg->thisType != ThisPointer_Address && paramStruct->dg->thisType != ThisPointer_CBaseEntity)
{ {

View File

@ -162,6 +162,7 @@ public:
int entity; int entity;
ThisPointerType thisType; ThisPointerType thisType;
HookType hookType; HookType hookType;
CallingConvention thisFuncCallConv;
}; };
class DHooksCallback : public SourceHook::ISHDelegate, public DHooksInfo class DHooksCallback : public SourceHook::ISHDelegate, public DHooksInfo