Advertisement
Atheuz

Untitled

Jun 6th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Runtime.InteropServices;
  6. using System.Diagnostics;
  7. using System.Data;
  8.  
  9. namespace TrackManiaTimesTracker
  10. {
  11.     public class Win32
  12.     {
  13.         [DllImport("kernel32.dll", SetLastError = true)]
  14.         public static extern bool ReadProcessMemory(
  15.           IntPtr hProcess,
  16.           IntPtr lpBaseAddress,
  17.           [Out] byte[] lpBuffer,
  18.           int dwSize,
  19.           out int lpNumberOfBytesRead
  20.          );
  21.     }
  22.  
  23.     class Program
  24.     {
  25.         public static Process[] processes;
  26.         public static int processID;
  27.         public static IntPtr handleID;
  28.         public static IntPtr time = (IntPtr)0x00EC3AEC;
  29.         public static uint lastTime;
  30.         public static uint tempTime;
  31.  
  32.         static void Main(string[] args)
  33.         {
  34.             while ((processes = Process.GetProcessesByName("TmForever")).Length != 0)
  35.             {
  36.                 processID = processes[0].Id;
  37.                 handleID = processes[0].Handle;
  38.                 tempTime = ReadInt32(handleID, time);
  39.                 if (tempTime != lastTime)
  40.                 {
  41.                     lastTime = tempTime;
  42.                     Console.WriteLine(lastTime);
  43.                 }
  44.             }
  45.  
  46.             Console.WriteLine("TrackMania is not open. Quitting...");
  47.         }
  48.  
  49.         [DllImport("kernel32.dll", SetLastError = true)]
  50.         static extern bool ReadProcessMemory(
  51.           IntPtr hProcess,
  52.           IntPtr lpBaseAddress,
  53.           [Out] byte[] lpBuffer,
  54.           int dwSize,
  55.           out int lpNumberOfBytesRead
  56.          );
  57.  
  58.         public static uint ReadInt32(IntPtr hProcess, IntPtr dwAddress)
  59.         {
  60.             byte[] buffer = new byte[4];
  61.             int bytesread;
  62.  
  63.             Win32.ReadProcessMemory(hProcess, dwAddress, buffer, 4, out bytesread);
  64.             return BitConverter.ToUInt32(buffer, 0);
  65.         }
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement