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, bool unpackpld(const char *filedata,
unsigned int filesize, unsigned int filesize,
const char *filename) { const char *filename) {
struct PldHeader h; if (filedata == NULL || filesize <= 0) {
if (filedata != NULL && filesize > 0) { return false;
getpldh(&h, filedata);
} }
struct PldHeader h;
getpldh(&h, filedata);
char *fn = NULL;
fn = (char*)malloc(strlen(filename) + 3 + 4);
int size = 0; int size = 0;
unsigned int i = 0; unsigned int i = 0;
for (i = 0; i < h.numOffset; i++) { for (i = 0; i < h.numOffset; i++) {
size = sizeofpldstruct(&h, i, filesize); 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, void write(const char *filename,