]> cvs.zerfleddert.de Git - rsbs2/commitdiff
begin lz implementation
authorMichael Gernoth <michael@gernoth.net>
Fri, 30 Jan 2009 19:37:03 +0000 (20:37 +0100)
committerMichael Gernoth <michael@gernoth.net>
Fri, 30 Jan 2009 19:37:03 +0000 (20:37 +0100)
firmware.c
rsb-lz.c

index 706a8336ff09eb07273a29283dc6be4f77380246..2c9960fa7436ad745160b512977e108db2c3475e 100644 (file)
@@ -255,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");
@@ -352,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;
@@ -367,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':
@@ -453,6 +458,9 @@ int main(int argc, char **argv)
        if (showall) {
                show_properties(fw, statbuf.st_size - 4);
                handle_boarddescription(fw, statbuf.st_size -4, 0);
+       }
+
+       if (extract) {
                search_lz_sections(fw, statbuf.st_size - 4);
        }
 
index 4960fc0b7ee76eb9caf975f2699d597cfea33c91..e3ce0914d4fbbce6fe721d63f4c9350c710a21bc 100644 (file)
--- a/rsb-lz.c
+++ b/rsb-lz.c
@@ -1,4 +1,8 @@
 #include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <string.h>
+#include <errno.h>
 #include "rsb-lz.h"
 
 /* TODO: IMPLEMET THIS! */
  * 59b80:      46335053        undefined
  */
 
+void fn_59560(unsigned int arg1)
+{
+}
+
+void fn_59578(unsigned int arg1, unsigned int arg2, unsigned int arg3, unsigned int arg4)
+{
+}
+
+void fn_59788()
+{
+       fprintf(stderr,"error extracting...\n");
+       exit(1);
+}
+
+struct s_59b78 {
+       unsigned char *start;
+       unsigned char *stop;
+       unsigned char y; /* 8 */
+       unsigned char x; /* 9 */
+};
+
+void fn_5993c(struct s_59b78 *data, unsigned int mem[])
+{
+}
+
+void extract_lz_file(unsigned char *buf, unsigned char *name)
+{
+       unsigned int r0;
+       unsigned int r1;
+       unsigned int r2;
+       unsigned char *r3;
+       unsigned int r4;
+       unsigned int r5;
+       unsigned int r6;
+       unsigned char *r7 = NULL; /* Arg1, mem start */
+       unsigned int r8;
+       unsigned int r9;
+       unsigned char *r10 = NULL; /* Arg2, mem end */
+       unsigned char *r11 = buf; /* Arg3 */
+       unsigned int r12;
+       unsigned int r13;
+       struct s_59b78 struct1;
+       unsigned int arr_59b7c[1024];
+
+       r7 = malloc(1024*1024*1024);
+       r10 = r7 + (1024*1024*1024);
+
+       if (r7 == NULL) {
+               perror("malloc");
+               exit(1);
+       }
+
+       fn_59578(0, 0, 0x3f, 0x33);
+       fn_59578(4, 0x10000000, 0x33, 0x366);
+       fn_59578(5, 0x14000000, 0x1b, 0x733);
+       fn_59578(7, 0xc0000000, 0x3b, 0x33);
+       fn_59560(0x1005);
+
+       if (*((unsigned int*)r11) != LZ_MAGIC)
+               fn_59788();
+       r3 = r11 + 4;
+       r5 = *((unsigned int*)r3);
+       printf(", Length: %d\n", r5);
+
+       r3 = r7 + r5;
+       if (r3 > r10)
+               fn_59788();
+       
+       struct1.start = r11 + 8;
+       struct1.stop = r5 + r11;
+       struct1.x = 0;
+       struct1.y = 0x80;
+
+       arr_59b7c[0] = (unsigned int)r7;
+       arr_59b7c[1] = (unsigned int)(r5 + r7);
+
+       fn_5993c(&struct1, arr_59b7c);
+
+       free(r7);
+}
+
 void search_lz_sections(unsigned char *fw, int len)
 {
        int i;
@@ -436,6 +521,7 @@ void search_lz_sections(unsigned char *fw, int len)
                        while (j > fw) {
                                if (*j == 0x00) {
                                        printf("%s", j+1);
+                                       extract_lz_file(fw + i, j+1);
                                        break;
                                }
                                j--;
Impressum, Datenschutz