Created
June 11, 2019 11:25
-
-
Save austinkeeley/f0fe37cbc1f94a7610be59da2e20b0c4 to your computer and use it in GitHub Desktop.
Memory dumping code snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Dumps memory to stdout | |
*/ | |
void dump_mem(void *addr, size_t len) { | |
int i; | |
unsigned char *p = addr; | |
for (i=0; i<len; i++) { | |
if (i % 16 == 0) { | |
printf("\n0x%x ", p); | |
} | |
if (i % 4 == 0) { | |
printf(" "); | |
} | |
printf("%.2x", *p & 0xff); | |
p = p + 1; | |
} | |
printf("\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment