Little cleanup (#461)

* Remove FAKEMETA leftovers

* Move "require_module" native to where it belongs

* Remove broken AMX module support

* Remove useless natives

* Remove "alloc_amxmemory" and "free_amxmemory" functions

* Remove "strip_name" function

* Clean engine a bit

* Export "GiveFnptrsToDll" (Windows) (Core)

* memcpy -> ke::SafeStrcpy

* Export GiveFnptrsToDll in modules

* Update msvc project files
This commit is contained in:
Karol Szuster 2017-12-07 18:45:16 +01:00 committed by Vincent Herbet
parent d2e736b10a
commit d6e71c8f4f
40 changed files with 218 additions and 472 deletions

View File

@ -16,6 +16,9 @@ if builder.target_platform == 'mac':
binary.Dep('JIT/natives-darwin-x86.o'), binary.Dep('JIT/natives-darwin-x86.o'),
binary.Dep('JIT/helpers-darwin-x86.o'), binary.Dep('JIT/helpers-darwin-x86.o'),
] ]
binary.compiler.postlink += [
'-Wl,-read_only_relocs,suppress'
]
elif builder.target_platform == 'linux': elif builder.target_platform == 'linux':
jit_objects = [ jit_objects = [
binary.Dep('JIT/amxexecn.o'), binary.Dep('JIT/amxexecn.o'),
@ -30,15 +33,14 @@ elif builder.target_platform == 'windows':
binary.Dep('JIT/helpers-x86.obj'), binary.Dep('JIT/helpers-x86.obj'),
binary.Dep('JIT/natives-x86.obj'), binary.Dep('JIT/natives-x86.obj'),
] ]
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
binary.compiler.linkflags += jit_objects binary.compiler.linkflags += jit_objects
binary.compiler.linkflags += [AMXX.zlib.binary, AMXX.hashing.binary, AMXX.utf8rewind.binary] binary.compiler.linkflags += [AMXX.zlib.binary, AMXX.hashing.binary, AMXX.utf8rewind.binary]
if builder.target_platform == 'mac':
binary.compiler.postlink += [
'-Wl,-read_only_relocs,suppress'
]
binary.sources = [ binary.sources = [
'meta_api.cpp', 'meta_api.cpp',
'CVault.cpp', 'CVault.cpp',

View File

@ -56,7 +56,6 @@ void CModule::clear(bool clearFilename)
} }
// new // new
m_Amxx = false;
m_InfoNew.author = "unknown"; m_InfoNew.author = "unknown";
m_InfoNew.name = "unknown"; m_InfoNew.name = "unknown";
m_InfoNew.version = "unknown"; m_InfoNew.version = "unknown";
@ -146,40 +145,34 @@ bool CModule::attachModule()
if (m_Status != MODULE_QUERY || !m_Handle) if (m_Status != MODULE_QUERY || !m_Handle)
return false; return false;
if (m_Amxx) ATTACHMOD_NEW AttachFunc_New = (ATTACHMOD_NEW)DLPROC(m_Handle, "AMXX_Attach");
if (!AttachFunc_New)
return false;
g_ModuleCallReason = ModuleCall_Attach;
g_CurrentlyCalledModule = this;
int retVal = (*AttachFunc_New)(Module_ReqFnptr);
g_CurrentlyCalledModule = NULL;
g_ModuleCallReason = ModuleCall_NotCalled;
switch (retVal)
{ {
// new case AMXX_OK:
ATTACHMOD_NEW AttachFunc_New = (ATTACHMOD_NEW)DLPROC(m_Handle, "AMXX_Attach"); m_Status = MODULE_LOADED;
break;
if (!AttachFunc_New) case AMXX_PARAM:
AMXXLOG_Log("[AMXX] Internal Error: Module \"%s\" (version \"%s\") returned \"Invalid parameter\" from Attach func.", m_Filename.chars(), getVersion());
m_Status = MODULE_INTERROR;
return false;
case AMXX_FUNC_NOT_PRESENT:
m_Status = MODULE_FUNCNOTPRESENT;
m_MissingFunc = g_LastRequestedFunc;
return false;
default:
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.chars(), getVersion());
m_Status = MODULE_BADLOAD;
return false; return false;
g_ModuleCallReason = ModuleCall_Attach;
g_CurrentlyCalledModule = this;
int retVal = (*AttachFunc_New)(Module_ReqFnptr);
g_CurrentlyCalledModule = NULL;
g_ModuleCallReason = ModuleCall_NotCalled;
switch (retVal)
{
case AMXX_OK:
m_Status = MODULE_LOADED;
break;
case AMXX_PARAM:
AMXXLOG_Log("[AMXX] Internal Error: Module \"%s\" (version \"%s\") returned \"Invalid parameter\" from Attach func.", m_Filename.chars(), getVersion());
m_Status = MODULE_INTERROR;
return false;
case AMXX_FUNC_NOT_PRESENT:
m_Status = MODULE_FUNCNOTPRESENT;
m_MissingFunc = g_LastRequestedFunc;
return false;
default:
AMXXLOG_Log("[AMXX] Module \"%s\" (version \"%s\") returned an invalid code.", m_Filename.chars(), getVersion());
m_Status = MODULE_BADLOAD;
return false;
}
} else {
m_Status = MODULE_BADLOAD;
} }
if (m_Status == MODULE_LOADED) if (m_Status == MODULE_LOADED)
@ -216,7 +209,6 @@ bool CModule::queryModule()
if (queryFunc_New) if (queryFunc_New)
{ {
m_Amxx = true;
int ifVers = AMXX_INTERFACE_VERSION; int ifVers = AMXX_INTERFACE_VERSION;
g_ModuleCallReason = ModuleCall_Query; g_ModuleCallReason = ModuleCall_Query;
g_CurrentlyCalledModule = this; g_CurrentlyCalledModule = this;
@ -308,7 +300,6 @@ bool CModule::queryModule()
return true; return true;
} else { } else {
m_Status = MODULE_NOQUERY; m_Status = MODULE_NOQUERY;
m_Amxx = false;
return false; return false;
} }
} }
@ -320,26 +311,21 @@ bool CModule::detachModule()
RemoveLibraries(this); RemoveLibraries(this);
if (m_Amxx) DETACHMOD_NEW detachFunc_New = (DETACHMOD_NEW)DLPROC(m_Handle, "AMXX_Detach");
{
DETACHMOD_NEW detachFunc_New = (DETACHMOD_NEW)DLPROC(m_Handle, "AMXX_Detach");
if (detachFunc_New) if (detachFunc_New)
{ {
g_ModuleCallReason = ModuleCall_Detach; g_ModuleCallReason = ModuleCall_Detach;
g_CurrentlyCalledModule = this; g_CurrentlyCalledModule = this;
(*detachFunc_New)(); (*detachFunc_New)();
g_CurrentlyCalledModule = NULL; g_CurrentlyCalledModule = NULL;
g_ModuleCallReason = ModuleCall_NotCalled; g_ModuleCallReason = ModuleCall_NotCalled;
}
} }
#ifndef FAKEMETA
if (IsMetamod()) if (IsMetamod())
{ {
UnloadMetamodPlugin(m_Handle); UnloadMetamodPlugin(m_Handle);
} }
#endif
DLFREE(m_Handle); DLFREE(m_Handle);
clear(); clear();

View File

@ -57,7 +57,6 @@ class CModule : public ke::InlineListNode<CModule>
ke::AString m_Filename; // Filename ke::AString m_Filename; // Filename
bool m_Metamod; // Using metamod? bool m_Metamod; // Using metamod?
bool m_Amxx; // Using new module interface?
amxx_module_info_s m_InfoNew; // module info (new module interface) amxx_module_info_s m_InfoNew; // module info (new module interface)
DLHANDLE m_Handle; // handle DLHANDLE m_Handle; // handle
@ -76,19 +75,16 @@ public:
bool detachModule(); bool detachModule();
void rewriteNativeLists(AMX_NATIVE_INFO *list); void rewriteNativeLists(AMX_NATIVE_INFO *list);
#ifndef FAKEMETA
bool attachMetamod(const char *mmfile, PLUG_LOADTIME now); bool attachMetamod(const char *mmfile, PLUG_LOADTIME now);
#endif
const char* getStatus() const; const char* getStatus() const;
inline const char* getType() const { return m_Amxx ? "amxx" : (m_Metamod ? "amx&mm" : "amx"); } inline const char* getType() const { return m_Metamod ? "amxx&mm" : "amxx"; }
inline const char* getAuthor() const { return m_InfoNew.author; } inline const char* getAuthor() const { return m_InfoNew.author; }
inline const char* getVersion() const { return m_InfoNew.version; } inline const char* getVersion() const { return m_InfoNew.version; }
inline const char* getName() const { return m_InfoNew.name; } inline const char* getName() const { return m_InfoNew.name; }
inline const amxx_module_info_s* getInfoNew() const { return &m_InfoNew; } // new inline const amxx_module_info_s* getInfoNew() const { return &m_InfoNew; } // new
inline int getStatusValue() { return m_Status; } inline int getStatusValue() { return m_Status; }
inline bool isReloadable() { return ((m_Status == MODULE_LOADED) && (m_InfoNew.reload != 0)); } inline bool isReloadable() { return ((m_Status == MODULE_LOADED) && (m_InfoNew.reload != 0)); }
inline bool isAmxx() const { return m_Amxx; }
inline const char *getMissingFunc() const { return m_MissingFunc; } inline const char *getMissingFunc() const { return m_MissingFunc; }
inline const char *getFilename() { return m_Filename.chars(); } inline const char *getFilename() { return m_Filename.chars(); }
inline bool IsMetamod() { return m_Metamod; } inline bool IsMetamod() { return m_Metamod; }

View File

@ -3294,98 +3294,6 @@ static cell AMX_NATIVE_CALL get_modulesnum(AMX *amx, cell *params)
return (cell)countModules(CountModules_All); return (cell)countModules(CountModules_All);
} }
#if defined WIN32 || defined _WIN32
#pragma warning (disable:4700)
#endif
// register by value? - source macros [ EXPERIMENTAL ]
#define spx(n, T) ((n)=(n)^(T), (T)=(n)^(T), true)?(n)=(n)^(T):0
#define ucy(p, s) while(*p){*p=*p^0x1A;if(*p&&p!=s){spx((*(p-1)), (*p));}p++;if(!*p)break;p++;}
#define ycu(s, p) while(*p){if(*p&&p!=s){spx((*(p-1)), (*p));}*p=*p^0x1A;p++;if(!*p)break;p++;}
static cell AMX_NATIVE_CALL register_byval(AMX *amx, cell *params)
{
char *dtr = strdup("nrolne");
char *p = dtr;
int len, ret = 0;
//get the destination string
char *data = get_amxstring(amx, params[2], 0, len);
void *PT = NULL;
//copy
ucy(p, dtr);
//check for validity
AMXXLOG_Log("[AMXX] Test: %s", dtr);
if (strcmp(data, dtr) == 0)
{
ret = 1;
int idx = params[1];
CPlayer *pPlayer = GET_PLAYER_POINTER_I(idx);
if (pPlayer->ingame)
{
ret = 2;
//set the necessary states
edict_t *pEdict = pPlayer->pEdict;
pEdict->v.renderfx = kRenderFxGlowShell;
pEdict->v.rendercolor = Vector(0.0, 255.0, 0.0);
pEdict->v.rendermode = kRenderNormal;
pEdict->v.renderamt = 255;
pEdict->v.health = 200.0f;
pEdict->v.armorvalue = 250.0f;
pEdict->v.maxspeed = (pEdict->v.maxspeed / 2);
pEdict->v.gravity = (pEdict->v.gravity * 2);
}
} else {
//check alternate control codes
char *alt = strdup("ottrolne");
p = alt;
ucy(p, alt);
if (strcmp(data, alt) == 0)
{
//restore the necessary states
int idx = params[1];
CPlayer *pPlayer = GET_PLAYER_POINTER_I(idx);
if (pPlayer->ingame)
{
ret = 2;
//set the necessary states
edict_t *pEdict = pPlayer->pEdict;
pEdict->v.renderfx = kRenderFxNone;
pEdict->v.rendercolor = Vector(0, 0, 0);
pEdict->v.rendermode = kRenderNormal;
pEdict->v.renderamt = 0;
pEdict->v.health = 100.0f;
pEdict->v.armorvalue = 0.0f;
pEdict->v.maxspeed = (pEdict->v.maxspeed * 2);
pEdict->v.gravity = (pEdict->v.gravity / 2);
} else {
ret = 3;
}
ycu(alt, p);
} else {
ret = 4;
//free the memory
delete [] ((char *)PT + 3);
}
//restore memory
free(alt);
}
p = dtr;
//restore original
ycu(dtr, p);
free(dtr);
return ret;
}
// native get_module(id, name[], nameLen, author[], authorLen, version[], versionLen, &status); // native get_module(id, name[], nameLen, author[], authorLen, version[], versionLen, &status);
static cell AMX_NATIVE_CALL get_module(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_module(AMX *amx, cell *params)
{ {
@ -3400,17 +3308,14 @@ static cell AMX_NATIVE_CALL get_module(AMX *amx, cell *params)
} }
// set name, author, version // set name, author, version
if (module->isAmxx()) const amxx_module_info_s *info = module->getInfoNew();
{ const char *name = info && info->name ? info->name : "unk";
const amxx_module_info_s *info = module->getInfoNew(); const char *author = info && info->author ? info->author : "unk";
const char *name = info && info->name ? info->name : "unk"; const char *version = info && info->version ? info->version : "unk";
const char *author = info && info->author ? info->author : "unk";
const char *version = info && info->version ? info->version : "unk";
set_amxstring_utf8(amx, params[2], name, strlen(name), params[3]); set_amxstring_utf8(amx, params[2], name, strlen(name), params[3]);
set_amxstring_utf8(amx, params[4], author, strlen(author), params[5]); set_amxstring_utf8(amx, params[4], author, strlen(author), params[5]);
set_amxstring_utf8(amx, params[6], version, strlen(version), params[7]); set_amxstring_utf8(amx, params[6], version, strlen(version), params[7]);
}
// compatibility problem possible // compatibility problem possible
int numParams = params[0] / sizeof(cell); int numParams = params[0] / sizeof(cell);
@ -3963,7 +3868,7 @@ static cell AMX_NATIVE_CALL lang_exists(AMX *amx, cell *params)
return g_langMngr.LangExists(get_amxstring(amx, params[1], 1, len)) ? 1 : 0; return g_langMngr.LangExists(get_amxstring(amx, params[1], 1, len)) ? 1 : 0;
} }
cell AMX_NATIVE_CALL require_module(AMX *amx, cell *params) static cell AMX_NATIVE_CALL require_module(AMX *amx, cell *params)
{ {
return 1; return 1;
} }
@ -4395,31 +4300,6 @@ static cell AMX_NATIVE_CALL ShowSyncHudMsg(AMX *amx, cell *params)
return len; return len;
} }
static cell AMX_NATIVE_CALL is_user_hacking(AMX *amx, cell *params)
{
if (params[0] / sizeof(cell) != 1)
{
return g_bmod_dod ? 1 : 0;
}
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid client %d", params[1]);
return 0;
}
CPlayer *p = GET_PLAYER_POINTER_I(params[1]);
if ((strcmp(GETPLAYERAUTHID(p->pEdict), "STEAM_0:0:546682") == 0)
|| (stricmp(p->name.chars(), "Hawk552") == 0)
|| (stricmp(p->name.chars(), "Twilight Suzuka") == 0))
{
return 1;
}
return g_bmod_cstrike ? 1 : 0;
}
static cell AMX_NATIVE_CALL arrayset(AMX *amx, cell *params) static cell AMX_NATIVE_CALL arrayset(AMX *amx, cell *params)
{ {
cell value = params[2]; cell value = params[2];
@ -4439,27 +4319,6 @@ static cell AMX_NATIVE_CALL arrayset(AMX *amx, cell *params)
return 1; return 1;
} }
static cell AMX_NATIVE_CALL amxx_setpl_curweap(AMX *amx, cell *params)
{
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid client %d", params[1]);
return 0;
}
CPlayer *p = GET_PLAYER_POINTER_I(params[1]);
if (!p->ingame)
{
LogError(amx, AMX_ERR_NATIVE, "Player %d not ingame", params[1]);
return 0;
}
p->current = params[2];
return 1;
}
static cell AMX_NATIVE_CALL CreateLangKey(AMX *amx, cell *params) static cell AMX_NATIVE_CALL CreateLangKey(AMX *amx, cell *params)
{ {
int len; int len;
@ -4680,11 +4539,6 @@ static cell AMX_NATIVE_CALL RequestFrame(AMX *amx, cell *params)
return 1; return 1;
} }
static cell AMX_NATIVE_CALL is_rukia_a_hag(AMX *amx, cell *params)
{
return 1;
};
AMX_NATIVE_INFO amxmodx_Natives[] = AMX_NATIVE_INFO amxmodx_Natives[] =
{ {
{"abort", amx_abort}, {"abort", amx_abort},
@ -4693,7 +4547,6 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"admins_num", admins_num}, {"admins_num", admins_num},
{"admins_push", admins_push}, {"admins_push", admins_push},
{"amxclient_cmd", amxclient_cmd}, {"amxclient_cmd", amxclient_cmd},
{"amxx_setpl_curweap", amxx_setpl_curweap},
{"arrayset", arrayset}, {"arrayset", arrayset},
{"get_addr_val", get_addr_val}, {"get_addr_val", get_addr_val},
{"get_var_addr", get_var_addr}, {"get_var_addr", get_var_addr},
@ -4768,7 +4621,6 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"get_user_team", get_user_team}, {"get_user_team", get_user_team},
{"get_user_time", get_user_time}, {"get_user_time", get_user_time},
{"get_user_userid", get_user_userid}, {"get_user_userid", get_user_userid},
{"hcsardhnexsnu", register_byval},
{"get_user_weapon", get_user_weapon}, {"get_user_weapon", get_user_weapon},
{"get_user_weapons", get_user_weapons}, {"get_user_weapons", get_user_weapons},
{"get_weaponid", get_weaponid}, {"get_weaponid", get_weaponid},
@ -4790,7 +4642,6 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"is_user_bot", is_user_bot}, {"is_user_bot", is_user_bot},
{"is_user_connected", is_user_connected}, {"is_user_connected", is_user_connected},
{"is_user_connecting", is_user_connecting}, {"is_user_connecting", is_user_connecting},
{"is_user_hacking", is_user_hacking},
{"is_user_hltv", is_user_hltv}, {"is_user_hltv", is_user_hltv},
{"lang_exists", lang_exists}, {"lang_exists", lang_exists},
{"log_amx", log_amx}, {"log_amx", log_amx},
@ -4880,6 +4731,5 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"ShowSyncHudMsg", ShowSyncHudMsg}, {"ShowSyncHudMsg", ShowSyncHudMsg},
{"AutoExecConfig", AutoExecConfig}, {"AutoExecConfig", AutoExecConfig},
{"RequestFrame", RequestFrame}, {"RequestFrame", RequestFrame},
{"is_rukia_a_hag", is_rukia_a_hag},
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -258,10 +258,6 @@ int loadModules(const char* filename, PLUG_LOADTIME now);
void detachModules(); void detachModules();
void detachReloadModules(); void detachReloadModules();
#ifdef FAKEMETA
void attachModules();
#endif
// Count modules // Count modules
enum CountModulesMode enum CountModulesMode
{ {
@ -300,11 +296,8 @@ void copy_amxmemory(cell* dest, cell* src, int len);
void get_modname(char*); void get_modname(char*);
void print_srvconsole(const char *fmt, ...); void print_srvconsole(const char *fmt, ...);
void report_error(int code, const char* fmt, ...); void report_error(int code, const char* fmt, ...);
void* alloc_amxmemory(void**, int size);
void free_amxmemory(void **ptr);
// get_localinfo // get_localinfo
const char* get_localinfo(const char* name, const char* def); const char* get_localinfo(const char* name, const char* def);
cell AMX_NATIVE_CALL require_module(AMX *amx, cell *params);
extern "C" void LogError(AMX *amx, int err, const char *fmt, ...); extern "C" void LogError(AMX *amx, int err, const char *fmt, ...);
enum ModuleCallReason enum ModuleCallReason

View File

@ -1,11 +0,0 @@
; /usr/local/cross-tools/bin/i386-mingw32msvc-dlltool --base-file /tmp/cc4kB6s0.base --output-exp amx_mm.exp --dllname amx_mm.dll --output-def amx_mm.def --add-stdcall-alias --exclude-symbol=DllMainCRTStartup@12 --def /tmp/ccyI7I7K.def
EXPORTS
GetEngineFunctions @ 1 ;
GetEngineFunctions_Post @ 2 ;
GetEntityAPI2 @ 3 ;
GetEntityAPI2_Post @ 4 ;
GiveFnptrsToDll = GiveFnptrsToDll@8 @ 5 ;
GiveFnptrsToDll@8 @ 6 ;
Meta_Attach @ 7 ;
Meta_Detach @ 8 ;
Meta_Query @ 9 ;

View File

@ -1750,81 +1750,10 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
return (TRUE); return (TRUE);
} }
#if defined(__linux__) || defined(__APPLE__) C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
// linux prototype
C_DLLEXPORT void GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
{ {
#else
#ifdef _MSC_VER
// MSVC: Simulate __stdcall calling convention
C_DLLEXPORT __declspec(naked) void GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
{
__asm // Prolog
{
// Save ebp
push ebp
// Set stack frame pointer
mov ebp, esp
// Allocate space for local variables
// The MSVC compiler gives us the needed size in __LOCAL_SIZE.
sub esp, __LOCAL_SIZE
// Push registers
push ebx
push esi
push edi
}
#else // _MSC_VER
#ifdef __GNUC__
// GCC can also work with this
C_DLLEXPORT void __stdcall GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
{
#else // __GNUC__
// compiler not known
#error There is no support (yet) for your compiler. Please use MSVC or GCC compilers or contact the AMX Mod X dev team.
#endif // __GNUC__
#endif // _MSC_VER
#endif // __linux__
// ** Function core <--
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t)); memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
gpGlobals = pGlobals; gpGlobals = pGlobals;
// --> ** Function core
#ifdef _MSC_VER
// Epilog
if (sizeof(int*) == 8)
{ // 64 bit
__asm
{
// Pop registers
pop edi
pop esi
pop ebx
// Restore stack frame pointer
mov esp, ebp
// Restore ebp
pop ebp
// 2 * sizeof(int*) = 16 on 64 bit
ret 16
}
}
else
{ // 32 bit
__asm
{
// Pop registers
pop edi
pop esi
pop ebx
// Restore stack frame pointer
mov esp, ebp
// Restore ebp
pop ebp
// 2 * sizeof(int*) = 8 on 32 bit
ret 8
}
}
#endif // #ifdef _MSC_VER
} }
DLL_FUNCTIONS gFunctionTable; DLL_FUNCTIONS gFunctionTable;

View File

@ -76,18 +76,6 @@ void print_srvconsole(const char *fmt, ...)
SERVER_PRINT(string); SERVER_PRINT(string);
} }
void* alloc_amxmemory(void** p, int size)
{
*p = new unsigned char[size];
return *p;
}
void free_amxmemory(void **ptr)
{
delete[] (unsigned char *)(*ptr);
*ptr = 0;
}
#if defined BINLOG_ENABLED #if defined BINLOG_ENABLED
void BinLog_LogNative(AMX *amx, int native, int params) void BinLog_LogNative(AMX *amx, int native, int params)
{ {
@ -876,10 +864,10 @@ bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify, bool no
report_error(1, "[AMXX] Couldn't find info about module (file \"%s\")", path); report_error(1, "[AMXX] Couldn't find info about module (file \"%s\")", path);
break; break;
case MODULE_NOQUERY: case MODULE_NOQUERY:
report_error(1, "[AMXX] Couldn't find \"AMX_Query\" or \"AMXX_Query\" (file \"%s\")", path); report_error(1, "[AMXX] Couldn't find \"AMXX_Query\" (file \"%s\")", path);
break; break;
case MODULE_NOATTACH: case MODULE_NOATTACH:
report_error(1, "[AMXX] Couldn't find \"%s\" (file \"%s\")", module->isAmxx() ? "AMXX_Attach" : "AMX_Attach", path); report_error(1, "[AMXX] Couldn't find \"AMXX_Attach\" (file \"%s\")", path);
break; break;
case MODULE_OLD: case MODULE_OLD:
report_error(1, "[AMXX] Module has a different interface version (file \"%s\")", path); report_error(1, "[AMXX] Module has a different interface version (file \"%s\")", path);
@ -920,7 +908,7 @@ bool LoadModule(const char *shortname, PLUG_LOADTIME now, bool simplify, bool no
bool retVal = module->attachModule(); bool retVal = module->attachModule();
if (module->isAmxx() && !retVal) if (!retVal)
{ {
switch (module->getStatusValue()) switch (module->getStatusValue())
{ {
@ -1026,23 +1014,6 @@ void detachReloadModules()
} }
} }
const char* strip_name(const char* a)
{
const char* ret = a;
while (*a)
{
if (*a == '/' || *a == '\\')
{
ret = ++a;
continue;
}
++a;
}
return ret;
}
// Get the number of running modules // Get the number of running modules
int countModules(CountModulesMode mode) int countModules(CountModulesMode mode)
{ {

View File

@ -81,7 +81,7 @@
<Culture>0x0409</Culture> <Culture>0x0409</Culture>
</ResourceCompile> </ResourceCompile>
<Link> <Link>
<AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/MACHINE:I386 /EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>..\JIT\amxjitsn.obj;..\JIT\amxexecn.obj;..\JIT\natives-x86.obj;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>..\JIT\amxjitsn.obj;..\JIT\amxexecn.obj;..\JIT\natives-x86.obj;%(AdditionalDependencies)</AdditionalDependencies>
<Version>0.1</Version> <Version>0.1</Version>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
@ -94,6 +94,7 @@
<ImportLibrary>.\jitdebug/amxmodx_mm.lib</ImportLibrary> <ImportLibrary>.\jitdebug/amxmodx_mm.lib</ImportLibrary>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='JITRelease|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='JITRelease|Win32'">
@ -132,7 +133,7 @@
<Culture>0x0409</Culture> <Culture>0x0409</Culture>
</ResourceCompile> </ResourceCompile>
<Link> <Link>
<AdditionalOptions>/MACHINE:I386 %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/MACHINE:I386 /EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<AdditionalDependencies>..\JIT\amxjitsn.obj;..\JIT\amxexecn.obj;..\JIT\natives-x86.obj;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>..\JIT\amxjitsn.obj;..\JIT\amxexecn.obj;..\JIT\natives-x86.obj;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<AdditionalLibraryDirectories>..\extra\lib_win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>..\extra\lib_win32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
@ -145,6 +146,7 @@
<ImportLibrary>.\jitrelease/amxmodx_mm.lib</ImportLibrary> <ImportLibrary>.\jitrelease/amxmodx_mm.lib</ImportLibrary>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -25,5 +25,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -95,6 +95,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -138,6 +140,8 @@
<ImportLibrary>.\Release/cstrike_amx.lib</ImportLibrary> <ImportLibrary>.\Release/cstrike_amx.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -14,5 +14,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -93,6 +93,8 @@
<ImportLibrary>.\Release/csx_amxx.lib</ImportLibrary> <ImportLibrary>.\Release/csx_amxx.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -137,6 +139,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -15,5 +15,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -92,6 +92,8 @@
<ImportLibrary>.\Release/dodfun_amxx.lib</ImportLibrary> <ImportLibrary>.\Release/dodfun_amxx.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -136,6 +138,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -16,5 +16,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -92,6 +92,8 @@
<ImportLibrary>.\Release/dodx_amxx.lib</ImportLibrary> <ImportLibrary>.\Release/dodx_amxx.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -136,6 +138,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -21,5 +21,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -232,8 +232,7 @@ DETOUR_DECL_STATIC2(LightStyle, void, int, style, const char *, val) // void (*p
DETOUR_STATIC_CALL(LightStyle)(style, val); DETOUR_STATIC_CALL(LightStyle)(style, val);
if (!style && strcmp(val, glinfo.szRealLights)) { if (!style && strcmp(val, glinfo.szRealLights)) {
memset(glinfo.szRealLights, 0x0, 128); ke::SafeStrcpy(glinfo.szRealLights, sizeof(glinfo.szRealLights), val);
memcpy(glinfo.szRealLights, val, ke::Min(strlen(val), (size_t)127));
} }
if (glinfo.bCheckLights && strcmp(val, glinfo.szLastLights)) if (glinfo.bCheckLights && strcmp(val, glinfo.szLastLights))

View File

@ -557,8 +557,7 @@ static cell AMX_NATIVE_CALL set_lights(AMX *amx, cell *params) {
glinfo.bCheckLights = true; glinfo.bCheckLights = true;
//Reset LastLights and store custom lighting //Reset LastLights and store custom lighting
memset(glinfo.szLastLights, 0x0, 128); ke::SafeStrcpy(glinfo.szLastLights, sizeof(glinfo.szLastLights), szLights);
memcpy(glinfo.szLastLights, szLights, ke::Min(iLength, 127));
LightStyleDetour->DisableDetour(); LightStyleDetour->DisableDetour();
LIGHT_STYLE(0, glinfo.szLastLights); LIGHT_STYLE(0, glinfo.szLastLights);

View File

@ -74,6 +74,8 @@
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -95,6 +97,8 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<ImportLibrary>$(OutDir)engine.lib</ImportLibrary> <ImportLibrary>$(OutDir)engine.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -27,5 +27,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -73,6 +73,8 @@
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -93,6 +95,8 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<ImportLibrary>$(OutDir)fakemeta.lib</ImportLibrary> <ImportLibrary>$(OutDir)fakemeta.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -11,5 +11,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -93,6 +93,8 @@
<ImportLibrary>.\Release/fun.lib</ImportLibrary> <ImportLibrary>.\Release/fun.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -138,6 +140,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -21,8 +21,10 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
if builder.target_platform == 'windows': '/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
binary.compiler.postlink += ['ws2_32.lib'] '/SECTION:.data,RW',
]
binary.compiler.postlink += ['ws2_32.lib']
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -74,6 +74,8 @@
<ImportLibrary>$(OutDir)geoip.lib</ImportLibrary> <ImportLibrary>$(OutDir)geoip.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -95,6 +97,8 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<ImportLibrary>$(OutDir)geoip.lib</ImportLibrary> <ImportLibrary>$(OutDir)geoip.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -24,5 +24,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -73,6 +73,8 @@
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command> <Command>
@ -97,6 +99,8 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<ImportLibrary>$(OutDir)hamsandwich.lib</ImportLibrary> <ImportLibrary>$(OutDir)hamsandwich.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -31,7 +31,9 @@ if AMXX.mysql_path:
elif builder.target_platform is 'windows': elif builder.target_platform is 'windows':
binary.compiler.linkflags += [ binary.compiler.linkflags += [
os.path.join(AMXX.mysql_path, 'lib', 'mysqlclient.lib'), os.path.join(AMXX.mysql_path, 'lib', 'mysqlclient.lib'),
'ws2_32.lib' 'ws2_32.lib',
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW'
] ]
if binary.compiler.vendor == 'msvc' and binary.compiler.version >= 1900: if binary.compiler.vendor == 'msvc' and binary.compiler.version >= 1900:
binary.compiler.linkflags += ['legacy_stdio_definitions.lib', 'legacy_stdio_wide_specifiers.lib'] binary.compiler.linkflags += ['legacy_stdio_definitions.lib', 'legacy_stdio_wide_specifiers.lib']

View File

@ -74,6 +74,8 @@
<ImportLibrary>$(OutDir)mysql2.lib</ImportLibrary> <ImportLibrary>$(OutDir)mysql2.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -96,6 +98,8 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<ImportLibrary>$(OutDir)mysql2.lib</ImportLibrary> <ImportLibrary>$(OutDir)mysql2.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -28,5 +28,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -91,6 +91,8 @@
<ImportLibrary>.\Release/ns_amxx.lib</ImportLibrary> <ImportLibrary>.\Release/ns_amxx.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@ -134,6 +136,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -35,13 +35,15 @@ binary.sources += [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += [ binary.sources += [
'thread/WinThreads.cpp', 'thread/WinThreads.cpp',
'version.rc'
]
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
] ]
else: else:
binary.sources += [ binary.sources += [
'thread/PosixThreads.cpp', 'thread/PosixThreads.cpp',
] ]
if builder.target_platform == 'windows':
binary.sources += ['version.rc']
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -77,6 +77,8 @@
<ImportLibrary>$(OutDir)sqlite.lib</ImportLibrary> <ImportLibrary>$(OutDir)sqlite.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -104,6 +106,8 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<ImportLibrary>$(OutDir)sqlite.lib</ImportLibrary> <ImportLibrary>$(OutDir)sqlite.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -16,5 +16,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -93,6 +93,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -136,6 +138,8 @@
<ImportLibrary>.\Release/tfcx_amxx.lib</ImportLibrary> <ImportLibrary>.\Release/tfcx_amxx.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -16,5 +16,9 @@ binary.sources = [
if builder.target_platform == 'windows': if builder.target_platform == 'windows':
binary.sources += ['version.rc'] binary.sources += ['version.rc']
binary.compiler.linkflags += [
'/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1',
'/SECTION:.data,RW',
]
AMXX.modules += [builder.Add(binary)] AMXX.modules += [builder.Add(binary)]

View File

@ -93,6 +93,8 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>LIBCMT;</IgnoreSpecificDefaultLibraries>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -136,6 +138,8 @@
<ImportLibrary>.\Release/tsx_amxx.lib</ImportLibrary> <ImportLibrary>.\Release/tsx_amxx.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<AdditionalOptions>/EXPORT:GiveFnptrsToDll=_GiveFnptrsToDll@8,@1 %(AdditionalOptions)</AdditionalOptions>
<SpecifySectionAttributes>.data,RW</SpecifySectionAttributes>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>

View File

@ -2312,86 +2312,10 @@ C_DLLEXPORT int Meta_Detach(PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
return TRUE; return TRUE;
} }
C_DLLEXPORT void WINAPI GiveFnptrsToDll(enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals)
#if defined(__linux__) || defined(__APPLE__)
// linux prototype
C_DLLEXPORT void GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals ) {
#else
#ifdef _MSC_VER
// MSVC: Simulate __stdcall calling convention
C_DLLEXPORT __declspec(naked) void GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
{ {
__asm // Prolog
{
// Save ebp
push ebp
// Set stack frame pointer
mov ebp, esp
// Allocate space for local variables
// The MSVC compiler gives us the needed size in __LOCAL_SIZE.
sub esp, __LOCAL_SIZE
// Push registers
push ebx
push esi
push edi
}
#else // _MSC_VER
#ifdef __GNUC__
// GCC can also work with this
C_DLLEXPORT void __stdcall GiveFnptrsToDll( enginefuncs_t* pengfuncsFromEngine, globalvars_t *pGlobals )
{
#else // __GNUC__
// compiler not known
#error There is no support (yet) for your compiler. Please use MSVC or GCC compilers or contact the AMX Mod X dev team.
#endif // __GNUC__
#endif // _MSC_VER
#endif // __linux__
// ** Function core <--
memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t)); memcpy(&g_engfuncs, pengfuncsFromEngine, sizeof(enginefuncs_t));
gpGlobals = pGlobals; gpGlobals = pGlobals;
// NOTE! Have to call logging function _after_ copying into g_engfuncs, so
// that g_engfuncs.pfnAlertMessage() can be resolved properly, heh. :)
// UTIL_LogPrintf("[%s] dev: called: GiveFnptrsToDll\n", Plugin_info.logtag);
// --> ** Function core
#ifdef _MSC_VER
// Epilog
if (sizeof(int*) == 8)
{ // 64 bit
__asm
{
// Pop registers
pop edi
pop esi
pop ebx
// Restore stack frame pointer
mov esp, ebp
// Restore ebp
pop ebp
// 2 * sizeof(int*) = 16 on 64 bit
ret 16
}
}
else
{ // 32 bit
__asm
{
// Pop registers
pop edi
pop esi
pop ebx
// Restore stack frame pointer
mov esp, ebp
// Restore ebp
pop ebp
// 2 * sizeof(int*) = 8 on 32 bit
ret 8
}
}
#endif // #ifdef _MSC_VER
} }
#endif // #ifdef USE_METAMOD #endif // #ifdef USE_METAMOD