amxplugin.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. //----------------------------------------------------------
  2. //
  3. // SA:MP Multiplayer Modification For GTA:SA
  4. // Copyright 2004-2007 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. #include "plugin.h"
  31. //----------------------------------------------------------
  32. void *pAMXFunctions;
  33. //----------------------------------------------------------
  34. #if (defined(WIN32) || defined(_WIN32)) && defined(_MSC_VER)
  35. // Optimized Inline Assembly Thunks for MS VC++
  36. #define NUDE _declspec(naked)
  37. NUDE uint16_t * AMXAPI amx_Align16(uint16_t *v)
  38. {
  39. _asm mov eax, pAMXFunctions;
  40. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Align16*4];
  41. }
  42. NUDE uint32_t * AMXAPI amx_Align32(uint32_t *v)
  43. {
  44. _asm mov eax, pAMXFunctions;
  45. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Align32*4];
  46. }
  47. #if defined _I64_MAX || defined HAVE_I64
  48. NUDE uint64_t * AMXAPI amx_Align64(uint64_t *v)
  49. {
  50. _asm mov eax, pAMXFunctions;
  51. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Align64*4];
  52. }
  53. #endif
  54. NUDE int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr)
  55. {
  56. _asm mov eax, pAMXFunctions;
  57. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Allot*4];
  58. }
  59. NUDE int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
  60. {
  61. _asm mov eax, pAMXFunctions;
  62. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Callback*4];
  63. }
  64. NUDE int AMXAPI amx_Cleanup(AMX *amx)
  65. {
  66. _asm mov eax, pAMXFunctions;
  67. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Cleanup*4];
  68. }
  69. NUDE int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data)
  70. {
  71. _asm mov eax, pAMXFunctions;
  72. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Clone*4];
  73. }
  74. NUDE int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
  75. {
  76. _asm mov eax, pAMXFunctions;
  77. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Exec*4];
  78. }
  79. NUDE int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index)
  80. {
  81. _asm mov eax, pAMXFunctions;
  82. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_FindNative*4];
  83. }
  84. NUDE int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index)
  85. {
  86. _asm mov eax, pAMXFunctions;
  87. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_FindPublic*4];
  88. }
  89. NUDE int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr)
  90. {
  91. _asm mov eax, pAMXFunctions;
  92. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_FindPubVar*4];
  93. }
  94. NUDE int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname)
  95. {
  96. _asm mov eax, pAMXFunctions;
  97. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_FindTagId*4];
  98. }
  99. NUDE int AMXAPI amx_Flags(AMX *amx,uint16_t *flags)
  100. {
  101. _asm mov eax, pAMXFunctions;
  102. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Flags*4];
  103. }
  104. NUDE int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr)
  105. {
  106. _asm mov eax, pAMXFunctions;
  107. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetAddr*4];
  108. }
  109. NUDE int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname)
  110. {
  111. _asm mov eax, pAMXFunctions;
  112. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetNative*4];
  113. }
  114. NUDE int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname)
  115. {
  116. _asm mov eax, pAMXFunctions;
  117. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetPublic*4];
  118. }
  119. NUDE int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr)
  120. {
  121. _asm mov eax, pAMXFunctions;
  122. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetPubVar*4];
  123. }
  124. NUDE int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size)
  125. {
  126. _asm mov eax, pAMXFunctions;
  127. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetString*4];
  128. }
  129. NUDE int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id)
  130. {
  131. _asm mov eax, pAMXFunctions;
  132. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetTag*4];
  133. }
  134. NUDE int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr)
  135. {
  136. _asm mov eax, pAMXFunctions;
  137. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_GetUserData*4];
  138. }
  139. NUDE int AMXAPI amx_Init(AMX *amx, void *program)
  140. {
  141. _asm mov eax, pAMXFunctions;
  142. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Init*4];
  143. }
  144. NUDE int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code)
  145. {
  146. _asm mov eax, pAMXFunctions;
  147. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_InitJIT*4];
  148. }
  149. NUDE int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap)
  150. {
  151. _asm mov eax, pAMXFunctions;
  152. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_MemInfo*4];
  153. }
  154. NUDE int AMXAPI amx_NameLength(AMX *amx, int *length)
  155. {
  156. _asm mov eax, pAMXFunctions;
  157. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NameLength*4];
  158. }
  159. NUDE AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func)
  160. {
  161. _asm mov eax, pAMXFunctions;
  162. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NativeInfo*4];
  163. }
  164. NUDE int AMXAPI amx_NumNatives(AMX *amx, int *number)
  165. {
  166. _asm mov eax, pAMXFunctions;
  167. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NumNatives*4];
  168. }
  169. NUDE int AMXAPI amx_NumPublics(AMX *amx, int *number)
  170. {
  171. _asm mov eax, pAMXFunctions;
  172. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NumPublics*4];
  173. }
  174. NUDE int AMXAPI amx_NumPubVars(AMX *amx, int *number)
  175. {
  176. _asm mov eax, pAMXFunctions;
  177. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NumPubVars*4];
  178. }
  179. NUDE int AMXAPI amx_NumTags(AMX *amx, int *number)
  180. {
  181. _asm mov eax, pAMXFunctions;
  182. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_NumTags*4];
  183. }
  184. NUDE int AMXAPI amx_Push(AMX *amx, cell value)
  185. {
  186. _asm mov eax, pAMXFunctions;
  187. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Push*4];
  188. }
  189. NUDE int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells)
  190. {
  191. _asm mov eax, pAMXFunctions;
  192. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_PushArray*4];
  193. }
  194. NUDE int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar)
  195. {
  196. _asm mov eax, pAMXFunctions;
  197. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_PushString*4];
  198. }
  199. NUDE int AMXAPI amx_RaiseError(AMX *amx, int error)
  200. {
  201. _asm mov eax, pAMXFunctions;
  202. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_RaiseError*4];
  203. }
  204. NUDE int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number)
  205. {
  206. _asm mov eax, pAMXFunctions;
  207. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Register*4];
  208. }
  209. NUDE int AMXAPI amx_Release(AMX *amx, cell amx_addr)
  210. {
  211. _asm mov eax, pAMXFunctions;
  212. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_Release*4];
  213. }
  214. NUDE int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback)
  215. {
  216. _asm mov eax, pAMXFunctions;
  217. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_SetCallback*4];
  218. }
  219. NUDE int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug)
  220. {
  221. _asm mov eax, pAMXFunctions;
  222. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_SetDebugHook*4];
  223. }
  224. NUDE int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size)
  225. {
  226. _asm mov eax, pAMXFunctions;
  227. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_SetString*4];
  228. }
  229. NUDE int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr)
  230. {
  231. _asm mov eax, pAMXFunctions;
  232. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_SetUserData*4];
  233. }
  234. NUDE int AMXAPI amx_StrLen(const cell *cstring, int *length)
  235. {
  236. _asm mov eax, pAMXFunctions;
  237. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_StrLen*4];
  238. }
  239. NUDE int AMXAPI amx_UTF8Check(const char *string, int *length)
  240. {
  241. _asm mov eax, pAMXFunctions;
  242. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_UTF8Check*4];
  243. }
  244. NUDE int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value)
  245. {
  246. _asm mov eax, pAMXFunctions;
  247. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_UTF8Get*4];
  248. }
  249. NUDE int AMXAPI amx_UTF8Len(const cell *cstr, int *length)
  250. {
  251. _asm mov eax, pAMXFunctions;
  252. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_UTF8Len*4];
  253. }
  254. NUDE int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value)
  255. {
  256. _asm mov eax, pAMXFunctions;
  257. _asm jmp dword ptr [eax+PLUGIN_AMX_EXPORT_UTF8Put*4];
  258. }
  259. #else
  260. // Unoptimized Thunks (Linux/BSD/non MSVC++)
  261. typedef uint16_t * AMXAPI (*amx_Align16_t)(uint16_t *v);
  262. uint16_t * AMXAPI amx_Align16(uint16_t *v)
  263. {
  264. amx_Align16_t fn = ((amx_Align16_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align16];
  265. return fn(v);
  266. }
  267. typedef uint32_t * AMXAPI (*amx_Align32_t)(uint32_t *v);
  268. uint32_t * AMXAPI amx_Align32(uint32_t *v)
  269. {
  270. amx_Align32_t fn = ((amx_Align32_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align32];
  271. return fn(v);
  272. }
  273. #if defined _I64_MAX || defined HAVE_I64
  274. typedef uint64_t * AMXAPI (*amx_Align64_t)(uint64_t *v);
  275. uint64_t * AMXAPI amx_Align64(uint64_t *v)
  276. {
  277. amx_Align64_t fn = ((amx_Align64_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Align64];
  278. return fn(v);
  279. }
  280. #endif
  281. typedef int AMXAPI (*amx_Allot_t)(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
  282. int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr)
  283. {
  284. amx_Allot_t fn = ((amx_Allot_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Allot];
  285. return fn(amx, cells, amx_addr, phys_addr);
  286. }
  287. typedef int AMXAPI (*amx_Callback_t)(AMX *amx, cell index, cell *result, cell *params);
  288. int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params)
  289. {
  290. amx_Callback_t fn = ((amx_Callback_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Callback];
  291. return fn(amx, index, result, params);
  292. }
  293. typedef int AMXAPI (*amx_Cleanup_t)(AMX *amx);
  294. int AMXAPI amx_Cleanup(AMX *amx)
  295. {
  296. amx_Cleanup_t fn = ((amx_Cleanup_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Cleanup];
  297. return fn(amx);
  298. }
  299. typedef int AMXAPI (*amx_Clone_t)(AMX *amxClone, AMX *amxSource, void *data);
  300. int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data)
  301. {
  302. amx_Clone_t fn = ((amx_Clone_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Clone];
  303. return fn(amxClone, amxSource, data);
  304. }
  305. typedef int AMXAPI (*amx_Exec_t)(AMX *amx, cell *retval, int index);
  306. int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
  307. {
  308. amx_Exec_t fn = ((amx_Exec_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Exec];
  309. return fn(amx, retval, index);
  310. }
  311. typedef int AMXAPI (*amx_FindNative_t)(AMX *amx, const char *name, int *index);
  312. int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index)
  313. {
  314. amx_FindNative_t fn = ((amx_FindNative_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindNative];
  315. return fn(amx, name, index);
  316. }
  317. typedef int AMXAPI (*amx_FindPublic_t)(AMX *amx, const char *funcname, int *index);
  318. int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index)
  319. {
  320. amx_FindPublic_t fn = ((amx_FindPublic_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindPublic];
  321. return fn(amx, funcname, index);
  322. }
  323. typedef int AMXAPI (*amx_FindPubVar_t)(AMX *amx, const char *varname, cell *amx_addr);
  324. int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr)
  325. {
  326. amx_FindPubVar_t fn = ((amx_FindPubVar_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindPubVar];
  327. return fn(amx, varname, amx_addr);
  328. }
  329. typedef int AMXAPI (*amx_FindTagId_t)(AMX *amx, cell tag_id, char *tagname);
  330. int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname)
  331. {
  332. amx_FindTagId_t fn = ((amx_FindTagId_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_FindTagId];
  333. return fn(amx, tag_id, tagname);
  334. }
  335. typedef int AMXAPI (*amx_Flags_t)(AMX *amx,uint16_t *flags);
  336. int AMXAPI amx_Flags(AMX *amx,uint16_t *flags)
  337. {
  338. amx_Flags_t fn = ((amx_Flags_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Flags];
  339. return fn(amx,flags);
  340. }
  341. typedef int AMXAPI (*amx_GetAddr_t)(AMX *amx,cell amx_addr,cell **phys_addr);
  342. int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr)
  343. {
  344. amx_GetAddr_t fn = ((amx_GetAddr_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetAddr];
  345. return fn(amx,amx_addr,phys_addr);
  346. }
  347. typedef int AMXAPI (*amx_GetNative_t)(AMX *amx, int index, char *funcname);
  348. int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname)
  349. {
  350. amx_GetNative_t fn = ((amx_GetNative_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetNative];
  351. return fn(amx, index, funcname);
  352. }
  353. typedef int AMXAPI (*amx_GetPublic_t)(AMX *amx, int index, char *funcname);
  354. int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname)
  355. {
  356. amx_GetPublic_t fn = ((amx_GetPublic_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetPublic];
  357. return fn(amx, index, funcname);
  358. }
  359. typedef int AMXAPI (*amx_GetPubVar_t)(AMX *amx, int index, char *varname, cell *amx_addr);
  360. int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr)
  361. {
  362. amx_GetPubVar_t fn = ((amx_GetPubVar_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetPubVar];
  363. return fn(amx, index, varname, amx_addr);
  364. }
  365. typedef int AMXAPI (*amx_GetString_t)(char *dest,const cell *source, int use_wchar, size_t size);
  366. int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size)
  367. {
  368. amx_GetString_t fn = ((amx_GetString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetString];
  369. return fn(dest,source, use_wchar, size);
  370. }
  371. typedef int AMXAPI (*amx_GetTag_t)(AMX *amx, int index, char *tagname, cell *tag_id);
  372. int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id)
  373. {
  374. amx_GetTag_t fn = ((amx_GetTag_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetTag];
  375. return fn(amx, index, tagname, tag_id);
  376. }
  377. typedef int AMXAPI (*amx_GetUserData_t)(AMX *amx, long tag, void **ptr);
  378. int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr)
  379. {
  380. amx_GetUserData_t fn = ((amx_GetUserData_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_GetUserData];
  381. return fn(amx, tag, ptr);
  382. }
  383. typedef int AMXAPI (*amx_Init_t)(AMX *amx, void *program);
  384. int AMXAPI amx_Init(AMX *amx, void *program)
  385. {
  386. amx_Init_t fn = ((amx_Init_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Init];
  387. return fn(amx, program);
  388. }
  389. typedef int AMXAPI (*amx_InitJIT_t)(AMX *amx, void *reloc_table, void *native_code);
  390. int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code)
  391. {
  392. amx_InitJIT_t fn = ((amx_InitJIT_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_InitJIT];
  393. return fn(amx, reloc_table, native_code);
  394. }
  395. typedef int AMXAPI (*amx_MemInfo_t)(AMX *amx, long *codesize, long *datasize, long *stackheap);
  396. int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap)
  397. {
  398. amx_MemInfo_t fn = ((amx_MemInfo_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_MemInfo];
  399. return fn(amx, codesize, datasize, stackheap);
  400. }
  401. typedef int AMXAPI (*amx_NameLength_t)(AMX *amx, int *length);
  402. int AMXAPI amx_NameLength(AMX *amx, int *length)
  403. {
  404. amx_NameLength_t fn = ((amx_NameLength_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NameLength];
  405. return fn(amx, length);
  406. }
  407. typedef AMX_NATIVE_INFO * AMXAPI (*amx_NativeInfo_t)(const char *name, AMX_NATIVE func);
  408. AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func)
  409. {
  410. amx_NativeInfo_t fn = ((amx_NativeInfo_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NativeInfo];
  411. return fn(name, func);
  412. }
  413. typedef int AMXAPI (*amx_NumNatives_t)(AMX *amx, int *number);
  414. int AMXAPI amx_NumNatives(AMX *amx, int *number)
  415. {
  416. amx_NumNatives_t fn = ((amx_NumNatives_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumNatives];
  417. return fn(amx, number);
  418. }
  419. typedef int AMXAPI (*amx_NumPublics_t)(AMX *amx, int *number);
  420. int AMXAPI amx_NumPublics(AMX *amx, int *number)
  421. {
  422. amx_NumPublics_t fn = ((amx_NumPublics_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumPublics];
  423. return fn(amx, number);
  424. }
  425. typedef int AMXAPI (*amx_NumPubVars_t)(AMX *amx, int *number);
  426. int AMXAPI amx_NumPubVars(AMX *amx, int *number)
  427. {
  428. amx_NumPubVars_t fn = ((amx_NumPubVars_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumPubVars];
  429. return fn(amx, number);
  430. }
  431. typedef int AMXAPI (*amx_NumTags_t)(AMX *amx, int *number);
  432. int AMXAPI amx_NumTags(AMX *amx, int *number)
  433. {
  434. amx_NumTags_t fn = ((amx_NumTags_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_NumTags];
  435. return fn(amx, number);
  436. }
  437. typedef int AMXAPI (*amx_Push_t)(AMX *amx, cell value);
  438. int AMXAPI amx_Push(AMX *amx, cell value)
  439. {
  440. amx_Push_t fn = ((amx_Push_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Push];
  441. return fn(amx, value);
  442. }
  443. typedef int AMXAPI (*amx_PushArray_t)(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells);
  444. int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells)
  445. {
  446. amx_PushArray_t fn = ((amx_PushArray_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_PushArray];
  447. return fn(amx, amx_addr, phys_addr, array, numcells);
  448. }
  449. typedef int AMXAPI (*amx_PushString_t)(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar);
  450. int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar)
  451. {
  452. amx_PushString_t fn = ((amx_PushString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_PushString];
  453. return fn(amx, amx_addr, phys_addr, string, pack, use_wchar);
  454. }
  455. typedef int AMXAPI (*amx_RaiseError_t)(AMX *amx, int error);
  456. int AMXAPI amx_RaiseError(AMX *amx, int error)
  457. {
  458. amx_RaiseError_t fn = ((amx_RaiseError_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_RaiseError];
  459. return fn(amx, error);
  460. }
  461. typedef int AMXAPI (*amx_Register_t)(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number);
  462. int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number)
  463. {
  464. amx_Register_t fn = ((amx_Register_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Register];
  465. return fn(amx, nativelist, number);
  466. }
  467. typedef int AMXAPI (*amx_Release_t)(AMX *amx, cell amx_addr);
  468. int AMXAPI amx_Release(AMX *amx, cell amx_addr)
  469. {
  470. amx_Release_t fn = ((amx_Release_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_Release];
  471. return fn(amx, amx_addr);
  472. }
  473. typedef int AMXAPI (*amx_SetCallback_t)(AMX *amx, AMX_CALLBACK callback);
  474. int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback)
  475. {
  476. amx_SetCallback_t fn = ((amx_SetCallback_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetCallback];
  477. return fn(amx, callback);
  478. }
  479. typedef int AMXAPI (*amx_SetDebugHook_t)(AMX *amx, AMX_DEBUG debug);
  480. int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug)
  481. {
  482. amx_SetDebugHook_t fn = ((amx_SetDebugHook_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetDebugHook];
  483. return fn(amx, debug);
  484. }
  485. typedef int AMXAPI (*amx_SetString_t)(cell *dest, const char *source, int pack, int use_wchar, size_t size);
  486. int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size)
  487. {
  488. amx_SetString_t fn = ((amx_SetString_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetString];
  489. return fn(dest, source, pack, use_wchar, size);
  490. }
  491. typedef int AMXAPI (*amx_SetUserData_t)(AMX *amx, long tag, void *ptr);
  492. int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr)
  493. {
  494. amx_SetUserData_t fn = ((amx_SetUserData_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_SetUserData];
  495. return fn(amx, tag, ptr);
  496. }
  497. typedef int AMXAPI (*amx_StrLen_t)(const cell *cstring, int *length);
  498. int AMXAPI amx_StrLen(const cell *cstring, int *length)
  499. {
  500. amx_StrLen_t fn = ((amx_StrLen_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_StrLen];
  501. return fn(cstring, length);
  502. }
  503. typedef int AMXAPI (*amx_UTF8Check_t)(const char *string, int *length);
  504. int AMXAPI amx_UTF8Check(const char *string, int *length)
  505. {
  506. amx_UTF8Check_t fn = ((amx_UTF8Check_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Check];
  507. return fn(string, length);
  508. }
  509. typedef int AMXAPI (*amx_UTF8Get_t)(const char *string, const char **endptr, cell *value);
  510. int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value)
  511. {
  512. amx_UTF8Get_t fn = ((amx_UTF8Get_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Get];
  513. return fn(string, endptr, value);
  514. }
  515. typedef int AMXAPI (*amx_UTF8Len_t)(const cell *cstr, int *length);
  516. int AMXAPI amx_UTF8Len(const cell *cstr, int *length)
  517. {
  518. amx_UTF8Len_t fn = ((amx_UTF8Len_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Len];
  519. return fn(cstr, length);
  520. }
  521. typedef int AMXAPI (*amx_UTF8Put_t)(char *string, char **endptr, int maxchars, cell value);
  522. int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value)
  523. {
  524. amx_UTF8Put_t fn = ((amx_UTF8Put_t*)pAMXFunctions)[PLUGIN_AMX_EXPORT_UTF8Put];
  525. return fn(string, endptr, maxchars, value);
  526. }
  527. #endif
  528. //----------------------------------------------------------
  529. // EOF