Skip to content

Instantly share code, notes, and snippets.

@austinkeeley
Created June 11, 2019 11:25
Show Gist options
  • Save austinkeeley/f0fe37cbc1f94a7610be59da2e20b0c4 to your computer and use it in GitHub Desktop.
Save austinkeeley/f0fe37cbc1f94a7610be59da2e20b0c4 to your computer and use it in GitHub Desktop.
Memory dumping code snippet
/*
* 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