12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- // dllmain.cpp : 定义 DLL 应用程序的入口点。
- #include "stdafx.h"
- HHOOK g_hook = NULL;
- LRESULT CALLBACK Hook_CBT_Proc(int nCode, WPARAM wParam, LPARAM lParam)
- {
- tagMSG* msg;
- msg = (tagMSG*)lParam;
- if (nCode == HCBT_MINMAX)
- {
- WriteTextLog(_T("窗口HCBT_MINMAX"));
- return 1;
- }
- return CallNextHookEx(g_hook, nCode, wParam, lParam);
- }
- BOOL APIENTRY DllMain(HMODULE hModule,
- DWORD ul_reason_for_call,
- LPVOID lpReserved
- )
- {
- g_hCurModule = hModule;
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- {
- if (g_hook == NULL)
- g_hook = SetWindowsHookEx(WH_CBT, Hook_CBT_Proc, NULL, ::GetCurrentThreadId());
- WriteTextLog(_T("dll已成功注入:%d,%d"), ::GetCurrentThreadId(), ::GetCurrentProcessId());
- WxInfo wxInfo;
- GetWxInfo(wxInfo);
- }
- break;
- case DLL_THREAD_ATTACH:
- break;
- case DLL_THREAD_DETACH:
- break;
- case DLL_PROCESS_DETACH:
- if (g_hook)
- UnhookWindowsHookEx(g_hook);
- WriteTextLog(_T("dll已成功卸载"));
- break;
- default:
- break;
- }
- return TRUE;
- }
|