Fix crash when accessing invalid argument index
Just return null if a user tries to access an invalid argument that wasn't defined when detouring the function.
This commit is contained in:
parent
9bbca712b6
commit
b16d1f9f3f
@ -129,6 +129,9 @@ int x86MsCdecl::GetArgRegisterSize()
|
|||||||
|
|
||||||
void* x86MsCdecl::GetArgumentPtr(int iIndex, CRegisters* pRegisters)
|
void* x86MsCdecl::GetArgumentPtr(int iIndex, CRegisters* pRegisters)
|
||||||
{
|
{
|
||||||
|
if (iIndex < 0 || iIndex >= m_vecArgTypes.length())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// Check if this argument was passed in a register.
|
// Check if this argument was passed in a register.
|
||||||
if (m_vecArgTypes[iIndex].custom_register != None)
|
if (m_vecArgTypes[iIndex].custom_register != None)
|
||||||
{
|
{
|
||||||
|
@ -137,6 +137,9 @@ int x86MsStdcall::GetArgRegisterSize()
|
|||||||
|
|
||||||
void* x86MsStdcall::GetArgumentPtr(int iIndex, CRegisters* pRegisters)
|
void* x86MsStdcall::GetArgumentPtr(int iIndex, CRegisters* pRegisters)
|
||||||
{
|
{
|
||||||
|
if (iIndex < 0 || iIndex >= m_vecArgTypes.length())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// Check if this argument was passed in a register.
|
// Check if this argument was passed in a register.
|
||||||
if (m_vecArgTypes[iIndex].custom_register != None)
|
if (m_vecArgTypes[iIndex].custom_register != None)
|
||||||
{
|
{
|
||||||
|
@ -150,11 +150,17 @@ void* x86MsThiscall::GetArgumentPtr(int iIndex, CRegisters* pRegisters)
|
|||||||
// TODO: Allow custom this register.
|
// TODO: Allow custom this register.
|
||||||
return pRegisters->m_ecx->m_pAddress;
|
return pRegisters->m_ecx->m_pAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The this pointer isn't explicitly defined as an argument.
|
||||||
|
iIndex--;
|
||||||
|
|
||||||
|
if (iIndex < 0 || iIndex >= m_vecArgTypes.length())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
// Check if this argument was passed in a register.
|
// Check if this argument was passed in a register.
|
||||||
if (m_vecArgTypes[iIndex-1].custom_register != None)
|
if (m_vecArgTypes[iIndex].custom_register != None)
|
||||||
{
|
{
|
||||||
CRegister *pRegister = pRegisters->GetRegister(m_vecArgTypes[iIndex-1].custom_register);
|
CRegister *pRegister = pRegisters->GetRegister(m_vecArgTypes[iIndex].custom_register);
|
||||||
if (!pRegister)
|
if (!pRegister)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -162,7 +168,7 @@ void* x86MsThiscall::GetArgumentPtr(int iIndex, CRegisters* pRegisters)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int iOffset = 4;
|
int iOffset = 4;
|
||||||
for(int i=0; i < iIndex-1; i++)
|
for(int i=0; i < iIndex; i++)
|
||||||
{
|
{
|
||||||
if (m_vecArgTypes[i].custom_register == None)
|
if (m_vecArgTypes[i].custom_register == None)
|
||||||
iOffset += m_vecArgTypes[i].size;
|
iOffset += m_vecArgTypes[i].size;
|
||||||
|
Loading…
Reference in New Issue
Block a user