Advertisement
tinyevil

Untitled

Mar 16th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. void print_memory(const void* mem, int size){
  2. #define BYTES_PER_LINE 16
  3. const char* ptr = (const char*)mem;
  4. for ( int i = 0; i < (size + BYTES_PER_LINE - 1) / BYTES_PER_LINE; i++ ){
  5. printf("%04x|", i * BYTES_PER_LINE);
  6. for ( int j = 0; j < BYTES_PER_LINE; j++ ){
  7. int addr = i * BYTES_PER_LINE + j;
  8. if ( addr < size ){
  9. printf(" %02x", (int)(unsigned char)ptr[addr]);
  10. }
  11. }
  12. printf("\n");
  13. }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement