M
Matt Burland
I am trying to read the memory being used by a process but I can't
quite figure out how to do it (or if it's even possible). I can get a
reference to the process using Process.GetProcessesByName and I can get the
base address using Process.MainModule.BaseAddress (which returns a IntPtr).
I thought that by using IntPtr.ToPointer() and casting to a char* I would be
able to read the memory as a stream of chars but it doesn't work because it
always throws a NullReferenceException when I try and dereference the
pointer.
Can anybody help me out here?
Thanks
class Class1 { [STAThread] static unsafe void Main(string[] args) {
Process[] p = Process.GetProcessesByName("notepad"); ProcessModule pm =
p[0].MainModule; Console.WriteLine(pm.BaseAddress); char* ptr = (char*)
pm.BaseAddress.ToPointer(); char c = *ptr; // Throws
System.NullReferenceException Console.WriteLine(c);
Console.ReadLine(); } }
quite figure out how to do it (or if it's even possible). I can get a
reference to the process using Process.GetProcessesByName and I can get the
base address using Process.MainModule.BaseAddress (which returns a IntPtr).
I thought that by using IntPtr.ToPointer() and casting to a char* I would be
able to read the memory as a stream of chars but it doesn't work because it
always throws a NullReferenceException when I try and dereference the
pointer.
Can anybody help me out here?
Thanks
class Class1 { [STAThread] static unsafe void Main(string[] args) {
Process[] p = Process.GetProcessesByName("notepad"); ProcessModule pm =
p[0].MainModule; Console.WriteLine(pm.BaseAddress); char* ptr = (char*)
pm.BaseAddress.ToPointer(); char c = *ptr; // Throws
System.NullReferenceException Console.WriteLine(c);
Console.ReadLine(); } }