日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

使用CE进行扫雷

發布時間:2024/3/26 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 使用CE进行扫雷 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原理

使用ce進行掃描,直到找到存儲信息的位置,然后讀取就行了

具體方法

使用未知的初始值進行第一次掃描,數據類型大多是Byte,之后點第一行第一列雷,根據數據選擇變化的值或者未變化的值進行下一次掃描,直到找到存儲位置

代碼

#include <iostream> #include <conio.h> #include <windows.h>using namespace std;class Pos { public:int _x;int _y;Pos() {_x = 0;_y = 0;}Pos(int x, int y) :_x(x), _y(y) {} };// 簡單封裝下Windows API void SetMousePos(Pos pos) {SetCursorPos(pos._x, pos._y); } void MouseLeftEvent() {mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); } void MouseRightEvent() {mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); } template<typename T> void GetArr(T **&arr,int h,int w) {arr = new T *[h];for (int i = 0; i < h; ++i) {arr[i] = new T[w];}} template<typename T> void DelArr(T **&arr,int h,int w) {for (int i = 0; i < h; ++i) {delete[]arr[i];}delete arr;arr = nullptr; }int main() {// 修改cmd顯示編碼,防止中文亂碼system("chcp 65001");// 打開掃雷進程HWND handle = FindWindow(NULL,"Minesweeper");if (handle == NULL) {cout << "打開失敗" << endl;return 0;}DWORD pid;GetWindowThreadProcessId(handle, &pid);HANDLE process_handle = OpenProcess(PROCESS_ALL_ACCESS, false, pid);// 獲取掃雷的雷盤信息BYTE h, w;ReadProcessMemory(process_handle, (void*)0x01005338, &h, sizeof(h), NULL);ReadProcessMemory(process_handle, (void*)0x01005334, &w, sizeof(h), NULL);BYTE* buf = (BYTE*)malloc(h * 32);ReadProcessMemory(process_handle, (void*)0x01005361, (void*)buf, h * 32, NULL);// 獲取窗口位置,并依此移動鼠標RECT rect;GetWindowRect(handle, &rect);cout << "窗口位置:" << rect.left << "," << rect.top;cout << "行數:" << (int)h << endl;cout << "列數:" << (int)w << endl;SetMousePos(Pos(rect.left, rect.top));MouseLeftEvent();// 將鼠標移動到掃雷的左上第一個點POINT begin_pos;begin_pos.x = rect.left + 20;begin_pos.y = rect.top + 105;SetMousePos(Pos(begin_pos.x, begin_pos.y));MouseLeftEvent();Pos** mouse_pos;bool** mines;GetArr<Pos>(mouse_pos, h, w);GetArr<bool>(mines, h, w);// 將每個點的鼠標坐標都計算出來,并保存到數組中for (int i = 0; i < h; ++i) {for (int j = 0; j < w; ++j) {mouse_pos[i][j] = Pos(begin_pos.x + 16 * j, begin_pos.y + 16 * i);}}int num = 0;int i, j;BYTE* line = buf;for (i = 0; i < h; i++) {for (j = 0; j < w; j++) {if (line[j] == 0x8F) {mines[i][j] = true;num++;}printf("%2X ", line[j]);}cout << endl;line = line + 32;}cout << num << endl;num = 0;for (int i = 0; i < h; ++i) {for (int j = 0; j < w; ++j) {if (mines[i][j] == true)num++;printf("%2d", mines[i][j]);}cout << endl;}cout << num << endl;num = 0;for (int i = 0; i < h; ++i) {for (int j = 0; j < w; ++j) {SetMousePos(mouse_pos[i][j]);// 如果當前鼠標下是雷,模擬鼠標右鍵if (mines[i][j] == true) {MouseRightEvent();num++;}// 否則模擬左鍵else {MouseLeftEvent();}// Sleep(1);}}cout << num << endl;DelArr(mines,h,w);DelArr(mouse_pos, h, w);return 0; }

運行結果

已知問題

  • 僅適用于 Minesweeper 2000 xp 版本

題外

  • ce 7.4安裝后存在捆綁軟件可以在安裝時選擇拒絕
  • ce 7.4安裝時無法選擇安裝路徑,可以通過github獲取源碼并手動編譯

總結

以上是生活随笔為你收集整理的使用CE进行扫雷的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。