]> git.zerfleddert.de Git - rsbs2/blobdiff - firmware.c
solved the mistrey of 4 unknown bytes, only one left
[rsbs2] / firmware.c
index 55556fc15a2a1c8ba3c1ef2197e8b5f120c8ad40..cd7927b8f9854d86c20696adcfaabd8285f18dbf 100644 (file)
@@ -8,6 +8,7 @@
 #include <string.h>
 #include <strings.h>
 #include "rsb-crc.h"
+#include "extract.h"
 
 #define FINDSTR(addr, str) (!strncmp((char*)addr, str, strlen(str)))
 
@@ -75,13 +76,13 @@ void show_properties(unsigned char *fw, int len)
                        }
 
                        if (prop->right_rw == 0x00 && prop->rw_mask == 0x00) {
-                               printf("(R-) ");
+                               printf("(R-)");
                        } else if (prop->right_rw == 0x01) {
-                               printf("(RW mask: 0x%02x) ", prop->rw_mask);
+                               printf("(RW mask: 0x%02x)", prop->rw_mask);
                        } else {
-                               printf("(UNK 0x%02x 0x%02x) ", prop->right_rw, prop->rw_mask);
+                               printf("(UNK 0x%02x 0x%02x)", prop->right_rw, prop->rw_mask);
                        }
-                       printf("\n");
+                       printf(", length: %d\n", *((unsigned int*)(fw + i - 4)));
                }
        }
 }
@@ -254,6 +255,7 @@ void syntax(char *name)
        fprintf(stderr,"\t-d\t\tdisplay all properties of the image\n");
        fprintf(stderr,"\t-u\t\tupdate checksum of the image\n");
        fprintf(stderr,"\t-b\t\tmodify BOARD_DESCRIPTION for more power-switch options\n");
+       fprintf(stderr,"\t-e\t\textract files in firmware\n");
        fprintf(stderr,"\t-t property\tset 'property' to true\n");
        fprintf(stderr,"\t-f property\tset 'property' to false\n");
        fprintf(stderr,"\t-w property\tallow read-write access to 'property'\n");
@@ -351,11 +353,12 @@ int main(int argc, char **argv)
        int update_crc = 0;
        int patch_bd = 0;
        int patch_fw = 0;
+       int extract = 0;
 
        if (argc < 2)
                syntax(argv[0]);
 
-       while ((opt = getopt(argc, argv, "dubt:f:w:r:")) != -1) {
+       while ((opt = getopt(argc, argv, "dubet:f:w:r:")) != -1) {
                switch(opt) {
                        case 'd':
                                showall = 1;
@@ -366,6 +369,9 @@ int main(int argc, char **argv)
                        case 'b':
                                patch_bd = 1;
                                break;
+                       case 'e':
+                               extract = 1;
+                               break;
                        case 't':
                        case 'f':
                        case 'w':
@@ -417,6 +423,7 @@ int main(int argc, char **argv)
        ret = check_crc(fw, statbuf.st_size);
        if ((ret != 0) && (!update_crc)) {
                fprintf(stderr,"Checksum incorrect, aborting...\n");
+               exit(1);
        }
 
        if (patch_fw) {
@@ -454,6 +461,10 @@ int main(int argc, char **argv)
                handle_boarddescription(fw, statbuf.st_size -4, 0);
        }
 
+       if (extract) {
+               extract_files(fw, statbuf.st_size - 4);
+       }
+
        if (update_crc || patch_fw || patch_bd) {
                ret = rsb_crc2(fw, statbuf.st_size, 0x55335053, &crc);
                if (ret == 4) {
Impressum, Datenschutz