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.Threading.Tasks;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- using System.ComponentModel;
- namespace ConsoleApplication9
- {
- class Program
- {
- [Flags]
- public enum ProcessAccessFlags : uint
- {
- All = 0x001F0FFF,
- Terminate = 0x00000001,
- CreateThread = 0x00000002,
- VirtualMemoryOperation = 0x00000008,
- VirtualMemoryRead = 0x00000010,
- VirtualMemoryWrite = 0x00000020,
- DuplicateHandle = 0x00000040,
- CreateProcess = 0x000000080,
- SetQuota = 0x00000100,
- SetInformation = 0x00000200,
- QueryInformation = 0x00000400,
- QueryLimitedInformation = 0x00001000,
- Synchronize = 0x00100000
- }
- [DllImport("kernel32.dll")]
- public static extern IntPtr OpenProcess(
- ProcessAccessFlags processAccess,
- bool bInheritHandle,
- int processId
- );
- [DllImport("kernel32.dll", SetLastError = true)]
- static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, [Out] byte[] lpBuffer, int dwSize, IntPtr lpNumberOfBytesRead);
- static void Main(string[] args)
- {
- var process = Process.GetProcessesByName("TERA")[0];
- Int32[] offset = {0x14,0x40,0x10,0x78};
- byte[] buffer = new byte[4];
- int bytesread;
- var baseadres = 0x400000 + 0x01CB53B8;
- var handl = OpenProcess(ProcessAccessFlags.All, false, process.Id);
- ReadProcessMemory(process.Handle, (IntPtr)baseadres, buffer, 4, IntPtr.Zero);
- for (int i = 0; i < offset.Length; i++)
- {
- baseadres = BitConverter.ToInt32(buffer, 0);
- baseadres += offset[i];
- ReadProcessMemory(process.Handle, (IntPtr)baseadres, buffer, 4, IntPtr.Zero);
- }
- var res = BitConverter.ToInt32(buffer, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement