twotecs How do I cheat?
Reputation: 0
Joined: 17 Dec 2014 Posts: 1
|
Posted: Wed Dec 17, 2014 9:45 am Post subject: C# How would you calculate this offset? (minesweeper timer) |
|
|
Goal
I'm trying to write a c# program to read the minesweeper timer every time it launches. i.e. not just hardcoding the address.
Cheat engine data
I have found the timer in CE, this picture shows what 'writes to this address'. What is the offset(s) that I add to the base address so that ReadProcessMemory() finds the timer every time I open minesweeper?
i.imgur(DOT)com/K5lQK82.png
c#
Code: | using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Linq;
public class MemoryRead
{
const int PROCESS_WM_READ = 0x0010;
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll")]
public static extern bool ReadProcessMemory(int hProcess,
int lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead);
public static void Main()
{
Process process = Process.GetProcessesByName("minesweeper").FirstOrDefault();
IntPtr processHandle = OpenProcess(PROCESS_WM_READ, false, process.Id);
ProcessModule myProcessModule;
myProcessModule = process.MainModule;
IntPtr baseaddy = myProcessModule.BaseAddress;
Console.WriteLine("BaseAddress: " + baseaddy);
int bytesRead = 0;
byte[] buffer = new byte[4];
/* IntPtr.Add(baseaddy, offset);
*
* How can I determine the offset from the CE data?
*/
ReadProcessMemory((int)processHandle, 0x0010B230, buffer, buffer.Length, ref bytesRead);
Console.WriteLine("current time: " + BitConverter.ToSingle(buffer, 0));
}
} |
|
|