Reading memory that belongs to another process on Windows
Mostrar comentarios más antiguos
Suppose I have another process running on Windws. That process is stopped in the debugger (Visual Studio). Visual Studio does not have a means of dumping the contents of specified memory locations into a file. However, Visual Studio will tell me the starting address in memory for the data.
Is there a way that Matlab can take a process i.d., a starting address and the number of bytes and read the memory from the process and load it into a Matlab variable / array? Then I would want to have Matlab read this data as 4-byte integer data and give me an array of the integers.
Is there anything that has to be set on the other process to make its memory readable of can Matlab read memory that belongs to any other process?
Thank you for your replies. This would be enormously cool if it worked.
Linda Seltzer
Respuestas (2)
James Tursa
el 23 de Jul. de 2012
0 votos
No. In general, the memory of one process cannot be accessed by another process. There are ways to pass data such as the address itself across (e.g., a COM link ala the MATLAB Engine etc), but the address of one process means nothing to the other process and will not map correctly to the memory you are trying to access (you will likely get a seg fault if you try it).
6 comentarios
Linda
el 23 de Jul. de 2012
Editada: Walter Roberson
el 23 de Jul. de 2012
James Tursa
el 23 de Jul. de 2012
You could start here with the doc and examples:
Basically, your program opens a MATLAB Engine (another process that is linked to your program via a COM link). Then your program can create MATLAB variables with the various mxCreateDoubleMatrix etc functions (i.e., copies of your data) and send those over the COM link to the MATLAB Engine, where they can be independently examined. When the Engine is opened you basically have a MATLAB session running with a command line available, so there is a lot of flexibility in how you want to look at the data.
Walter Roberson
el 23 de Jul. de 2012
Note: Linux and (probably) OS-X have mechanisms for accessing memory that is in a different process. There are, of course, security restrictions on the mechanism.
Linda
el 23 de Jul. de 2012
Editada: Walter Roberson
el 23 de Jul. de 2012
James Tursa
el 23 de Jul. de 2012
Am I to understand from your comment below that you cannot modify the C/C++ program? This would be required to add the code for the MATLAB Engine.
Walter Roberson
el 23 de Jul. de 2012
Can COM be used to control Visual Studios? And can Visual Studios, so controlled, report back memory contents?
Walter Roberson
el 23 de Jul. de 2012
0 votos
It appears that it is possible on MS Windows. See http://www.codeproject.com/Articles/4865/Performing-a-hex-dump-of-another-process-s-memory
1 comentario
Linda
el 23 de Jul. de 2012
Categorías
Más información sobre COM Component Integration en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!