Hi
I use a pointer to specify some kind of "shared memory" which I use to exchange data between different processes/threads. Now I would like to have a hex dump of the content of the shared buffer. Does anyone know how to do that?
thanks, R
Hi
I use a pointer to specify some kind of "shared memory" which I use to exchange data between different processes/threads. Now I would like to have a hex dump of the content of the shared buffer. Does anyone know how to do that?
thanks, R
On Windows, you can use ReadProcessMemory
. I do not know the Linux equivalent.
Use casts, of course :-) The function should look something like this:
void Dump( const void * mem, unsigned int n ) {
const char * p = reinterpret_cast< const char *>( mem );
for ( unsigned int i = 0; i < n; i++ ) {
std::cout << hex << int(p[i]) << " ";
}
std::cout << std::endl;
}
Then in use:
Foo * f = GetSharedFoo();
Dump( f, somesize );
where somesize is how much you want to dump.