Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- TDE2 plugin
- By adri1
- */
- #define PLUGIN_VERSION "0.1"
- #include <Windows.h>
- #include "../SDK/plugin.h"
- typedef void (*logprintf_t)(char* format, ...);
- logprintf_t logprintf;
- void **ppPluginData;
- extern void *pAMXFunctions;
- PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
- {
- pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
- logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];
- logprintf("--- TDE2 plugin %s loaded ---\n", PLUGIN_VERSION);
- return 1;
- }
- PLUGIN_EXPORT void PLUGIN_CALL Unload()
- {
- }
- /* NATIVES */
- static cell AMX_NATIVE_CALL GetVirtualKeyState(AMX*amx, cell*params)
- {
- return GetAsyncKeyState(params[1]);
- }
- static cell AMX_NATIVE_CALL GetKeyState(AMX*amx, cell*params)
- {
- return GetKeyState(params[1]);
- }
- static cell AMX_NATIVE_CALL SendKeyboardInput(AMX*amx, cell*params)
- {
- INPUT input;
- input.type = INPUT_KEYBOARD;
- input.ki.wVk = params[1];
- input.ki.dwFlags = KEYEVENTF_KEYUP;
- return SendInput(1, &input, sizeof(INPUT));
- }
- static cell AMX_NATIVE_CALL GetScreenSize(AMX*amx, cell*params)
- {
- RECT screen;
- GetWindowRect(GetDesktopWindow(), &screen);
- float width = (float)screen.right;
- float height = (float)screen.bottom;
- cell* addr[2] = { NULL, NULL };
- amx_GetAddr(amx, params[1], &addr[0]);
- amx_GetAddr(amx, params[2], &addr[1]);
- *addr[0] = amx_ftoc(width);
- *addr[1] = amx_ftoc(height);
- return 1;
- }
- static cell AMX_NATIVE_CALL GetMousePos(AMX*amx, cell*params)
- {
- POINT cursor;
- GetCursorPos(&cursor);
- float x = (float)cursor.x;
- float y = (float)cursor.y;
- cell* addr[2] = { NULL, NULL };
- amx_GetAddr(amx, params[1], &addr[0]);
- amx_GetAddr(amx, params[2], &addr[1]);
- *addr[0] = amx_ftoc(x);
- *addr[1] = amx_ftoc(y);
- return 1;
- }
- AMX_NATIVE_INFO projectNatives[] =
- {
- { "GetVirtualKeyState", GetVirtualKeyState },
- { "GetKeyState", GetKeyState },
- { "SendKeyboardInput", SendKeyboardInput },
- { "GetScreenSize", GetScreenSize },
- { "GetMousePos", GetMousePos },
- { 0, 0 }
- };
- PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
- {
- return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
- }
- PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
- {
- return amx_Register(amx, projectNatives, -1);
- }
- PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
- {
- return AMX_ERR_NONE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement