From 89f7c4553afb4759a50df6e7070b1eb6179948dc Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Thu, 23 Nov 2023 23:34:47 +0800 Subject: [PATCH] [server] Update CPlugins constructor --- server/plugincommon.h | 62 +++++++++++++++++++++++++++++++++++++++++ server/plugininternal.h | 8 ++++++ server/plugins.cpp | 55 ++++++++++++++++++++++++++++++++++++ server/plugins.h | 7 +++++ server/server.vcproj | 6 ++++ 5 files changed, 138 insertions(+) create mode 100644 server/plugincommon.h create mode 100644 server/plugininternal.h diff --git a/server/plugincommon.h b/server/plugincommon.h new file mode 100644 index 0000000..bd787e9 --- /dev/null +++ b/server/plugincommon.h @@ -0,0 +1,62 @@ + +#ifndef _PLUGINCOMMON_H_INCLUDED +#define _PLUGINCOMMON_H_INCLUDED + +enum PLUGIN_DATA_TYPE +{ + // For some debugging + PLUGIN_DATA_LOGPRINTF = 0x00, // void (*logprintf)(char* format, ...) + + // AMX + PLUGIN_DATA_AMX_EXPORTS = 0x10, // void* AmxFunctionTable[] (see PLUGIN_AMX_EXPORT) +}; + +enum PLUGIN_AMX_EXPORT +{ + PLUGIN_AMX_EXPORT_Align16 = 0, + PLUGIN_AMX_EXPORT_Align32 = 1, + PLUGIN_AMX_EXPORT_Align64 = 2, + PLUGIN_AMX_EXPORT_Allot = 3, + PLUGIN_AMX_EXPORT_Callback = 4, + PLUGIN_AMX_EXPORT_Cleanup = 5, + PLUGIN_AMX_EXPORT_Clone = 6, + PLUGIN_AMX_EXPORT_Exec = 7, + PLUGIN_AMX_EXPORT_FindNative = 8, + PLUGIN_AMX_EXPORT_FindPublic = 9, + PLUGIN_AMX_EXPORT_FindPubVar = 10, + PLUGIN_AMX_EXPORT_FindTagId = 11, + PLUGIN_AMX_EXPORT_Flags = 12, + PLUGIN_AMX_EXPORT_GetAddr = 13, + PLUGIN_AMX_EXPORT_GetNative = 14, + PLUGIN_AMX_EXPORT_GetPublic = 15, + PLUGIN_AMX_EXPORT_GetPubVar = 16, + PLUGIN_AMX_EXPORT_GetString = 17, + PLUGIN_AMX_EXPORT_GetTag = 18, + PLUGIN_AMX_EXPORT_GetUserData = 19, + PLUGIN_AMX_EXPORT_Init = 20, + PLUGIN_AMX_EXPORT_InitJIT = 21, + PLUGIN_AMX_EXPORT_MemInfo = 22, + PLUGIN_AMX_EXPORT_NameLength = 23, + PLUGIN_AMX_EXPORT_NativeInfo = 24, + PLUGIN_AMX_EXPORT_NumNatives = 25, + PLUGIN_AMX_EXPORT_NumPublics = 26, + PLUGIN_AMX_EXPORT_NumPubVars = 27, + PLUGIN_AMX_EXPORT_NumTags = 28, + PLUGIN_AMX_EXPORT_Push = 29, + PLUGIN_AMX_EXPORT_PushArray = 30, + PLUGIN_AMX_EXPORT_PushString = 31, + PLUGIN_AMX_EXPORT_RaiseError = 32, + PLUGIN_AMX_EXPORT_Register = 33, + PLUGIN_AMX_EXPORT_Release = 34, + PLUGIN_AMX_EXPORT_SetCallback = 35, + PLUGIN_AMX_EXPORT_SetDebugHook = 36, + PLUGIN_AMX_EXPORT_SetString = 37, + PLUGIN_AMX_EXPORT_SetUserData = 38, + PLUGIN_AMX_EXPORT_StrLen = 39, + PLUGIN_AMX_EXPORT_UTF8Check = 40, + PLUGIN_AMX_EXPORT_UTF8Get = 41, + PLUGIN_AMX_EXPORT_UTF8Len = 42, + PLUGIN_AMX_EXPORT_UTF8Put = 43, +}; + +#endif // _PLUGINCOMMON_H_INCLUDED diff --git a/server/plugininternal.h b/server/plugininternal.h new file mode 100644 index 0000000..7afb0fe --- /dev/null +++ b/server/plugininternal.h @@ -0,0 +1,8 @@ + +#ifndef _PLUGININTERNAL_H_INCLUDED +#define _PLUGININTERNAL_H_INCLUDED + +#define MAX_PLUGIN_DATA 256 +#define MAX_PLUGIN_AMX_EXPORT 44 + +#endif diff --git a/server/plugins.cpp b/server/plugins.cpp index 73cd7dc..0cb33f9 100644 --- a/server/plugins.cpp +++ b/server/plugins.cpp @@ -3,6 +3,61 @@ CPlugins::CPlugins() { + // Set up the table of AMX functions to be exported +#if defined AMX_ALIGN || defined AMX_INIT + m_AMXExports[PLUGIN_AMX_EXPORT_Align16] = (void*)&amx_Align16; + m_AMXExports[PLUGIN_AMX_EXPORT_Align32] = (void*)&amx_Align32; +#if defined _I64_MAX || defined HAVE_I64 + m_AMXExports[PLUGIN_AMX_EXPORT_Align64] = (void*)&amx_Align64; +#endif +#endif + m_AMXExports[PLUGIN_AMX_EXPORT_Allot] = (void*)&amx_Allot; + m_AMXExports[PLUGIN_AMX_EXPORT_Callback] = (void*)&amx_Callback; + m_AMXExports[PLUGIN_AMX_EXPORT_Cleanup] = (void*)&amx_Cleanup; + m_AMXExports[PLUGIN_AMX_EXPORT_Clone] = (void*)&amx_Clone; + m_AMXExports[PLUGIN_AMX_EXPORT_Exec] = (void*)&amx_Exec; + m_AMXExports[PLUGIN_AMX_EXPORT_FindNative] = (void*)&amx_FindNative; + m_AMXExports[PLUGIN_AMX_EXPORT_FindPublic] = (void*)&amx_FindPublic; + m_AMXExports[PLUGIN_AMX_EXPORT_FindPubVar] = (void*)&amx_FindPubVar; + m_AMXExports[PLUGIN_AMX_EXPORT_FindTagId] = (void*)&amx_FindTagId; + m_AMXExports[PLUGIN_AMX_EXPORT_Flags] = (void*)&amx_Flags; + m_AMXExports[PLUGIN_AMX_EXPORT_GetAddr] = (void*)&amx_GetAddr; + m_AMXExports[PLUGIN_AMX_EXPORT_GetNative] = (void*)&amx_GetNative; + m_AMXExports[PLUGIN_AMX_EXPORT_GetPublic] = (void*)&amx_GetPublic; + m_AMXExports[PLUGIN_AMX_EXPORT_GetPubVar] = (void*)&amx_GetPubVar; + m_AMXExports[PLUGIN_AMX_EXPORT_GetString] = (void*)&amx_GetString; + m_AMXExports[PLUGIN_AMX_EXPORT_GetTag] = (void*)&amx_GetTag; + m_AMXExports[PLUGIN_AMX_EXPORT_GetUserData] = (void*)&amx_GetUserData; + m_AMXExports[PLUGIN_AMX_EXPORT_Init] = (void*)&amx_Init; + m_AMXExports[PLUGIN_AMX_EXPORT_InitJIT] = (void*)&amx_InitJIT; + m_AMXExports[PLUGIN_AMX_EXPORT_MemInfo] = (void*)&amx_MemInfo; + m_AMXExports[PLUGIN_AMX_EXPORT_NameLength] = (void*)&amx_NameLength; + m_AMXExports[PLUGIN_AMX_EXPORT_NativeInfo] = (void*)&amx_NativeInfo; + m_AMXExports[PLUGIN_AMX_EXPORT_NumNatives] = (void*)&amx_NumNatives; + m_AMXExports[PLUGIN_AMX_EXPORT_NumPublics] = (void*)&amx_NumPublics; + m_AMXExports[PLUGIN_AMX_EXPORT_NumPubVars] = (void*)&amx_NumPubVars; + m_AMXExports[PLUGIN_AMX_EXPORT_NumTags] = (void*)&amx_NumTags; + m_AMXExports[PLUGIN_AMX_EXPORT_Push] = (void*)&amx_Push; + m_AMXExports[PLUGIN_AMX_EXPORT_PushArray] = (void*)&amx_PushArray; + m_AMXExports[PLUGIN_AMX_EXPORT_PushString] = (void*)&amx_PushString; + m_AMXExports[PLUGIN_AMX_EXPORT_RaiseError] = (void*)&amx_RaiseError; + m_AMXExports[PLUGIN_AMX_EXPORT_Register] = (void*)&amx_Register; + m_AMXExports[PLUGIN_AMX_EXPORT_Release] = (void*)&amx_Release; + m_AMXExports[PLUGIN_AMX_EXPORT_SetCallback] = (void*)&amx_SetCallback; + m_AMXExports[PLUGIN_AMX_EXPORT_SetDebugHook] = (void*)&amx_SetDebugHook; + m_AMXExports[PLUGIN_AMX_EXPORT_SetString] = (void*)&amx_SetString; + m_AMXExports[PLUGIN_AMX_EXPORT_SetUserData] = (void*)&amx_SetUserData; + m_AMXExports[PLUGIN_AMX_EXPORT_StrLen] = (void*)&amx_StrLen; + //m_AMXExports[PLUGIN_AMX_EXPORT_UTF8Check] = (void*)&amx_UTF8Check; + //m_AMXExports[PLUGIN_AMX_EXPORT_UTF8Get] = (void*)&amx_UTF8Get; + //m_AMXExports[PLUGIN_AMX_EXPORT_UTF8Len] = (void*)&amx_UTF8Len; + //m_AMXExports[PLUGIN_AMX_EXPORT_UTF8Put] = (void*)&amx_UTF8Put; + + // Set up table of Plugin exports + m_PluginData[PLUGIN_DATA_LOGPRINTF] = (void*)&logprintf; + + m_PluginData[PLUGIN_DATA_AMX_EXPORTS] = m_AMXExports; + // TODO: CPlugins::CPlugins W: 0046A1D0 L: constructor } diff --git a/server/plugins.h b/server/plugins.h index d2e5290..b7e8ce1 100644 --- a/server/plugins.h +++ b/server/plugins.h @@ -2,9 +2,16 @@ #ifndef _PLUGINS_H_INCLUDED #define _PLUGINS_H_INCLUDED +#include "plugincommon.h" +#include "plugininternal.h" + class CPlugins // size: W: 1216 L: 1212 { private: + + void* m_PluginData[MAX_PLUGIN_DATA]; + void* m_AMXExports[MAX_PLUGIN_AMX_EXPORT]; + public: CPlugins(); ~CPlugins(); diff --git a/server/server.vcproj b/server/server.vcproj index c4a12f3..0a023cf 100644 --- a/server/server.vcproj +++ b/server/server.vcproj @@ -238,6 +238,12 @@ + + + +