QT| C/C++之win98扫雷外挂增强版

看到这篇前请先看这篇http://blog.csdn.net/qq78442761/article/details/53312300

当我们到初级场和中级场和自定义的时候,发现并不好分辨具体的雷和非雷的位置,但我们只要对那段内存进行大批量修改就可以了。这是最简单的方法,下面是演示:


下面是C/C++代码:

widget.h

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <windows.h>

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();

public slots:
    void StartMine();   //开始扫雷

private:
    Ui::Widget *ui;
};


#endif // WIDGET_H


widget.cpp

#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);
    this->setWindowTitle("扫雷外挂");
    connect(ui->StartpushButton,SIGNAL(clicked(bool)),this,SLOT(StartMine()));
}
void Widget::StartMine()
{
    //寻找窗口
    HWND hWinmine=FindWindow(NULL,L"扫雷");
    DWORD dwPID=0;
    GetWindowThreadProcessId(hWinmine,&dwPID);//获取ProcessID,写入dwPID中

    //成功:返回进程句柄。
    //失败:返回0。
    // 通过PID得到进程的句柄信息
    HANDLE hProcess=OpenProcess(PROCESS_ALL_ACCESS,false,dwPID);

    //找基础地址、雷数、宽度、高度
    DWORD dwBaseAddr=0x01005330;
    DWORD dwNum=0,dwWidth=0,dwHight=0,dwSize=0;

    // 读取内存信息
    ReadProcessMemory(hProcess,(LPVOID)dwBaseAddr,&dwNum,sizeof(DWORD),&dwSize);
    ReadProcessMemory(hProcess,(LPVOID)(dwBaseAddr+0x4),&dwWidth,sizeof(DWORD),&dwSize);
    ReadProcessMemory(hProcess,(LPVOID)(dwBaseAddr+0x8),&dwHight,sizeof(DWORD),&dwSize);

    //显示到程序上
    ui->MineNumLable->setText(QString::number(int(dwNum),10));
    ui->WideLable->setText(QString::number(int(dwWidth),10));
    ui->HighLable_3->setText(QString::number(int(dwHight),10));
    //棋盘总大小
    DWORD dwReadsize=(dwWidth+20)*(dwHight+20);
    PBYTE pByte=new BYTE[dwReadsize];

    ReadProcessMemory(hProcess,(LPVOID)(dwBaseAddr),pByte,dwReadsize,&dwSize);

    BYTE bClear=0x8E;
    for(size_t i=0;i<dwReadsize;i++)
    {
        if(pByte[i]==0x8F)
        {
            WriteProcessMemory(hProcess,(LPVOID)(dwBaseAddr+i),&bClear,sizeof(BYTE),&dwSize);
        }
    }
    RECT rt={0};
    GetClientRect(hWinmine,&rt);
    InvalidateRect(hWinmine,&rt,true);
    delete pByte;
    CloseHandle(hProcess);
}

Widget::~Widget()
{
    delete ui;
}


main.cpp

#include "widget.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Widget w;
    w.show();

    return a.exec();
}


阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq78442761/article/details/53312637
文章标签: CC++ qt
个人分类: Qt C/C++
所属专栏: HackerCode
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭