⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kbhookdll.cpp

📁 wince 下的hook 程序 进行系统 GetMessage的拦截
💻 CPP
字号:
// kbhookdll.cpp : Defines the entry point for the DLL application.
//

#include "stdafx.h"
#include "kbhookdll.h"
#include "winceKBhook.h"
HANDLE hMod;
BOOL APIENTRY DllMain( HANDLE hModule, 
                       DWORD  ul_reason_for_call, 
                       LPVOID lpReserved
					 )
{
	hMod=hModule;
    switch (ul_reason_for_call)
	{
		case DLL_PROCESS_ATTACH:
		case DLL_THREAD_ATTACH:
		case DLL_THREAD_DETACH:
		case DLL_PROCESS_DETACH:
			break;
    }
    return TRUE;
}


// This is an example of an exported variable
KBHOOKDLL_API int nKbhookdll=0;

// This is an example of an exported function.
KBHOOKDLL_API int fnKbhookdll(void)
{
	return 42;
}

// This is the constructor of a class that has been exported.
// see kbhookdll.h for the class definition
CKbhookdll::CKbhookdll()
{ 
	return; 
}

HHOOK Hook; 
LRESULT CALLBACK LauncherHook(int nCode,WPARAM wParam,LPARAM lParam); 
DllExport void WINAPI InstallLaunchEv() 
{ 
	/*
	Hook=(HHOOK)SetWindowsHookEx(WH_GETMESSAGE, 
		(HOOKPROC)LauncherHook, 
		hMod, 
		0); 
		*/
	if(!ActivateKBHook((HINSTANCE)hMod, LauncherHook))
	{
		MessageBox(GetActiveWindow(), 
			TEXT("Couldn't intall hook...Terminating"), 
			TEXT("Warning"), NULL);
		PostQuitMessage(0);
	}
} 
bool show9=false;
LRESULT CALLBACK LauncherHook(int nCode,WPARAM wParam,LPARAM lParam) 
{ 
	LRESULT Result=CallNextHookEx(Hook,nCode,wParam,lParam); 
	
	if(nCode==HC_ACTION) 
	{ 
		//if(wParam==PM_REMOVE){
			MSG *pMsg=(MSG*)lParam;
			if(pMsg->message==WM_CHAR){
				//SaveLog("in wm_char \n");
				if(pMsg->wParam=='9'){
					if(!show9){
						//SaveLog("show9 is false\n");
						keybd_event(VK_BACK,0,0,0);
					}else{
						//SaveLog("show9 is true\n");
					}
					//SaveLog("show9 is set to false\n");
					show9=false;
				}else if(pMsg->wParam=='`'){
					keybd_event(VK_BACK,0,0,0);
					show9=true;
					//SaveLog("set show9 to true when ` is press\n");
					keybd_event('9',0,0,0);
				}else if(pMsg->wParam==VK_BACK){
					//do not deal with back space
				}else{
					//SaveLog("set show9 to false when other char is press\n");
					show9=false;
				}
			}
		//}
	} 
	return Result; 
	//return 0;
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -