fixes wrong head.bin when it is larger than 64KB

This commit is contained in:
Martins Mozeiko
2017-09-23 14:11:02 -07:00
parent 0a7c2955d2
commit 271f9beb0b
+4 -2
View File
@@ -128,7 +128,7 @@ static const char* get_region(const char* id)
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
printf("pkg2zip v1.0\n"); printf("pkg2zip v1.1\n");
if (argc < 2 || argc > 3) if (argc < 2 || argc > 3)
{ {
fatal("Usage: %s file.pkg [NoNpDrmKey]\n", argv[0]); 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); snprintf(path, sizeof(path), "app/%.9s/sce_sys/package/head.bin", id);
zip_begin_file(&z, path); zip_begin_file(&z, path);
size_t head_offset = 0;
while (head_size != 0) while (head_size != 0)
{ {
uint8_t buffer[1 << 16]; uint8_t buffer[1 << 16];
uint32_t size = (uint32_t)min64(head_size, sizeof(buffer)); 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); zip_write_file(&z, buffer, size);
head_size -= size; head_size -= size;
head_offset += size;
} }
zip_end_file(&z); zip_end_file(&z);