Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Runtime.InteropServices;
  7. using System.Diagnostics;
  8. using System.ComponentModel;
  9. namespace ConsoleApplication9
  10. {
  11.  
  12.     class Program
  13.     {
  14.         [Flags]
  15.         public enum ProcessAccessFlags : uint
  16.         {
  17.             All = 0x001F0FFF,
  18.             Terminate = 0x00000001,
  19.             CreateThread = 0x00000002,
  20.             VirtualMemoryOperation = 0x00000008,
  21.             VirtualMemoryRead = 0x00000010,
  22.             VirtualMemoryWrite = 0x00000020,
  23.             DuplicateHandle = 0x00000040,
  24.             CreateProcess = 0x000000080,
  25.             SetQuota = 0x00000100,
  26.             SetInformation = 0x00000200,
  27.             QueryInformation = 0x00000400,
  28.             QueryLimitedInformation = 0x00001000,
  29.             Synchronize = 0x00100000
  30.         }
  31.  
  32.         [DllImport("kernel32.dll")]
  33.         public static extern IntPtr OpenProcess(
  34.              ProcessAccessFlags processAccess,
  35.              bool bInheritHandle,
  36.              int processId
  37.         );
  38.         [DllImport("kernel32.dll", SetLastError = true)]
  39.         static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer, int dwSize, IntPtr lpNumberOfBytesRead);
  40.         static void Main(string[] args)
  41.         {
  42.  
  43.             var process = Process.GetProcessesByName("TERA")[0];
  44.             Int32[] offset = {0x14,0x40,0x10,0x78};
  45.             byte[] buffer = new byte[4];
  46.             int bytesread;
  47.             var baseadres = 0x400000 + 0x01CB53B8;
  48.  
  49.             var handl = OpenProcess(ProcessAccessFlags.All, false, process.Id);
  50.             ReadProcessMemory(process.Handle, (IntPtr)baseadres, buffer, 4, IntPtr.Zero);
  51.             for (int i = 0; i < offset.Length; i++)
  52.             {
  53.                 baseadres = BitConverter.ToInt32(buffer, 0);
  54.                 baseadres += offset[i];
  55.                 ReadProcessMemory(process.Handle, (IntPtr)baseadres, buffer, 4, IntPtr.Zero);
  56.             }
  57.             var res = BitConverter.ToInt32(buffer, 0);
  58.            
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement