* add svn ignore
[ezgdi.git] / contrib / msgbeep.cpp
blob163dd729420ca67b7f0aee98c27b0b0564ddb27b
1 #include <easyhook.h>
2 #include <stdio.h>
4 HOOK_TRACE_INFO hinfo = {NULL};
5 ULONG acl_entries[128] = {};
6 int thread_num = 0;
8 BOOL WINAPI MessageBeep_hook(UINT type)
10 printf("Beep!\n");
11 return TRUE;
14 void hook_install()
16 LhInstallHook(MessageBeep, MessageBeep_hook, 0, &hinfo);
19 void hook_uninstall()
21 LhUninstallAllHooks();
22 LhWaitForPendingRemovals();
25 void hook_enable_thread()
27 LhSetInclusiveACL(acl_entries, ++thread_num, &hinfo);
30 BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID)
32 switch(reason) {
33 case DLL_PROCESS_ATTACH:
34 hook_install();
35 /* go through to enable current thread */
36 case DLL_THREAD_ATTACH:
37 hook_enable_thread();
38 break;
39 case DLL_THREAD_DETACH:
40 break;
41 case DLL_PROCESS_DETACH:
42 hook_uninstall();
44 return TRUE;