gamerfunkie
Erfahrenes Mitglied
Hallo,
ich habe eine DLL programmiert die sich in die HookChain einklinkt und dann über :
ostMessage() eine Information über einen tastendruck an mein programm sendet.
leider werden nur hooks empfangen, wenn sie zur anwendung gehören,also keine globalen hooks.
Hoffentlich könnt ihr mir helfen.
ich habe eine DLL programmiert die sich in die HookChain einklinkt und dann über :

Code:
#define BUILDING_DLL
#include "dll.h"
// Globale Variablen
#pragma comment(linker, "/SECTION:.HOOKDATA,RWS")
#pragma data_seg(".shr")
HHOOK g_hKeyboardHook = NULL; // Handle unseres Hooks (als "shared" Deklariert)
HHOOK g_hMouseHook = NULL; // Handle unseres Hooks (als "shared" Deklariert)
HINSTANCE g_hInst = NULL; // Handle der DLL selbst
#pragma data_seg()
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
g_hInst = hInst;
return TRUE;
}
DLLIMPORT BOOL InstallHook()
{
if(g_hKeyboardHook != NULL)
return TRUE;
if(g_hMouseHook != NULL)
return TRUE;
g_hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, g_hInst, NULL);
g_hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseProc, g_hInst, NULL);
if(g_hKeyboardHook == NULL)
return FALSE;
if(g_hMouseHook == NULL)
return FALSE;
return TRUE;
}
DLLIMPORT BOOL UninstallHook()
{
if(g_hKeyboardHook != NULL)
{
UnhookWindowsHookEx(g_hKeyboardHook);
g_hKeyboardHook = NULL;
}
if(g_hMouseHook != NULL)
{
UnhookWindowsHookEx(g_hMouseHook);
g_hMouseHook = NULL;
}
return TRUE;
}
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode >= 0)
{
HWND hwnd = FindWindowA(NULL,"hook_test_app");
PostMessage(hwnd,WM_USER+wParam,wParam,lParam);
}
return CallNextHookEx(g_hKeyboardHook, nCode, wParam, lParam);
}
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode >= 0)
{
HWND hwnd = FindWindowA(NULL,"hook_test_app");
//PostMessage(hwnd,WM_USER+wParam,wParam,lParam);
}
return CallNextHookEx(g_hMouseHook, nCode, wPaporam, lParam);
}
p
leider werden nur hooks empfangen, wenn sie zur anwendung gehören,also keine globalen hooks.
Hoffentlich könnt ihr mir helfen.