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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
DTIToolsExport BOOL HOOK_Init(void)
{
// Initialisation
g_Memory = NULL;
g_hMemShare = NULL;
// Get share memory
if((g_Memory = sHOOK_GetShareMem(&g_hMemShare)) == NULL)
EXIT(ERROR);
// Get system windows handle
g_Memory->ProcessID = GetCurrentProcessId();
g_Memory->hShell_TrayWnd = FindWindowEx(NULL,NULL,"Shell_TrayWnd",NULL);
g_Memory->hReBarWindow32 = FindWindowEx(g_Memory->hShell_TrayWnd,NULL,"ReBarWindow32",NULL);
g_Memory->hMSTaskSwWClass = FindWindowEx(g_Memory->hReBarWindow32,NULL,"MSTaskSwWClass",NULL);
g_Memory->hSysTabControl32 = FindWindowEx(g_Memory->hMSTaskSwWClass,NULL,"SysTabControl32",NULL);
// Set new hook
if((g_Memory->hHook = SetWindowsHookEx(WH_CBT,sHOOK_Proc,g_hInstance,0)) == NULL)
EXIT(ERROR);
FlushViewOfFile(g_Memory,sizeof(SHAREMEM));
return(TRUE);
ON_EXIT(ERROR)
return(FALSE);
}
LRESULT WINAPI sHOOK_Proc(int nCode,WPARAM wParam,LPARAM lParam)
{
SHAREMEM *ShareMem;
HHOOK hHook;
HANDLE hShareMem;
// Initialisation
if((ShareMem = sHOOK_GetShareMem(&hShareMem)) == NULL)
EXIT(ERROR);
hHook = ShareMem->hHook;
// ... le code du hook, j'ai le même problème si je le mets en commentaire, alors je l'ai enlevé pour être plus facile à lire.
sHOOK_ReleaseShareMem(&ShareMem,&hShareMem);
return(CallNextHookEx(hHook,nCode,wParam,lParam));
ON_EXIT(ERROR)
return(0);
} |
Partager