sdktools: Throw error when invalid address passed to SDKCall (#1265)
This commit is contained in:
parent
1282f13442
commit
f27dc2f4f4
@ -45,6 +45,9 @@ enum SDKPassMethod
|
|||||||
SDKPass_ByRef, /**< Pass an object by reference */
|
SDKPass_ByRef, /**< Pass an object by reference */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//memory addresses below 0x10000 are automatically considered invalid for dereferencing
|
||||||
|
#define VALID_MINIMUM_MEMORY_ADDRESS 0x10000
|
||||||
|
|
||||||
int s_vtbl_index = -1;
|
int s_vtbl_index = -1;
|
||||||
void *s_call_addr = NULL;
|
void *s_call_addr = NULL;
|
||||||
ValveCallType s_vcalltype = ValveCall_Static;
|
ValveCallType s_vcalltype = ValveCall_Static;
|
||||||
@ -365,6 +368,17 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params)
|
|||||||
pContext->LocalToPhysAddr(params[startparam], &cell);
|
pContext->LocalToPhysAddr(params[startparam], &cell);
|
||||||
void *thisptr = reinterpret_cast<void*>(*cell);
|
void *thisptr = reinterpret_cast<void*>(*cell);
|
||||||
|
|
||||||
|
if (thisptr == nullptr)
|
||||||
|
{
|
||||||
|
vc->stk_put(ptr);
|
||||||
|
return pContext->ThrowNativeError("ThisPtr address cannot be null");
|
||||||
|
}
|
||||||
|
else if (reinterpret_cast<uintptr_t>(thisptr) < VALID_MINIMUM_MEMORY_ADDRESS)
|
||||||
|
{
|
||||||
|
vc->stk_put(ptr);
|
||||||
|
return pContext->ThrowNativeError("Invalid ThisPtr address 0x%x is pointing to reserved memory.", thisptr);
|
||||||
|
}
|
||||||
|
|
||||||
*(void **)ptr = thisptr;
|
*(void **)ptr = thisptr;
|
||||||
startparam++;
|
startparam++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user