开发者

How do I read a programs memory?

Okay, I just asked how to read two vars in my C# app. It was two simple vars int intfoo = 1234 and string strinfoo = "This is a test".

I now understand why it was silly to ask since the testapp was written in c# and therefor managed code. So i fixed that, I've made a c++ application that holds the two same vars :)

Now, with C#, how do I loop through the C++ test application to fi开发者_Python百科nd the value "1234" and "this is a test" which are the values for intfoo and stringfoo.

What would be the start of the loop and end? I've read somewhere that start is 0x00100000 and other places its 0x00400000? What would the end condition be? The test c++ app uses 388 kB in memory.

How do I loop to find the int and how do I loop to find the string?

Thanks in advance for any help :-)


You don't want to do it, but there is an API function called ReadProcessMemory.


We are talking about virtual memory so any process see as private space of adresses and a process can't see any other one process memory without any effort. Usually you make twop process communicate by using some well defined IPC strategyes ( Named Pipes, memory mapped files, and so on )


Use unsafe C#. Get a pointer to one of these values and you'll get a start address. The first 'object' in you're application should be pretty close to the start of the used memory.

Now you can simply use you're unsafe c# pointer as a integer array and 'walk' through the memory(I don't really know if its that easy).

Remember, Garbage collection can move objects in memory at any time! Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜