- 性别
- 保密
- 积分
- 100
- 积分
- 106
- 精华
- 0
- 阅读权限
- 20
- 注册时间
- 2013-6-24
- 最后登录
- 2013-9-13
- 帖子
- 1
- 性别
- 保密
|
本帖最后由 sky_yx 于 2015-12-30 14:16 编辑
环境:VS2008 WINXP
编写的一个MFC的DLL
经测试代码应该错在呼出窗体和隐藏窗体
DLL代码如下:- GameInfo *Gamedlg;
- HHOOK g_hHook;
- LRESULT CALLBACK GameProc(int nCode, WPARAM wParam, LPARAM lParam); //键盘钩子
- //////////////////////////////////////////////////////////////////////////
- LRESULT CALLBACK GameProc(int nCode, WPARAM wParam, LPARAM lParam)
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState()); //宏
- //BOOL bKeyUp = lParam & (1<<31);
- //if (bKeyUp && wParam == VK_HOME && nCode == HC_ACTION) //HOME为热键
- if ((wParam==VK_HOME) && (lParam&(1<<31))==0)
- {
- if (Gamedlg==NULL) //如果GameDlg是空的 说明没有窗体
- {
- //AFX_MANAGE_STATE(AfxGetStaticModuleState());//宏
- CWnd *pCWnd = CWnd::GetForegroundWindow();
- Gamedlg=new GameInfo;
- Gamedlg->Create(IDD_GameMain,pCWnd);
- //Gamedlg->Create(IDD_GameMain);
- Gamedlg->ShowWindow(SW_SHOW);
- }
- else
- {
- Gamedlg->ShowWindow(Gamedlg->IsWindowVisible() ? SW_HIDE : SW_SHOW);
- //Gamedlg->ShowWindow(Gamedlg->IsWindowVisible() ? SW_SHOW:SW_HIDE);
- //Gamedlg->ShowWindow(SW_HIDE);
- //Gamedlg=NULL;
- }
- }
- return ::CallNextHookEx(g_hHook, nCode, wParam, lParam);
- }
- void SetHook()
- {
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
- //HWND GameH=::FindWindow(L"SciCalc",L"计算器"); //音乐播放器 By:年少 QQ:348619517
- //HWND GameH=::FindWindow(NULL,L"无标题 - 记事本");
- //HWND GameH=::FindWindow(NULL,L"音乐播放器 By:年少 QQ:348619517");
- HWND GameH=::FindWindow(L"TFrmMain",L"legend of mir2");
- if (GameH==0)
- {
- AfxMessageBox(L"未找到游戏进程!",MB_OK);
- return ;
- }
- DWORD ProcID=::GetWindowThreadProcessId(GameH,NULL);
- g_hHook=::SetWindowsHookEx(WH_KEYBOARD,&GameProc,GetModuleHandle(L"SoftDll.dll"),ProcID);
- if (g_hHook!=NULL)
- {
- AfxMessageBox(L"DLL注入成功!",MB_OK);
- return;
- }
- }
- BOOL CSoftDllApp::InitInstance()
- {
- CWinApp::InitInstance();
- return TRUE;
- }
- BOOL CSoftDllApp::ExitInstance()
- {
- delete Gamedlg;
- Gamedlg = NULL;
- return CWinApp::ExitInstance();
- //ShowWindow(Gamedlg->m_hWnd,SW_HIDE); //这样做 退出时会报内存错
- return TRUE;
- }
复制代码 注入计算器 记事本都可以 按Home键呼出 按Home键隐藏 很好用。 (游戏没有保护)
|
|