]> cvs.zerfleddert.de Git - rsbs2/blobdiff - rsb-lz.c
ignore rsb-lz.o
[rsbs2] / rsb-lz.c
index 4960fc0b7ee76eb9caf975f2699d597cfea33c91..e43b74b21552134921aa8f0193b761e7d7dec06c 100644 (file)
--- a/rsb-lz.c
+++ b/rsb-lz.c
@@ -1,4 +1,9 @@
 #include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <string.h>
+#include <errno.h>
+#include "rsb-crc.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 */
+};
+
+unsigned int fn_59848(struct s_59b78 *data)
+{
+       return 0;
+}
+
+unsigned int fn_598b4(struct s_59b78 *data, unsigned int arg2)
+{
+       return 0;
+}
+
+void fn_5980c(unsigned int arg1, unsigned int mem[])
+{
+}
+
+void fn_5993c(struct s_59b78 *data, unsigned int mem[])
+{
+       unsigned int r5;
+       unsigned int r2;
+       unsigned int r4;
+       unsigned char arr_59b64[1024];
+
+       r5 = 1;
+
+       do {
+               r2 = fn_59848(data);
+               if (r2 == 0)
+                       break;
+
+               r2 = fn_598b4(data, 8) & 0xff;
+               r4 = r2;
+
+               fn_5980c(r4, mem);
+               arr_59b64[r5] = r4;
+               r2 = r5 + 1;
+               r2 = r2 << 22;
+               r2 = r2 >> 22;
+               r5 = r2;
+       } while(1);
+
+       /* CONT: 599a4 */
+
+}
+
+unsigned int crc_check_59684(unsigned char *arg1, unsigned int arg2, unsigned int magic)
+{
+       unsigned int r3;
+       unsigned int r4;
+       unsigned int r5;
+
+#if 0
+       if (r0 < 0xc0000000)
+               return 1;
+#endif
+
+       r4 = *((unsigned int*)arg1 + 0x20);
+       r5 = *((unsigned int*)arg1 + 0x24);
+
+       if (r5 != magic)
+               return 2;
+       
+       if (arg2 >= r4)
+               r5 = 0;
+       else
+               return 3;
+
+       r5 = ~rsb_crc(~0x00, arg1, r4);
+       r3 = *((unsigned int*)(arg1 + r4));
+       printf("Checksums: 0x%02x <-> 0x%02x\n", r5, r3);
+
+       if (r3 == r5)
+               return 0;
+
+       return 0;
+}
+
+void fn_59508()
+{
+}
+
+void extract_lz_file(unsigned char *buf, unsigned char *name)
+{
+       unsigned char *r3;
+       unsigned int r5;
+       unsigned char *r7 = NULL; /* Arg1, mem start */
+       unsigned char *r10 = NULL; /* Arg2, mem end */
+       unsigned char *r11 = buf; /* Arg3 */
+       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);
+
+       r3 = r7 + 0x20;
+       r5 = *((unsigned int*)r3);
+
+       if (crc_check_59684(r7, r5, 0x46335053) != 0)
+               fn_59788();
+       
+       fn_59508();
+
+       free(r7);
+}
+
 void search_lz_sections(unsigned char *fw, int len)
 {
        int i;
@@ -436,6 +596,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