64-bit support for CSGO on Linux and macOS (#705)
This commit is contained in:
@@ -1,27 +1,30 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
binary = SM.ExtLibrary(builder, 'bintools.ext')
|
||||
binary.compiler.defines += ['HOOKING_ENABLED']
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
for arch in SM.archs:
|
||||
binary = SM.ExtLibrary(builder, 'bintools.ext', arch)
|
||||
binary.compiler.defines += ['HOOKING_ENABLED']
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit'),
|
||||
os.path.join(builder.sourcePath, 'public', 'jit', 'x86'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'CallMaker.cpp',
|
||||
'CallWrapper.cpp',
|
||||
'HookWrapper.cpp',
|
||||
'jit_call.cpp',
|
||||
'jit_hook.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'CallMaker.cpp',
|
||||
'CallWrapper.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
|
||||
if arch == 'x64':
|
||||
binary.sources += ['jit_call_x64.cpp']
|
||||
else:
|
||||
binary.sources += ['jit_call.cpp']
|
||||
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
|
||||
|
||||
@@ -82,7 +82,8 @@ ICallWrapper *CallMaker::CreateCall(void *address,
|
||||
CallConvention cv,
|
||||
const PassInfo *retInfo,
|
||||
const PassInfo paramInfo[],
|
||||
unsigned int numParams)
|
||||
unsigned int numParams,
|
||||
unsigned int fnFlags)
|
||||
{
|
||||
SourceHook::CProtoInfoBuilder protoInfo(GetSHCallConvention(cv));
|
||||
|
||||
@@ -103,7 +104,11 @@ ICallWrapper *CallMaker::CreateCall(void *address,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
#if defined PLATFORM_X64
|
||||
return g_CallMaker2.CreateCall(address, &(*protoInfo), retInfo, paramInfo, fnFlags);
|
||||
#else
|
||||
return g_CallMaker2.CreateCall(address, &(*protoInfo));
|
||||
#endif
|
||||
}
|
||||
|
||||
ICallWrapper *CallMaker::CreateVCall(unsigned int vtblIdx,
|
||||
@@ -111,7 +116,8 @@ ICallWrapper *CallMaker::CreateVCall(unsigned int vtblIdx,
|
||||
unsigned int thisOffs,
|
||||
const PassInfo *retInfo,
|
||||
const PassInfo paramInfo[],
|
||||
unsigned int numParams)
|
||||
unsigned int numParams,
|
||||
unsigned int fnFlags)
|
||||
{
|
||||
SourceHook::MemFuncInfo info;
|
||||
info.isVirtual = true;
|
||||
@@ -138,12 +144,16 @@ ICallWrapper *CallMaker::CreateVCall(unsigned int vtblIdx,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
||||
#if defined PLATFORM_X64
|
||||
return g_CallMaker2.CreateVirtualCall(&(*protoInfo), &info, retInfo, paramInfo, fnFlags);
|
||||
#else
|
||||
return g_CallMaker2.CreateVirtualCall(&(*protoInfo), &info);
|
||||
#endif
|
||||
}
|
||||
|
||||
ICallWrapper *CallMaker2::CreateCall(void *address, const SourceHook::ProtoInfo *protoInfo)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
CallWrapper *pWrapper = new CallWrapper(protoInfo);
|
||||
pWrapper->SetCalleeAddr(address);
|
||||
|
||||
@@ -151,11 +161,15 @@ ICallWrapper *CallMaker2::CreateCall(void *address, const SourceHook::ProtoInfo
|
||||
pWrapper->SetCodeBaseAddr(addr);
|
||||
|
||||
return pWrapper;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
ICallWrapper *CallMaker2::CreateVirtualCall(const SourceHook::ProtoInfo *protoInfo,
|
||||
const SourceHook::MemFuncInfo *info)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
CallWrapper *pWrapper = new CallWrapper(protoInfo);
|
||||
pWrapper->SetMemFuncInfo(info);
|
||||
|
||||
@@ -163,9 +177,48 @@ ICallWrapper *CallMaker2::CreateVirtualCall(const SourceHook::ProtoInfo *protoIn
|
||||
pWrapper->SetCodeBaseAddr(addr);
|
||||
|
||||
return pWrapper;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined HOOKING_ENABLED
|
||||
ICallWrapper *CallMaker2::CreateCall(void *address, const SourceHook::ProtoInfo *protoInfo,
|
||||
const PassInfo *retInfo, const PassInfo paramInfo[],
|
||||
unsigned int fnFlags)
|
||||
{
|
||||
#ifdef PLATFORM_X64
|
||||
CallWrapper *pWrapper = new CallWrapper(protoInfo, retInfo, paramInfo, fnFlags);
|
||||
pWrapper->SetCalleeAddr(address);
|
||||
|
||||
void *addr = JIT_CallCompile(pWrapper, FuncAddr_Direct);
|
||||
pWrapper->SetCodeBaseAddr(addr);
|
||||
|
||||
return pWrapper;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
ICallWrapper *CallMaker2::CreateVirtualCall(const SourceHook::ProtoInfo *protoInfo,
|
||||
const SourceHook::MemFuncInfo *info,
|
||||
const PassInfo *retInfo,
|
||||
const PassInfo paramInfo[],
|
||||
unsigned int fnFlags)
|
||||
{
|
||||
#ifdef PLATFORM_X64
|
||||
CallWrapper *pWrapper = new CallWrapper(protoInfo, retInfo, paramInfo, fnFlags);
|
||||
pWrapper->SetMemFuncInfo(info);
|
||||
|
||||
void *addr = JIT_CallCompile(pWrapper, FuncAddr_VTable);
|
||||
pWrapper->SetCodeBaseAddr(addr);
|
||||
|
||||
return pWrapper;
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
IHookWrapper *CallMaker2::CreateVirtualHook(SourceHook::ISourceHook *pSH,
|
||||
const SourceHook::ProtoInfo *protoInfo,
|
||||
const SourceHook::MemFuncInfo *info,
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
|
||||
#include "CallWrapper.h"
|
||||
#include "HookWrapper.h"
|
||||
|
||||
using namespace SourceMod;
|
||||
|
||||
@@ -45,26 +44,30 @@ public: //IBinTools
|
||||
CallConvention cv,
|
||||
const PassInfo *retInfo,
|
||||
const PassInfo paramInfo[],
|
||||
unsigned int numParams);
|
||||
unsigned int numParams,
|
||||
unsigned int fnFlags);
|
||||
ICallWrapper *CreateVCall(unsigned int vtblIdx,
|
||||
unsigned int vtblOffs,
|
||||
unsigned int thisOffs,
|
||||
const PassInfo *retInfo,
|
||||
const PassInfo paramInfo[],
|
||||
unsigned int numParams);
|
||||
unsigned int numParams,
|
||||
unsigned int fnFlags);
|
||||
};
|
||||
|
||||
class CallMaker2
|
||||
#if defined HOOKING_ENABLED
|
||||
: public IBinTools2
|
||||
#endif
|
||||
{
|
||||
public: //IBinTools2
|
||||
virtual ICallWrapper *CreateCall(void *address,
|
||||
const SourceHook::ProtoInfo *protoInfo);
|
||||
virtual ICallWrapper *CreateVirtualCall(const SourceHook::ProtoInfo *protoInfo,
|
||||
const SourceHook::MemFuncInfo *info);
|
||||
#if defined HOOKING_ENABLED
|
||||
ICallWrapper *CreateCall(void *address, const SourceHook::ProtoInfo *protoInfo,
|
||||
const PassInfo *retInfo, const PassInfo paramInfo[], unsigned int fnFlags);
|
||||
ICallWrapper *CreateVirtualCall(const SourceHook::ProtoInfo *protoInfo,
|
||||
const SourceHook::MemFuncInfo *info, const PassInfo *retInfo,
|
||||
const PassInfo paramInfo[], unsigned int fnFlags);
|
||||
#if 0
|
||||
virtual IHookWrapper *CreateVirtualHook(SourceHook::ISourceHook *pSH,
|
||||
const SourceHook::ProtoInfo *protoInfo,
|
||||
const SourceHook::MemFuncInfo *info,
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "CallWrapper.h"
|
||||
#include "CallMaker.h"
|
||||
|
||||
CallWrapper::CallWrapper(const SourceHook::ProtoInfo *protoInfo)
|
||||
CallWrapper::CallWrapper(const SourceHook::ProtoInfo *protoInfo) : m_FnFlags(0)
|
||||
{
|
||||
m_AddrCodeBase = NULL;
|
||||
m_AddrCallee = NULL;
|
||||
@@ -77,6 +77,22 @@ CallWrapper::CallWrapper(const SourceHook::ProtoInfo *protoInfo)
|
||||
}
|
||||
}
|
||||
|
||||
CallWrapper::CallWrapper(const SourceHook::ProtoInfo *protoInfo, const PassInfo *retInfo,
|
||||
const PassInfo paramInfo[], unsigned int fnFlags) : CallWrapper(protoInfo)
|
||||
{
|
||||
m_RetParam->fields = retInfo->fields;
|
||||
m_RetParam->numFields = retInfo->numFields;
|
||||
|
||||
unsigned int argnum = protoInfo->numOfParams;
|
||||
for (unsigned int i = 0; i < argnum; i++)
|
||||
{
|
||||
m_Params[i].info.fields = paramInfo[i].fields;
|
||||
m_Params[i].info.numFields = paramInfo[i].numFields;
|
||||
}
|
||||
|
||||
m_FnFlags = fnFlags;
|
||||
}
|
||||
|
||||
CallWrapper::~CallWrapper()
|
||||
{
|
||||
delete [] m_Params;
|
||||
@@ -184,3 +200,8 @@ unsigned int CallWrapper::GetParamOffset(unsigned int num)
|
||||
|
||||
return m_Params[num].offset;
|
||||
}
|
||||
|
||||
unsigned int CallWrapper::GetFunctionFlags()
|
||||
{
|
||||
return m_FnFlags;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ class CallWrapper : public ICallWrapper
|
||||
{
|
||||
public:
|
||||
CallWrapper(const SourceHook::ProtoInfo *protoInfo);
|
||||
CallWrapper(const SourceHook::ProtoInfo *protoInfo, const PassInfo *retInfo,
|
||||
const PassInfo paramInfo[], unsigned int fnFlags);
|
||||
~CallWrapper();
|
||||
public: //ICallWrapper
|
||||
CallConvention GetCallConvention();
|
||||
@@ -59,6 +61,7 @@ public: //ICallWrapper
|
||||
SourceHook::ProtoInfo::CallConvention GetSHCallConvention();
|
||||
const SourceHook::PassInfo *GetSHParamInfo(unsigned int num);
|
||||
unsigned int GetParamOffset(unsigned int num);
|
||||
unsigned int GetFunctionFlags();
|
||||
public:
|
||||
void SetCalleeAddr(void *addr);
|
||||
void SetCodeBaseAddr(void *addr);
|
||||
@@ -74,6 +77,7 @@ private:
|
||||
void *m_AddrCallee;
|
||||
void *m_AddrCodeBase;
|
||||
SourceHook::MemFuncInfo m_FuncInfo;
|
||||
unsigned int m_FnFlags;
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_CALLWRAPPER_H_
|
||||
|
||||
@@ -50,12 +50,6 @@ bool BinTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
g_SPEngine = g_pSM->GetScriptingEngine();
|
||||
g_pShareSys->AddInterface(myself, &g_CallMaker);
|
||||
|
||||
/* IBinTools2 is only compatible with SH v5 */
|
||||
if (g_pSM->GetShApiVersion() >= 5)
|
||||
{
|
||||
g_pShareSys->AddInterface(myself, &g_CallMaker2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -34,11 +34,12 @@
|
||||
|
||||
#include <jit_helpers.h>
|
||||
#include <x86_macros.h>
|
||||
#include <sm_platform.h>
|
||||
#include "CallWrapper.h"
|
||||
#include "HookWrapper.h"
|
||||
|
||||
void *JIT_CallCompile(CallWrapper *pWrapper, FuncAddrMethod method);
|
||||
#if defined HOOKING_ENABLED
|
||||
|
||||
#if 0
|
||||
void *JIT_HookCompile(HookWrapper *pWrapper);
|
||||
void JIT_FreeHook(void *addr);
|
||||
#endif
|
||||
|
||||
@@ -214,7 +214,7 @@ inline void Write_Push_Params(JitWriter *jit,
|
||||
IA32_Push_Reg(jit, kREG_EBX);
|
||||
|
||||
//push <pWrapper>
|
||||
IA32_Push_Imm32(jit, (jit_int32_t)pWrapper);
|
||||
IA32_Push_Imm32(jit, (jit_int32_t)(intptr_t)pWrapper);
|
||||
}
|
||||
|
||||
inline void Write_Call_Handler(JitWriter *jit, void *addr)
|
||||
|
||||
@@ -0,0 +1,656 @@
|
||||
/**
|
||||
* vim: set ts=4 :
|
||||
* =============================================================================
|
||||
* SourceMod BinTools Extension
|
||||
* Copyright (C) 2004-2017 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>.
|
||||
*/
|
||||
|
||||
#include <jit_helpers.h>
|
||||
#include <x86_macros.h>
|
||||
|
||||
// 64-bit registers
|
||||
const jit_uint8_t kREG_RAX = kREG_EAX;
|
||||
const jit_uint8_t kREG_RCX = kREG_ECX;
|
||||
const jit_uint8_t kREG_RDX = kREG_EDX;
|
||||
const jit_uint8_t kREG_RBX = kREG_EBX;
|
||||
const jit_uint8_t kREG_RSP = kREG_ESP;
|
||||
const jit_uint8_t kREG_RBP = kREG_EBP;
|
||||
const jit_uint8_t kREG_RSI = kREG_ESI;
|
||||
const jit_uint8_t kREG_RDI = kREG_EDI;
|
||||
const jit_uint8_t kREG_R8 = 8;
|
||||
const jit_uint8_t kREG_R9 = 9;
|
||||
const jit_uint8_t kREG_R10 = 10;
|
||||
const jit_uint8_t kREG_R11 = 11;
|
||||
const jit_uint8_t kREG_R12 = 12;
|
||||
const jit_uint8_t kREG_R13 = 13;
|
||||
const jit_uint8_t kREG_R14 = 14;
|
||||
const jit_uint8_t kREG_R15 = 15;
|
||||
|
||||
const jit_uint8_t kREG_XMM0 = 0;
|
||||
const jit_uint8_t kREG_XMM1 = 1;
|
||||
const jit_uint8_t kREG_XMM2 = 2;
|
||||
const jit_uint8_t kREG_XMM3 = 3;
|
||||
const jit_uint8_t kREG_XMM4 = 4;
|
||||
const jit_uint8_t kREG_XMM5 = 5;
|
||||
const jit_uint8_t kREG_XMM6 = 6;
|
||||
const jit_uint8_t kREG_XMM7 = 7;
|
||||
const jit_uint8_t kREG_XMM8 = 8;
|
||||
const jit_uint8_t kREG_XMM9 = 9;
|
||||
const jit_uint8_t kREG_XMM10 = 10;
|
||||
const jit_uint8_t kREG_XMM11 = 11;
|
||||
const jit_uint8_t kREG_XMM12 = 12;
|
||||
const jit_uint8_t kREG_XMM13 = 13;
|
||||
const jit_uint8_t kREG_XMM14 = 14;
|
||||
const jit_uint8_t kREG_XMM15 = 15;
|
||||
|
||||
#define X64_REX_PREFIX 0x40
|
||||
|
||||
#define IA32_MOV_REG8_IMM8 0xB0
|
||||
|
||||
inline jit_uint8_t x64_rex(bool w, jit_uint8_t r, jit_uint8_t x, jit_uint8_t b)
|
||||
{
|
||||
return (X64_REX_PREFIX | ((jit_uint8_t)w << 3) | ((r>>3) << 2) | ((x>>3) << 1) | (b >> 3));
|
||||
}
|
||||
|
||||
inline void X64_Push_Reg(JitWriter *jit, jit_uint8_t reg)
|
||||
{
|
||||
if (reg >= kREG_R8)
|
||||
jit->write_ubyte(x64_rex(false, 0, 0, reg));
|
||||
IA32_Push_Reg(jit, reg & 7);
|
||||
}
|
||||
|
||||
inline void X64_Mov_Reg_Rm(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_uint8_t mode)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src));
|
||||
IA32_Mov_Reg_Rm(jit, dest & 7, src & 7, mode);
|
||||
}
|
||||
|
||||
inline void X64_Mov_Reg_Rm_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src));
|
||||
IA32_Mov_Reg_Rm_Disp8(jit, dest & 7, src & 7, disp);
|
||||
}
|
||||
|
||||
inline void X64_Mov_Reg_Rm_Disp32(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int32_t disp)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src));
|
||||
IA32_Mov_Reg_Rm_Disp32(jit, dest & 7, src & 7, disp);
|
||||
}
|
||||
|
||||
inline void X64_Mov_Reg32_Rm(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_uint8_t mode)
|
||||
{
|
||||
if (src>= kREG_R8 || dest >= kREG_R8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
IA32_Mov_Reg_Rm(jit, dest & 7, src & 7, mode);
|
||||
}
|
||||
|
||||
inline void X64_Mov_Reg32_Rm_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
if (src>= kREG_R8 || dest >= kREG_R8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
IA32_Mov_Reg_Rm_Disp8(jit, dest & 7, src & 7, disp);
|
||||
}
|
||||
|
||||
inline void X64_Mov_Reg32_Rm_Disp32(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int32_t disp)
|
||||
{
|
||||
if (src>= kREG_R8 || dest >= kREG_R8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
IA32_Mov_Reg_Rm_Disp32(jit, dest & 7, src & 7, disp);
|
||||
}
|
||||
|
||||
inline void X64_And_Rm_Imm8(JitWriter *jit, jit_uint8_t reg, jit_uint8_t mode, jit_int8_t value)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, 0, 0, reg));
|
||||
IA32_And_Rm_Imm8(jit, reg & 7, mode, value);
|
||||
}
|
||||
|
||||
inline void X64_Sub_Rm_Imm8(JitWriter *jit, jit_uint8_t reg, jit_int8_t val, jit_uint8_t mode)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, 5, 0, reg));
|
||||
IA32_Sub_Rm_Imm8(jit, reg & 7, val, mode);
|
||||
}
|
||||
|
||||
inline void X64_Sub_Rm_Imm32(JitWriter *jit, jit_uint8_t reg, jit_int32_t val, jit_uint8_t mode)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, 5, 0, reg));
|
||||
IA32_Sub_Rm_Imm32(jit, reg & 7, val, mode);
|
||||
}
|
||||
|
||||
inline void X64_Pop_Reg(JitWriter *jit, jit_uint8_t reg)
|
||||
{
|
||||
if (reg >= kREG_R8)
|
||||
jit->write_ubyte(x64_rex(false, 0, 0, reg));
|
||||
IA32_Pop_Reg(jit, reg & 7);
|
||||
}
|
||||
|
||||
inline void X64_Return(JitWriter *jit)
|
||||
{
|
||||
IA32_Return(jit);
|
||||
}
|
||||
|
||||
inline void X64_Movzx_Reg64_Rm8_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src));
|
||||
IA32_Movzx_Reg32_Rm8_Disp8(jit, dest & 7, src & 7, disp);
|
||||
}
|
||||
|
||||
inline void X64_Movzx_Reg64_Rm8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_uint8_t mode)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src));
|
||||
IA32_Movzx_Reg32_Rm8(jit, dest & 7, src & 7, mode);
|
||||
}
|
||||
|
||||
inline void X64_Movzx_Reg64_Rm8_Disp32(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int32_t disp)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src));
|
||||
IA32_Movzx_Reg32_Rm8_Disp32(jit, dest & 7, src & 7, disp);
|
||||
}
|
||||
|
||||
inline void X64_Mov_RmRSP_Reg(JitWriter *jit, jit_uint8_t src)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, kREG_RSP, 0, src));
|
||||
jit->write_ubyte(IA32_MOV_RM_REG);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, src & 7, kREG_RSP));
|
||||
jit->write_ubyte(ia32_sib(NOSCALE, kREG_NOIDX, kREG_RSP));
|
||||
}
|
||||
|
||||
inline void X64_Mov_RmRSP_Disp8_Reg(JitWriter *jit, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, src, 0, kREG_RSP));
|
||||
jit->write_ubyte(IA32_MOV_RM_REG);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP8, src & 7, kREG_RSP));
|
||||
jit->write_ubyte(ia32_sib(NOSCALE, kREG_NOIDX, kREG_RSP));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Mov_RmRSP_Disp32_Reg(JitWriter *jit, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, src, 0, kREG_RSP));
|
||||
jit->write_ubyte(IA32_MOV_RM_REG);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP32, src & 7, kREG_RSP));
|
||||
jit->write_ubyte(ia32_sib(NOSCALE, kREG_NOIDX, kREG_RSP));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movzx_Reg64_Rm16(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_uint8_t mode)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src));
|
||||
IA32_Movzx_Reg32_Rm16(jit, dest & 7, src & 7, mode);
|
||||
}
|
||||
|
||||
inline void X64_Movzx_Reg64_Rm16_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src));
|
||||
IA32_Movzx_Reg32_Rm16_Disp8(jit, dest & 7, src & 7, disp);
|
||||
}
|
||||
|
||||
inline void X64_Movzx_Reg64_Rm16_Disp32(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int32_t disp)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src));
|
||||
IA32_Movzx_Reg32_Rm16_Disp32(jit, dest & 7, src & 7, disp);
|
||||
}
|
||||
|
||||
inline void X64_Lea_DispRegImm8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src_base, jit_int8_t val)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src_base));
|
||||
IA32_Lea_DispRegImm8(jit, dest & 7, src_base & 7, val);
|
||||
}
|
||||
|
||||
inline void X64_Lea_DispRegImm32(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src_base, jit_int32_t val)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src_base));
|
||||
IA32_Lea_DispRegImm32(jit, dest & 7, src_base & 7, val);
|
||||
}
|
||||
|
||||
inline void X64_Add_Rm_Imm8(JitWriter *jit, jit_uint8_t reg, jit_int8_t value, jit_uint8_t mode)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, 0, 0, reg));
|
||||
IA32_Add_Rm_Imm8(jit, reg & 7, value, mode);
|
||||
}
|
||||
|
||||
inline void X64_Add_Rm_Imm32(JitWriter *jit, jit_uint8_t reg, jit_int32_t value, jit_uint8_t mode)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, 0, 0, reg));
|
||||
IA32_Add_Rm_Imm32(jit, reg & 7, value, mode);
|
||||
}
|
||||
|
||||
inline void X64_Movaps_Rm(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x28);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, dest & 7, src & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movups_Rm(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x10);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, dest & 7, src & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movaps_Rm_Reg(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x29);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, src & 7, dest & 7));
|
||||
jit->write_ubyte(ia32_sib(NOSCALE, kREG_NOIDX, dest & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movapd_Rm_Reg(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
jit->write_ubyte(0x66);
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x29);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, src & 7, dest & 7));
|
||||
jit->write_ubyte(ia32_sib(NOSCALE, kREG_NOIDX, dest & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movups_Rm_Reg(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x11);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, src & 7, dest & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movupd_Rm_Reg(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
jit->write_ubyte(0x66);
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x11);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, src & 7, dest & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movupd_Rm_Disp8_Reg(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
jit->write_ubyte(0x66);
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x11);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP8, src & 7, dest & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movaps_Rm_Disp8_Reg(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x29);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP8, src & 7, dest & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movups_Rm_Disp8_Reg(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x11);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP8, src & 7, dest & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movaps_Rm_Disp32_Reg(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int32_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x29);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP32, src & 7, dest & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movups_Rm_Disp32_Reg(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int32_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x11);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP32, src & 7, dest & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movlps_Rm(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x12);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, dest & 7, src & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movhps_Rm(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x16);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, dest & 7, src & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movaps_Rm_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x28);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP8, dest & 7, src & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movups_Rm_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x10);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP8, dest & 7, src & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movlps_Rm_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x12);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP8, dest & 7, src & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movhps_Rm_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x16);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP8, dest & 7, src & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movaps_Rm_Disp32(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int32_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x28);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP32, dest & 7, src & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movups_Rm_Disp32(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int32_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x10);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP32, dest & 7, src & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movapd_Rm(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x66);
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x28);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, dest & 7, src & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movupd_Rm(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x66);
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x10);
|
||||
jit->write_ubyte(ia32_modrm(MOD_MEM_REG, dest & 7, src & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movapd_Rm_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x66);
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x28);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP8, dest & 7, src & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movupd_Rm_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x66);
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x10);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP8, dest & 7, src & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movapd_Rm_Disp32(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int32_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x66);
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x28);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP32, dest & 7, src & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Movupd_Rm_Disp32(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int32_t disp)
|
||||
{
|
||||
if (dest >= kREG_XMM8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, dest, 0, src));
|
||||
jit->write_ubyte(0x66);
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x10);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP32, dest & 7, src & 7));
|
||||
jit->write_byte(disp);
|
||||
}
|
||||
|
||||
inline void X64_Cld(JitWriter *jit)
|
||||
{
|
||||
IA32_Cld(jit);
|
||||
}
|
||||
|
||||
inline void X64_Rep(JitWriter *jit)
|
||||
{
|
||||
IA32_Rep(jit);
|
||||
}
|
||||
|
||||
inline void X64_Movsq(JitWriter *jit)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, 0, 0, 0));
|
||||
jit->write_ubyte(IA32_MOVSD);
|
||||
}
|
||||
|
||||
inline void X64_Movsb(JitWriter *jit)
|
||||
{
|
||||
jit->write_ubyte(IA32_MOVSB);
|
||||
}
|
||||
|
||||
inline void X64_Lea_Reg_DispRegMultImm8(JitWriter *jit,
|
||||
jit_uint8_t dest,
|
||||
jit_uint8_t src_base,
|
||||
jit_uint8_t src_index,
|
||||
jit_uint8_t scale,
|
||||
jit_int8_t val)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src_index));
|
||||
IA32_Lea_Reg_DispRegMultImm8(jit, dest & 7, src_base, src_index & 7, scale, val);
|
||||
}
|
||||
|
||||
inline void X64_Lea_Reg_DispRegMultImm32(JitWriter *jit,
|
||||
jit_uint8_t dest,
|
||||
jit_uint8_t src_base,
|
||||
jit_uint8_t src_index,
|
||||
jit_uint8_t scale,
|
||||
jit_int32_t val)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, dest, 0, src_index));
|
||||
jit->write_ubyte(IA32_LEA_REG_MEM);
|
||||
jit->write_ubyte(ia32_modrm(MOD_DISP32, dest & 7, kREG_SIB));
|
||||
jit->write_ubyte(ia32_sib(scale, src_index & 7, src_base));
|
||||
jit->write_int32(val);
|
||||
}
|
||||
|
||||
inline jitoffs_t X64_Mov_Reg_Imm32(JitWriter *jit, jit_uint8_t dest, jit_int32_t num)
|
||||
{
|
||||
jitoffs_t offs;
|
||||
jit->write_ubyte(x64_rex(true, 0, 0, dest));
|
||||
jit->write_ubyte(0xC7);
|
||||
jit->write_ubyte(ia32_modrm(MOD_REG, 0, dest & 7));
|
||||
offs = jit->get_outputpos();
|
||||
jit->write_int32(num);
|
||||
return offs;
|
||||
}
|
||||
|
||||
inline jitoffs_t X64_Mov_Reg_Imm64(JitWriter *jit, jit_uint8_t dest, jit_int64_t num)
|
||||
{
|
||||
jitoffs_t offs;
|
||||
jit->write_ubyte(x64_rex(true, 0, 0, dest));
|
||||
jit->write_ubyte(IA32_MOV_REG_IMM+(dest & 7));
|
||||
offs = jit->get_outputpos();
|
||||
jit->write_int64(num);
|
||||
return offs;
|
||||
}
|
||||
|
||||
inline void X64_Mov_Rm8_Reg8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_uint8_t mode)
|
||||
{
|
||||
if (dest >= kREG_R8 || src > kREG_R8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(IA32_MOV_RM8_REG8);
|
||||
if ((dest & 7) == kREG_RBP) // Using rbp/r13 requires a displacement
|
||||
mode = MOD_DISP8;
|
||||
jit->write_ubyte(ia32_modrm(mode, src & 7, dest & 7));
|
||||
if ((dest & 7) == kREG_RSP) // rsp/r12 needs SIB byte
|
||||
jit->write_ubyte(ia32_sib(NOSCALE, kREG_NOIDX, dest & 7));
|
||||
else if ((dest & 7) == kREG_RBP)
|
||||
jit->write_ubyte(0); // Displacement of 0 needed to use rbp/r13
|
||||
}
|
||||
|
||||
inline void X64_Mov_Rm32_Reg32(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_uint8_t mode)
|
||||
{
|
||||
if (dest >= kREG_R8 || src > kREG_R8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(IA32_MOV_RM_REG);
|
||||
if ((dest & 7) == kREG_RBP) // Using rbp/r13 requires a displacement
|
||||
mode = MOD_DISP8;
|
||||
jit->write_ubyte(ia32_modrm(mode, src & 7, dest & 7));
|
||||
if ((dest & 7) == kREG_RSP) // rsp/r12 needs SIB byte
|
||||
jit->write_ubyte(ia32_sib(NOSCALE, kREG_NOIDX, dest & 7));
|
||||
else if ((dest & 7) == kREG_RBP)
|
||||
jit->write_ubyte(0); // Displacement of 0 needed to use rbp/r13
|
||||
}
|
||||
|
||||
inline void X64_Mov_Rm16_Reg16(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_uint8_t mode)
|
||||
{
|
||||
jit->write_ubyte(IA32_16BIT_PREFIX);
|
||||
X64_Mov_Rm32_Reg32(jit, dest, src, mode);
|
||||
}
|
||||
|
||||
|
||||
inline void X64_Mov_Rm_Reg(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_uint8_t mode)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, src, 0, dest));
|
||||
jit->write_ubyte(IA32_MOV_RM_REG);
|
||||
if ((dest & 7) == kREG_RBP) // Using rbp/r13 requires a displacement
|
||||
mode = MOD_DISP8;
|
||||
jit->write_ubyte(ia32_modrm(mode, src & 7, dest & 7));
|
||||
if ((dest & 7) == kREG_RSP) // rsp/r12 needs SIB byte
|
||||
jit->write_ubyte(ia32_sib(NOSCALE, kREG_NOIDX, dest & 7));
|
||||
else if ((dest & 7) == kREG_RBP)
|
||||
jit->write_ubyte(0); // Displacement of 0 needed to use rbp/r13
|
||||
}
|
||||
|
||||
inline void X64_Mov_Rm_Reg_Disp8(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src, jit_int8_t disp)
|
||||
{
|
||||
jit->write_ubyte(x64_rex(true, src, 0, dest));
|
||||
IA32_Mov_Rm_Reg_Disp8(jit, dest & 7, src & 7, disp);
|
||||
}
|
||||
|
||||
inline jitoffs_t X64_Call_Imm32(JitWriter *jit, jit_int32_t disp)
|
||||
{
|
||||
return IA32_Call_Imm32(jit, disp);
|
||||
}
|
||||
|
||||
inline void X64_Write_Jump32_Abs(JitWriter *jit, jitoffs_t jmp, void *target)
|
||||
{
|
||||
IA32_Write_Jump32_Abs(jit, jmp, target);
|
||||
}
|
||||
|
||||
inline void X64_Call_Reg(JitWriter *jit, jit_uint8_t reg)
|
||||
{
|
||||
if (reg >= kREG_R8)
|
||||
jit->write_ubyte(x64_rex(false, 0, 0, reg));
|
||||
IA32_Call_Reg(jit, reg & 7);
|
||||
}
|
||||
|
||||
inline jitoffs_t X64_Mov_Reg8_Imm8(JitWriter *jit, jit_uint8_t dest, jit_int8_t value)
|
||||
{
|
||||
jitoffs_t offs;
|
||||
if (dest >= kREG_R8)
|
||||
jit->write_ubyte(x64_rex(false, 0, 0, dest));
|
||||
jit->write_ubyte(IA32_MOV_REG8_IMM8+(dest & 7));
|
||||
offs = jit->get_outputpos();
|
||||
jit->write_byte(value);
|
||||
return offs;
|
||||
}
|
||||
|
||||
inline void X64_Movd_Reg32_Xmm(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
jit->write_ubyte(0x66);
|
||||
if (dest >= kREG_R8 || src >= kREG_XMM8)
|
||||
jit->write_ubyte(x64_rex(false, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x7E);
|
||||
jit->write_ubyte(ia32_modrm(MOD_REG, src & 7, dest & 7));
|
||||
}
|
||||
|
||||
inline void X64_Movq_Reg_Xmm(JitWriter *jit, jit_uint8_t dest, jit_uint8_t src)
|
||||
{
|
||||
jit->write_ubyte(0x66);
|
||||
jit->write_ubyte(x64_rex(true, src, 0, dest));
|
||||
jit->write_ubyte(0x0F);
|
||||
jit->write_ubyte(0x7E);
|
||||
jit->write_ubyte(ia32_modrm(MOD_REG, src & 7, dest & 7));
|
||||
}
|
||||
@@ -1,23 +1,24 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
binary = SM.ExtLibrary(builder, 'clientprefs.ext')
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
for arch in SM.archs:
|
||||
binary = SM.ExtLibrary(builder, 'clientprefs.ext', arch)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'cookie.cpp',
|
||||
'menus.cpp',
|
||||
'natives.cpp',
|
||||
'query.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'cookie.cpp',
|
||||
'menus.cpp',
|
||||
'natives.cpp',
|
||||
'query.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
|
||||
|
||||
@@ -11,14 +11,24 @@ project.sources += [
|
||||
'util_cstrike.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 ['css', 'csgo']:
|
||||
if sdk_name not in SM.sdks:
|
||||
continue
|
||||
sdk = SM.sdks[sdk_name]
|
||||
|
||||
SM.HL2Config(project, 'game.cstrike.ext.' + sdk.ext, sdk)
|
||||
for arch in SM.archs:
|
||||
if not arch in sdk.platformSpec[builder.target.platform]:
|
||||
continue
|
||||
|
||||
SM.HL2Config(project, 'game.cstrike.ext.' + sdk.ext, sdk, arch)
|
||||
|
||||
SM.extensions += builder.Add(project)
|
||||
|
||||
@@ -18,7 +18,11 @@ struct HashItemDef_Node
|
||||
class CHashItemDef
|
||||
{
|
||||
public:
|
||||
#ifdef PLATFORM_X86
|
||||
unsigned char padding[36];
|
||||
#else
|
||||
unsigned char padding[56];
|
||||
#endif
|
||||
HashItemDef_Node *pMem;
|
||||
int nAllocatedCount;
|
||||
int nGrowSize;
|
||||
|
||||
@@ -192,9 +192,9 @@ CEconItemSchema *GetItemSchema()
|
||||
void *pSchema = NULL;
|
||||
pWrapper->Execute(NULL, &pSchema);
|
||||
|
||||
//In windows this is actually ItemSystem() + 4 is ItemSchema
|
||||
#ifdef WIN32
|
||||
return (CEconItemSchema *)((intptr_t)pSchema + 4);
|
||||
//On windows/mac this is actually ItemSystem() + sizeof(void *) is ItemSchema
|
||||
#if defined(PLATFORM_WINDOWS) || defined(PLATFORM_APPLE)
|
||||
return (CEconItemSchema *)((intptr_t)pSchema + sizeof(void *));
|
||||
#else
|
||||
return (CEconItemSchema *)pSchema;
|
||||
#endif
|
||||
|
||||
+21
-21
@@ -2,27 +2,27 @@
|
||||
import os
|
||||
|
||||
libcurl = builder.Build('curl-src/lib/AMBuilder')
|
||||
for arch in SM.archs:
|
||||
binary = SM.ExtLibrary(builder, 'webternet.ext', arch)
|
||||
binary.compiler.includes += [
|
||||
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'include')
|
||||
]
|
||||
binary.compiler.defines += ['CURL_STATICLIB']
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
binary.compiler.postlink += [libcurl[arch].binary]
|
||||
if builder.target.platform == 'linux':
|
||||
binary.compiler.postlink += ['-lrt']
|
||||
elif builder.target.platform == 'windows':
|
||||
binary.compiler.postlink += ['ws2_32.lib']
|
||||
|
||||
binary = SM.ExtLibrary(builder, 'webternet.ext')
|
||||
binary.compiler.includes += [
|
||||
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'include')
|
||||
]
|
||||
binary.compiler.defines += ['CURL_STATICLIB']
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
binary.compiler.postlink += [libcurl.binary]
|
||||
if builder.target.platform == 'linux':
|
||||
binary.compiler.postlink += ['-lrt']
|
||||
elif builder.target.platform == 'windows':
|
||||
binary.compiler.postlink += ['ws2_32.lib']
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'curlapi.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'curlapi.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
|
||||
|
||||
@@ -3,96 +3,98 @@ import os, platform
|
||||
|
||||
builder.SetBuildFolder('libcurl')
|
||||
|
||||
binary = SM.StaticLibrary(builder, 'curl')
|
||||
binary.compiler.includes += [
|
||||
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'lib'),
|
||||
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'include')
|
||||
]
|
||||
|
||||
if builder.target.platform == 'mac':
|
||||
mac_version, ignore, ignore = platform.mac_ver()
|
||||
mac_tuple = mac_version.split('.')
|
||||
if int(mac_tuple[0]) >= 10 and int(mac_tuple[1]) >= 9:
|
||||
binary.compiler.defines += ['BUILTIN_STRLCAT']
|
||||
elif builder.target.platform == 'windows':
|
||||
binary.compiler.defines += [
|
||||
'BUILDING_LIBCURL',
|
||||
'CURL_STATICLIB',
|
||||
'CURL_DISABLE_LDAP',
|
||||
rvalue = {}
|
||||
for arch in SM.archs:
|
||||
binary = SM.StaticLibrary(builder, 'curl', arch)
|
||||
binary.compiler.includes += [
|
||||
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'lib'),
|
||||
os.path.join(builder.sourcePath, 'extensions', 'curl', 'curl-src', 'include')
|
||||
]
|
||||
elif builder.target.platform == 'linux':
|
||||
binary.compiler.defines += ['_GNU_SOURCE']
|
||||
|
||||
if binary.compiler.family == 'clang':
|
||||
# https://llvm.org/bugs/show_bug.cgi?id=16428
|
||||
binary.compiler.cflags += ['-Wno-attributes']
|
||||
if builder.target.platform == 'mac':
|
||||
mac_version, ignore, ignore = platform.mac_ver()
|
||||
mac_tuple = mac_version.split('.')
|
||||
if int(mac_tuple[0]) >= 10 and int(mac_tuple[1]) >= 9:
|
||||
binary.compiler.defines += ['BUILTIN_STRLCAT']
|
||||
elif builder.target.platform == 'windows':
|
||||
binary.compiler.defines += [
|
||||
'BUILDING_LIBCURL',
|
||||
'CURL_STATICLIB',
|
||||
'CURL_DISABLE_LDAP',
|
||||
]
|
||||
elif builder.target.platform == 'linux':
|
||||
binary.compiler.defines += ['_GNU_SOURCE']
|
||||
|
||||
binary.sources += [
|
||||
'base64.c',
|
||||
'connect.c',
|
||||
'content_encoding.c',
|
||||
'cookie.c',
|
||||
'curl_addrinfo.c',
|
||||
'dict.c',
|
||||
'easy.c',
|
||||
'escape.c',
|
||||
'file.c',
|
||||
'formdata.c',
|
||||
'ftp.c',
|
||||
'getenv.c',
|
||||
'getinfo.c',
|
||||
'gtls.c',
|
||||
'hash.c',
|
||||
'hostares.c',
|
||||
'hostasyn.c',
|
||||
'hostip.c',
|
||||
'hostip4.c',
|
||||
'hostip6.c',
|
||||
'hostsyn.c',
|
||||
'hostthre.c',
|
||||
'http.c',
|
||||
'http_chunks.c',
|
||||
'http_digest.c',
|
||||
'http_negotiate.c',
|
||||
'http_ntlm.c',
|
||||
'if2ip.c',
|
||||
'inet_ntop.c',
|
||||
'inet_pton.c',
|
||||
'krb4.c',
|
||||
'krb5.c',
|
||||
'ldap.c',
|
||||
'llist.c',
|
||||
'md5.c',
|
||||
'memdebug.c',
|
||||
'mprintf.c',
|
||||
'multi.c',
|
||||
'netrc.c',
|
||||
'nss.c',
|
||||
'parsedate.c',
|
||||
'progress.c',
|
||||
'qssl.c',
|
||||
'rawstr.c',
|
||||
'security.c',
|
||||
'select.c',
|
||||
'sendf.c',
|
||||
'share.c',
|
||||
'socks.c',
|
||||
'speedcheck.c',
|
||||
'splay.c',
|
||||
'ssh.c',
|
||||
'sslgen.c',
|
||||
'ssluse.c',
|
||||
'strdup.c',
|
||||
'strequal.c',
|
||||
'strerror.c',
|
||||
'strtok.c',
|
||||
'strtoofft.c',
|
||||
'telnet.c',
|
||||
'tftp.c',
|
||||
'timeval.c',
|
||||
'transfer.c',
|
||||
'url.c',
|
||||
'version.c'
|
||||
]
|
||||
rvalue = builder.Add(binary)
|
||||
if binary.compiler.family == 'clang':
|
||||
# https://llvm.org/bugs/show_bug.cgi?id=16428
|
||||
binary.compiler.cflags += ['-Wno-attributes']
|
||||
|
||||
binary.sources += [
|
||||
'base64.c',
|
||||
'connect.c',
|
||||
'content_encoding.c',
|
||||
'cookie.c',
|
||||
'curl_addrinfo.c',
|
||||
'dict.c',
|
||||
'easy.c',
|
||||
'escape.c',
|
||||
'file.c',
|
||||
'formdata.c',
|
||||
'ftp.c',
|
||||
'getenv.c',
|
||||
'getinfo.c',
|
||||
'gtls.c',
|
||||
'hash.c',
|
||||
'hostares.c',
|
||||
'hostasyn.c',
|
||||
'hostip.c',
|
||||
'hostip4.c',
|
||||
'hostip6.c',
|
||||
'hostsyn.c',
|
||||
'hostthre.c',
|
||||
'http.c',
|
||||
'http_chunks.c',
|
||||
'http_digest.c',
|
||||
'http_negotiate.c',
|
||||
'http_ntlm.c',
|
||||
'if2ip.c',
|
||||
'inet_ntop.c',
|
||||
'inet_pton.c',
|
||||
'krb4.c',
|
||||
'krb5.c',
|
||||
'ldap.c',
|
||||
'llist.c',
|
||||
'md5.c',
|
||||
'memdebug.c',
|
||||
'mprintf.c',
|
||||
'multi.c',
|
||||
'netrc.c',
|
||||
'nss.c',
|
||||
'parsedate.c',
|
||||
'progress.c',
|
||||
'qssl.c',
|
||||
'rawstr.c',
|
||||
'security.c',
|
||||
'select.c',
|
||||
'sendf.c',
|
||||
'share.c',
|
||||
'socks.c',
|
||||
'speedcheck.c',
|
||||
'splay.c',
|
||||
'ssh.c',
|
||||
'sslgen.c',
|
||||
'ssluse.c',
|
||||
'strdup.c',
|
||||
'strequal.c',
|
||||
'strerror.c',
|
||||
'strtok.c',
|
||||
'strtoofft.c',
|
||||
'telnet.c',
|
||||
'tftp.c',
|
||||
'timeval.c',
|
||||
'transfer.c',
|
||||
'url.c',
|
||||
'version.c'
|
||||
]
|
||||
rvalue[arch] = builder.Add(binary)
|
||||
|
||||
|
||||
+14
-13
@@ -1,19 +1,20 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
binary = SM.ExtLibrary(builder, 'geoip.ext')
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
if builder.target.platform == 'windows':
|
||||
binary.compiler.postlink += ['wsock32.lib']
|
||||
for arch in SM.archs:
|
||||
binary = SM.ExtLibrary(builder, 'geoip.ext', arch)
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
if builder.target.platform == 'windows':
|
||||
binary.compiler.postlink += ['wsock32.lib']
|
||||
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'GeoIP.c',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'GeoIP.c',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
|
||||
|
||||
+38
-37
@@ -2,45 +2,46 @@
|
||||
import os
|
||||
|
||||
if SM.mysql_root:
|
||||
binary = SM.ExtLibrary(builder, 'dbi.mysql.ext')
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mysql_root, 'include'),
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook')
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
|
||||
if builder.target.platform == 'linux' or builder.target.platform == 'mac':
|
||||
binary.compiler.postlink += [
|
||||
os.path.join(SM.mysql_root, 'lib', 'libmysqlclient_r.a'),
|
||||
'-lz',
|
||||
'-lpthread',
|
||||
'-lm',
|
||||
]
|
||||
if builder.target.platform == 'linux':
|
||||
binary.compiler.postlink += ['-lrt']
|
||||
elif builder.target.platform == 'windows':
|
||||
binary.compiler.postlink += [
|
||||
os.path.join(SM.mysql_root, 'lib', 'opt', 'mysqlclient.lib'),
|
||||
os.path.join(SM.mysql_root, 'lib', 'opt', 'zlib.lib'),
|
||||
'wsock32.lib'
|
||||
for arch in SM.archs:
|
||||
binary = SM.ExtLibrary(builder, 'dbi.mysql.ext', arch)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mysql_root[arch], 'include'),
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook')
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
|
||||
binary.sources += [
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'mysql/MyBasicResults.cpp',
|
||||
'mysql/MyBoundResults.cpp',
|
||||
'mysql/MyDatabase.cpp',
|
||||
'mysql/MyDriver.cpp',
|
||||
'mysql/MyStatement.cpp',
|
||||
'extension.cpp'
|
||||
]
|
||||
if builder.target.platform == 'linux' or builder.target.platform == 'mac':
|
||||
binary.compiler.postlink += [
|
||||
os.path.join(SM.mysql_root[arch], 'lib', 'libmysqlclient_r.a'),
|
||||
'-lz',
|
||||
'-lpthread',
|
||||
'-lm',
|
||||
]
|
||||
if builder.target.platform == 'linux':
|
||||
binary.compiler.postlink += ['-lrt']
|
||||
elif builder.target.platform == 'windows':
|
||||
binary.compiler.postlink += [
|
||||
os.path.join(SM.mysql_root, 'lib', 'opt', 'mysqlclient.lib'),
|
||||
os.path.join(SM.mysql_root, 'lib', 'opt', 'zlib.lib'),
|
||||
'wsock32.lib'
|
||||
]
|
||||
|
||||
binary.sources += [
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'mysql/MyBasicResults.cpp',
|
||||
'mysql/MyBoundResults.cpp',
|
||||
'mysql/MyDatabase.cpp',
|
||||
'mysql/MyDriver.cpp',
|
||||
'mysql/MyStatement.cpp',
|
||||
'extension.cpp'
|
||||
]
|
||||
|
||||
if binary.compiler.family == 'msvc' and binary.compiler.version >= 1900:
|
||||
binary.sources += [ 'msvc15hack.c' ]
|
||||
binary.compiler.linkflags += ['legacy_stdio_definitions.lib', 'legacy_stdio_wide_specifiers.lib']
|
||||
if binary.compiler.family == 'msvc' and binary.compiler.version >= 1900:
|
||||
binary.sources += [ 'msvc15hack.c' ]
|
||||
binary.compiler.linkflags += ['legacy_stdio_definitions.lib', 'legacy_stdio_wide_specifiers.lib']
|
||||
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
|
||||
|
||||
+28
-21
@@ -1,28 +1,35 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
binary = SM.ExtLibrary(builder, 'regex.ext')
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
for arch in SM.archs:
|
||||
binary = SM.ExtLibrary(builder, 'regex.ext', arch)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
|
||||
if builder.target.platform == 'linux':
|
||||
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_linux', 'libpcre.a')
|
||||
elif builder.target.platform == 'windows':
|
||||
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_win', 'pcre.lib')
|
||||
elif builder.target.platform == 'mac':
|
||||
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_darwin', 'libpcre.a')
|
||||
binary.compiler.postlink += [binary.Dep(path)]
|
||||
if builder.target.platform == 'linux':
|
||||
if arch == 'x86':
|
||||
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_linux', 'libpcre.a')
|
||||
elif arch == 'x64':
|
||||
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_linux64', 'libpcre.a')
|
||||
elif builder.target.platform == 'windows':
|
||||
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_win', 'pcre.lib')
|
||||
elif builder.target.platform == 'mac':
|
||||
if arch == 'x86':
|
||||
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_darwin', 'libpcre.a')
|
||||
elif arch == 'x64':
|
||||
path = os.path.join(builder.sourcePath, 'extensions', 'regex', 'lib_darwin64', 'libpcre.a')
|
||||
binary.compiler.postlink += [binary.Dep(path)]
|
||||
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'CRegEx.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'CRegEx.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -12,12 +12,16 @@ project.sources += [
|
||||
|
||||
for sdk_name in SM.sdks:
|
||||
sdk = SM.sdks[sdk_name]
|
||||
|
||||
for arch in SM.archs:
|
||||
if not arch in sdk.platformSpec[builder.target.platform]:
|
||||
continue
|
||||
|
||||
binary = SM.HL2Config(project, 'sdkhooks.ext.' + sdk.ext, sdk)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(sdk.path, 'game', 'shared')
|
||||
]
|
||||
if binary.compiler.behavior == 'gcc':
|
||||
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
|
||||
binary = SM.HL2Config(project, 'sdkhooks.ext.' + sdk.ext, sdk, arch)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(sdk.path, 'game', 'shared')
|
||||
]
|
||||
if binary.compiler.behavior == 'gcc':
|
||||
binary.compiler.cxxflags += ['-Wno-invalid-offsetof']
|
||||
|
||||
SM.extensions += builder.Add(project)
|
||||
|
||||
@@ -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 */
|
||||
|
||||
+27
-26
@@ -1,33 +1,34 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
binary = SM.ExtLibrary(builder, 'dbi.sqlite.ext')
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
for arch in SM.archs:
|
||||
binary = SM.ExtLibrary(builder, 'dbi.sqlite.ext', arch)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
|
||||
binary.compiler.defines += [
|
||||
'SQLITE_OMIT_LOAD_EXTENSION',
|
||||
'SQLITE_THREADSAFE',
|
||||
'SQLITE_USE_URI',
|
||||
'SQLITE_ALLOW_URI_AUTHORITY',
|
||||
]
|
||||
if builder.target.platform == 'linux':
|
||||
binary.compiler.postlink += ['-ldl', '-lpthread']
|
||||
binary.compiler.defines += [
|
||||
'SQLITE_OMIT_LOAD_EXTENSION',
|
||||
'SQLITE_THREADSAFE',
|
||||
'SQLITE_USE_URI',
|
||||
'SQLITE_ALLOW_URI_AUTHORITY',
|
||||
]
|
||||
if builder.target.platform == 'linux':
|
||||
binary.compiler.postlink += ['-ldl', '-lpthread']
|
||||
|
||||
binary.sources += [
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'extension.cpp',
|
||||
'driver/SqDatabase.cpp',
|
||||
'driver/SqDriver.cpp',
|
||||
'driver/SqQuery.cpp',
|
||||
'driver/SqResults.cpp',
|
||||
'sqlite-source/sqlite3.c'
|
||||
]
|
||||
binary.sources += [
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'extension.cpp',
|
||||
'driver/SqDatabase.cpp',
|
||||
'driver/SqDriver.cpp',
|
||||
'driver/SqQuery.cpp',
|
||||
'driver/SqResults.cpp',
|
||||
'sqlite-source/sqlite3.c'
|
||||
]
|
||||
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
|
||||
|
||||
+24
-16
@@ -4,19 +4,27 @@ import os
|
||||
if 'tf2' in SM.sdks:
|
||||
sdk = SM.sdks['tf2']
|
||||
|
||||
binary = SM.HL2Library(builder, 'game.tf2.ext.' + sdk.ext, sdk)
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'natives.cpp',
|
||||
'RegNatives.cpp',
|
||||
'util.cpp',
|
||||
'criticals.cpp',
|
||||
'holiday.cpp',
|
||||
'teleporter.cpp',
|
||||
'gameplayrules.cpp',
|
||||
'conditions.cpp',
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'../../public/CDetour/detours.cpp',
|
||||
'../../public/asm/asm.c'
|
||||
]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
for arch in SM.archs:
|
||||
binary = SM.HL2Library(builder, 'game.tf2.ext.' + sdk.ext, sdk, arch)
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'natives.cpp',
|
||||
'RegNatives.cpp',
|
||||
'util.cpp',
|
||||
'criticals.cpp',
|
||||
'holiday.cpp',
|
||||
'teleporter.cpp',
|
||||
'gameplayrules.cpp',
|
||||
'conditions.cpp',
|
||||
'../../public/smsdk_ext.cpp',
|
||||
'../../public/CDetour/detours.cpp',
|
||||
'../../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',
|
||||
]
|
||||
binary.compiler.defines += ['HAVE_STRING_H'];
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
binary = SM.ExtLibrary(builder, 'topmenus.ext')
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
for arch in SM.archs:
|
||||
binary = SM.ExtLibrary(builder, 'topmenus.ext', arch)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'smn_topmenus.cpp',
|
||||
'TopMenu.cpp',
|
||||
'TopMenuManager.cpp',
|
||||
'../../public/smsdk_ext.cpp',
|
||||
]
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'smn_topmenus.cpp',
|
||||
'TopMenu.cpp',
|
||||
'TopMenuManager.cpp',
|
||||
'../../public/smsdk_ext.cpp',
|
||||
]
|
||||
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
binary = SM.ExtLibrary(builder, 'updater.ext')
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
for arch in SM.archs:
|
||||
binary = SM.ExtLibrary(builder, 'updater.ext', arch)
|
||||
binary.compiler.cxxincludes += [
|
||||
os.path.join(SM.mms_root, 'core', 'sourcehook'),
|
||||
]
|
||||
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||
binary.compiler.cxxflags += ['-fno-rtti']
|
||||
elif binary.compiler.family == 'msvc':
|
||||
binary.compiler.cxxflags += ['/GR-']
|
||||
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'MemoryDownloader.cpp',
|
||||
'Updater.cpp',
|
||||
'md5.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
binary.sources += [
|
||||
'extension.cpp',
|
||||
'MemoryDownloader.cpp',
|
||||
'Updater.cpp',
|
||||
'md5.cpp',
|
||||
'../../public/smsdk_ext.cpp'
|
||||
]
|
||||
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
SM.extensions += [builder.Add(binary)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user