关于dll注入的hook

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/lj820348789/article/details/42643263
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam){
OutputDebugString(L"---------------------------事件");
return CallNextHookEx(hookResult, nCode, wParam, lParam);
};


BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD dwReason, void* lpReserved)
{
    HINSTANCE g_hModule;
    switch(dwReason)
    {
    case DLL_THREAD_ATTACH:
{
g_hModule = hModule;
HWND h=FindWindow(NULL, L"333");
DWORD id;
LPDWORD pid=&id;
hookResult = SetWindowsHookEx(WH_KEYBOARD,MouseProc,hModule,GetWindowThreadProcessId(h,pid));
if (hookResult == 0)
{
OutputDebugString(L"---------------------------失败");
}
else
{
//MessageBox(NULL, L"成功", L"失败", 0);
OutputDebugString(L"---------------------------成功");
}
}
break;
    case DLL_PROCESS_DETACH:
       std::cout<<"Dll is detached!"<<std::endl;
       g_hModule=NULL;
       break;
    }


    return true;

}

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页