mirror of
https://github.com/alliedmodders/sourcemod.git
synced 2025-12-06 18:08:36 +00:00
Some checks failed
Continuous Integration / ${{ matrix.os_short }}-${{ matrix.compiler_cc }} (clang, clang++, ubuntu-latest, linux) (push) Has been cancelled
Continuous Integration / ${{ matrix.os_short }}-${{ matrix.compiler_cc }} (clang-14, clang++-14, ubuntu-22.04, linux) (push) Has been cancelled
Continuous Integration / ${{ matrix.os_short }}-${{ matrix.compiler_cc }} (msvc, windows-latest, win) (push) Has been cancelled
hl2sdk-mock tests / mock (push) Has been cancelled
SourcePawn scripting / build (ubuntu-latest, linux) (push) Has been cancelled
SourcePawn scripting / build (windows-latest, win) (push) Has been cancelled
In the current ongoing effort for sourcemod to fully support 64 bits, we are introducing "virtual address".
# Explanation
Because SourcePawn does not yet support a 64 bits-wide type it's been impossible for any plugins to hold addresses in regular 32-bits wide variable.
A first attempt at solving this issue was made in commit ce1a4dcac0 therein dubbed "PseudoAddress", however this turned out to be an unsatisfactory solution, as any 'high' address if offsetted could turn invalid (or outright be impossible to map).
This leaves us with three alternatives :
- New type
- Convert Address into a handle
- Virtual Address
A new type is the most destructive solution, as it entails breaking every single Address related method. While that solution is still not off the table, we're reserving it as the last attempt should this commit fail.
Converting into a handle type is a good compromise between a brand new type whilst also preserving the Address methods. However, this comes with two issues: the first being that you can no longer offset Address, the second is that we would require authors to free the handle type which will be very confusing. This will likely not be implemented.
# Virtual address
Under a reasonable assumption, we've noted that the average plugin is unlikely to play with more than 4 GB of memory; this shouldn't be too surprising as all valve games were once 32bits and therefore limited to 4GB. Assuming this stays mostly true and a plugin isn't interested with the mapped memory of lesser known modules (like soundlib or matlib), it is fair to assume plugins are unlikely to access more than 4GB of mapped memory. Working with this in mind, we map the memory the plugins are likely to access to our custom virtual address ranges (from 0 to 4Gb, the values of which can fit on 32bits variable). If any memory was missed and plugins were to try an access it later those ranges will be late-mapped to our virtual address ranges until we run out of them.
In order to use virtual addressing, whether on 32 bits or 64 bits. Plugins must now "#include <virtual_address>", as well as use the new SDKCall_VirtualAddress, SDKType_VirtualAddress, LoadAddressFromAddress & StoreAddressToAddress where it's appropriate to.
643 lines
16 KiB
C++
643 lines
16 KiB
C++
/**
|
|
* vim: set ts=4 :
|
|
* =============================================================================
|
|
* SourceMod SDKTools Extension
|
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
* =============================================================================
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
* Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
* details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License along with
|
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
* this exception to all derivative works. AlliedModders LLC defines further
|
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
* or <http://www.sourcemod.net/license.php>.
|
|
*
|
|
* Version: $Id$
|
|
*/
|
|
|
|
#include "smsdk_ext.h"
|
|
#include "extension.h"
|
|
#include "vdecoder.h"
|
|
#include "vcallbuilder.h"
|
|
|
|
using namespace SourceMod;
|
|
using namespace SourcePawn;
|
|
|
|
/**
|
|
* For object pointers, the data looks like this instead:
|
|
* 4 bytes: POINTER TO LATER
|
|
* + bytes: Object internal data
|
|
*
|
|
* We use the virtual stack as extra fake stack space and create a temp object.
|
|
* If these objects had destructors, we'd need to fake destroy toom of course.
|
|
* Of course, BinTools only reads the first four bytes and passes the pointer.
|
|
*/
|
|
|
|
size_t ValveParamToBinParam(ValveType type,
|
|
PassType pass,
|
|
unsigned int flags,
|
|
PassInfo *info,
|
|
bool &needs_extra)
|
|
{
|
|
needs_extra = false;
|
|
switch (type)
|
|
{
|
|
case Valve_Vector:
|
|
{
|
|
size_t mySize = sizeof(Vector *);
|
|
if (pass == PassType_Basic)
|
|
{
|
|
if (flags & PASSFLAG_BYREF)
|
|
{
|
|
return 0;
|
|
}
|
|
info->type = PassType_Basic;
|
|
info->flags = flags;
|
|
info->size = sizeof(Vector *);
|
|
mySize = sizeof(Vector);
|
|
needs_extra = true;
|
|
} else if (pass == PassType_Object) {
|
|
info->type = PassType_Object;
|
|
info->flags = flags | PASSFLAG_OASSIGNOP | PASSFLAG_OCTOR;
|
|
info->size = sizeof(Vector);
|
|
info->fields[0] = info->fields[1] = info->fields[2] = ObjectField::Float;
|
|
info->numFields = 3;
|
|
} else {
|
|
return 0;
|
|
}
|
|
return mySize;
|
|
}
|
|
case Valve_QAngle:
|
|
{
|
|
size_t mySize = sizeof(QAngle *);
|
|
if (pass == PassType_Basic)
|
|
{
|
|
if (flags & PASSFLAG_BYREF)
|
|
{
|
|
return 0;
|
|
}
|
|
info->type = PassType_Basic;
|
|
info->flags = flags;
|
|
info->size = sizeof(QAngle *);
|
|
mySize = sizeof(QAngle);
|
|
needs_extra = true;
|
|
} else if (pass == PassType_Object) {
|
|
info->type = PassType_Object;
|
|
info->flags = flags | PASSFLAG_OASSIGNOP | PASSFLAG_OCTOR;
|
|
info->size = sizeof(QAngle);
|
|
info->fields[0] = info->fields[1] = info->fields[2] = ObjectField::Float;
|
|
info->numFields = 3;
|
|
} else {
|
|
return 0;
|
|
}
|
|
return mySize;
|
|
}
|
|
case Valve_CBaseEntity:
|
|
case Valve_CBasePlayer:
|
|
case Valve_Edict:
|
|
case Valve_String:
|
|
case Valve_Object:
|
|
{
|
|
if (pass != PassType_Basic || (flags & PASSFLAG_BYREF))
|
|
{
|
|
return 0;
|
|
}
|
|
info->type = PassType_Basic;
|
|
info->flags = flags;
|
|
info->size = sizeof(void *);
|
|
return sizeof(void *);
|
|
}
|
|
case Valve_POD:
|
|
{
|
|
info->type = PassType_Basic;
|
|
info->flags = flags;
|
|
if (flags & PASSFLAG_ASPOINTER)
|
|
{
|
|
needs_extra = true;
|
|
info->size = sizeof(int *);
|
|
return sizeof(int *) + sizeof(int);
|
|
} else {
|
|
info->size = sizeof(int);
|
|
return sizeof(int);
|
|
}
|
|
}
|
|
case Valve_Bool:
|
|
{
|
|
info->type = PassType_Basic;
|
|
info->flags = flags;
|
|
if (flags & PASSFLAG_ASPOINTER)
|
|
{
|
|
needs_extra = true;
|
|
info->size = sizeof(bool *);
|
|
return sizeof(bool *) + sizeof(bool);
|
|
} else {
|
|
info->size = sizeof(bool);
|
|
return sizeof(bool);
|
|
}
|
|
}
|
|
case Valve_Float:
|
|
{
|
|
info->flags = flags;
|
|
if (flags & PASSFLAG_ASPOINTER)
|
|
{
|
|
needs_extra = true;
|
|
info->type = PassType_Basic;
|
|
info->size = sizeof(float *);
|
|
return sizeof(float *) + sizeof(float);
|
|
} else {
|
|
info->type = PassType_Float;
|
|
info->size = sizeof(float);
|
|
return sizeof(float);
|
|
}
|
|
}
|
|
case Valve_VirtualAddress:
|
|
{
|
|
info->flags = flags;
|
|
if (flags & PASSFLAG_ASPOINTER)
|
|
{
|
|
needs_extra = true;
|
|
info->type = PassType_Basic;
|
|
info->size = sizeof(void**);
|
|
return sizeof(void**) + sizeof(void*);
|
|
} else {
|
|
info->type = PassType_Basic;
|
|
info->size = sizeof(void*);
|
|
return sizeof(void*);
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
DataStatus EncodeValveParam(IPluginContext *pContext,
|
|
cell_t param,
|
|
const ValveCall *pCall,
|
|
const ValvePassInfo *data,
|
|
const void *_buffer)
|
|
{
|
|
const void *buffer = (const unsigned char *)_buffer + data->offset;
|
|
switch (data->vtype)
|
|
{
|
|
case Valve_Vector:
|
|
{
|
|
Vector *v = NULL;
|
|
|
|
if (data->type == PassType_Basic)
|
|
{
|
|
v = *(Vector **)buffer;
|
|
} else if (data->type == PassType_Object) {
|
|
v = (Vector *)buffer;
|
|
}
|
|
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
|
|
addr[0] = sp_ftoc(v->x);
|
|
addr[1] = sp_ftoc(v->y);
|
|
addr[2] = sp_ftoc(v->z);
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_QAngle:
|
|
{
|
|
QAngle *q = NULL;
|
|
|
|
if (data->type == PassType_Basic)
|
|
{
|
|
q = *(QAngle **)buffer;
|
|
} else if (data->type == PassType_Object) {
|
|
q = (QAngle *)buffer;
|
|
}
|
|
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
|
|
addr[0] = sp_ftoc(q->x);
|
|
addr[1] = sp_ftoc(q->y);
|
|
addr[2] = sp_ftoc(q->z);
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_CBaseEntity:
|
|
case Valve_CBasePlayer:
|
|
{
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
|
|
CBaseEntity *pEntity = *(CBaseEntity **)buffer;
|
|
if (pEntity)
|
|
{
|
|
*addr = gamehelpers->EntityToBCompatRef(pEntity);
|
|
} else {
|
|
*addr = -1;
|
|
}
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_Edict:
|
|
{
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
|
|
edict_t *pEdict = *(edict_t **)buffer;
|
|
if (pEdict)
|
|
{
|
|
*addr = IndexOfEdict(pEdict);
|
|
} else {
|
|
*addr = -1;
|
|
}
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_POD:
|
|
case Valve_Float:
|
|
{
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
|
|
if (data->flags & PASSFLAG_ASPOINTER)
|
|
{
|
|
buffer = *(cell_t **)buffer;
|
|
}
|
|
|
|
*addr = *(cell_t *)buffer;
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_Bool:
|
|
{
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
|
|
if (data->flags & PASSFLAG_ASPOINTER)
|
|
{
|
|
buffer = *(bool **)buffer;
|
|
}
|
|
|
|
*addr = *(bool *)buffer ? 1 : 0;
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_VirtualAddress:
|
|
{
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
|
|
if (data->flags & PASSFLAG_ASPOINTER)
|
|
{
|
|
buffer = *(void **)buffer;
|
|
}
|
|
*addr = g_pSM->ToPseudoAddress(*(void**)buffer);
|
|
|
|
return Data_Okay;
|
|
}
|
|
}
|
|
|
|
return Data_Fail;
|
|
}
|
|
|
|
DataStatus DecodeValveParam(IPluginContext *pContext,
|
|
cell_t param,
|
|
const ValveCall *pCall,
|
|
const ValvePassInfo *data,
|
|
void *_buffer)
|
|
{
|
|
void *buffer = (unsigned char *)_buffer + data->offset;
|
|
switch (data->vtype)
|
|
{
|
|
case Valve_Vector:
|
|
{
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
|
|
unsigned char *mem = (unsigned char *)buffer;
|
|
if (data->type == PassType_Basic)
|
|
{
|
|
/* Store the object in the next N bytes, and store
|
|
* a pointer to that object right beforehand.
|
|
*/
|
|
Vector **realPtr = (Vector **)buffer;
|
|
|
|
if (addr == pContext->GetNullRef(SP_NULL_VECTOR))
|
|
{
|
|
if (data->decflags & VDECODE_FLAG_ALLOWNULL)
|
|
{
|
|
*realPtr = NULL;
|
|
return Data_Okay;
|
|
} else {
|
|
pContext->ThrowNativeError("NULL not allowed");
|
|
return Data_Fail;
|
|
}
|
|
} else {
|
|
mem = (unsigned char *)_buffer + pCall->stackEnd + data->obj_offset;
|
|
*realPtr = (Vector *)mem;
|
|
}
|
|
}
|
|
|
|
/* Use placement new to initialize the object cleanly
|
|
* This has no destructor so we don't need to do
|
|
* DestroyValveParam() or something :]
|
|
*/
|
|
Vector *v = new (mem) Vector(
|
|
sp_ctof(addr[0]),
|
|
sp_ctof(addr[1]),
|
|
sp_ctof(addr[2]));
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_QAngle:
|
|
{
|
|
cell_t *addr;
|
|
int err;
|
|
err = pContext->LocalToPhysAddr(param, &addr);
|
|
|
|
unsigned char *mem = (unsigned char *)buffer;
|
|
if (data->type == PassType_Basic)
|
|
{
|
|
/* Store the object in the next N bytes, and store
|
|
* a pointer to that object right beforehand.
|
|
*/
|
|
QAngle **realPtr = (QAngle **)buffer;
|
|
|
|
if (addr == pContext->GetNullRef(SP_NULL_VECTOR))
|
|
{
|
|
if (!(data->decflags & VDECODE_FLAG_ALLOWNULL))
|
|
{
|
|
pContext->ThrowNativeError("NULL not allowed");
|
|
return Data_Fail;
|
|
} else {
|
|
*realPtr = NULL;
|
|
return Data_Okay;
|
|
}
|
|
} else {
|
|
mem = (unsigned char *)_buffer + pCall->stackEnd + data->obj_offset;
|
|
*realPtr = (QAngle *)mem;
|
|
}
|
|
}
|
|
|
|
if (err != SP_ERROR_NONE)
|
|
{
|
|
pContext->ThrowNativeErrorEx(err, "Could not read plugin data");
|
|
return Data_Fail;
|
|
}
|
|
|
|
/* Use placement new to initialize the object cleanly
|
|
* This has no destructor so we don't need to do
|
|
* DestroyValveParam() or something :]
|
|
*/
|
|
QAngle *v = new (mem) QAngle(
|
|
sp_ctof(addr[0]),
|
|
sp_ctof(addr[1]),
|
|
sp_ctof(addr[2]));
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_CBasePlayer:
|
|
{
|
|
CBaseEntity *pEntity = NULL;
|
|
if (data->decflags & VDECODE_FLAG_BYREF)
|
|
{
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
param = *addr;
|
|
}
|
|
int index = gamehelpers->ReferenceToIndex(param);
|
|
if ((unsigned)index == INVALID_EHANDLE_INDEX && param != -1)
|
|
{
|
|
return Data_Fail;
|
|
}
|
|
if (index >= 1 && index <= playerhelpers->GetMaxClients())
|
|
{
|
|
IGamePlayer *player = playerhelpers->GetGamePlayer(index);
|
|
|
|
if(!player->IsConnected()) {
|
|
pContext->ThrowNativeError("Client %d is not connected", param);
|
|
return Data_Fail;
|
|
}
|
|
|
|
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
|
|
pContext->ThrowNativeError("Client %d is not in game", param);
|
|
return Data_Fail;
|
|
}
|
|
|
|
pEntity = gamehelpers->ReferenceToEntity(param);
|
|
} else if (param == -1) {
|
|
if (data->decflags & VDECODE_FLAG_ALLOWNULL)
|
|
{
|
|
pEntity = NULL;
|
|
} else {
|
|
pContext->ThrowNativeError("NULL not allowed");
|
|
return Data_Fail;
|
|
}
|
|
} else {
|
|
pContext->ThrowNativeError("Entity index %d is not a valid client", param);
|
|
return Data_Fail;
|
|
}
|
|
|
|
CBaseEntity **ebuf = (CBaseEntity **)buffer;
|
|
*ebuf = pEntity;
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_CBaseEntity:
|
|
{
|
|
CBaseEntity *pEntity = NULL;
|
|
if (data->decflags & VDECODE_FLAG_BYREF)
|
|
{
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
param = *addr;
|
|
}
|
|
int index = gamehelpers->ReferenceToIndex(param);
|
|
if ((unsigned)index == INVALID_EHANDLE_INDEX && param != -1)
|
|
{
|
|
return Data_Fail;
|
|
}
|
|
if (index >= 1 && index <= playerhelpers->GetMaxClients())
|
|
{
|
|
IGamePlayer *player = playerhelpers->GetGamePlayer(index);
|
|
|
|
if(!player->IsConnected()) {
|
|
pContext->ThrowNativeError("Client %d is not connected", param);
|
|
return Data_Fail;
|
|
}
|
|
|
|
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
|
|
pContext->ThrowNativeError("Client %d is not in game", param);
|
|
return Data_Fail;
|
|
}
|
|
|
|
pEntity = gamehelpers->ReferenceToEntity(param);
|
|
} else if (param == -1) {
|
|
if (data->decflags & VDECODE_FLAG_ALLOWNULL)
|
|
{
|
|
pEntity = NULL;
|
|
} else {
|
|
pContext->ThrowNativeError("NULL not allowed");
|
|
return Data_Fail;
|
|
}
|
|
} else if (index == 0) {
|
|
if (data->decflags & VDECODE_FLAG_ALLOWWORLD)
|
|
{
|
|
pEntity = gamehelpers->ReferenceToEntity(0);
|
|
} else {
|
|
pContext->ThrowNativeError("World not allowed");
|
|
return Data_Fail;
|
|
}
|
|
} else {
|
|
pEntity = gamehelpers->ReferenceToEntity(param);
|
|
if (!pEntity)
|
|
{
|
|
pContext->ThrowNativeError("Entity %d is not valid", param);
|
|
return Data_Fail;
|
|
}
|
|
}
|
|
|
|
CBaseEntity **ebuf = (CBaseEntity **)buffer;
|
|
*ebuf = pEntity;
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_Edict:
|
|
{
|
|
edict_t *pEdict;
|
|
if (data->decflags & VDECODE_FLAG_BYREF)
|
|
{
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
param = *addr;
|
|
}
|
|
if (param >= 1 && param <= playerhelpers->GetMaxClients())
|
|
{
|
|
IGamePlayer *player = playerhelpers->GetGamePlayer(param);
|
|
|
|
if(!player->IsConnected()) {
|
|
pContext->ThrowNativeError("Client %d is not connected", param);
|
|
return Data_Fail;
|
|
}
|
|
|
|
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
|
|
pContext->ThrowNativeError("Client %d is not in game", param);
|
|
return Data_Fail;
|
|
}
|
|
|
|
pEdict = player->GetEdict();
|
|
} else if (param == -1) {
|
|
if (data->decflags & VDECODE_FLAG_ALLOWNULL)
|
|
{
|
|
pEdict = NULL;
|
|
} else {
|
|
pContext->ThrowNativeError("NULL not allowed");
|
|
return Data_Fail;
|
|
}
|
|
} else if (param == 0) {
|
|
if (data->decflags & VDECODE_FLAG_ALLOWWORLD)
|
|
{
|
|
pEdict = PEntityOfEntIndex(0);
|
|
} else {
|
|
pContext->ThrowNativeError("World not allowed");
|
|
return Data_Fail;
|
|
}
|
|
} else {
|
|
pEdict = PEntityOfEntIndex(param);
|
|
if (!pEdict || pEdict->IsFree())
|
|
{
|
|
pContext->ThrowNativeError("Entity %d is not valid or is freed", param);
|
|
return Data_Fail;
|
|
}
|
|
}
|
|
|
|
edict_t **ebuf = (edict_t **)buffer;
|
|
*ebuf = pEdict;
|
|
|
|
return Data_Okay;
|
|
}
|
|
case Valve_POD:
|
|
case Valve_Float:
|
|
{
|
|
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;
|
|
}
|
|
*(cell_t *)buffer = param;
|
|
return Data_Okay;
|
|
}
|
|
case Valve_Bool:
|
|
{
|
|
if (data->decflags & VDECODE_FLAG_BYREF)
|
|
{
|
|
cell_t *addr;
|
|
pContext->LocalToPhysAddr(param, &addr);
|
|
param = *addr;
|
|
}
|
|
if (data->flags & PASSFLAG_ASPOINTER)
|
|
{
|
|
*(bool **)buffer = (bool *)((unsigned char *)_buffer + pCall->stackEnd + data->obj_offset);
|
|
buffer = *(bool **)buffer;
|
|
}
|
|
*(bool *)buffer = param ? true : false;
|
|
return Data_Okay;
|
|
}
|
|
case Valve_String:
|
|
{
|
|
char *addr;
|
|
pContext->LocalToStringNULL(param, &addr);
|
|
if (addr == NULL && (data->decflags & VDECODE_FLAG_ALLOWNULL) == 0)
|
|
{
|
|
pContext->ThrowNativeError("NULL not allowed");
|
|
return Data_Fail;
|
|
}
|
|
|
|
*(char **)buffer = addr;
|
|
return Data_Okay;
|
|
}
|
|
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);
|
|
if (addr == nullptr && (data->decflags & VDECODE_FLAG_ALLOWNULL) == 0)
|
|
{
|
|
pContext->ThrowNativeError("NULL Address not allowed");
|
|
return Data_Fail;
|
|
}
|
|
|
|
*(void **)buffer = addr;
|
|
return Data_Okay;
|
|
}
|
|
}
|
|
|
|
return Data_Fail;
|
|
}
|