From 271f9beb0b83627e4b7aac11d2b9b2206963bb6c Mon Sep 17 00:00:00 2001 From: Martins Mozeiko Date: Sat, 23 Sep 2017 14:07:31 -0700 Subject: [PATCH] fixes wrong head.bin when it is larger than 64KB --- pkg2zip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg2zip.c b/pkg2zip.c index f36242e..e31634b 100644 --- a/pkg2zip.c +++ b/pkg2zip.c @@ -128,7 +128,7 @@ static const char* get_region(const char* id) int main(int argc, char* argv[]) { - printf("pkg2zip v1.0\n"); + printf("pkg2zip v1.1\n"); if (argc < 2 || argc > 3) { fatal("Usage: %s file.pkg [NoNpDrmKey]\n", argv[0]); @@ -301,13 +301,15 @@ int main(int argc, char* argv[]) snprintf(path, sizeof(path), "app/%.9s/sce_sys/package/head.bin", id); zip_begin_file(&z, path); + size_t head_offset = 0; while (head_size != 0) { uint8_t buffer[1 << 16]; uint32_t size = (uint32_t)min64(head_size, sizeof(buffer)); - sys_read(pkg, 0, buffer, size); + sys_read(pkg, head_offset, buffer, size); zip_write_file(&z, buffer, size); head_size -= size; + head_offset += size; } zip_end_file(&z);