#ifndef __WX_OBJECT__ #define __WX_OBJECT__ #pragma once typedef struct _WNDINFO_ { // 返回的窗口句柄; HWND hWxWnd; // 要遍历的进程id; DWORD dwWxProcId; // 返回的窗口线程id; DWORD dwThreadId; // 窗口名称; TCHAR szWndName[MAX_PATH]; // 窗口类名; TCHAR szClassName[MAX_PATH]; // 窗口原始大小; CRect rcWnd; }WNDINFO, *pWNDINFO; class CWxObject { public: CWxObject(); explicit CWxObject(DWORD dwProcId, LPCTSTR lpDynamicLibraryPath); ~CWxObject(); public: // 进程id; DWORD m_dwWxProcId; // 进程句柄; HANDLE m_hWxProcess; // 进程窗口句柄; HWND m_hWxMainWnd; WNDINFO m_WxMainWndInfo; HWND m_hWxLoginWnd; WNDINFO m_WxLoginWndInfo; // 窗口大小; CRect m_rcWxWnd; // 是否附加到主窗口; BOOL m_bAttached; private: // 动态库路径; WCHAR m_wszDllPath[MAX_PATH]; CHAR m_szDllPath[MAX_PATH]; // 路径分配的内存; LPVOID m_lpInjectData; LPVOID m_lpEjectData; // 路径长度; DWORD m_dwPathLen; // 注入线程句柄; HANDLE m_hInjectThread; // 卸载线程句柄; HANDLE m_hEjectThread; // static HHOOK m_hook; public: inline DWORD GetWxProcId() { return m_dwWxProcId; } inline HWND GetWxMainWnd() { return m_WxMainWndInfo.hWxWnd; } inline HWND GetWxLoginWnd() { return m_WxLoginWndInfo.hWxWnd; } // dll路径和要注入的进程id; void setInjectionObj(DWORD dwProcId, LPCTSTR lpDynamicLibraryPath); BOOL InjectDynamicLibrary(); BOOL EjectDynamicLibrary(); BOOL FindWxMainWnd(); BOOL FindWxLoginWnd(); BOOL Attach2MainWnd(CWnd *pMainWnd, BOOL bLoginWnd = FALSE); BOOL DetachWxWnd(); BOOL SetHook(); BOOL OpenWeChat(); static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam); static LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam); }; #endif //__WX_OBJECT__