征途辅助的vc部分源码

2020-12-12 16:00:08

虾米是部分代码:
// ZhengTuDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ZhengTu.h"
#include "Search.h"
#include "ZhengTuDlg.h"
#include <afxdao.h>
#include "DataBase1.h"
//#include "winbase.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()

/////////////////////////////////////////////////////////////////////////////
// CZhengTuDlg dialog

CZhengTuDlg::CZhengTuDlg(CWnd* pParent /*=NULL*/)
    : CDialog(CZhengTuDlg::IDD, pParent)
{
    //{{AFX_DATA_INIT(CZhengTuDlg)
    m_Anser = _T("");
    m_Lan = 0;
    m_Xue = 0;
    //}}AFX_DATA_INIT
    // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
    m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
    Question = NULL;
    Anser = NULL;
    lNumQuestion = 0;
    m_Anser = "还未开始答题";
    lAnserAddr = 0;
    lRenAdd = 0;
    iFront = 0;
    lCurLife = 0;
    lCurMag = 0;
    sprintf(cSearch, "");

    GetAppPath( gcAppPath );

//    lBaseAddr = 0X01780898;        /**  人物地址指针 接着是怪地址指针 **/

    char cFileName[1025];
    sprintf(cFileName,"%s\\地址.ini",gcAppPath);
   
    char cTmp[51];
    char *cUpper;
    GetPrivateProfileString("Config", "人物基地址","0X01780898", cTmp, 50, cFileName);
    cUpper = _strupr( cTmp );
    sscanf(cUpper, "0X%08X", &lBaseAddr);
}

void CZhengTuDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CZhengTuDlg)
    DDX_Text(pDX, IDC_ANSER, m_Anser);
    DDV_MaxChars(pDX, m_Anser, 150);
    DDX_Text(pDX, IDC_EDIT2, m_Lan);
    DDV_MinMaxLong(pDX, m_Lan, 0, 9999999);
    DDX_Text(pDX, IDC_EDIT1, m_Xue);
    DDV_MinMaxLong(pDX, m_Xue, 0, 9999999);
    //}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CZhengTuDlg, CDialog)
    //{{AFX_MSG_MAP(CZhengTuDlg)
    ON_WM_SYSCOMMAND()
    ON_WM_PAINT()
    ON_WM_QUERYDRAGICON()
    ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
    ON_WM_TIMER()
    ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
    ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
    ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
    ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
    ON_WM_LBUTTONDBLCLK()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CZhengTuDlg message handlers

BOOL CZhengTuDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    // Add "About..." menu item to system menu.

    // 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
   
    // TODO: Add extra initialization here
   
    return TRUE;  // return TRUE  unless you set the focus to a control
}

void CZhengTuDlg::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 CZhengTuDlg::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();
    }
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CZhengTuDlg::OnQueryDragIcon()
{
    return (HCURSOR) m_hIcon;
}

void CZhengTuDlg::OnOK()
{
    // TODO: Add extra validation here
   
    CDialog::OnOK();
}

void CZhengTuDlg::OnCancel()
{
    // TODO: Add extra cleanup here
   
    CDialog::OnCancel();
}

//打开进程操作
int CZhengTuDlg::MyOpenProcess(HANDLE *Process)
{
    HWND cWnd = ::FindWindow("zhengtu_client",NULL);
    if( cWnd == NULL )
    {
//        AfxMessageBox("征途未运行!");
        return -1;
    }

    char strWinText[101];
    ::GetWindowText(cWnd,strWinText,100);

    DWORD lPid = 0 ;
    GetWindowThreadProcessId(cWnd, &lPid);

    *Process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, lPid);
    if( *Process == NULL )
    {
        AfxMessageBox("打开进程失败!");
        return -2;
    }
    return 0;
}

void CZhengTuDlg::OnButton1()
{
    // TODO: Add your control notification handler code here

    HANDLE Process=NULL;
    if( MyOpenProcess( &Process ) )        //打开进程
    {
        AfxMessageBox("征途未运行!");
        return;
    }

    CFile  file;
    CFileDialog savePath(FALSE,"请选择保存路径并输入文件名","save.bin",OFN_HIDEREADONLY,"Binary File(*.bin)|*.bin||",NULL);
    if( savePath.DoModal() == IDOK )
    {
        CString fullName;
        fullName = savePath.GetPathName();
        CFileException e;
        if(!(file.Open(fullName,CFile::modeCreate|CFile::modeWrite,&e)))
        {
            char cTmp[1201];
            e.GetErrorMessage(cTmp, 1000);
            sprintf(cTmp,"打开文件失败!原因:%s",cTmp);
            AfxMessageBox(cTmp);
            CloseHandle (Process);
            return;
        }
    }
    else
    {
        CloseHandle( Process );
        return;
    }
   
    const ULONG lSize = 1024;
    ULONG lAddr = 0x00000000;
    ULONG lOld = 0;
    char cTmp[lSize+1];

    while( lAddr < 0x0fffffff  )
    {
        memset(cTmp,0x00,lSize);
        ReadProcessMemory(Process,(LPVOID)(lAddr),cTmp,lSize,NULL);
        file.Write( cTmp, lSize );
        lAddr = lAddr + lSize;
    }

    file.Close();
    CloseHandle (Process);

    return;
}

void CZhengTuDlg::OnTimer(UINT nIDEvent)
{
    // TODO: Add your message handler code here and/or call default
    switch(nIDEvent)
    {
    case 1://自动吃药
        ChiYao();
        break;
    case 2://显示人物属性
        if( ShowAttrib() )
        {
            KillTimer(1);
//            AfxMessageBox("征途未运行!");
        }
        ShowGuaiAttrib();
        break;
    case 3://答题
        MyAnser();
        break;
    }

//    CDialog::OnTimer(nIDEvent);
}

void CZhengTuDlg::OnButton2()
{
    // TODO: Add your control notification handler code here
    UpdateData(TRUE);
    if( m_Lan == 0 && m_Xue == 0 )
    {
        AfxMessageBox("请输入生命值和法术值的下限!!");
        return;
    }
    if( m_Xue > 0 )
    {
        CComboBox *comboXue=(CComboBox *)GetDlgItem( IDC_COMBO_XUE );
        int iCurSel = comboXue->GetCurSel();
        if( iCurSel < 0 )
        {
            AfxMessageBox( "请选择补充生命值的快捷键!!" );
            return;
        }
    }
    if( m_Lan > 0 )
    {
        CComboBox *comboXue=(CComboBox *)GetDlgItem( IDC_COMBO_LAN );
        int iCurSel = comboXue->GetCurSel();
        if( iCurSel < 0 )
        {
            AfxMessageBox( "请选择补充法术值的快捷键!!" );
            return;
        }
    }

特色标签

精彩合集,奇葩无下限 更多

最新游戏

更多

最新专题

更多

相关文章