]> cvs.zerfleddert.de Git - rsbs2/blobdiff - rsb-lz.c
search for compressed sections in firmware image
[rsbs2] / rsb-lz.c
index 495d8d855c92a5123bc3d0c7b4b1164ca8f61031..4960fc0b7ee76eb9caf975f2699d597cfea33c91 100644 (file)
--- a/rsb-lz.c
+++ b/rsb-lz.c
@@ -1,3 +1,6 @@
+#include <stdio.h>
+#include "rsb-lz.h"
+
 /* TODO: IMPLEMET THIS! */
 /* Probably very broken lzw implementation by Agilent:
  *
  * 59b7c:      14000410        strne   r0, [r0], #-1040
  * 59b80:      46335053        undefined
  */
+
+void search_lz_sections(unsigned char *fw, int len)
+{
+       int i;
+       unsigned char *j;
+
+       for(i = 0; i < len - 4; i++) {
+               if (*((unsigned int*)(fw+i)) == LZ_MAGIC) {
+                       j = fw + i - 1;
+                       if (*j != 0x00)
+                               continue;
+                       printf("0x%02x: ", i);
+                       j--;
+                       while (j > fw) {
+                               if (*j == 0x00) {
+                                       printf("%s", j+1);
+                                       break;
+                               }
+                               j--;
+                       }
+                       printf("\n");
+               }
+       }
+}
Impressum, Datenschutz