Added simplier pld unpacking

This commit is contained in:
_ 2018-04-06 16:05:12 -07:00
parent 0ea47e44c3
commit a7cee528f3

View File

@ -93,16 +93,22 @@ char *loadfile(const char *fname, unsigned int *s) {
bool unpackpld(const char *filedata,
unsigned int filesize,
const char *filename) {
if (filedata == NULL || filesize <= 0) {
return false;
}
struct PldHeader h;
if (filedata != NULL && filesize > 0) {
getpldh(&h, filedata);
}
int size = 0;
getpldh(&h, filedata);
char *fn = NULL;
fn = (char*)malloc(strlen(filename) + 3 + 4);
int size = 0;
unsigned int i = 0;
for (i = 0; i < h.numOffset; i++) {
size = sizeofpldstruct(&h, i, filesize);
printf("%x\n", size);
sprintf(fn, "%s_%d", filename, i);
write(fn, filedata + h.offsets[i], size);
}
free(fn);
return true;
}
void write(const char *filename,