├── amx ├── getch.h ├── amx2.h ├── sclinux.h ├── getch.c └── amx.h ├── amxplugin2.cpp ├── plugincommon.h └── amxplugin.cpp /amx/getch.h: -------------------------------------------------------------------------------- 1 | /* Extremely inefficient but portable POSIX getch(), see getch.c */ 2 | #ifndef GETCH_H 3 | #define GETCH_H 4 | 5 | #if defined __cplusplus 6 | extern "C" { 7 | #endif 8 | int getch(void); 9 | int kbhit(void); 10 | 11 | #if defined __cplusplus 12 | } 13 | #endif 14 | 15 | #endif /* GETCH_H */ 16 | -------------------------------------------------------------------------------- /amx/amx2.h: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------- 2 | // 3 | // SA-MP Multiplayer Modification For GTA:SA 4 | // Copyright 2014 SA-MP Team, Dan, maddinat0r 5 | // 6 | //---------------------------------------------------------- 7 | 8 | #pragma once 9 | 10 | //---------------------------------------------------------- 11 | 12 | #if defined __cplusplus 13 | #include 14 | #endif 15 | 16 | //---------------------------------------------------------- 17 | 18 | #include "amx.h" 19 | 20 | //---------------------------------------------------------- 21 | 22 | #define USENAMETABLE(hdr) \ 23 | ((hdr)->defsize==sizeof(AMX_FUNCSTUBNT)) 24 | 25 | #define NUMENTRIES(hdr,field,nextfield) \ 26 | (unsigned)(((hdr)->nextfield - (hdr)->field) / (hdr)->defsize) 27 | 28 | #define GETENTRY(hdr,table,index) \ 29 | (AMX_FUNCSTUB *)((unsigned char*)(hdr) + (unsigned)(hdr)->table + (unsigned)index*(hdr)->defsize) 30 | 31 | #define GETENTRYNAME(hdr,entry) \ 32 | (USENAMETABLE(hdr) ? \ 33 | (char *)((unsigned char*)(hdr) + (unsigned)((AMX_FUNCSTUBNT*)(entry))->nameofs) : \ 34 | ((AMX_FUNCSTUB*)(entry))->name) 35 | 36 | //---------------------------------------------------------- 37 | 38 | extern int AMXAPI amx_PushAddress(AMX *amx, cell *address); 39 | extern void AMXAPI amx_Redirect(AMX *amx, char *from, ucell to, AMX_NATIVE *store); 40 | extern int AMXAPI amx_GetCString(AMX *amx, cell param, char *&dest); 41 | extern int AMXAPI amx_SetCString(AMX *amx, cell param, const char *str, int len); 42 | 43 | #if defined __cplusplus 44 | extern std::string AMXAPI amx_GetCppString(AMX *amx, cell param); 45 | extern int AMXAPI amx_SetCppString(AMX *amx, cell param, const std::string &str, size_t maxlen); 46 | #endif 47 | 48 | //---------------------------------------------------------- 49 | // EOF 50 | -------------------------------------------------------------------------------- /amx/sclinux.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Things needed to compile under linux. 3 | * 4 | * Should be reworked totally to use GNU's 'configure' 5 | */ 6 | #ifndef SCLINUX_H 7 | #define SCLINUX_H 8 | 9 | /* getchar() is not a 'cool' replacement for MSDOS getch: Linux/unix depends on the features activated or not about the 10 | * controlling terminal's tty. This means that ioctl(2) calls must be performed, for instance to have the controlling 11 | * terminal tty's in 'raw' mode, if we want to be able to fetch a single character. This also means that everything must 12 | * be put back correctly when the function ends. See GETCH.C for an implementation. 13 | * 14 | * For interactive use of SRUN/SDBG if would be much better to use GNU's readline package: the user would be able to 15 | * have a complete emacs/vi like line editing system. 16 | */ 17 | #include "getch.h" 18 | 19 | #define stricmp(a,b) strcasecmp(a,b) 20 | #define strnicmp(a,b,c) strncasecmp(a,b,c) 21 | 22 | /* 23 | * WinWorld wants '\'. Unices do not. 24 | */ 25 | #define DIRECTORY_SEP_CHAR '/' 26 | #define DIRECTORY_SEP_STR "/" 27 | 28 | /* 29 | * SC assumes that a computer is Little Endian unless told otherwise. It uses 30 | * (and defines) the macros BYTE_ORDER and BIG_ENDIAN. 31 | * For Linux, we must overrule these settings with those defined in glibc. 32 | */ 33 | #if !defined __BYTE_ORDER 34 | # include 35 | #endif 36 | 37 | #if defined __APPLE__ 38 | # include 39 | #endif 40 | 41 | #if defined __OpenBSD__ || defined __FreeBSD__ || defined __APPLE__ 42 | # define __BYTE_ORDER BYTE_ORDER 43 | # define __LITTLE_ENDIAN LITTLE_ENDIAN 44 | # define __BIG_ENDIAN BIG_ENDIAN 45 | #endif 46 | 47 | #if !defined __BYTE_ORDER 48 | # error "Can't figure computer byte order (__BYTE_ORDER macro not found)" 49 | #endif 50 | 51 | #endif /* SCLINUX_H */ 52 | -------------------------------------------------------------------------------- /amx/getch.c: -------------------------------------------------------------------------------- 1 | /* Extremely inefficient but portable POSIX getch() */ 2 | #ifndef WIN32 3 | 4 | #include 5 | #include 6 | #include /* for tcgetattr() and tcsetattr() */ 7 | #include /* for read() */ 8 | #include 9 | #include 10 | #include 11 | #include "getch.h" 12 | 13 | #ifndef STDIN_FILENO 14 | # define STDIN_FILENO 0 15 | #endif 16 | 17 | int 18 | getch (void) 19 | { 20 | struct termios save_termios; 21 | struct termios ios; 22 | int c = 0; 23 | 24 | if (!isatty (STDIN_FILENO)) 25 | return EOF; 26 | 27 | if (tcgetattr (STDIN_FILENO, &save_termios) < 0) 28 | return EOF; 29 | 30 | ios = save_termios; 31 | ios.c_lflag &= ~(ICANON | ECHO | ISIG); 32 | ios.c_cc[VMIN] = 1; /* read() will return with one char */ 33 | ios.c_cc[VTIME] = 0; /* read() blocks forever */ 34 | 35 | if (tcsetattr (STDIN_FILENO, TCSANOW, &ios) < 0) 36 | return EOF; 37 | 38 | if (read (STDIN_FILENO, &c, 1) != 1) 39 | c = EOF; 40 | 41 | tcsetattr (STDIN_FILENO, TCSANOW, &save_termios); 42 | 43 | return c; 44 | } 45 | 46 | int 47 | kbhit (void) 48 | { 49 | struct termios save_termios; 50 | struct termios ios; 51 | fd_set inp; 52 | struct timeval timeout = {0, 0}; 53 | int result; 54 | 55 | if (!isatty (STDIN_FILENO)) 56 | return 0; 57 | 58 | if (tcgetattr (STDIN_FILENO, &save_termios) < 0) 59 | return 0; 60 | 61 | ios = save_termios; 62 | ios.c_lflag &= ~(ICANON | ECHO | ISIG); 63 | ios.c_cc[VMIN] = 1; /* read() will return with one char */ 64 | ios.c_cc[VTIME] = 0; /* read() blocks forever */ 65 | 66 | if (tcsetattr (STDIN_FILENO, TCSANOW, &ios) < 0) 67 | return 0; 68 | 69 | /* set up select() args */ 70 | FD_ZERO(&inp); 71 | FD_SET(STDIN_FILENO, &inp); 72 | 73 | result = select (STDIN_FILENO+1, &inp, NULL, NULL, &timeout) == 1; 74 | 75 | tcsetattr (STDIN_FILENO, TCSANOW, &save_termios); 76 | 77 | return result; 78 | } 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /amxplugin2.cpp: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------- 2 | // 3 | // SA-MP Multiplayer Modification For GTA:SA 4 | // Copyright 2014 SA-MP Team, Dan, maddinat0r 5 | // 6 | //---------------------------------------------------------- 7 | 8 | #include 9 | #include 10 | 11 | //---------------------------------------------------------- 12 | 13 | #include 14 | 15 | //---------------------------------------------------------- 16 | 17 | #include "amx/amx2.h" 18 | 19 | //---------------------------------------------------------- 20 | 21 | int AMXAPI amx_PushAddress(AMX *amx, cell *address) 22 | { 23 | AMX_HEADER *hdr; 24 | unsigned char *data; 25 | cell xaddr; 26 | /* reverse relocate the address */ 27 | assert(amx != NULL); 28 | hdr = (AMX_HEADER *) amx->base; 29 | assert(hdr != NULL); 30 | assert(hdr->magic == AMX_MAGIC); 31 | data = (amx->data != NULL) ? amx->data : amx->base + (int) hdr->dat; 32 | xaddr = (cell) ((unsigned char*) address-data); 33 | if ((ucell) xaddr >= (ucell) amx->stp) 34 | { 35 | return AMX_ERR_MEMACCESS; 36 | } 37 | return amx_Push(amx,xaddr); 38 | } 39 | 40 | void AMXAPI amx_Redirect(AMX *amx, char *from, ucell to, AMX_NATIVE *store) 41 | { 42 | AMX_HEADER *hdr = (AMX_HEADER*) amx->base; 43 | AMX_FUNCSTUB *func; 44 | for (int idx = 0, num = NUMENTRIES(hdr, natives, libraries); idx != num; ++idx) 45 | { 46 | func = GETENTRY(hdr, natives, idx); 47 | if (!strcmp(from, GETENTRYNAME(hdr, func))) 48 | { 49 | if (store) 50 | { 51 | *store = (AMX_NATIVE) func->address; 52 | } 53 | func->address = to; 54 | return; 55 | } 56 | } 57 | } 58 | 59 | int AMXAPI amx_GetCString(AMX *amx, cell param, char *&dest) 60 | { 61 | cell *ptr; 62 | amx_GetAddr(amx, param, &ptr); 63 | int len; 64 | amx_StrLen(ptr, &len); 65 | dest = (char*) malloc((len + 1) * sizeof(char)); 66 | if (dest != NULL) 67 | { 68 | amx_GetString(dest, ptr, 0, UNLIMITED); 69 | dest[len] = 0; 70 | return len; 71 | } 72 | return 0; 73 | } 74 | 75 | int AMXAPI amx_SetCString(AMX *amx, cell param, const char *str, int len) 76 | { 77 | cell *dest; 78 | int error; 79 | if ((error = amx_GetAddr(amx, param, &dest)) != AMX_ERR_NONE) 80 | return error; 81 | 82 | return amx_SetString(dest, str, 0, 0, len); 83 | } 84 | 85 | #if defined __cplusplus 86 | 87 | std::string AMXAPI amx_GetCppString(AMX *amx, cell param) 88 | { 89 | cell *addr = nullptr; 90 | amx_GetAddr(amx, param, &addr); 91 | 92 | int len = 0; 93 | amx_StrLen(addr, &len); 94 | 95 | std::string string(len, ' '); 96 | amx_GetString(&string[0], addr, 0, len + 1); 97 | 98 | return string; 99 | } 100 | 101 | int AMXAPI amx_SetCppString(AMX *amx, cell param, const std::string &str, size_t maxlen) 102 | { 103 | cell *dest = nullptr; 104 | int error; 105 | if ((error = amx_GetAddr(amx, param, &dest)) != AMX_ERR_NONE) 106 | return error; 107 | 108 | return amx_SetString(dest, str.c_str(), 0, 0, maxlen); 109 | } 110 | 111 | #endif // __cplusplus 112 | 113 | //---------------------------------------------------------- 114 | // EOF 115 | -------------------------------------------------------------------------------- /plugincommon.h: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------- 2 | // 3 | // SA-MP Multiplayer Modification For GTA:SA 4 | // Copyright 2004-2009 SA-MP Team 5 | // 6 | //---------------------------------------------------------- 7 | 8 | #pragma once 9 | 10 | //---------------------------------------------------------- 11 | 12 | #define SAMP_PLUGIN_VERSION 0x0200 13 | 14 | //---------------------------------------------------------- 15 | 16 | #ifdef __cplusplus 17 | #define PLUGIN_EXTERN_C extern "C" 18 | #else 19 | #define PLUGIN_EXTERN_C 20 | #endif 21 | 22 | #if defined(LINUX) || defined(FREEBSD) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) 23 | #ifndef __GNUC__ 24 | #pragma message "Warning: Not using a GNU compiler." 25 | #endif 26 | #define PLUGIN_CALL 27 | #ifndef SAMPSVR 28 | // Compile code with -fvisibility=hidden to hide non-exported functions. 29 | #define PLUGIN_EXPORT PLUGIN_EXTERN_C __attribute__((visibility("default"))) 30 | #else 31 | #define PLUGIN_EXPORT PLUGIN_EXTERN_C 32 | #endif 33 | #elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__) 34 | #ifndef _MSC_VER 35 | #pragma message "Warning: Not using a VC++ compiler." 36 | #endif 37 | #define PLUGIN_CALL __stdcall 38 | #define PLUGIN_EXPORT PLUGIN_EXTERN_C 39 | #else 40 | #error "You must define one of WIN32, LINUX or FREEBSD" 41 | #endif 42 | 43 | //---------------------------------------------------------- 44 | 45 | enum SUPPORTS_FLAGS 46 | { 47 | SUPPORTS_VERSION = SAMP_PLUGIN_VERSION, 48 | SUPPORTS_VERSION_MASK = 0xffff, 49 | SUPPORTS_AMX_NATIVES = 0x10000, 50 | SUPPORTS_PROCESS_TICK = 0x20000 51 | }; 52 | 53 | //---------------------------------------------------------- 54 | 55 | enum PLUGIN_DATA_TYPE 56 | { 57 | // For some debugging 58 | PLUGIN_DATA_LOGPRINTF = 0x00, // void (*logprintf)(char* format, ...) 59 | PLUGIN_DATA_NETGAME = 0xE1, // CNetGame* GetNetGame(); 60 | PLUGIN_DATA_RAKSERVER = 0xE2, // RakServerInterface* PluginGetRakServer() 61 | PLUGIN_DATA_LOADFSCRIPT = 0xE3, // bool LoadFilterscriptFromMemory(char* pFileName, char* pFileData) 62 | PLUGIN_DATA_UNLOADFSCRIPT = 0xE5, // bool UnloadFilterScript(char* pFileName) 63 | PLUGIN_DATA_CONSOLE = 0xE4, // CConsole* GetConsole(); 64 | 65 | // AMX 66 | PLUGIN_DATA_AMX_EXPORTS = 0x10, // void* AmxFunctionTable[] (see PLUGIN_AMX_EXPORT) 67 | PLUGIN_DATA_CALLPUBLIC_FS = 0x11, // int (*AmxCallPublicFilterScript)(char *szFunctionName) 68 | PLUGIN_DATA_CALLPUBLIC_GM = 0x12, // int (*AmxCallPublicGameMode)(char *szFunctionName) 69 | 70 | }; 71 | 72 | //---------------------------------------------------------- 73 | 74 | enum PLUGIN_AMX_EXPORT 75 | { 76 | PLUGIN_AMX_EXPORT_Align16 = 0, 77 | PLUGIN_AMX_EXPORT_Align32 = 1, 78 | PLUGIN_AMX_EXPORT_Align64 = 2, 79 | PLUGIN_AMX_EXPORT_Allot = 3, 80 | PLUGIN_AMX_EXPORT_Callback = 4, 81 | PLUGIN_AMX_EXPORT_Cleanup = 5, 82 | PLUGIN_AMX_EXPORT_Clone = 6, 83 | PLUGIN_AMX_EXPORT_Exec = 7, 84 | PLUGIN_AMX_EXPORT_FindNative = 8, 85 | PLUGIN_AMX_EXPORT_FindPublic = 9, 86 | PLUGIN_AMX_EXPORT_FindPubVar = 10, 87 | PLUGIN_AMX_EXPORT_FindTagId = 11, 88 | PLUGIN_AMX_EXPORT_Flags = 12, 89 | PLUGIN_AMX_EXPORT_GetAddr = 13, 90 | PLUGIN_AMX_EXPORT_GetNative = 14, 91 | PLUGIN_AMX_EXPORT_GetPublic = 15, 92 | PLUGIN_AMX_EXPORT_GetPubVar = 16, 93 | PLUGIN_AMX_EXPORT_GetString = 17, 94 | PLUGIN_AMX_EXPORT_GetTag = 18, 95 | PLUGIN_AMX_EXPORT_GetUserData = 19, 96 | PLUGIN_AMX_EXPORT_Init = 20, 97 | PLUGIN_AMX_EXPORT_InitJIT = 21, 98 | PLUGIN_AMX_EXPORT_MemInfo = 22, 99 | PLUGIN_AMX_EXPORT_NameLength = 23, 100 | PLUGIN_AMX_EXPORT_NativeInfo = 24, 101 | PLUGIN_AMX_EXPORT_NumNatives = 25, 102 | PLUGIN_AMX_EXPORT_NumPublics = 26, 103 | PLUGIN_AMX_EXPORT_NumPubVars = 27, 104 | PLUGIN_AMX_EXPORT_NumTags = 28, 105 | PLUGIN_AMX_EXPORT_Push = 29, 106 | PLUGIN_AMX_EXPORT_PushArray = 30, 107 | PLUGIN_AMX_EXPORT_PushString = 31, 108 | PLUGIN_AMX_EXPORT_RaiseError = 32, 109 | PLUGIN_AMX_EXPORT_Register = 33, 110 | PLUGIN_AMX_EXPORT_Release = 34, 111 | PLUGIN_AMX_EXPORT_SetCallback = 35, 112 | PLUGIN_AMX_EXPORT_SetDebugHook = 36, 113 | PLUGIN_AMX_EXPORT_SetString = 37, 114 | PLUGIN_AMX_EXPORT_SetUserData = 38, 115 | PLUGIN_AMX_EXPORT_StrLen = 39, 116 | PLUGIN_AMX_EXPORT_UTF8Check = 40, 117 | PLUGIN_AMX_EXPORT_UTF8Get = 41, 118 | PLUGIN_AMX_EXPORT_UTF8Len = 42, 119 | PLUGIN_AMX_EXPORT_UTF8Put = 43, 120 | }; 121 | 122 | //---------------------------------------------------------- 123 | // EOF 124 | -------------------------------------------------------------------------------- /amx/amx.h: -------------------------------------------------------------------------------- 1 | /* Pawn Abstract Machine (for the Pawn language) 2 | * 3 | * Copyright (c) ITB CompuPhase, 1997-2005 4 | * 5 | * This software is provided "as-is", without any express or implied warranty. 6 | * In no event will the authors be held liable for any damages arising from 7 | * the use of this software. 8 | * 9 | * Permission is granted to anyone to use this software for any purpose, 10 | * including commercial applications, and to alter it and redistribute it 11 | * freely, subject to the following restrictions: 12 | * 13 | * 1. The origin of this software must not be misrepresented; you must not 14 | * claim that you wrote the original software. If you use this software in 15 | * a product, an acknowledgment in the product documentation would be 16 | * appreciated but is not required. 17 | * 2. Altered source versions must be plainly marked as such, and must not be 18 | * misrepresented as being the original software. 19 | * 3. This notice may not be removed or altered from any source distribution. 20 | * 21 | * Version: $Id: amx.h,v 1.5 2006/03/26 16:56:15 spookie Exp $ 22 | */ 23 | 24 | #if defined FREEBSD && !defined __FreeBSD__ 25 | #define __FreeBSD__ 26 | #endif 27 | #if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ 28 | #include "sclinux.h" 29 | #endif 30 | 31 | #ifndef AMX_H_INCLUDED 32 | #define AMX_H_INCLUDED 33 | 34 | #if defined HAVE_STDINT_H 35 | #include 36 | #else 37 | #if defined __LCC__ || defined __DMC__ || defined LINUX 38 | #if defined HAVE_INTTYPES_H 39 | #include 40 | #else 41 | #include 42 | #endif 43 | #elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L 44 | /* The ISO C99 defines the int16_t and int_32t types. If the compiler got 45 | * here, these types are probably undefined. 46 | */ 47 | #if defined __MACH__ 48 | #include 49 | typedef unsigned short int uint16_t; 50 | typedef unsigned long int uint32_t; 51 | #elif defined __FreeBSD__ 52 | #include 53 | #else 54 | typedef short int int16_t; 55 | typedef unsigned short int uint16_t; 56 | #if defined SN_TARGET_PS2 57 | typedef int int32_t; 58 | typedef unsigned int uint32_t; 59 | #else 60 | typedef long int int32_t; 61 | typedef unsigned long int uint32_t; 62 | #endif 63 | #if defined __WIN32__ || defined _WIN32 || defined WIN32 64 | typedef __int64 int64_t; 65 | typedef unsigned __int64 uint64_t; 66 | #define HAVE_I64 67 | #elif defined __GNUC__ 68 | typedef long long int64_t; 69 | typedef unsigned long long uint64_t; 70 | #define HAVE_I64 71 | #endif 72 | #endif 73 | #endif 74 | #define HAVE_STDINT_H 75 | #endif 76 | #if defined _LP64 || defined WIN64 || defined _WIN64 77 | #if !defined __64BIT__ 78 | #define __64BIT__ 79 | #endif 80 | #endif 81 | 82 | #if HAVE_ALLOCA_H 83 | #include 84 | #elif HAVE_MALLOC_H //alloca could be also defined here 85 | #include 86 | #endif 87 | #if defined __WIN32__ || defined _WIN32 || defined WIN32 /* || defined __MSDOS__ */ 88 | #if !defined alloca 89 | #define alloca(n) _alloca(n) 90 | #endif 91 | #endif 92 | 93 | #if !defined arraysize 94 | #define arraysize(array) (sizeof(array) / sizeof((array)[0])) 95 | #endif 96 | 97 | #ifdef __cplusplus 98 | extern "C" { 99 | #endif 100 | 101 | #if defined PAWN_DLL 102 | #if !defined AMX_NATIVE_CALL 103 | #define AMX_NATIVE_CALL __stdcall 104 | #endif 105 | #if !defined AMXAPI 106 | #define AMXAPI __stdcall 107 | #endif 108 | #endif 109 | 110 | /* calling convention for native functions */ 111 | #if !defined AMX_NATIVE_CALL 112 | #define AMX_NATIVE_CALL 113 | #endif 114 | /* calling convention for all interface functions and callback functions */ 115 | #if !defined AMXAPI 116 | #if defined STDECL 117 | #define AMXAPI __stdcall 118 | #elif defined CDECL 119 | #define AMXAPI __cdecl 120 | #elif defined GCC_HASCLASSVISIBILITY 121 | #define AMXAPI __attribute__ ((visibility("default"))) 122 | #else 123 | #define AMXAPI 124 | #endif 125 | #endif 126 | #if !defined AMXEXPORT 127 | #define AMXEXPORT 128 | #endif 129 | 130 | /* File format version Required AMX version 131 | * 0 (original version) 0 132 | * 1 (opcodes JUMP.pri, SWITCH and CASETBL) 1 133 | * 2 (compressed files) 2 134 | * 3 (public variables) 2 135 | * 4 (opcodes SWAP.pri/alt and PUSHADDR) 4 136 | * 5 (tagnames table) 4 137 | * 6 (reformatted header) 6 138 | * 7 (name table, opcodes SYMTAG & SYSREQ.D) 7 139 | * 8 (opcode STMT, renewed debug interface) 8 140 | */ 141 | #define CUR_FILE_VERSION 8 /* current file version; also the current AMX version */ 142 | #define MIN_FILE_VERSION 6 /* lowest supported file format version for the current AMX version */ 143 | #define MIN_AMX_VERSION 8 /* minimum AMX version needed to support the current file format */ 144 | 145 | #if !defined PAWN_CELL_SIZE 146 | #define PAWN_CELL_SIZE 32 /* by default, use 32-bit cells */ 147 | #endif 148 | #if PAWN_CELL_SIZE==16 149 | typedef uint16_t ucell; 150 | typedef int16_t cell; 151 | #elif PAWN_CELL_SIZE==32 152 | typedef uint32_t ucell; 153 | typedef int32_t cell; 154 | #elif PAWN_CELL_SIZE==64 155 | typedef uint64_t ucell; 156 | typedef int64_t cell; 157 | #else 158 | #error Unsupported cell size (PAWN_CELL_SIZE) 159 | #endif 160 | 161 | #define UNPACKEDMAX ((1L << (sizeof(cell)-1)*8) - 1) 162 | #define UNLIMITED (~1u >> 1) 163 | 164 | struct tagAMX; 165 | typedef cell (AMX_NATIVE_CALL *AMX_NATIVE)(struct tagAMX *amx, cell *params); 166 | typedef int (AMXAPI *AMX_CALLBACK)(struct tagAMX *amx, cell index, 167 | cell *result, cell *params); 168 | typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx); 169 | #if !defined _FAR 170 | #define _FAR 171 | #endif 172 | 173 | #if defined _MSC_VER 174 | #pragma warning(disable:4103) /* disable warning message 4103 that complains 175 | * about pragma pack in a header file */ 176 | #pragma warning(disable:4100) /* "'%$S' : unreferenced formal parameter" */ 177 | #endif 178 | 179 | /* Some compilers do not support the #pragma align, which should be fine. Some 180 | * compilers give a warning on unknown #pragmas, which is not so fine... 181 | */ 182 | #if (defined SN_TARGET_PS2 || defined __GNUC__) && !defined AMX_NO_ALIGN 183 | #define AMX_NO_ALIGN 184 | #endif 185 | 186 | #if defined __GNUC__ 187 | #define PACKED __attribute__((packed)) 188 | #else 189 | #define PACKED 190 | #endif 191 | 192 | #if !defined AMX_NO_ALIGN 193 | #if defined LINUX || defined __FreeBSD__ 194 | #pragma pack(1) /* structures must be packed (byte-aligned) */ 195 | #elif defined MACOS && defined __MWERKS__ 196 | #pragma options align=mac68k 197 | #else 198 | #pragma pack(push) 199 | #pragma pack(1) /* structures must be packed (byte-aligned) */ 200 | #if defined __TURBOC__ 201 | #pragma option -a- /* "pack" pragma for older Borland compilers */ 202 | #endif 203 | #endif 204 | #endif 205 | 206 | typedef struct tagAMX_NATIVE_INFO { 207 | const char _FAR *name PACKED; 208 | AMX_NATIVE func PACKED; 209 | } PACKED AMX_NATIVE_INFO; 210 | 211 | #define AMX_USERNUM 4 212 | #define sEXPMAX 19 /* maximum name length for file version <= 6 */ 213 | #define sNAMEMAX 31 /* maximum name length of symbol name */ 214 | 215 | typedef struct tagAMX_FUNCSTUB { 216 | ucell address PACKED; 217 | char name[sEXPMAX+1] PACKED; 218 | } PACKED AMX_FUNCSTUB; 219 | 220 | typedef struct tagFUNCSTUBNT { 221 | ucell address PACKED; 222 | uint32_t nameofs PACKED; 223 | } PACKED AMX_FUNCSTUBNT; 224 | 225 | /* The AMX structure is the internal structure for many functions. Not all 226 | * fields are valid at all times; many fields are cached in local variables. 227 | */ 228 | typedef struct tagAMX { 229 | unsigned char _FAR *base PACKED; /* points to the AMX header plus the code, optionally also the data */ 230 | unsigned char _FAR *data PACKED; /* points to separate data+stack+heap, may be NULL */ 231 | AMX_CALLBACK callback PACKED; 232 | AMX_DEBUG debug PACKED; /* debug callback */ 233 | /* for external functions a few registers must be accessible from the outside */ 234 | cell cip PACKED; /* instruction pointer: relative to base + amxhdr->cod */ 235 | cell frm PACKED; /* stack frame base: relative to base + amxhdr->dat */ 236 | cell hea PACKED; /* top of the heap: relative to base + amxhdr->dat */ 237 | cell hlw PACKED; /* bottom of the heap: relative to base + amxhdr->dat */ 238 | cell stk PACKED; /* stack pointer: relative to base + amxhdr->dat */ 239 | cell stp PACKED; /* top of the stack: relative to base + amxhdr->dat */ 240 | int flags PACKED; /* current status, see amx_Flags() */ 241 | /* user data */ 242 | long usertags[AMX_USERNUM] PACKED; 243 | void _FAR *userdata[AMX_USERNUM] PACKED; 244 | /* native functions can raise an error */ 245 | int error PACKED; 246 | /* passing parameters requires a "count" field */ 247 | int paramcount; 248 | /* the sleep opcode needs to store the full AMX status */ 249 | cell pri PACKED; 250 | cell alt PACKED; 251 | cell reset_stk PACKED; 252 | cell reset_hea PACKED; 253 | cell sysreq_d PACKED; /* relocated address/value for the SYSREQ.D opcode */ 254 | #if defined JIT 255 | /* support variables for the JIT */ 256 | int reloc_size PACKED; /* required temporary buffer for relocations */ 257 | long code_size PACKED; /* estimated memory footprint of the native code */ 258 | #endif 259 | } PACKED AMX; 260 | 261 | /* The AMX_HEADER structure is both the memory format as the file format. The 262 | * structure is used internaly. 263 | */ 264 | typedef struct tagAMX_HEADER { 265 | int32_t size PACKED; /* size of the "file" */ 266 | uint16_t magic PACKED; /* signature */ 267 | char file_version PACKED; /* file format version */ 268 | char amx_version PACKED; /* required version of the AMX */ 269 | int16_t flags PACKED; 270 | int16_t defsize PACKED; /* size of a definition record */ 271 | int32_t cod PACKED; /* initial value of COD - code block */ 272 | int32_t dat PACKED; /* initial value of DAT - data block */ 273 | int32_t hea PACKED; /* initial value of HEA - start of the heap */ 274 | int32_t stp PACKED; /* initial value of STP - stack top */ 275 | int32_t cip PACKED; /* initial value of CIP - the instruction pointer */ 276 | int32_t publics PACKED; /* offset to the "public functions" table */ 277 | int32_t natives PACKED; /* offset to the "native functions" table */ 278 | int32_t libraries PACKED; /* offset to the table of libraries */ 279 | int32_t pubvars PACKED; /* the "public variables" table */ 280 | int32_t tags PACKED; /* the "public tagnames" table */ 281 | int32_t nametable PACKED; /* name table */ 282 | } PACKED AMX_HEADER; 283 | 284 | #if PAWN_CELL_SIZE==16 285 | #define AMX_MAGIC 0xf1e2 286 | #elif PAWN_CELL_SIZE==32 287 | #define AMX_MAGIC 0xf1e0 288 | #elif PAWN_CELL_SIZE==64 289 | #define AMX_MAGIC 0xf1e1 290 | #endif 291 | 292 | enum { 293 | AMX_ERR_NONE, 294 | /* reserve the first 15 error codes for exit codes of the abstract machine */ 295 | AMX_ERR_EXIT, /* forced exit */ 296 | AMX_ERR_ASSERT, /* assertion failed */ 297 | AMX_ERR_STACKERR, /* stack/heap collision */ 298 | AMX_ERR_BOUNDS, /* index out of bounds */ 299 | AMX_ERR_MEMACCESS, /* invalid memory access */ 300 | AMX_ERR_INVINSTR, /* invalid instruction */ 301 | AMX_ERR_STACKLOW, /* stack underflow */ 302 | AMX_ERR_HEAPLOW, /* heap underflow */ 303 | AMX_ERR_CALLBACK, /* no callback, or invalid callback */ 304 | AMX_ERR_NATIVE, /* native function failed */ 305 | AMX_ERR_DIVIDE, /* divide by zero */ 306 | AMX_ERR_SLEEP, /* go into sleepmode - code can be restarted */ 307 | AMX_ERR_INVSTATE, /* invalid state for this access */ 308 | 309 | AMX_ERR_MEMORY = 16, /* out of memory */ 310 | AMX_ERR_FORMAT, /* invalid file format */ 311 | AMX_ERR_VERSION, /* file is for a newer version of the AMX */ 312 | AMX_ERR_NOTFOUND, /* function not found */ 313 | AMX_ERR_INDEX, /* invalid index parameter (bad entry point) */ 314 | AMX_ERR_DEBUG, /* debugger cannot run */ 315 | AMX_ERR_INIT, /* AMX not initialized (or doubly initialized) */ 316 | AMX_ERR_USERDATA, /* unable to set user data field (table full) */ 317 | AMX_ERR_INIT_JIT, /* cannot initialize the JIT */ 318 | AMX_ERR_PARAMS, /* parameter error */ 319 | AMX_ERR_DOMAIN, /* domain error, expression result does not fit in range */ 320 | AMX_ERR_GENERAL, /* general error (unknown or unspecific error) */ 321 | }; 322 | 323 | /* AMX_FLAG_CHAR16 0x01 no longer used */ 324 | #define AMX_FLAG_DEBUG 0x02 /* symbolic info. available */ 325 | #define AMX_FLAG_COMPACT 0x04 /* compact encoding */ 326 | #define AMX_FLAG_BYTEOPC 0x08 /* opcode is a byte (not a cell) */ 327 | #define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no STMT opcode */ 328 | #define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */ 329 | #define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */ 330 | #define AMX_FLAG_BROWSE 0x4000 /* busy browsing */ 331 | #define AMX_FLAG_RELOC 0x8000 /* jump/call addresses relocated */ 332 | 333 | #define AMX_EXEC_MAIN -1 /* start at program entry point */ 334 | #define AMX_EXEC_CONT -2 /* continue from last address */ 335 | 336 | #define AMX_USERTAG(a,b,c,d) ((a) | ((b)<<8) | ((long)(c)<<16) | ((long)(d)<<24)) 337 | 338 | #if !defined AMX_COMPACTMARGIN 339 | #define AMX_COMPACTMARGIN 64 340 | #endif 341 | 342 | /* for native functions that use floating point parameters, the following 343 | * two macros are convenient for casting a "cell" into a "float" type _without_ 344 | * changing the bit pattern 345 | */ 346 | #if PAWN_CELL_SIZE==32 347 | #define amx_ftoc(f) ( * ((cell*)&f) ) /* float to cell */ 348 | #define amx_ctof(c) ( * ((float*)&c) ) /* cell to float */ 349 | #elif PAWN_CELL_SIZE==64 350 | #define amx_ftoc(f) ( * ((cell*)&f) ) /* float to cell */ 351 | #define amx_ctof(c) ( * ((double*)&c) ) /* cell to float */ 352 | #else 353 | #error Unsupported cell size 354 | #endif 355 | 356 | #define amx_StrParam(amx,param,result) \ 357 | do { \ 358 | cell *amx_cstr_; int amx_length_; \ 359 | amx_GetAddr((amx), (param), &amx_cstr_); \ 360 | amx_StrLen(amx_cstr_, &amx_length_); \ 361 | if (amx_length_ > 0 && \ 362 | ((result) = (char*)alloca((amx_length_ + 1) * sizeof(*(result)))) != NULL) \ 363 | amx_GetString((char*)(result), amx_cstr_, sizeof(*(result))>1, amx_length_ + 1); \ 364 | else (result) = NULL; \ 365 | } while (0) 366 | 367 | uint16_t * AMXAPI amx_Align16(uint16_t *v); 368 | uint32_t * AMXAPI amx_Align32(uint32_t *v); 369 | #if defined _I64_MAX || defined HAVE_I64 370 | uint64_t * AMXAPI amx_Align64(uint64_t *v); 371 | #endif 372 | int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr); 373 | int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params); 374 | int AMXAPI amx_Cleanup(AMX *amx); 375 | int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data); 376 | int AMXAPI amx_Exec(AMX *amx, cell *retval, int index); 377 | int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index); 378 | int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index); 379 | int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr); 380 | int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname); 381 | int AMXAPI amx_Flags(AMX *amx,uint16_t *flags); 382 | int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr); 383 | int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname); 384 | int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname); 385 | int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr); 386 | int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size); 387 | int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id); 388 | int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr); 389 | int AMXAPI amx_Init(AMX *amx, void *program); 390 | int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code); 391 | int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap); 392 | int AMXAPI amx_NameLength(AMX *amx, int *length); 393 | AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func); 394 | int AMXAPI amx_NumNatives(AMX *amx, int *number); 395 | int AMXAPI amx_NumPublics(AMX *amx, int *number); 396 | int AMXAPI amx_NumPubVars(AMX *amx, int *number); 397 | int AMXAPI amx_NumTags(AMX *amx, int *number); 398 | int AMXAPI amx_Push(AMX *amx, cell value); 399 | int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells); 400 | int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar); 401 | int AMXAPI amx_RaiseError(AMX *amx, int error); 402 | int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number); 403 | int AMXAPI amx_Release(AMX *amx, cell amx_addr); 404 | int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback); 405 | int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug); 406 | int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size); 407 | int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr); 408 | int AMXAPI amx_StrLen(const cell *cstring, int *length); 409 | int AMXAPI amx_UTF8Check(const char *string, int *length); 410 | int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value); 411 | int AMXAPI amx_UTF8Len(const cell *cstr, int *length); 412 | int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value); 413 | 414 | #if PAWN_CELL_SIZE==16 415 | #define amx_AlignCell(v) amx_Align16(v) 416 | #elif PAWN_CELL_SIZE==32 417 | #define amx_AlignCell(v) amx_Align32(v) 418 | #elif PAWN_CELL_SIZE==64 && (defined _I64_MAX || defined HAVE_I64) 419 | #define amx_AlignCell(v) amx_Align64(v) 420 | #else 421 | #error Unsupported cell size 422 | #endif 423 | 424 | #define amx_RegisterFunc(amx, name, func) \ 425 | amx_Register((amx), amx_NativeInfo((name),(func)), 1); 426 | 427 | #if !defined AMX_NO_ALIGN 428 | #if defined LINUX || defined __FreeBSD__ 429 | #pragma pack() /* reset default packing */ 430 | #elif defined MACOS && defined __MWERKS__ 431 | #pragma options align=reset 432 | #else 433 | #pragma pack(pop) /* reset previous packing */ 434 | #endif 435 | #endif 436 | 437 | #ifdef __cplusplus 438 | } 439 | #endif 440 | 441 | #endif /* AMX_H_INCLUDED */ 442 | -------------------------------------------------------------------------------- /amxplugin.cpp: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------- 2 | // 3 | // SA-MP Multiplayer Modification For GTA:SA 4 | // Copyright 2004-2009 SA-MP Team 5 | // 6 | //---------------------------------------------------------- 7 | // 8 | // This provides an interface to call amx library functions 9 | // within samp-server. 10 | // 11 | // To use: 12 | // Define the extern in your main source file: 13 | // extern void *pAMXFunctions; 14 | // And, in your Initialize function, assign: 15 | // pAMXFunctions = data[PLUGIN_DATA_AMX]; 16 | // 17 | // 18 | // WIN32: To regenerate thunks for calls from prototypes in amx.h 19 | // Run a regex with: 20 | // S: ^(.*)(AMXAPI amx_)([^(]*)([^\;]*);$ 21 | // R: NUDE \1\2\3\4\n{\n\t_asm mov eax, pAMXFunctions;\n\t_asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_\3*4];\n}\n 22 | // 23 | // LINUX/BSD: To regenerate thunks for calls from prototypes in amx.h 24 | // Run a regex with: 25 | // S: ^(.*)(AMXAPI amx_)([^(]*)([^\;]*);$ 26 | // R: typedef \1 AMXAPI (*amx_\3_t)\4;\n\1\2\3\4\n{\n\tamx_\3_t fn = ((amx_\3_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_\3];\n\treturn fn\4;\n}\n 27 | // Modify internal function calls as nessesary 28 | // 29 | 30 | //---------------------------------------------------------- 31 | 32 | #include "amx/amx.h" 33 | #include "plugincommon.h" 34 | 35 | //---------------------------------------------------------- 36 | 37 | void *pAMXFunctions; 38 | 39 | //---------------------------------------------------------- 40 | 41 | #if (defined(WIN32) || defined(_WIN32)) && defined(_MSC_VER) 42 | 43 | // Optimized Inline Assembly Thunks for MS VC++ 44 | 45 | #define NUDE _declspec(naked) 46 | 47 | NUDE uint16_t * AMXAPI amx_Align16(uint16_t *v) 48 | { 49 | _asm mov eax, pAMXFunctions; 50 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Align16*4]; 51 | } 52 | 53 | NUDE uint32_t * AMXAPI amx_Align32(uint32_t *v) 54 | { 55 | _asm mov eax, pAMXFunctions; 56 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Align32*4]; 57 | } 58 | 59 | #if defined _I64_MAX || defined HAVE_I64 60 | NUDE uint64_t * AMXAPI amx_Align64(uint64_t *v) 61 | { 62 | _asm mov eax, pAMXFunctions; 63 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Align64*4]; 64 | } 65 | 66 | #endif 67 | NUDE int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr) 68 | { 69 | _asm mov eax, pAMXFunctions; 70 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Allot*4]; 71 | } 72 | 73 | NUDE int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params) 74 | { 75 | _asm mov eax, pAMXFunctions; 76 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Callback*4]; 77 | } 78 | 79 | NUDE int AMXAPI amx_Cleanup(AMX *amx) 80 | { 81 | _asm mov eax, pAMXFunctions; 82 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Cleanup*4]; 83 | } 84 | 85 | NUDE int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data) 86 | { 87 | _asm mov eax, pAMXFunctions; 88 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Clone*4]; 89 | } 90 | 91 | NUDE int AMXAPI amx_Exec(AMX *amx, cell *retval, int index) 92 | { 93 | _asm mov eax, pAMXFunctions; 94 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Exec*4]; 95 | } 96 | 97 | NUDE int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index) 98 | { 99 | _asm mov eax, pAMXFunctions; 100 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_FindNative*4]; 101 | } 102 | 103 | NUDE int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index) 104 | { 105 | _asm mov eax, pAMXFunctions; 106 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_FindPublic*4]; 107 | } 108 | 109 | NUDE int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr) 110 | { 111 | _asm mov eax, pAMXFunctions; 112 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_FindPubVar*4]; 113 | } 114 | 115 | NUDE int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname) 116 | { 117 | _asm mov eax, pAMXFunctions; 118 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_FindTagId*4]; 119 | } 120 | 121 | NUDE int AMXAPI amx_Flags(AMX *amx,uint16_t *flags) 122 | { 123 | _asm mov eax, pAMXFunctions; 124 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Flags*4]; 125 | } 126 | 127 | NUDE int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr) 128 | { 129 | _asm mov eax, pAMXFunctions; 130 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetAddr*4]; 131 | } 132 | 133 | NUDE int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname) 134 | { 135 | _asm mov eax, pAMXFunctions; 136 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetNative*4]; 137 | } 138 | 139 | NUDE int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname) 140 | { 141 | _asm mov eax, pAMXFunctions; 142 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetPublic*4]; 143 | } 144 | 145 | NUDE int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr) 146 | { 147 | _asm mov eax, pAMXFunctions; 148 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetPubVar*4]; 149 | } 150 | 151 | NUDE int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size) 152 | { 153 | _asm mov eax, pAMXFunctions; 154 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetString*4]; 155 | } 156 | 157 | NUDE int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id) 158 | { 159 | _asm mov eax, pAMXFunctions; 160 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetTag*4]; 161 | } 162 | 163 | NUDE int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr) 164 | { 165 | _asm mov eax, pAMXFunctions; 166 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetUserData*4]; 167 | } 168 | 169 | NUDE int AMXAPI amx_Init(AMX *amx, void *program) 170 | { 171 | _asm mov eax, pAMXFunctions; 172 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Init*4]; 173 | } 174 | 175 | NUDE int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code) 176 | { 177 | _asm mov eax, pAMXFunctions; 178 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_InitJIT*4]; 179 | } 180 | 181 | NUDE int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap) 182 | { 183 | _asm mov eax, pAMXFunctions; 184 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_MemInfo*4]; 185 | } 186 | 187 | NUDE int AMXAPI amx_NameLength(AMX *amx, int *length) 188 | { 189 | _asm mov eax, pAMXFunctions; 190 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NameLength*4]; 191 | } 192 | 193 | NUDE AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func) 194 | { 195 | _asm mov eax, pAMXFunctions; 196 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NativeInfo*4]; 197 | } 198 | 199 | NUDE int AMXAPI amx_NumNatives(AMX *amx, int *number) 200 | { 201 | _asm mov eax, pAMXFunctions; 202 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NumNatives*4]; 203 | } 204 | 205 | NUDE int AMXAPI amx_NumPublics(AMX *amx, int *number) 206 | { 207 | _asm mov eax, pAMXFunctions; 208 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NumPublics*4]; 209 | } 210 | 211 | NUDE int AMXAPI amx_NumPubVars(AMX *amx, int *number) 212 | { 213 | _asm mov eax, pAMXFunctions; 214 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NumPubVars*4]; 215 | } 216 | 217 | NUDE int AMXAPI amx_NumTags(AMX *amx, int *number) 218 | { 219 | _asm mov eax, pAMXFunctions; 220 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NumTags*4]; 221 | } 222 | 223 | NUDE int AMXAPI amx_Push(AMX *amx, cell value) 224 | { 225 | _asm mov eax, pAMXFunctions; 226 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Push*4]; 227 | } 228 | 229 | NUDE int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells) 230 | { 231 | _asm mov eax, pAMXFunctions; 232 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_PushArray*4]; 233 | } 234 | 235 | NUDE int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar) 236 | { 237 | _asm mov eax, pAMXFunctions; 238 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_PushString*4]; 239 | } 240 | 241 | NUDE int AMXAPI amx_RaiseError(AMX *amx, int error) 242 | { 243 | _asm mov eax, pAMXFunctions; 244 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_RaiseError*4]; 245 | } 246 | 247 | NUDE int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number) 248 | { 249 | _asm mov eax, pAMXFunctions; 250 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Register*4]; 251 | } 252 | 253 | NUDE int AMXAPI amx_Release(AMX *amx, cell amx_addr) 254 | { 255 | _asm mov eax, pAMXFunctions; 256 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Release*4]; 257 | } 258 | 259 | NUDE int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback) 260 | { 261 | _asm mov eax, pAMXFunctions; 262 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_SetCallback*4]; 263 | } 264 | 265 | NUDE int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug) 266 | { 267 | _asm mov eax, pAMXFunctions; 268 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_SetDebugHook*4]; 269 | } 270 | 271 | NUDE int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size) 272 | { 273 | _asm mov eax, pAMXFunctions; 274 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_SetString*4]; 275 | } 276 | 277 | NUDE int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr) 278 | { 279 | _asm mov eax, pAMXFunctions; 280 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_SetUserData*4]; 281 | } 282 | 283 | NUDE int AMXAPI amx_StrLen(const cell *cstring, int *length) 284 | { 285 | _asm mov eax, pAMXFunctions; 286 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_StrLen*4]; 287 | } 288 | 289 | NUDE int AMXAPI amx_UTF8Check(const char *string, int *length) 290 | { 291 | _asm mov eax, pAMXFunctions; 292 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_UTF8Check*4]; 293 | } 294 | 295 | NUDE int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value) 296 | { 297 | _asm mov eax, pAMXFunctions; 298 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_UTF8Get*4]; 299 | } 300 | 301 | NUDE int AMXAPI amx_UTF8Len(const cell *cstr, int *length) 302 | { 303 | _asm mov eax, pAMXFunctions; 304 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_UTF8Len*4]; 305 | } 306 | 307 | NUDE int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value) 308 | { 309 | _asm mov eax, pAMXFunctions; 310 | _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_UTF8Put*4]; 311 | } 312 | 313 | #else 314 | 315 | // Unoptimized Thunks (Linux/BSD/non MSVC++) 316 | 317 | typedef uint16_t * AMXAPI (*amx_Align16_t)(uint16_t *v); 318 | uint16_t * AMXAPI amx_Align16(uint16_t *v) 319 | { 320 | amx_Align16_t fn = ((amx_Align16_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align16]; 321 | return fn(v); 322 | } 323 | 324 | typedef uint32_t * AMXAPI (*amx_Align32_t)(uint32_t *v); 325 | uint32_t * AMXAPI amx_Align32(uint32_t *v) 326 | { 327 | amx_Align32_t fn = ((amx_Align32_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align32]; 328 | return fn(v); 329 | } 330 | 331 | #if defined _I64_MAX || defined HAVE_I64 332 | typedef uint64_t * AMXAPI (*amx_Align64_t)(uint64_t *v); 333 | uint64_t * AMXAPI amx_Align64(uint64_t *v) 334 | { 335 | amx_Align64_t fn = ((amx_Align64_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align64]; 336 | return fn(v); 337 | } 338 | #endif 339 | 340 | typedef int AMXAPI (*amx_Allot_t)(AMX *amx, int cells, cell *amx_addr, cell **phys_addr); 341 | int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr) 342 | { 343 | amx_Allot_t fn = ((amx_Allot_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Allot]; 344 | return fn(amx, cells, amx_addr, phys_addr); 345 | } 346 | 347 | typedef int AMXAPI (*amx_Callback_t)(AMX *amx, cell index, cell *result, cell *params); 348 | int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params) 349 | { 350 | amx_Callback_t fn = ((amx_Callback_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Callback]; 351 | return fn(amx, index, result, params); 352 | } 353 | 354 | typedef int AMXAPI (*amx_Cleanup_t)(AMX *amx); 355 | int AMXAPI amx_Cleanup(AMX *amx) 356 | { 357 | amx_Cleanup_t fn = ((amx_Cleanup_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Cleanup]; 358 | return fn(amx); 359 | } 360 | 361 | typedef int AMXAPI (*amx_Clone_t)(AMX *amxClone, AMX *amxSource, void *data); 362 | int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data) 363 | { 364 | amx_Clone_t fn = ((amx_Clone_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Clone]; 365 | return fn(amxClone, amxSource, data); 366 | } 367 | 368 | typedef int AMXAPI (*amx_Exec_t)(AMX *amx, cell *retval, int index); 369 | int AMXAPI amx_Exec(AMX *amx, cell *retval, int index) 370 | { 371 | amx_Exec_t fn = ((amx_Exec_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Exec]; 372 | return fn(amx, retval, index); 373 | } 374 | 375 | typedef int AMXAPI (*amx_FindNative_t)(AMX *amx, const char *name, int *index); 376 | int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index) 377 | { 378 | amx_FindNative_t fn = ((amx_FindNative_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindNative]; 379 | return fn(amx, name, index); 380 | } 381 | 382 | typedef int AMXAPI (*amx_FindPublic_t)(AMX *amx, const char *funcname, int *index); 383 | int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index) 384 | { 385 | amx_FindPublic_t fn = ((amx_FindPublic_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindPublic]; 386 | return fn(amx, funcname, index); 387 | } 388 | 389 | typedef int AMXAPI (*amx_FindPubVar_t)(AMX *amx, const char *varname, cell *amx_addr); 390 | int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr) 391 | { 392 | amx_FindPubVar_t fn = ((amx_FindPubVar_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindPubVar]; 393 | return fn(amx, varname, amx_addr); 394 | } 395 | 396 | typedef int AMXAPI (*amx_FindTagId_t)(AMX *amx, cell tag_id, char *tagname); 397 | int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname) 398 | { 399 | amx_FindTagId_t fn = ((amx_FindTagId_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindTagId]; 400 | return fn(amx, tag_id, tagname); 401 | } 402 | 403 | typedef int AMXAPI (*amx_Flags_t)(AMX *amx,uint16_t *flags); 404 | int AMXAPI amx_Flags(AMX *amx,uint16_t *flags) 405 | { 406 | amx_Flags_t fn = ((amx_Flags_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Flags]; 407 | return fn(amx,flags); 408 | } 409 | 410 | typedef int AMXAPI (*amx_GetAddr_t)(AMX *amx,cell amx_addr,cell **phys_addr); 411 | int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr) 412 | { 413 | amx_GetAddr_t fn = ((amx_GetAddr_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetAddr]; 414 | return fn(amx,amx_addr,phys_addr); 415 | } 416 | 417 | typedef int AMXAPI (*amx_GetNative_t)(AMX *amx, int index, char *funcname); 418 | int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname) 419 | { 420 | amx_GetNative_t fn = ((amx_GetNative_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetNative]; 421 | return fn(amx, index, funcname); 422 | } 423 | 424 | typedef int AMXAPI (*amx_GetPublic_t)(AMX *amx, int index, char *funcname); 425 | int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname) 426 | { 427 | amx_GetPublic_t fn = ((amx_GetPublic_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetPublic]; 428 | return fn(amx, index, funcname); 429 | } 430 | 431 | typedef int AMXAPI (*amx_GetPubVar_t)(AMX *amx, int index, char *varname, cell *amx_addr); 432 | int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr) 433 | { 434 | amx_GetPubVar_t fn = ((amx_GetPubVar_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetPubVar]; 435 | return fn(amx, index, varname, amx_addr); 436 | } 437 | 438 | typedef int AMXAPI (*amx_GetString_t)(char *dest,const cell *source, int use_wchar, size_t size); 439 | int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size) 440 | { 441 | amx_GetString_t fn = ((amx_GetString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetString]; 442 | return fn(dest,source, use_wchar, size); 443 | } 444 | 445 | typedef int AMXAPI (*amx_GetTag_t)(AMX *amx, int index, char *tagname, cell *tag_id); 446 | int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id) 447 | { 448 | amx_GetTag_t fn = ((amx_GetTag_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetTag]; 449 | return fn(amx, index, tagname, tag_id); 450 | } 451 | 452 | typedef int AMXAPI (*amx_GetUserData_t)(AMX *amx, long tag, void **ptr); 453 | int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr) 454 | { 455 | amx_GetUserData_t fn = ((amx_GetUserData_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetUserData]; 456 | return fn(amx, tag, ptr); 457 | } 458 | 459 | typedef int AMXAPI (*amx_Init_t)(AMX *amx, void *program); 460 | int AMXAPI amx_Init(AMX *amx, void *program) 461 | { 462 | amx_Init_t fn = ((amx_Init_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Init]; 463 | return fn(amx, program); 464 | } 465 | 466 | typedef int AMXAPI (*amx_InitJIT_t)(AMX *amx, void *reloc_table, void *native_code); 467 | int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code) 468 | { 469 | amx_InitJIT_t fn = ((amx_InitJIT_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_InitJIT]; 470 | return fn(amx, reloc_table, native_code); 471 | } 472 | 473 | typedef int AMXAPI (*amx_MemInfo_t)(AMX *amx, long *codesize, long *datasize, long *stackheap); 474 | int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap) 475 | { 476 | amx_MemInfo_t fn = ((amx_MemInfo_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_MemInfo]; 477 | return fn(amx, codesize, datasize, stackheap); 478 | } 479 | 480 | typedef int AMXAPI (*amx_NameLength_t)(AMX *amx, int *length); 481 | int AMXAPI amx_NameLength(AMX *amx, int *length) 482 | { 483 | amx_NameLength_t fn = ((amx_NameLength_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NameLength]; 484 | return fn(amx, length); 485 | } 486 | 487 | typedef AMX_NATIVE_INFO * AMXAPI (*amx_NativeInfo_t)(const char *name, AMX_NATIVE func); 488 | AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func) 489 | { 490 | amx_NativeInfo_t fn = ((amx_NativeInfo_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NativeInfo]; 491 | return fn(name, func); 492 | } 493 | 494 | typedef int AMXAPI (*amx_NumNatives_t)(AMX *amx, int *number); 495 | int AMXAPI amx_NumNatives(AMX *amx, int *number) 496 | { 497 | amx_NumNatives_t fn = ((amx_NumNatives_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumNatives]; 498 | return fn(amx, number); 499 | } 500 | 501 | typedef int AMXAPI (*amx_NumPublics_t)(AMX *amx, int *number); 502 | int AMXAPI amx_NumPublics(AMX *amx, int *number) 503 | { 504 | amx_NumPublics_t fn = ((amx_NumPublics_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumPublics]; 505 | return fn(amx, number); 506 | } 507 | 508 | typedef int AMXAPI (*amx_NumPubVars_t)(AMX *amx, int *number); 509 | int AMXAPI amx_NumPubVars(AMX *amx, int *number) 510 | { 511 | amx_NumPubVars_t fn = ((amx_NumPubVars_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumPubVars]; 512 | return fn(amx, number); 513 | } 514 | 515 | typedef int AMXAPI (*amx_NumTags_t)(AMX *amx, int *number); 516 | int AMXAPI amx_NumTags(AMX *amx, int *number) 517 | { 518 | amx_NumTags_t fn = ((amx_NumTags_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumTags]; 519 | return fn(amx, number); 520 | } 521 | 522 | typedef int AMXAPI (*amx_Push_t)(AMX *amx, cell value); 523 | int AMXAPI amx_Push(AMX *amx, cell value) 524 | { 525 | amx_Push_t fn = ((amx_Push_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Push]; 526 | return fn(amx, value); 527 | } 528 | 529 | typedef int AMXAPI (*amx_PushArray_t)(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells); 530 | int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells) 531 | { 532 | amx_PushArray_t fn = ((amx_PushArray_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_PushArray]; 533 | return fn(amx, amx_addr, phys_addr, array, numcells); 534 | } 535 | 536 | typedef int AMXAPI (*amx_PushString_t)(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar); 537 | int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar) 538 | { 539 | amx_PushString_t fn = ((amx_PushString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_PushString]; 540 | return fn(amx, amx_addr, phys_addr, string, pack, use_wchar); 541 | } 542 | 543 | typedef int AMXAPI (*amx_RaiseError_t)(AMX *amx, int error); 544 | int AMXAPI amx_RaiseError(AMX *amx, int error) 545 | { 546 | amx_RaiseError_t fn = ((amx_RaiseError_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_RaiseError]; 547 | return fn(amx, error); 548 | } 549 | 550 | typedef int AMXAPI (*amx_Register_t)(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number); 551 | int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number) 552 | { 553 | amx_Register_t fn = ((amx_Register_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Register]; 554 | return fn(amx, nativelist, number); 555 | } 556 | 557 | typedef int AMXAPI (*amx_Release_t)(AMX *amx, cell amx_addr); 558 | int AMXAPI amx_Release(AMX *amx, cell amx_addr) 559 | { 560 | amx_Release_t fn = ((amx_Release_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Release]; 561 | return fn(amx, amx_addr); 562 | } 563 | 564 | typedef int AMXAPI (*amx_SetCallback_t)(AMX *amx, AMX_CALLBACK callback); 565 | int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback) 566 | { 567 | amx_SetCallback_t fn = ((amx_SetCallback_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetCallback]; 568 | return fn(amx, callback); 569 | } 570 | 571 | typedef int AMXAPI (*amx_SetDebugHook_t)(AMX *amx, AMX_DEBUG debug); 572 | int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug) 573 | { 574 | amx_SetDebugHook_t fn = ((amx_SetDebugHook_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetDebugHook]; 575 | return fn(amx, debug); 576 | } 577 | 578 | typedef int AMXAPI (*amx_SetString_t)(cell *dest, const char *source, int pack, int use_wchar, size_t size); 579 | int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size) 580 | { 581 | amx_SetString_t fn = ((amx_SetString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetString]; 582 | return fn(dest, source, pack, use_wchar, size); 583 | } 584 | 585 | typedef int AMXAPI (*amx_SetUserData_t)(AMX *amx, long tag, void *ptr); 586 | int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr) 587 | { 588 | amx_SetUserData_t fn = ((amx_SetUserData_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetUserData]; 589 | return fn(amx, tag, ptr); 590 | } 591 | 592 | typedef int AMXAPI (*amx_StrLen_t)(const cell *cstring, int *length); 593 | int AMXAPI amx_StrLen(const cell *cstring, int *length) 594 | { 595 | amx_StrLen_t fn = ((amx_StrLen_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_StrLen]; 596 | return fn(cstring, length); 597 | } 598 | 599 | typedef int AMXAPI (*amx_UTF8Check_t)(const char *string, int *length); 600 | int AMXAPI amx_UTF8Check(const char *string, int *length) 601 | { 602 | amx_UTF8Check_t fn = ((amx_UTF8Check_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Check]; 603 | return fn(string, length); 604 | } 605 | 606 | typedef int AMXAPI (*amx_UTF8Get_t)(const char *string, const char **endptr, cell *value); 607 | int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value) 608 | { 609 | amx_UTF8Get_t fn = ((amx_UTF8Get_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Get]; 610 | return fn(string, endptr, value); 611 | } 612 | 613 | typedef int AMXAPI (*amx_UTF8Len_t)(const cell *cstr, int *length); 614 | int AMXAPI amx_UTF8Len(const cell *cstr, int *length) 615 | { 616 | amx_UTF8Len_t fn = ((amx_UTF8Len_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Len]; 617 | return fn(cstr, length); 618 | } 619 | 620 | typedef int AMXAPI (*amx_UTF8Put_t)(char *string, char **endptr, int maxchars, cell value); 621 | int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value) 622 | { 623 | amx_UTF8Put_t fn = ((amx_UTF8Put_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Put]; 624 | return fn(string, endptr, maxchars, value); 625 | } 626 | 627 | #endif 628 | 629 | //---------------------------------------------------------- 630 | // EOF 631 | --------------------------------------------------------------------------------