위는 작동영상이다.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
/*
* Open Source Project.
* 지뢰찾기 지뢰 위치 알아내기
* 분석, 프로그램작성 : sweetchip
* 날자 : 2013.01.21
*
* Blog : http://pgnsc.tistory.com
* Site : http://studyc.co.kr
*
*/
// youroffset은 메모리 주소입니다. 메모리 관련 함수는 처음이라서 그대로 가져오는도중 이름수정을 못햇네요 ㅋㅋㅋ
namespace winmine_hack
{
public partial class Form1 : Form
{
[DllImport("kernel32.dll")]
public static extern int OpenProcess(uint dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll")]
public static extern bool ReadProcessMemory(int hProcess, int lpBaseAddress, byte[] buffer, int size, int lpNumberOfBytesRead);
Process[] p;
public uint DELETE = 0x00010000;
public uint READ_CONTROL = 0x00020000;
public uint WRITE_DAC = 0x00040000;
public uint WRITE_OWNER = 0x00080000;
public uint SYNCHRONIZE = 0x00100000;
public uint END = 0xFFF;
public int temp = 0;
public Form1()
{
InitializeComponent();
}
public void auto(int x, int y)
{
int a_temp = 1;
int processHandle = OpenProcess((DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER | SYNCHRONIZE | END), false, p[0].Id);
int YOUR_OFFSET = 0x1005340;
int r = 0;
for (int i = 1; i < x 1; i )
{
for (int j = 1; j < y 1; j )
{
int cal = (i * (int)Math.Pow(2, 5)) j YOUR_OFFSET;
r = int.Parse(ReadMemory(cal, 1, processHandle)[0].ToString());
int t = r & 0xe0;
if (t == 0x80)
{
a_temp = i j;
}
}
}
if (a_temp != temp)
{
get();
temp = a_temp;
}
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval = 100;
timer1.Start();
}
public void get()
{
try
{
p = Process.GetProcessesByName("winmine");
listBox1.Items.Clear();
int x = xlength();
int y = ylength();
label1.Text = "우와! 신기하다 @_@\nStatus : " x " X " y " 지뢰 개수 " mine();
for (int i = 1; i < x 1; i )
{
for (int j = 1; j < y 1; j )
{
cal(i, j);
}
}
}
catch { MessageBox.Show("Error","Error"); }
}
public int mine()
{
//0x010056a8
int processHandle = OpenProcess((DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER | SYNCHRONIZE | END), false, p[0].Id);
int m = int.Parse(ReadMemory(0x01005330, 1, processHandle)[0].ToString());
return m;
}
public int xlength()
{
//0x010056a8
int processHandle = OpenProcess((DELETE |READ_CONTROL |WRITE_DAC |WRITE_OWNER |SYNCHRONIZE |END), false, p[0].Id);
int x = int.Parse(ReadMemory(0x010056a8, 1, processHandle)[0].ToString());
return x;
}
public int ylength()
{
//0x010056ac
int processHandle = OpenProcess((DELETE | READ_CONTROL | WRITE_DAC | WRITE_OWNER | SYNCHRONIZE | END), false, p[0].Id);
int y = int.Parse(ReadMemory(0x010056ac, 1, processHandle)[0].ToString());
return y;
}
public void cal(int x, int y)
{
int processHandle = OpenProcess((DELETE |READ_CONTROL |WRITE_DAC |WRITE_OWNER |SYNCHRONIZE |END), false, p[0].Id);
int YOUR_OFFSET = 0x1005340;
int cal = (x * (int)Math.Pow(2, 5)) y YOUR_OFFSET;
int r = int.Parse(ReadMemory(cal, 1, processHandle)[0].ToString());
int t = r & 0xe0;
if (t == 0x80)
{
temp = x y;
listBox1.Items.Add(x "," y "에 지뢰");
}
}
public static byte[] ReadMemory(int adress, int processSize, int processHandle)
{
byte[] buffer = new byte[processSize];
ReadProcessMemory(processHandle, adress, buffer, processSize, 0);
return buffer;
}
private void timer1_Tick(object sender, EventArgs e)
{
try{
p = Process.GetProcessesByName("winmine");
auto(xlength(), ylength());
button1.Enabled = true;
}
catch
{
button1.Enabled = false;
listBox1.Items.Clear();
label1.Text = "우와! 신기하다 @_@";
}
}
private void button1_Click(object sender, EventArgs e)
{
get();
}
}
}