123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- // WeChatsDlg.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "WeChats.h"
- #include "WeChatsDlg.h"
- #include "CWxObject.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
- // 对话框数据
- enum { IDD = IDD_ABOUTBOX };
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
- // 实现
- protected:
- DECLARE_MESSAGE_MAP()
- };
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- }
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- }
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- END_MESSAGE_MAP()
- // CWeChatsDlg 对话框
- HWND g_hWxWnd = NULL;
- CWeChatsDlg::CWeChatsDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CWeChatsDlg::IDD, pParent)
- {
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- }
- void CWeChatsDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- }
- BEGIN_MESSAGE_MAP(CWeChatsDlg, CDialog)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(BTN_OPEN_WX, &CWeChatsDlg::OnBnClickedOpenWx)
- ON_WM_CTLCOLOR()
- END_MESSAGE_MAP()
- // CWeChatsDlg 消息处理程序
- BOOL CWeChatsDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // 将“关于...”菜单项添加到系统菜单中。
- // IDM_ABOUTBOX 必须在系统命令范围内。
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
- CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
- BOOL bNameValid;
- CString strAboutMenu;
- bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
- ASSERT(bNameValid);
- if (!strAboutMenu.IsEmpty())
- {
- pSysMenu->AppendMenu(MF_SEPARATOR);
- pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- }
- }
- // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
- // 执行此操作
- SetIcon(m_hIcon, TRUE); // 设置大图标
- SetIcon(m_hIcon, FALSE); // 设置小图标
- // TODO: 在此添加额外的初始化代码
- return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
- }
- void CWeChatsDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
- // 如果向对话框添加最小化按钮,则需要下面的代码
- // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
- // 这将由框架自动完成。
- void CWeChatsDlg::OnPaint()
- {
- if (IsIconic())
- {
- CPaintDC dc(this); // 用于绘制的设备上下文
- SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
- // 使图标在工作区矩形中居中
- int cxIcon = GetSystemMetrics(SM_CXICON);
- int cyIcon = GetSystemMetrics(SM_CYICON);
- CRect rect;
- GetClientRect(&rect);
- int x = (rect.Width() - cxIcon + 1) / 2;
- int y = (rect.Height() - cyIcon + 1) / 2;
- // 绘制图标
- dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
- if (g_hWxWnd)
- ::UpdateWindow(g_hWxWnd);
- CDialog::OnPaint();
- }
- }
- //当用户拖动最小化窗口时系统调用此函数取得光标
- //显示。
- HCURSOR CWeChatsDlg::OnQueryDragIcon()
- {
- return static_cast<HCURSOR>(m_hIcon);
- }
- void CWeChatsDlg::OnBnClickedOpenWx()
- {
- // TODO: 在此添加控件通知处理程序代码
- #ifdef _DEBUG
- //vector<DWORD> vtPID = FindAllProcess(_T("lyfzServer.exe"));
- vector<DWORD> vtPID = FindAllProcess(WECHAT);
- //vector<DWORD> vtPID = FindAllProcess(_T("cheatengine-x86_64.exe"));
- //vector<DWORD> vtPID = FindAllProcess(_T("AliIM.exe"));
- //vector<DWORD> vtPID = FindAllProcess(_T("AliIM.exe"));
- if (vtPID.size() != 0)
- {
- CWxObject wxobj(*vtPID.begin(), g_szDynamicLibraryPath);
- if (wxobj.FindWxMainWnd())
- {
- wxobj.InjectDynamicLibrary();
- wxobj.Attach2MainWnd(GetDlgItem(WX_RECT), FALSE);
- Sleep(10000);
- wxobj.DetachWxWnd();
- }
- //if (wxobj.FindWxMainWnd())
- //if (wxobj.FindWxLoginWnd())
- //{
- // //g_hWxWnd = wxobj.GetWxMainWnd();
- // g_hWxWnd = wxobj.GetWxLoginWnd();
- // if (g_hWxWnd != NULL)
- // {
- // // 获取微信窗口的样式;
- // DWORD dwStyle = ::GetWindowLong(g_hWxWnd, GWL_STYLE);
- // // WS_CLIPSIBLINGS告诉父窗口不要绘制子窗口出现的区域;
- // dwStyle |= WS_CLIPSIBLINGS;
- // // 重新设置窗口样式 ;
- // ::SetWindowLong(g_hWxWnd, GWL_STYLE, dwStyle);
- // CRect rect;
- // GetDlgItem(WX_RECT)->GetWindowRect(&rect);
- // // 设置背景透明;
- // ::SetParent(g_hWxWnd, GetDlgItem(WX_RECT)->m_hWnd);//set parent of ms paint to our dialog.
- // //::SetParent(hWxWnd, m_hWnd);
- // // 擦除背景;
- // //SetWindowLong(hWxWnd, GWL_STYLE, WS_VISIBLE);//eraze title of ms paint window.
- // //Positioning ms paint.
- // ScreenToClient(wxobj.m_rcWnd);
- // ::MoveWindow(g_hWxWnd, wxobj.m_rcWnd.left, wxobj.m_rcWnd.top, wxobj.m_rcWnd.right, wxobj.m_rcWnd.bottom, true);
- // //ClientToScreen(&rect);
- // //ScreenToClient(&rect);
- // //::SetWindowPos(hWxWnd, NULL, rect.left, rect.top, rect.right, rect.bottom, SWP_SHOWWINDOW | SWP_HIDEWINDOW);
- // //窗口重绘,(因创建exe时,设置为SW_HIDE,导致exe窗口会被父窗口覆盖一部分)
- // //Invalidate();
- // ::UpdateWindow(g_hWxWnd);
- // ::ShowWindow(g_hWxWnd, SW_SHOW);
- // }
- //}
- }
- #endif
- }
- HBRUSH CWeChatsDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
- // TODO: 在此更改 DC 的任何特性
- //pDC->SetBkMode(TRANSPARENT);
- // TODO: 如果默认的不是所需画笔,则返回另一个画笔
- return hbr;
- }
|