Advertisement
adri1

Untitled

Nov 23rd, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. /*
  2. TDE2 plugin
  3. By adri1
  4. */
  5.  
  6. #define PLUGIN_VERSION "0.1"
  7.  
  8. #include <Windows.h>
  9. #include "../SDK/plugin.h"
  10.  
  11. typedef void (*logprintf_t)(char* format, ...);
  12. logprintf_t logprintf;
  13. void **ppPluginData;
  14. extern void *pAMXFunctions;
  15.  
  16. PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
  17. {
  18. pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
  19. logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];
  20.  
  21. logprintf("--- TDE2 plugin %s loaded ---\n", PLUGIN_VERSION);
  22. return 1;
  23. }
  24.  
  25. PLUGIN_EXPORT void PLUGIN_CALL Unload()
  26. {
  27. }
  28.  
  29. /* NATIVES */
  30. static cell AMX_NATIVE_CALL GetVirtualKeyState(AMX*amx, cell*params)
  31. {
  32. return GetAsyncKeyState(params[1]);
  33. }
  34.  
  35. static cell AMX_NATIVE_CALL GetKeyState(AMX*amx, cell*params)
  36. {
  37. return GetKeyState(params[1]);
  38. }
  39.  
  40. static cell AMX_NATIVE_CALL SendKeyboardInput(AMX*amx, cell*params)
  41. {
  42. INPUT input;
  43. input.type = INPUT_KEYBOARD;
  44. input.ki.wVk = params[1];
  45. input.ki.dwFlags = KEYEVENTF_KEYUP;
  46. return SendInput(1, &input, sizeof(INPUT));
  47. }
  48.  
  49. static cell AMX_NATIVE_CALL GetScreenSize(AMX*amx, cell*params)
  50. {
  51. RECT screen;
  52. GetWindowRect(GetDesktopWindow(), &screen);
  53. float width = (float)screen.right;
  54. float height = (float)screen.bottom;
  55.  
  56. cell* addr[2] = { NULL, NULL };
  57. amx_GetAddr(amx, params[1], &addr[0]);
  58. amx_GetAddr(amx, params[2], &addr[1]);
  59. *addr[0] = amx_ftoc(width);
  60. *addr[1] = amx_ftoc(height);
  61. return 1;
  62. }
  63.  
  64. static cell AMX_NATIVE_CALL GetMousePos(AMX*amx, cell*params)
  65. {
  66. POINT cursor;
  67. GetCursorPos(&cursor);
  68. float x = (float)cursor.x;
  69. float y = (float)cursor.y;
  70.  
  71. cell* addr[2] = { NULL, NULL };
  72. amx_GetAddr(amx, params[1], &addr[0]);
  73. amx_GetAddr(amx, params[2], &addr[1]);
  74. *addr[0] = amx_ftoc(x);
  75. *addr[1] = amx_ftoc(y);
  76. return 1;
  77. }
  78.  
  79. AMX_NATIVE_INFO projectNatives[] =
  80. {
  81. { "GetVirtualKeyState", GetVirtualKeyState },
  82. { "GetKeyState", GetKeyState },
  83. { "SendKeyboardInput", SendKeyboardInput },
  84. { "GetScreenSize", GetScreenSize },
  85. { "GetMousePos", GetMousePos },
  86. { 0, 0 }
  87. };
  88.  
  89. PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
  90. {
  91. return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
  92. }
  93.  
  94. PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
  95. {
  96. return amx_Register(amx, projectNatives, -1);
  97. }
  98.  
  99. PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
  100. {
  101. return AMX_ERR_NONE;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement