Fix-up encoding/decoding of virtualaddress sdktools type

This commit is contained in:
Kenzzer 2025-11-11 03:48:44 +00:00
parent 6368eb4a5a
commit 871bc2bde3
No known key found for this signature in database
GPG Key ID: 9C827CC8AAC1701D
2 changed files with 19 additions and 4 deletions

View File

@ -63,7 +63,8 @@ inline void DecodePassMethod(ValveType vtype, SDKPassMethod method, PassType &ty
type = PassType_Basic; type = PassType_Basic;
if (vtype == Valve_POD if (vtype == Valve_POD
|| vtype == Valve_Float || vtype == Valve_Float
|| vtype == Valve_Bool) || vtype == Valve_Bool
|| vtype == Valve_VirtualAddress)
{ {
flags = PASSFLAG_BYVAL | PASSFLAG_ASPOINTER; flags = PASSFLAG_BYVAL | PASSFLAG_ASPOINTER;
} else { } else {
@ -573,12 +574,12 @@ static cell_t SDKCall(IPluginContext *pContext, const cell_t *params)
} }
return *addr ? 1 : 0; return *addr ? 1 : 0;
} else if (vc->retinfo->vtype == Valve_VirtualAddress) { } else if (vc->retinfo->vtype == Valve_VirtualAddress) {
void *addr = (void *)vc->retbuf; void *addr = *(void **)vc->retbuf;
if (vc->retinfo->flags & PASSFLAG_ASPOINTER) if (vc->retinfo->flags & PASSFLAG_ASPOINTER)
{ {
addr = *(void **)addr; addr = *(void **)addr;
} }
return g_pSM->ToPseudoAddress((void*)addr); return g_pSM->ToPseudoAddress(addr);
} else { } else {
cell_t *addr = (cell_t *)vc->retbuf; cell_t *addr = (cell_t *)vc->retbuf;
if (vc->retinfo->flags & PASSFLAG_ASPOINTER) if (vc->retinfo->flags & PASSFLAG_ASPOINTER)

View File

@ -295,11 +295,14 @@ DataStatus EncodeValveParam(IPluginContext *pContext,
} }
case Valve_VirtualAddress: case Valve_VirtualAddress:
{ {
cell_t *addr;
pContext->LocalToPhysAddr(param, &addr);
if (data->flags & PASSFLAG_ASPOINTER) if (data->flags & PASSFLAG_ASPOINTER)
{ {
buffer = *(void **)buffer; buffer = *(void **)buffer;
} }
param = g_pSM->ToPseudoAddress((void*)buffer); *addr = g_pSM->ToPseudoAddress(*(void**)buffer);
return Data_Okay; return Data_Okay;
} }
@ -612,6 +615,17 @@ DataStatus DecodeValveParam(IPluginContext *pContext,
} }
case Valve_VirtualAddress: case Valve_VirtualAddress:
{ {
if (data->decflags & VDECODE_FLAG_BYREF)
{
cell_t *addr;
pContext->LocalToPhysAddr(param, &addr);
param = *addr;
}
if (data->flags & PASSFLAG_ASPOINTER)
{
*(void **)buffer = (unsigned char *)_buffer + pCall->stackEnd + data->obj_offset;
buffer = *(void **)buffer;
}
void* addr = g_pSM->FromPseudoAddress(param); void* addr = g_pSM->FromPseudoAddress(param);
if (addr == nullptr && (data->decflags & VDECODE_FLAG_ALLOWNULL) == 0) if (addr == nullptr && (data->decflags & VDECODE_FLAG_ALLOWNULL) == 0)
{ {