XXXXDlg.cpp
上传用户:gzdongxi
上传日期:2007-07-05
资源大小:30k
文件大小:10k
源码类别:

ICQ弱点检测代码

开发平台:

Visual C++

  1. // XXXXDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "XXXX.h"
  5. #include "XXXXDlg.h"
  6. #include "TLHELP32.H"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12.    HWND hwnd;
  13.        HWND  IWANT;
  14. HWND m_hwndFind[100] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  15.                     NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  16. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  17. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  18. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  19. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  20. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  21. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  22. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,
  23. NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
  24. int m_num = 0 ;
  25. TCHAR m_store[MAX_PATH];
  26. TCHAR m_name[MAX_PATH];
  27. TCHAR m_strClass[MAX_PATH];
  28. TCHAR m_FilePath[MAX_PATH];
  29. TCHAR m_FileName[24];
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CAboutDlg dialog used for App About
  32. class CAboutDlg : public CDialog
  33. {
  34. public:
  35. CAboutDlg();
  36. // Dialog Data
  37. //{{AFX_DATA(CAboutDlg)
  38. enum { IDD = IDD_ABOUTBOX };
  39. //}}AFX_DATA
  40. // ClassWizard generated virtual function overrides
  41. //{{AFX_VIRTUAL(CAboutDlg)
  42. protected:
  43. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  44. //}}AFX_VIRTUAL
  45. // Implementation
  46. protected:
  47. //{{AFX_MSG(CAboutDlg)
  48. //}}AFX_MSG
  49. DECLARE_MESSAGE_MAP()
  50. };
  51. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  52. {
  53. //{{AFX_DATA_INIT(CAboutDlg)
  54. //}}AFX_DATA_INIT
  55. }
  56. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  57. {
  58. CDialog::DoDataExchange(pDX);
  59. //{{AFX_DATA_MAP(CAboutDlg)
  60. //}}AFX_DATA_MAP
  61. }
  62. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  63. //{{AFX_MSG_MAP(CAboutDlg)
  64. // No message handlers
  65. //}}AFX_MSG_MAP
  66. END_MESSAGE_MAP()
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CXXXXDlg dialog
  69. CXXXXDlg::CXXXXDlg(CWnd* pParent /*=NULL*/)
  70. : CDialog(CXXXXDlg::IDD, pParent)
  71. {
  72. //{{AFX_DATA_INIT(CXXXXDlg)
  73. m_fileName = _T("C:\Program Files\Tencent\QQ\QQ.exe");//作者的qq目录,你可以把隐藏窗口的代码去掉,自己在程序里设置
  74. online=false;
  75. //}}AFX_DATA_INIT
  76. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  77. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  78. }
  79. void CXXXXDlg::DoDataExchange(CDataExchange* pDX)
  80. {
  81. CDialog::DoDataExchange(pDX);
  82. //{{AFX_DATA_MAP(CXXXXDlg)
  83. DDX_Text(pDX, IDC_EDIT1, m_fileName);
  84. //}}AFX_DATA_MAP
  85. }
  86. BEGIN_MESSAGE_MAP(CXXXXDlg, CDialog)
  87. //{{AFX_MSG_MAP(CXXXXDlg)
  88. ON_WM_SYSCOMMAND()
  89. ON_WM_PAINT()
  90. ON_WM_QUERYDRAGICON()
  91. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  92. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  93. ON_WM_TIMER()
  94. ON_WM_SIZE()
  95. ON_MESSAGE(WM_HOTKEY, OnHotKey)
  96. //}}AFX_MSG_MAP
  97. END_MESSAGE_MAP()
  98. /////////////////////////////////////////////////////////////////////////////
  99. // CXXXXDlg message handlers
  100. BOOL CXXXXDlg::OnInitDialog()
  101. {
  102. CDialog::OnInitDialog();
  103. // Add "About..." menu item to system menu.
  104. // IDM_ABOUTBOX must be in the system command range.
  105. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  106. ASSERT(IDM_ABOUTBOX < 0xF000);
  107. CMenu* pSysMenu = GetSystemMenu(FALSE);
  108. if (pSysMenu != NULL)
  109. {
  110. CString strAboutMenu;
  111. strAboutMenu.LoadString(IDS_ABOUTBOX);
  112. if (!strAboutMenu.IsEmpty())
  113. {
  114. pSysMenu->AppendMenu(MF_SEPARATOR);
  115. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  116. }
  117. }
  118. // Set the icon for this dialog.  The framework does this automatically
  119. //  when the application's main window is not a dialog
  120. SetIcon(m_hIcon, TRUE); // Set big icon
  121. SetIcon(m_hIcon, FALSE); // Set small icon
  122. RegisterHotKey(this->m_hWnd,1001,MOD_CONTROL|MOD_ALT,'z');
  123. RegisterHotKey(this->m_hWnd,1002,MOD_CONTROL|MOD_ALT,'Z');
  124. // TODO: Add extra initialization here
  125. CDialog::OnInitDialog(); 
  126. PostMessage(WM_SIZE,0,0);///这是增加的一句隐藏对话框,
  127. SetTimer(1,30000,NULL);//计时器开始工作,30秒
  128. return TRUE;  // return TRUE  unless you set the focus to a control
  129. }
  130. void CXXXXDlg::OnSysCommand(UINT nID, LPARAM lParam)
  131. {
  132. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  133. {
  134. CAboutDlg dlgAbout;
  135. dlgAbout.DoModal();
  136. }
  137. else
  138. {
  139. CDialog::OnSysCommand(nID, lParam);
  140. }
  141. }
  142. // If you add a minimize button to your dialog, you will need the code below
  143. //  to draw the icon.  For MFC applications using the document/view model,
  144. //  this is automatically done for you by the framework.
  145. void CXXXXDlg::OnPaint() 
  146. {
  147. if (IsIconic())
  148. {
  149. CPaintDC dc(this); // device context for painting
  150. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  151. // Center icon in client rectangle
  152. int cxIcon = GetSystemMetrics(SM_CXICON);
  153. int cyIcon = GetSystemMetrics(SM_CYICON);
  154. CRect rect;
  155. GetClientRect(&rect);
  156. int x = (rect.Width() - cxIcon + 1) / 2;
  157. int y = (rect.Height() - cyIcon + 1) / 2;
  158. // Draw the icon
  159. dc.DrawIcon(x, y, m_hIcon);
  160. }
  161. else
  162. {
  163. CDialog::OnPaint();
  164. }
  165. }
  166. // The system calls this to obtain the cursor to display while the user drags
  167. //  the minimized window.
  168. HCURSOR CXXXXDlg::OnQueryDragIcon()
  169. {
  170. return (HCURSOR) m_hIcon;
  171. }
  172. void CXXXXDlg::OnButton1() //枚举进程iD,通过对比枚举的窗口获得的程序ID,直接找到qq句柄,不管它有没有标题栏
  173. {
  174.     DWORD pID=0;
  175.     DWORD ProcessID[50];
  176. CString kkk[50];
  177.     HANDLE SnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); 
  178.     PROCESSENTRY32* info=new PROCESSENTRY32;
  179.     PROCESSENTRY32 ProcessInfo;//声明进程信息变量
  180.     ProcessInfo.dwSize=sizeof(ProcessInfo);//设置ProcessInfo的大小  
  181.     BOOL Status=Process32First(SnapShot,&ProcessInfo);//返回系统中第一个进程的信息
  182.  
  183.     int m_nProcess=0; 
  184.     while(Status)
  185.     {
  186.         CString s,str1,str2;
  187.         s.Format("%d",ProcessInfo.cntThreads);
  188.         str1.Format("%s",ProcessInfo.szExeFile);
  189.         str1=ProcessInfo.szExeFile;
  190.         kkk[m_nProcess]=ProcessInfo.szExeFile; 
  191.         ProcessID[m_nProcess]=ProcessInfo.th32ProcessID; 
  192.         if(str1=="QQ.exe")//***.exe就是你要结束的进程的名称
  193.         {
  194. ::EnumWindows(CXXXXDlg::EnumWindowsProc,NULL);
  195. for(int i = 0;i <=m_num;i++)
  196. {
  197. HWND m_wnd = m_hwndFind[i];
  198. ::GetWindowText(m_wnd,m_store,128);
  199. ::GetClassName(m_wnd,m_strClass,MAX_PATH-1);
  200.         ::GetWindowThreadProcessId(m_wnd,&pID);
  201. if(ProcessID[m_nProcess]==pID)
  202. {
  203. IWANT=m_wnd;
  204. settext();
  205. }
  206. }
  207.       
  208.         }
  209.         Status=Process32Next(SnapShot,&ProcessInfo);
  210.         m_nProcess++;    
  211.     }
  212. }
  213. BOOL  CXXXXDlg::EnumWindowsProc(HWND hWnd, LPARAM lParam)
  214. {
  215. //be sure the current window is visible
  216. if(::GetWindowLong(hWnd,GWL_STYLE)& WS_VISIBLE)
  217. {
  218.    m_hwndFind[m_num] = hWnd;//record the HWND handle into array
  219.    m_num++;//count start
  220.    }
  221. return 1;
  222. }
  223. void CXXXXDlg::settext()
  224. {
  225.     HWND hwndname = ::FindWindowEx( IWANT, NULL, "ComboBox", NULL );//查找ComboBox句柄
  226. if(hwndname==NULL)
  227. return;
  228. CString Message;
  229.     Message="12447886";//号码
  230. if(::GetForegroundWindow()!=IWANT)
  231. ::SetForegroundWindow(IWANT);
  232.     
  233. keybd_event(49,0,0,0); //按下1 因为没细致去研究,所以采用逐个输入密码的方式输入,请自己把密码转ASCI码
  234. keybd_event(49,0,2,0); //释放
  235. keybd_event(48,0,0,0); //按下0 
  236. keybd_event(48,0,2,0); //释放
  237.         keybd_event(49,0,0,0); //按下1 
  238. keybd_event(49,0,2,0); //释放
  239. keybd_event(56,0,0,0); //
  240. keybd_event(56,0,2,0); //释放
  241. ::SetFocus(hwndname);//定位到号码框,QQ2004以后的密码edit框我定位不到,所以只能先这样
  242.                              //因为,在一台机器上登录过后,光标首先停在password框,所以就用keybd_event输入密码
  243.                              //然后定位到号码框,输入号码QQ2005,QQ2004测试通过,以前的版本更容易,可以直接定位密码框
  244.                              //自己用spy++找吧~~
  245.   
  246. ::SendMessage(hwndname, WM_SETTEXT, Message.GetLength(), (LPARAM)Message.GetBuffer(Message.GetLength()));
  247.   keybd_event(VK_RETURN,0,0,0); //按下回车
  248. keybd_event(VK_RETURN,0,2,0); //释放
  249. }
  250. void CXXXXDlg::OnButton2() 
  251. {
  252. // TODO: Add your control notification handler code here
  253. CFileDialog OpenDlg(true);
  254. OpenDlg.m_ofn.lpstrFilter="QQ Files*.exe";
  255. if(OpenDlg.DoModal()==IDOK){
  256. m_fileName=OpenDlg.GetPathName();
  257. UpdateData(false);
  258. }
  259. ShellExecute(0,NULL,m_fileName,NULL,NULL,SW_NORMAL);
  260. }
  261. void CXXXXDlg::OnTimer(UINT nIDEvent) 
  262. {
  263. // TODO: Add your message handler code here and/or call default
  264. OnButton3();
  265. CDialog::OnTimer(nIDEvent);
  266. }
  267. void CXXXXDlg::OnButton3() 
  268. {
  269. SYSTEMTIME SysTime;
  270. CString StrCurTime,str;
  271. ::GetLocalTime(&SysTime);
  272. StrCurTime.Format("%d%d%d",SysTime.wHour,SysTime.wMinute,SysTime.wSecond);
  273. str=StrCurTime.Left(2);
  274. int x=atoi(str);
  275. if(x==23&&!online)//如果现在是11点
  276. {
  277. online=true;
  278. close();//关闭其他qq
  279. ::Sleep(200);
  280. ShellExecute(0,NULL,m_fileName,NULL,NULL,SW_NORMAL);
  281. ::Sleep(15000);//停止2秒,等待QQ正常运行
  282. OnButton1();
  283. }
  284. if(x>81&&online)//如果是早上八点多,qq开着
  285. {
  286. online=false;
  287. close();//关闭其他qq
  288. }
  289. }
  290. void CXXXXDlg::close()//枚举进程关闭qq程序,
  291. {
  292.  DWORD ProcessID[50];
  293.     CString kkk[50];
  294.     HANDLE SnapShot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); 
  295.     PROCESSENTRY32* info=new PROCESSENTRY32;
  296.     PROCESSENTRY32 ProcessInfo;//????????
  297.     ProcessInfo.dwSize=sizeof(ProcessInfo);//??ProcessInfo???
  298.     //?????????????
  299.     BOOL Status=Process32First(SnapShot,&ProcessInfo);
  300.     int m_nProcess=0; 
  301.     while(Status)
  302.     {
  303.         CString s,str1,str2;
  304.         s.Format("%d",ProcessInfo.cntThreads);
  305.         str1.Format("%s",ProcessInfo.szExeFile);
  306.         str1=ProcessInfo.szExeFile;
  307.         kkk[m_nProcess]=ProcessInfo.szExeFile; 
  308.         ProcessID[m_nProcess]=ProcessInfo.th32ProcessID; 
  309.         if(str1=="QQ.exe")//***.exe????????????
  310.         {
  311.             HANDLE ProcessHandle;
  312.             ProcessHandle=OpenProcess (PROCESS_ALL_ACCESS,FALSE,ProcessID[m_nProcess]);
  313.             TerminateProcess(ProcessHandle,0);
  314.         }
  315.         Status=Process32Next(SnapShot,&ProcessInfo);
  316.         m_nProcess++;
  317.     }
  318. }
  319. void CXXXXDlg::OnSize(UINT nType, int cx, int cy) //隐藏对话框
  320. {
  321. //CDialog::OnSize(nType, cx, cy);
  322. // TODO: Add your message handler code here
  323. ShowWindow(SW_HIDE); ///隐藏对话框
  324. }
  325. LRESULT CXXXXDlg::OnHotKey(WPARAM wParam, LPARAM lParam)
  326. {
  327.     MessageBox("孙鹏程的QQ程序正常运行","QQ");//设置热键让自己方便看看程序是不是在运行
  328. return 1;
  329. }