1 #include <metahook.h> 2 3 struct event_hook_t 4 { 5 event_hook_t *next; 6 char *name; 7 void (*pfnEvent)(event_args_s *args); 8 }; 9 10 #define HOOKEVENT_SIG "x8Dx44x24x08x56x8Dx4Cx24x08x50x51xFFx15x2Ax2Ax2Ax2Ax8Bx44x24x10x83xC4x08x85xC0x74x2Ax80x38x00" 11 12 event_hook_t *g_pEventHooks = NULL; 13 14 void EV_Init(void) 15 { 16 DWORD base = (DWORD)g_pMetaHookAPI->SearchPattern((void *)g_dwEngineBase, g_dwEngineSize, HOOKEVENT_SIG, sizeof(HOOKEVENT_SIG) - 1); 17 18 if (base) 19 { 20 g_pEventHooks = (event_hook_t *)(*(DWORD *)(base + 0x72)); 21 } 22 } 23 24 event_hook_t *EV_FindHook(const char *name) 25 { 26 if (!g_pEventHooks) 27 { 28 return NULL; 29 } 30 31 event_hook_t *ev = g_pEventHooks; 32 33 while (ev) 34 { 35 if (ev->name && !stricmp(name, ev->name)) 36 { 37 return ev; 38 } 39 40 ev = ev->next; 41 } 42 43 return NULL; 44 }