Advertisement
Guest User

Untitled

a guest
Oct 25th, 2019
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Runtime.InteropServices;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace ConsoleApp4
  10. {
  11. class Program
  12. {
  13. const int PROCESS_WM_READ = 0x0010;
  14.  
  15. [DllImport("kernel32.dll")]
  16. public static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
  17.  
  18. [DllImport("kernel32.dll")]
  19. public static extern bool ReadProcessMemory(int hProcess,
  20. Int64 lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead);
  21.  
  22. static void Main(string[] args)
  23. {
  24. Process process = Process.GetProcessesByName("Wow")[0];
  25. IntPtr processHandle = OpenProcess(PROCESS_WM_READ, false, process.Id);
  26.  
  27. int bytesRead = 0;
  28. byte[] btBuffer = new byte[8];
  29. ReadProcessMemory((int) processHandle, (long)process.MainModule.BaseAddress + 0x26243E8, btBuffer, btBuffer.Length, ref bytesRead);
  30.  
  31. //ReadProcessMemory((int)processHandle, new IntPtr(BitConverter.ToInt64(buffer, 0) + 0x26243E8), buffer, buffer.Length, ref bytesRead);
  32.  
  33. Console.WriteLine(Encoding.Unicode.GetString(btBuffer) +
  34. " (" + bytesRead.ToString() + "bytes)");
  35. Console.ReadLine();
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement