Is possible in c# grab file loaded into memory by other process? For example image file or txt file. I've a application that load some of that file in memory. i need dump it to disk. i suppose is hard way, can put me in correct way.
1 Answer
This is technically not impossible. Assuming you have sufficient rights, you can peek at the memory of another process with the ReadProcessMemory() winapi function. Pinvoke required.
The problem you'll however run into is that you'll discover that you are trying to find a needle in a haystack. You'll have no clue on what virtual memory to start reading unless you know a lot about the process. You start off with a cool 2 billion possible choices, you can probably whittle it down to a million or so. Throw in complications like a garbage collector that randomly moves stuff around.
Get insight in what the virtual memory of another process looks like with the SysInternals' VMMap utility.
ReadProcessMemory? (you're going to have topinvokeit to access it) (edit see also stackoverflow.com/questions/9966515/…)