Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- using System.Data;
- namespace TrackManiaTimesTracker
- {
- public class Win32
- {
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern bool ReadProcessMemory(
- IntPtr hProcess,
- IntPtr lpBaseAddress,
- [Out] byte[] lpBuffer,
- int dwSize,
- out int lpNumberOfBytesRead
- );
- }
- class Program
- {
- public static Process[] processes;
- public static int processID;
- public static IntPtr handleID;
- public static IntPtr time = (IntPtr)0x00EC3AEC;
- public static uint lastTime;
- public static uint tempTime;
- static void Main(string[] args)
- {
- while ((processes = Process.GetProcessesByName("TmForever")).Length != 0)
- {
- processID = processes[0].Id;
- handleID = processes[0].Handle;
- tempTime = ReadInt32(handleID, time);
- if (tempTime != lastTime)
- {
- lastTime = tempTime;
- Console.WriteLine(lastTime);
- }
- }
- Console.WriteLine("TrackMania is not open. Quitting...");
- }
- [DllImport("kernel32.dll", SetLastError = true)]
- static extern bool ReadProcessMemory(
- IntPtr hProcess,
- IntPtr lpBaseAddress,
- [Out] byte[] lpBuffer,
- int dwSize,
- out int lpNumberOfBytesRead
- );
- public static uint ReadInt32(IntPtr hProcess, IntPtr dwAddress)
- {
- byte[] buffer = new byte[4];
- int bytesread;
- Win32.ReadProcessMemory(hProcess, dwAddress, buffer, 4, out bytesread);
- return BitConverter.ToUInt32(buffer, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement