From b94ee66ea960458e6995ae97baeb138f2195c94c Mon Sep 17 00:00:00 2001 From: TJ Date: Fri, 13 Nov 2015 22:34:04 +0000 Subject: [PATCH] Display uncompressed file size; debug-mode: show possible checksum of payload --- installshield_main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/installshield_main.c b/installshield_main.c index ed458b3..9e95071 100644 --- a/installshield_main.c +++ b/installshield_main.c @@ -80,7 +80,7 @@ headers_decode(int z_fd) printf("File entries: %d ( %08x bytes @ 0x%08x)\n", header->files_entries, header->files_bytes, header->files_offset); for (int i = 0; i < header->files_entries; ++i) { - printf(" Entry %4d Size %06x @ %08x payload size %06x @ %08x", i, q->entry_bytes, header->files_offset +(uint32_t)((void *)q - (void *)fileent), q->payload_bytes, q->payload_offset); + printf(" Entry %4d uses %06x bytes @ %08x. file-size %08x (payload %08x @ %08x)", i, q->entry_bytes, header->files_offset +(uint32_t)((void *)q - (void *)fileent), q->file_bytes, q->payload_bytes, q->payload_offset); if (debug) { printf(" next @ %08x", q->payload_offset + q->payload_bytes); @@ -93,7 +93,7 @@ headers_decode(int z_fd) char *dir_name = strdup(dirents[q->dir_index].entry->name); for (char *p = dir_name; *p; ++p) if (*p == '\\') *p = '/'; - printf("Parsing '%s' (%d bytes)\n", dir_name, strlen(dir_name)); + if (debug) printf("Parsing '%s' (%ld bytes)\n", dir_name, strlen(dir_name)); int dir_fd = AT_FDCWD; int dir_fd_last = dir_fd; @@ -108,7 +108,7 @@ headers_decode(int z_fd) char temp = *sep; *sep = 0; if (strlen(component) > 0) { - if (debug) printf("Component: '%s' %d bytes @ %p\n", component, strlen(component), component); + if (debug) printf("Component: '%s' %ld bytes @ %p\n", component, strlen(component), component); int ret = mkdirat(dir_fd, component, 0755); if (ret == 0 || (ret == -1 && errno == EEXIST)) { if (debug) @@ -157,6 +157,13 @@ headers_decode(int z_fd) if ((pay_fd = openat(dir_fd, z_filename, O_WRONLY | O_CREAT | O_TRUNC, 0644))) { ssize_t z_qty, pay_qty; if ((z_qty = read(z_fd, buffer, q->payload_bytes)) == q->payload_bytes) { + if (debug) { + unsigned int checksum = 0x0; + for (int i = 0; i < q->payload_bytes / sizeof(unsigned int); ++i) { + checksum ^= ((unsigned int *)buffer)[i]; + } + printf("Checksum: %08x\n", checksum); + } if ((pay_qty = write(pay_fd, buffer, q->payload_bytes)) != q->payload_bytes) fprintf(stderr, "Error: whilst writing payload expected %d bytes but wrote %ld\n", q->payload_bytes, pay_qty); } else -- 2.17.1