逆向 | hook WM_PAINT消息进行绘制

hook WM_PAINT消息进行绘制

采用dll注入的方式(有bug还挺严重的,搞不定了md)

dll:

HHOOK g_hHook = NULL;
// hook后用来重绘的过程函数
LRESULT CALLBACK CallWndProc(int nCode,
							WPARAM wParam,
							LPARAM lParam){
	CWPSTRUCT* msg = (CWPSTRUCT*)lParam;
	if(msg->message == WM_PAINT)
	{
		//....
	}
	return CallNextHookEx(g_hHook, nCode, wParam, lParam);   // 传递消息给下面的处理函数
}
void hook_wm_paint(){
	HHOOK hhook;
	// 尝试注册消息钩子
	hhook = SetWindowsHookEx(WH_CALLWNDPROC, 
		CallWndProc,
		GetModuleHandle("apparent.dll"), 0);
	if (hhook == NULL)
	{
		char a[20] = {0};
		sprintf(a, "hook err: %d", GetLastError());
		MessageBox(0,a, 0, 0);
	}else{
		g_hHook = hhook;
	}
}

调用hook_wm_paint函数实现注册hook

posted @ 2021-10-12 15:37  Mz1  阅读(249)  评论(0编辑  收藏  举报