]> cvs.zerfleddert.de Git - rsbs2/blobdiff - extract.c
solved the mistrey of 4 unknown bytes, only one left
[rsbs2] / extract.c
index feab68f33570da5f068b22c1953afa9147814df2..5d2a6fc8b6d7d1ca2076168e9d7b8060623b3888 100644 (file)
--- a/extract.c
+++ b/extract.c
@@ -15,7 +15,9 @@
 void extract_files(unsigned char *fw, int len)
 {
        unsigned char *pos;
-       unsigned int type, length;
+       unsigned int content_length;
+       unsigned int name_length;
+       unsigned char unknown;
        char *name;
 
        pos = fw + 0x28;
@@ -24,23 +26,25 @@ void extract_files(unsigned char *fw, int len)
        pos = fw + *((unsigned int*)pos);
 
        while (pos < (fw + len)) {
-               type = *((unsigned int*)pos);
+               unknown = *pos; pos++;
+               name_length = *((unsigned int*)pos);
                pos += 4;
-               /* ??? */
-               pos++;
-               length = *((unsigned int*)pos);
+               content_length = *((unsigned int*)pos);
                pos += 4;
                name = (char*)pos;
-               pos += strlen(name) + 1;
 
-               if ((pos + length) > (fw + len)) {
+               if (((pos + content_length) > (fw + len)) ||
+                   ((pos + name_length) > (fw + len))) {
                        printf("EOF reached\n");
                        break;
                }
-               printf("%s: type: 0x%x, length: %d", name, type, length);
+               pos += name_length;
 
-               if (length > 0) {
-                       write_file(name, pos, length);
+               printf("%s: unknown: 0x%02x, length: %d",
+                       name, unknown, content_length);
+
+               if (content_length > 0) {
+                       write_file(name, pos, content_length);
                        if (*((unsigned int*)pos) == LZ_MAGIC) {
                                char *lzname;
 
@@ -76,7 +80,7 @@ void extract_files(unsigned char *fw, int len)
                        }
                }
 
-               pos += length;
+               pos += content_length;
 
        }
 }
Impressum, Datenschutz