winmine hack 扫雷游戏辅助外挂源码C语言学习笔记

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq750509600/article/details/80318909
//使用C++控制台程序编写
// winmine.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <Windows.h>

int main()
{
	//取得窗口句柄
	HWND hWnd = FindWindowA("扫雷", "扫雷");

	DWORD pid = 0;
	//取得进程标识PID
	GetWindowThreadProcessId(hWnd, &pid);
	//取得进程句柄
	HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);

	if (hWnd == NULL || pid == 0) {

		printf("error hWnd is null \n");
		goto end;

	}


	//发送点击消息的数组坐标 //高8位为游戏y,低8位为游戏x,具体查看WM_LBUTTONDOWN 
	WORD yxPos[2];
	//定义数据存放的数组
	unsigned char buffer[24][32];

	//定义第一个格子的点击坐标
	int  gameX = 14 + 6;
	int  gameY = 56 + 6;

	BOOL bRead = ReadProcessMemory(handle, (LPCVOID)0x01005361, buffer, 24 * 32, NULL);

	//读取游戏当前的宽高有多少格
	int high = 0;
	int wide = 0;
	ReadProcessMemory(handle, (LPCVOID)0x01005334, &high, 4, NULL);
	ReadProcessMemory(handle, (LPCVOID)0x01005338, &wide, 4, NULL);
	//printf("%d \n", bRead);


	for (int y = 0; y < high; y++)
	{
		for (int x = 0; x < 32; x++)
		{

			//扫雷中的数据8F是雷,10是换行,换行返回
			if (buffer[y][x] == 0x10)
			{
				break;
			}

			//需要点击的坐标,每格大小是16*16
			yxPos[0] = gameX + x * 16;
			yxPos[1] = gameY + y * 16;

			//如果不是雷,就点开
			if (buffer[y][x] != 0x8F)
			{
				//游戏只接收WM_LBUTTONDOWN,WM_LBUTTONUP消息,使用spy++x86查看
				PostMessageW(hWnd, WM_LBUTTONDOWN, 1, *(int*)yxPos);
				PostMessageW(hWnd, WM_LBUTTONUP, 0, *(int*)yxPos);
				//Sleep(100);

			}

			printf("%02X,", buffer[y][x]);

		}
		printf("\n");
	}

end:
	//关闭OpenProcess打开的句柄
	CloseHandle(handle);
	system("pause");

	return 0;
}


阅读更多
想对作者说点什么?

博主推荐

换一批

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