From: Michael Gernoth Date: Wed, 28 Jan 2009 20:34:53 +0000 (+0100) Subject: use a struct for the property fields X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/rsbs2/commitdiff_plain/39601b0e14fba4df3a556a84b1aae3d0c15cea7b use a struct for the property fields --- diff --git a/firmware.c b/firmware.c index 0361634..a5bdfdb 100644 --- a/firmware.c +++ b/firmware.c @@ -11,7 +11,21 @@ #define FINDSTR(addr, str) (!strncmp((char*)addr, str, strlen(str))) -void handle_defaults(unsigned char *fw, int len, int patch) +struct properties { + unsigned int magic; + unsigned char unknown0; + unsigned char unknown1; + unsigned char right_rw; + unsigned char rw_mask; + unsigned char type1; + unsigned char unknown5; + unsigned char unknown6; + unsigned char unknown7; + unsigned char type2; + unsigned char val[]; +}; + +void show_properties(unsigned char *fw, int len) { int i; @@ -19,50 +33,35 @@ void handle_defaults(unsigned char *fw, int len, int patch) if (FINDSTR(fw+i, "/default/fw_prop/") || FINDSTR(fw+i, "/default/fw_setup/") || FINDSTR(fw+i, "/default/oem_prop/")) { + struct properties *prop; unsigned char *pos = fw + i; - unsigned char type1, type2; - unsigned char right_rw, rw_mask; - unsigned char *val; printf("0x%08x: found setting: %s: ", i, pos); - - pos += strlen((char*)pos) + 1; - if ((pos[0] != 0x11) || - (pos[1] != 0x11) || - (pos[2] != 0x01) || - (pos[3] != 0x83)) { + prop = (struct properties*)(pos + strlen((char*)pos) + 1); + + if (prop->magic != 0x83011111) { printf("ignoring...\n"); continue; } - - pos += 4; - - right_rw = pos[2]; - rw_mask = pos[3]; - - type1 = pos[4]; - type2 = pos[8]; - val = pos + 9; - - if (type1 == 0x00 && type2 == 0x04) { - printf("STRING: %s ", val); - } else if (type1 == 0x01 && type2 == 0x01) { - printf("BOOL: %s ",(*val ? "TRUE" : "FALSE")); - } else if (type1 == 0x04 && type2 == 0x02) { - printf("VAL: 0x%x ", *((unsigned int*)val)); + if (prop->type1 == 0x00 && prop->type2 == 0x04) { + printf("STRING: %s ", prop->val); + } else if (prop->type1 == 0x01 && prop->type2 == 0x01) { + printf("BOOL: %s ",(*prop->val ? "TRUE" : "FALSE")); + } else if (prop->type1 == 0x04 && prop->type2 == 0x02) { + printf("VAL: 0x%x ", *((unsigned int*)prop->val)); } else { - printf("0x%02x 0x%2x...ignoring\n", type1, type2); + printf("0x%02x 0x%2x...ignoring\n", prop->type1, prop->type2); continue; } - if (right_rw == 0x00 && rw_mask == 0x00) { + if (prop->right_rw == 0x00 && prop->rw_mask == 0x00) { printf("(R-) "); - } else if (right_rw == 0x01) { - printf("(RW mask: 0x%02x) ", rw_mask); + } else if (prop->right_rw == 0x01) { + printf("(RW mask: 0x%02x) ", prop->rw_mask); } else { - printf("(UNK 0x%02x 0x%02x) ", right_rw, rw_mask); + printf("(UNK 0x%02x 0x%02x) ", prop->right_rw, prop->rw_mask); } printf("\n"); } @@ -124,7 +123,7 @@ int main(int argc, char **argv) oldcrc); if (1) { - handle_defaults(fw, statbuf.st_size - 4, 0); + show_properties(fw, statbuf.st_size - 4); handle_boarddescription(fw, statbuf.st_size - 4, 0); if (0) { ret = rsb_crc2(fw, statbuf.st_size, 0x55335053, &crc);