CWxObject.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef __WX_OBJECT__
  2. #define __WX_OBJECT__
  3. #pragma once
  4. typedef struct _WNDINFO_
  5. {
  6. // 返回的窗口句柄;
  7. HWND hWxWnd;
  8. // 要遍历的进程id;
  9. DWORD dwWxProcId;
  10. // 返回的窗口线程id;
  11. DWORD dwThreadId;
  12. // 窗口名称;
  13. TCHAR szWndName[MAX_PATH];
  14. // 窗口类名;
  15. TCHAR szClassName[MAX_PATH];
  16. // 窗口原始大小;
  17. CRect rcWnd;
  18. }WNDINFO, *pWNDINFO;
  19. class CWxObject
  20. {
  21. public:
  22. CWxObject();
  23. explicit CWxObject(DWORD dwProcId, LPCTSTR lpDynamicLibraryPath);
  24. ~CWxObject();
  25. public:
  26. // 进程id;
  27. DWORD m_dwWxProcId;
  28. // 进程句柄;
  29. HANDLE m_hWxProcess;
  30. // 进程窗口句柄;
  31. HWND m_hWxMainWnd;
  32. HWND m_hWxLoginWnd;
  33. // 窗口大小;
  34. CRect m_rcWxWnd;
  35. // 是否附加到主窗口;
  36. BOOL m_bAttached;
  37. private:
  38. // 动态库路径;
  39. WCHAR m_wszDllPath[MAX_PATH];
  40. CHAR m_szDllPath[MAX_PATH];
  41. // 路径分配的内存;
  42. LPVOID m_lpInjectData;
  43. LPVOID m_lpEjectData;
  44. // 路径长度;
  45. DWORD m_dwPathLen;
  46. // 注入线程句柄;
  47. HANDLE m_hInjectThread;
  48. // 卸载线程句柄;
  49. HANDLE m_hEjectThread;
  50. public:
  51. inline DWORD GetWxProcId() { return m_dwWxProcId; }
  52. inline HWND GetWxMainWnd() { return m_hWxMainWnd; }
  53. inline HWND GetWxLoginWnd() { return m_hWxLoginWnd; }
  54. // dll路径和要注入的进程id;
  55. void setInjectionObj(DWORD dwProcId, LPCTSTR lpDynamicLibraryPath);
  56. BOOL InjectDynamicLibrary();
  57. BOOL EjectDynamicLibrary();
  58. BOOL FindWxMainWnd();
  59. BOOL FindWxLoginWnd();
  60. BOOL Attach2MainWnd(CWnd *pMainWnd, BOOL bLoginWnd = FALSE);
  61. BOOL DetachWxWnd();
  62. static BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);
  63. };
  64. #endif //__WX_OBJECT__