Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "amx.h"
- #include "plugincommon.h"
- #include <windows.h>
- typedef void (*logprintf_t)(char* format, ...);
- logprintf_t logprintf;
- void **ppPluginData;
- extern void *pAMXFunctions;
- AMX *gMachines[51];
- PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports()
- {
- return SUPPORTS_VERSION | SUPPORTS_AMX_NATIVES;
- }
- void Call(DWORD from, DWORD to)
- {
- DWORD oldp, newp, disp;
- disp = to - (from + 5);
- VirtualProtect((LPVOID)from, 5, PAGE_EXECUTE_READWRITE, &oldp);
- *(PBYTE)(from) = 0xE8;
- *(PDWORD)(from + 1) = (DWORD)disp;
- VirtualProtect((LPVOID)from, 5, oldp, &newp);
- }
- void OnModifiedPacket(char *string, int playerid, char *ip)
- {
- cell retval;
- for(short i = 0; i < sizeof gMachines; ++i)
- {
- if(gMachines[i])
- {
- int index;
- if(amx_FindPublic(gMachines[i], "OnModifiedPacket", &index) == AMX_ERR_NONE)
- {
- amx_Push(gMachines[i], (cell)playerid);
- amx_Exec(gMachines[i], &retval, index);
- }
- }
- }
- if(retval)
- {
- logprintf(string, playerid, ip);
- }
- }
- PLUGIN_EXPORT bool PLUGIN_CALL Load(void **ppData)
- {
- pAMXFunctions = ppData[PLUGIN_DATA_AMX_EXPORTS];
- logprintf = (logprintf_t)ppData[PLUGIN_DATA_LOGPRINTF];
- Call(0x0049B801, (DWORD)OnModifiedPacket);
- logprintf("Anti-packet-modifier by Flavio Toribio loaded.");
- return true;
- }
- PLUGIN_EXPORT void PLUGIN_CALL Unload()
- {
- logprintf("Anti-packet-modifier by Flavio Toribio unloaded.");
- }
- PLUGIN_EXPORT int PLUGIN_CALL AmxLoad(AMX *amx)
- {
- for(short i = 0; i < sizeof gMachines; ++i)
- {
- if(!gMachines[i])
- {
- gMachines[i] = amx;
- break;
- }
- }
- return AMX_ERR_NONE;
- }
- PLUGIN_EXPORT int PLUGIN_CALL AmxUnload(AMX *amx)
- {
- for(short i = 0; i < sizeof gMachines; ++i)
- {
- if(gMachines[i] == amx)
- {
- gMachines[i] = NULL;
- break;
- }
- }
- return AMX_ERR_NONE;
- }
Add Comment
Please, Sign In to add comment