Fixed amb583 - Heap courruption when calling functions non-virtually with SDKCall

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401092
This commit is contained in:
Scott Ehlert 2007-07-09 22:36:59 +00:00
parent b94de1dfae
commit 3c31cfe8f5

View File

@ -103,6 +103,34 @@ ValveCall *CreateValveCall(void *addr,
} }
} }
/* Get parameter info */
PassInfo paramBuf[32];
size_t sizes[32];
size_t normSize = 0;
size_t extraSize = 0;
for (unsigned int i=0; i<numParams; i++)
{
bool needs_extra;
if ((size = ValveParamToBinParam(params[i].vtype,
params[i].type,
params[i].flags,
&paramBuf[i],
needs_extra)) == 0)
{
delete vc;
return NULL;
}
if (needs_extra)
{
sizes[i] = size;
} else {
sizes[i] = 0;
}
normSize += paramBuf[i].size;
extraSize += sizes[i];
}
/* Get thisinfo if needed */ /* Get thisinfo if needed */
ValvePassInfo thisbuf; ValvePassInfo thisbuf;
ValvePassInfo *thisinfo = NULL; ValvePassInfo *thisinfo = NULL;
@ -130,37 +158,10 @@ ValveCall *CreateValveCall(void *addr,
} }
thisinfo->encflags = 0; thisinfo->encflags = 0;
thisinfo->offset = 0; thisinfo->offset = 0;
vc->stackSize += sizeof(void *); normSize += sizeof(void *);
cv = CallConv_ThisCall; cv = CallConv_ThisCall;
} }
/* Get parameter info */
PassInfo paramBuf[32];
size_t sizes[32];
size_t normSize = 0;
size_t extraSize = 0;
for (unsigned int i=0; i<numParams; i++)
{
bool needs_extra;
if ((size = ValveParamToBinParam(params[i].vtype,
params[i].type,
params[i].flags,
&paramBuf[i],
needs_extra)) == 0)
{
delete vc;
return NULL;
}
if (needs_extra)
{
sizes[i] = size;
} else {
sizes[i] = 0;
}
normSize += paramBuf[i].size;
extraSize += sizes[i];
}
/* Now we can try creating the call */ /* Now we can try creating the call */
if ((vc->call = g_pBinTools->CreateCall(addr, if ((vc->call = g_pBinTools->CreateCall(addr,
cv, cv,