Advertisement
Atheuz

Untitled

Jun 6th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 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.  
  30.         static void Main(string[] args)
  31.         {
  32.             processes = Process.GetProcessesByName("TmForever");
  33.  
  34.             if (processes.Length == 0)
  35.             {
  36.                 Environment.Exit(0);
  37.             }
  38.             else
  39.             {
  40.                 Console.WriteLine("Process found...");
  41.                 processID = processes[0].Id;
  42.                 handleID = processes[0].Handle;
  43.             }
  44.             Console.WriteLine(ReadInt32(handleID, time));
  45.         }
  46.  
  47.         [DllImport("kernel32.dll", SetLastError = true)]
  48.         static extern bool ReadProcessMemory(
  49.           IntPtr hProcess,
  50.           IntPtr lpBaseAddress,
  51.           [Out] byte[] lpBuffer,
  52.           int dwSize,
  53.           out int lpNumberOfBytesRead
  54.          );
  55.  
  56.         public static uint ReadInt32(IntPtr hProcess, IntPtr dwAddress)
  57.         {
  58.             byte[] buffer = new byte[4];
  59.             int bytesread;
  60.  
  61.             Win32.ReadProcessMemory(hProcess, dwAddress, buffer, 4, out bytesread);
  62.             return BitConverter.ToUInt32(buffer, 0);
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement