From 663521c5f5d02f83e256c72b287c8fae8c5062be Mon Sep 17 00:00:00 2001 From: Johannes Theiner Date: Fri, 2 Nov 2018 14:04:23 +0100 Subject: [PATCH] =?UTF-8?q?a3:=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/c/a3.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/c/a3.c b/src/c/a3.c index bd73458..5ce1db0 100644 --- a/src/c/a3.c +++ b/src/c/a3.c @@ -6,27 +6,30 @@ void memdump(unsigned char *string) { int i; - unsigned char buffer[16]; + unsigned char buffer[64]; - printf("ADDR 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF\n"); - for(i = 0; i <= 32; i++) { + printf("ADDR 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF\n"); + for(i = 0; i <= 64; i++) { + string++; if((i % 16) == 0) { - if(i != 0) printf(" %s\n", string++); + if(i != 0) printf(" %s\n", string); printf("0x%04x ", *string); + buffer[i] = string[i]; } printf(" %02x", string[i]); - if ((string[i] < 0x20) || (string[i] > 0x7e)) { - buffer[i % 16] = '.'; - } else { - buffer[i % 16] = string[i]; - } + /*if ((string[i] < 0x20) || (string[i] > 0x7e)) + buffer[i] = '.'; + else + buffer[i] = string[i];*/ + buffer[(i % 16) + 1] = '\0'; + + } while ((i % 16) != 0) { printf(" "); i++; } - printf(" %s\n", buffer); } @@ -41,7 +44,7 @@ int main(int argc, char **argv) { } - memdump((unsigned char*)argv); + memdump((unsigned char*)*argv); char **lastAddress; int count = memreplace(argv[1], *argv[2], *argv[3], 0); @@ -52,4 +55,6 @@ int main(int argc, char **argv) { memdump((unsigned char*)argv[1]); free(argv); + + return 0; } \ No newline at end of file