From: Michael Gernoth Date: Fri, 30 Jan 2009 14:48:28 +0000 (+0100) Subject: search for compressed sections in firmware image X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/commitdiff_plain/9083693311cfae1ba2f233cb651daaab0e9b4b20 search for compressed sections in firmware image --- diff --git a/firmware.c b/firmware.c index 55556fc..706a833 100644 --- a/firmware.c +++ b/firmware.c @@ -8,6 +8,7 @@ #include #include #include "rsb-crc.h" +#include "rsb-lz.h" #define FINDSTR(addr, str) (!strncmp((char*)addr, str, strlen(str))) @@ -452,6 +453,7 @@ int main(int argc, char **argv) if (showall) { show_properties(fw, statbuf.st_size - 4); handle_boarddescription(fw, statbuf.st_size -4, 0); + search_lz_sections(fw, statbuf.st_size - 4); } if (update_crc || patch_fw || patch_bd) { diff --git a/rsb-lz.c b/rsb-lz.c index 495d8d8..4960fc0 100644 --- a/rsb-lz.c +++ b/rsb-lz.c @@ -1,3 +1,6 @@ +#include +#include "rsb-lz.h" + /* TODO: IMPLEMET THIS! */ /* Probably very broken lzw implementation by Agilent: * @@ -417,3 +420,27 @@ * 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"); + } + } +} diff --git a/rsb-lz.h b/rsb-lz.h index bab8b64..5e1fd6d 100644 --- a/rsb-lz.h +++ b/rsb-lz.h @@ -1 +1,3 @@ #define LZ_MAGIC 0x6110beef + +void search_lz_sections(unsigned char *fw, int len);