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
| #include <windows.h>
HINSTANCE thismod;
HINSTANCE hInstance;
HHOOK hhk;
HWND hDlg;
HWND Dlg;
char fenetre[256];
BOOL WINAPI DllMain(HINSTANCE hDll, DWORD dwReason, LPVOID Reserved)
{
if(dwReason == DLL_PROCESS_ATTACH)
thismod = hDll;
return 1;
}
LRESULT CALLBACK kbdWinAmp(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode >= 0)
{
//quand une fenetre est activé
if(nCode == HCBT_ACTIVATE)
{
if (hDlg = FindWindow(fenetre,NULL))
{
if (Dlg=FindWindow(NULL,"Protection activée"))
PostMessage(Dlg, WM_USER+1, 0, 0);
}
}
}
return CallNextHookEx(hhk, nCode, wParam, lParam);
}
extern "C" __declspec(dllexport) int __stdcall Intercepte(char programme[256])
{
if(!hhk)
hhk = SetWindowsHookEx(WH_CBT, kbdWinAmp, thismod, 0);
strcpy(fenetre,programme);
return (int) hhk;
}
extern "C" __declspec(dllexport) void __stdcall FinIntercepte()
{
if(hhk)
{
UnhookWindowsHookEx(hhk);
hhk = 0;
}
} |