64-bit support for CSGO on Linux and macOS (#705)
This commit is contained in:
@@ -26,23 +26,34 @@ project.sources += [
|
||||
'vstringtable.cpp',
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'../../public/CDetour/detours.cpp',
|
||||
'../../public/asm/asm.c'
|
||||
'../../public/asm/asm.c',
|
||||
'../../public/libudis86/decode.c',
|
||||
'../../public/libudis86/itab.c',
|
||||
'../../public/libudis86/syn-att.c',
|
||||
'../../public/libudis86/syn-intel.c',
|
||||
'../../public/libudis86/syn.c',
|
||||
'../../public/libudis86/udis86.c',
|
||||
]
|
||||
project.compiler.defines += ['HAVE_STRING_H'];
|
||||
|
||||
for sdk_name in SM.sdks:
|
||||
sdk = SM.sdks[sdk_name]
|
||||
|
||||
binary = SM.HL2Config(project, 'sdktools.ext.' + sdk.ext, sdk)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(sdk.path, 'game', 'shared'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
|
||||
]
|
||||
for arch in SM.archs:
|
||||
if not arch in sdk.platformSpec[builder.target.platform]:
|
||||
continue
|
||||
|
||||
if sdk.name != 'episode1':
|
||||
binary.compiler.defines += ['HOOKING_ENABLED']
|
||||
binary = SM.HL2Config(project, 'sdktools.ext.' + sdk.ext, sdk, arch)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(sdk.path, 'game', 'shared'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
|
||||
]
|
||||
|
||||
if binary.compiler.behavior == 'gcc':
|
||||
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
|
||||
if sdk.name != 'episode1':
|
||||
binary.compiler.defines += ['HOOKING_ENABLED']
|
||||
|
||||
if binary.compiler.behavior == 'gcc':
|
||||
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
|
||||
|
||||
SM.extensions += builder.Add(project)
|
||||
|
||||
@@ -320,7 +320,12 @@ void TempEntityManager::Initialize()
|
||||
return;
|
||||
}
|
||||
/* Store the head of the TE linked list */
|
||||
#ifdef PLATFORM_X86
|
||||
m_ListHead = **(void ***) ((unsigned char *) addr + offset);
|
||||
#else
|
||||
int32_t varOffset = *(int32_t *) ((unsigned char *) addr + offset);
|
||||
m_ListHead = **(void ***) ((unsigned char *) addr + offset + sizeof(int32_t) + varOffset);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -96,10 +96,12 @@ ValveCall *CreateValveCall(void *addr,
|
||||
|
||||
/* Get return information - encode only */
|
||||
PassInfo retBuf;
|
||||
ObjectField retFieldBuf[16];
|
||||
size_t retBufSize = 0;
|
||||
bool retbuf_needs_extra;
|
||||
if (retInfo)
|
||||
{
|
||||
retBuf.fields = retFieldBuf;
|
||||
if ((size = ValveParamToBinParam(retInfo->vtype, retInfo->type, retInfo->flags, &retBuf, retbuf_needs_extra)) == 0)
|
||||
{
|
||||
delete vc;
|
||||
@@ -110,12 +112,14 @@ ValveCall *CreateValveCall(void *addr,
|
||||
|
||||
/* Get parameter info */
|
||||
PassInfo paramBuf[32];
|
||||
ObjectField fieldBuf[32][16];
|
||||
size_t sizes[32];
|
||||
size_t normSize = 0;
|
||||
size_t extraSize = 0;
|
||||
for (unsigned int i=0; i<numParams; i++)
|
||||
{
|
||||
bool needs_extra;
|
||||
paramBuf[i].fields = fieldBuf[i];
|
||||
if ((size = ValveParamToBinParam(params[i].vtype,
|
||||
params[i].type,
|
||||
params[i].flags,
|
||||
|
||||
@@ -159,7 +159,11 @@ static cell_t PrepSDKCall_SetSignature(IPluginContext *pContext, const cell_t *p
|
||||
|
||||
static cell_t PrepSDKCall_SetAddress(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
s_call_addr = reinterpret_cast<void *>(params[1]);
|
||||
#else
|
||||
s_call_addr = g_pSM->FromPseudoAddress(params[1]);
|
||||
#endif
|
||||
|
||||
return (s_call_addr != NULL) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ size_t ValveParamToBinParam(ValveType type,
|
||||
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;
|
||||
}
|
||||
@@ -97,6 +99,8 @@ size_t ValveParamToBinParam(ValveType type,
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -199,12 +199,18 @@ bool UTIL_VerifySignature(const void *addr, const char *sig, size_t len)
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef PLATFORM_X64
|
||||
#define KEY_SUFFIX "64"
|
||||
#else
|
||||
#define KEY_SUFFIX ""
|
||||
#endif
|
||||
|
||||
#if defined PLATFORM_WINDOWS
|
||||
#define FAKECLIENT_KEY "CreateFakeClient_Windows"
|
||||
#define FAKECLIENT_KEY "CreateFakeClient_Windows" KEY_SUFFIX
|
||||
#elif defined PLATFORM_LINUX
|
||||
#define FAKECLIENT_KEY "CreateFakeClient_Linux"
|
||||
#define FAKECLIENT_KEY "CreateFakeClient_Linux" KEY_SUFFIX
|
||||
#elif defined PLATFORM_APPLE
|
||||
#define FAKECLIENT_KEY "CreateFakeClient_Mac"
|
||||
#define FAKECLIENT_KEY "CreateFakeClient_Mac" KEY_SUFFIX
|
||||
#else
|
||||
#error "Unsupported platform"
|
||||
#endif
|
||||
@@ -273,7 +279,12 @@ void GetIServer()
|
||||
}
|
||||
|
||||
/* Finally we have the interface we were looking for */
|
||||
#ifdef PLATFORM_X86
|
||||
iserver = *reinterpret_cast<IServer **>(reinterpret_cast<unsigned char *>(vfunc) + offset);
|
||||
#elif defined PLATFORM_X64
|
||||
int32_t varOffset = *reinterpret_cast<int32_t *>(reinterpret_cast<unsigned char *>(vfunc) + offset);
|
||||
iserver = reinterpret_cast<IServer *>(reinterpret_cast<unsigned char *>(vfunc) + offset + sizeof(int32_t) + varOffset);
|
||||
#endif
|
||||
}
|
||||
|
||||
void GetResourceEntity()
|
||||
|
||||
@@ -1349,8 +1349,8 @@ static cell_t SetClientName(IPluginContext *pContext, const cell_t *params)
|
||||
}
|
||||
}
|
||||
|
||||
// The IClient vtable is +4 from the CBaseClient vtable due to multiple inheritance.
|
||||
void *pGameClient = (void *)((intptr_t)pClient - 4);
|
||||
// The IClient vtable is +sizeof(void *) from the CBaseClient vtable due to multiple inheritance.
|
||||
void *pGameClient = (void *)((intptr_t)pClient - sizeof(void *));
|
||||
|
||||
// Change the name in the engine.
|
||||
START_CALL();
|
||||
@@ -1427,7 +1427,7 @@ static cell_t SetClientInfo(IPluginContext *pContext, const cell_t *params)
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned char *CGameClient = (unsigned char *)pClient - 4;
|
||||
unsigned char *CGameClient = (unsigned char *)pClient - sizeof(void *);
|
||||
|
||||
START_CALL();
|
||||
/* Not really a CBaseEntity* but this works */
|
||||
|
||||
Reference in New Issue
Block a user