diff options
Diffstat (limited to 'hacking.h')
| -rw-r--r-- | hacking.h | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -17,3 +17,28 @@ void *ec_malloc(unsigned int size) fatal("in ec_malloc() on memory allocation"); return ptr; } + +void dump(const char *data_buffer, const unsigned int length) { + unsigned char byte; + unsigned int i, j; + + for (int i = 0; i < length; i++) { + byte = data_buffer[i]; + printf("%02x ", data_buffer[i]); + if ( ((i%16) == 15) || (i==length-1) ) { + for (int j = 0; j < 15 - (i%16); j++) { + printf(" "); + } + printf("| "); + for (j=(i-(i%16)); j <= i; j++) { + byte = data_buffer[j]; + if ((byte > 31) && (byte < 127)) { + printf("%c", byte); + } else { + printf("."); + } + } + printf("\n"); + } + } +} |
