Skip to content

Instantly share code, notes, and snippets.

@luqmaan
Last active December 15, 2015 13:29
Show Gist options
  • Save luqmaan/5268070 to your computer and use it in GitHub Desktop.
Save luqmaan/5268070 to your computer and use it in GitHub Desktop.
Dump memory in C++. Be sure to change the type from unsigned char* to whatever is needed. Original at http://stackoverflow.com/questions/1286725/hex-dump-from-memory-location.
void Dump( unsigned char* *mem, unsigned int stop ) {
cout << "mem = " << mem << endl;
unsigned char * p = reinterpret_cast< unsigned char*>( mem );
for ( int i = 0; i < n; i++ ) {
std::cout << " " << i << " " << (mem+i) << " " << std::hex << int(p[i]) << std::dec << " " << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment