1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include "../MQ2Plugin.h" //include file required for all MQ2 plugins
#define __SendPacket 0x624550
typedef struct _SendOp {
WORD opcode;
} SendOp;
BOOL PluginsSendPacket(DWORD Type, DWORD Packet, DWORD Size) {
typedef BOOL (__cdecl *fMQSendPacket)(DWORD, DWORD, DWORD);
bool bSend = true;
PMQPLUGIN pPlugin = pPlugins;
while(pPlugin) {
fMQSendPacket SendPacket = (fMQSendPacket)GetProcAddress(pPlugin->hModule, "OnSendPacket");
if (SendPacket)
if (!SendPacket(Type, Packet, Size)) bSend = false;
pPlugin = pPlugin->pNext;
}
return bSend;
}
class Packets {
public:
DWORD SendTramp(DWORD,DWORD,DWORD);
DWORD SendDetour(DWORD flag,DWORD pkt, DWORD size)
{
GOpcode *opst = (GOpcode *)pkt;
if (PluginsSendPacket((DWORD)opst->opcode,pkt,size)) {
return(SendTramp(flag,pkt,size));
} else {
return(12);
}
}
};
DETOUR_TRAMPOLINE_EMPTY(DWORD Packets::SendTramp(DWORD,DWORD,DWORD));
// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
DebugSpewAlways("Initializing MQ2PacketAPI");
EzDetour(__SendPacket,&Packets::SendDetour,&Packets::SendTramp);
}
|