键盘钩子无效- -无语中.~~~
用win32dll做#include<Windows.h>HHOOKg_hook=NULL;LRESULTCALLBACKKeyboardProc(intnCode,WP...
用win32 dll做
#include <Windows.h>
HHOOK g_hook = NULL;
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
//按F12弹起时呼出窗口
//BOOL bKeyUp = lParam & (1 << 31);
if (wParam == VK_F12)
{
MessageBox(0, TEXT("test"), TEXT("test"), 0);
}
return ::CallNextHookEx(g_hook, nCode, wParam ,lParam);
}
//开始拦截
bool __stdcall StartHook()
{
bool Ret = false;
g_hook = ::SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, GetModuleHandle(TEXT("ChannelDll.dll")), GetCurrentThreadId());
if (g_hook != NULL)
Ret = true;
return Ret;
}
//停止拦截
BOOL __stdcall EndHook()
{
return UnhookWindowsHookEx(g_hook);
}
BOOL APIENTRY DllMain(HANDLE hinstDLL,DWORD dwReason,LPVOID lpvReserved)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
if (StartHook())
MessageBox(0,TEXT("a"),TEXT("a"),0);
else
MessageBox(0,TEXT("b"),TEXT("b"),0);
break;
case DLL_PROCESS_DETACH:
EndHook();
break;
}
return TRUE;
}
所有代码全在这了..把这个DLL注入到目标进程后..按F12不会弹出MessageBox
不知道是什么原因..看代码.钩子.全都安装成功..有人能解答一下么 展开
#include <Windows.h>
HHOOK g_hook = NULL;
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
//按F12弹起时呼出窗口
//BOOL bKeyUp = lParam & (1 << 31);
if (wParam == VK_F12)
{
MessageBox(0, TEXT("test"), TEXT("test"), 0);
}
return ::CallNextHookEx(g_hook, nCode, wParam ,lParam);
}
//开始拦截
bool __stdcall StartHook()
{
bool Ret = false;
g_hook = ::SetWindowsHookEx(WH_KEYBOARD, KeyboardProc, GetModuleHandle(TEXT("ChannelDll.dll")), GetCurrentThreadId());
if (g_hook != NULL)
Ret = true;
return Ret;
}
//停止拦截
BOOL __stdcall EndHook()
{
return UnhookWindowsHookEx(g_hook);
}
BOOL APIENTRY DllMain(HANDLE hinstDLL,DWORD dwReason,LPVOID lpvReserved)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
if (StartHook())
MessageBox(0,TEXT("a"),TEXT("a"),0);
else
MessageBox(0,TEXT("b"),TEXT("b"),0);
break;
case DLL_PROCESS_DETACH:
EndHook();
break;
}
return TRUE;
}
所有代码全在这了..把这个DLL注入到目标进程后..按F12不会弹出MessageBox
不知道是什么原因..看代码.钩子.全都安装成功..有人能解答一下么 展开
展开全部
if (wParam == VK_F12)
{
MessageBox(0, TEXT("test"), TEXT("test"), 0);
return 1; //直接返回
}
g_hook要放到共享段中,不然下次这个dll被复制后g_hook的值是NULL。
#pragma data_seg("ShareData")
HHOOK g_hook = NULL;
#pragma data_seg()
#pragma comment(linker,"/SECTION:ShareData,RWS")
{
MessageBox(0, TEXT("test"), TEXT("test"), 0);
return 1; //直接返回
}
g_hook要放到共享段中,不然下次这个dll被复制后g_hook的值是NULL。
#pragma data_seg("ShareData")
HHOOK g_hook = NULL;
#pragma data_seg()
#pragma comment(linker,"/SECTION:ShareData,RWS")
金万码科技
2024-08-21 广告
2024-08-21 广告
巡更棒的设置涉及以下步骤:1. **巡更棒的初始化:在初次使用巡更棒时,需要配合管理软件进行初始化运行。首先开机并通过USB通信线连接到计算机上,使用巡更管理软件将巡检的人员信息和参数传输至巡更棒里面。2. 设置人员钮信息:巡更棒初始化后,...
点击进入详情页
本回答由金万码科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询