need help really bad please
HI. I am in a bit of a spot, I have some trouble. I have to make this program that blocks all keyboard and mouse input from all active windows exept one, the one window where the keyboard and mouse input are not blocked is the one where you are supposed to enter a password and if this password is correct you can unlock the other windows as well(they will once again be able to recieve keyboard and mouse input).I am using windows hooks(if you know another way I am all ears). So my problem is that after the user inserts the correct password and clicks ok the program terminates but the hooks that have been set on the other windows still run so even after the user inserts the correct pass he still can't work with the windows that have been activated during the time that the program has been active.
ok, so I am using to dlls and a main program, one dll is for the keyboard hook, one is for the mouse hook and one for the mouse hook, I am only going to post about the mouse hook because I think this is the most important one of them all.
Code:
#include "a.h"
#include <stdio.h>
#include <stdlib.h>
#include <process.h>
#include <windef.h>
static BOOL bHooked = FALSE;
DWORD tid1=0;
BOOL still_hook;
static mouse=0,CBT=0;
static HINSTANCE hInst;
static int count;
int c=0;
HHOOK hookuri[100];
DWORD iduri[100];
LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam);
LRESULT CALLBACK MouseProc(int code, WPARAM wParam, LPARAM lParam);
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason, LPVOID lpvReserved)
{
int i;
for(i=0;i<101;i++)
{
hookuri[i]=NULL;
iduri[i]=0;
}
switch (fdwReason)
{
case DLL_PROCESS_ATTACH:
hInst=hinstDLL;
count=0;
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
default:
break;
}
return TRUE;
}
DLL_EXPORT void OpresteMousu(void)
{
if(!bHooked)
{
CBT = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTProc, hInst, (DWORD)NULL);
bHooked = TRUE;
}
}
DLL_EXPORT void PornesteMousu(void)
{
UnhookWindowsHookEx(mouse);
UnhookWindowsHookEx(CBT);
}
LRESULT CALLBACK CBTProc(int code, WPARAM wParam, LPARAM lParam)
{
char x[100];
DWORD tid;
int q;
if(code==HCBT_ACTIVATE)
{
tid = GetWindowThreadProcessId(wParam, NULL);
GetWindowText((HWND)wParam,x,100);
if(!(_stricmp(x,"Criognia password window")==0))
{
if (tid!=tid1)
{
UnhookWindowsHookEx(mouse);
mouse= SetWindowsHookEx(WH_CBT, (HOOKPROC)MouseProc, hInst, tid);
tid1=tid;
}
}
}
return CallNextHookEx(CBT, code, wParam, lParam);
}
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode == HC_ACTION)
{
if (wParam == WM_LBUTTONDOWN)
Beep(500, 200);
}
return nCode < 0 ? CallNextHookEx(mouse, nCode, wParam, lParam) : -1;
}
please help
this project I have to do by next tuesday
thank you in advance
If I don't do it I may not get my 10(the equivalent of an A in america I should think)