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
| HHOOK Hook_Souris;
HINSTANCE DLL_instance;
BOOL WINAPI DllMain( HINSTANCE hModule, DWORD fdwreason, LPVOID lpReserved )
{
DLL_instance = hModule;
return TRUE;
}
void dll_init_hook_souris()
{
Hook_Souris = SetWindowsHookEx(WH_MOUSE, (HOOKPROC)Souris_proc, DLL_instance, 0);
if(Hook_Souris == NULL)
{
printf("La valeur du DLL_instance est de : %d\n", DLL_instance);
printf("L'initialisation du hook souris a echouee. valeur retournee : %d \n", GetLastError());
if(GetLastError() == ERROR_INVALID_HOOK_FILTER)
printf("ERROR_INVALID_HOOK_FILTER: The hook code is invalid.\n");
if(GetLastError() == ERROR_INVALID_FILTER_PROC)
printf("ERROR_INVALID_FILTER_PROC: The filter function is invalid.\n");
if(GetLastError() == ERROR_HOOK_NEEDS_HMOD)
printf("ERROR_HOOK_NEEDS_HMOD: A global hook is being set with a NULL hInstance parameter or a thread-specific hook is being set for a thread that is not in the setting application.\n");
if(GetLastError() == ERROR_GLOBAL_ONLY_HOOK)
printf("ERROR_GLOBAL_ONLY_HOOK: A hook that can only be a system hook is being installed to a specific thread.\n");
if(GetLastError() == ERROR_INVALID_PARAMETER)
printf("ERROR_INVALID_PARAMETER: The thread ID is invalid.\n");
if(GetLastError() == ERROR_JOURNAL_HOOK_SET)
printf("ERROR_JOURNAL_HOOK_SET: There is already a hook set for a journal hook type. Only one journal record or journal playback hook can be installed at one time. This code can also be set if an application tries to set a journal hook while a screen saver is running.\n");
if(GetLastError() == ERROR_MOD_NOT_FOUND)
printf("ERROR_MOD_NOT_FOUND: The hInstance parameter for a global hook was not a library. (Actually, this value simply means that User was unable to locate the module handle in its list of modules.)\n");
}
}
LRESULT CALLBACK _export Souris_proc(int nCode,WPARAM wParam,LPARAM lParam)
{
if(wParam == WM_LBUTTONDOWN)
printf("Clic gache appuye");
return CallNextHookEx(Hook_Souris,nCode,wParam,lParam);
} |
Partager