Monday, May 24, 2010

How can i make one c++ program read the virtual memory of another?

This is my problem...i need to use 2 matrixes, for fast information channels...in my algorithm. I can declare one of them in a program. If i declare both, then the program crashed (apparently due to some windows xp mem limit per program. When i declare 1 matrix in one program, but another in another program, and try to run both...i just get an error message saying that my page file is too small...so if i run this on a better computer, i'd be able to declare both matricies at once from two places. Now, i need to make the first program communicate with the second.


I want the first program to declare a matrix/array...get the memory address for the first element of the array, and length, and send that info through a text file to the other program...that would then take that number...load it into a pointer, and view the matrix without declaration. But this isn't working, why not?

How can i make one c++ program read the virtual memory of another?
There are a few ways that shared data can happen.





- create a RAM drive that has fast access. Then use both programs to open the same file. This is a GET IT DONE method.





- my second suggestion is what you have tried. But here is what might be wrong. Both programs have to be compiled, using the same compiler options. As I recall, if you use a LARGE scale object option, the pointers might work out universally. (the type of computer is not relavant).





- The other option is to install an ODBC text file or other global data structure. This could be an awesome and transportable method that would work on countless Windows computers of different flavors and environments. (Yet, I could not even begin to describe the programming details).





Good luck
Reply:I don't think you can just access shared memory on a whim, each modern program loads onto a computer in a separate memory space, the only way to communicate is through API calls, and memory addresses shouldn't be passed in them.





The other way is piping one program output into a master program but that is not going to solve your problem; in other words, without declaration is unlikely.


No comments:

Post a Comment