File hfwget.c changed (mode: 100644) (index 9b9f2fc..b00e747) |
... |
... |
static const struct { |
265 |
265 |
{ 22, "Intermediate firmware" }, |
{ 22, "Intermediate firmware" }, |
266 |
266 |
{ 31, "Station firmware" }, |
{ 31, "Station firmware" }, |
267 |
267 |
{ 32, "AP firmware" }, |
{ 32, "AP firmware" }, |
|
268 |
|
{ 0x14B, "AP firmware" }, |
268 |
269 |
|
|
269 |
270 |
/* Driver type */ |
/* Driver type */ |
270 |
271 |
{ 41, "Windows 9x/NT Miniport NDIS 3.1" }, |
{ 41, "Windows 9x/NT Miniport NDIS 3.1" }, |
|
... |
... |
static const struct { |
289 |
290 |
{ 81, "WaveLAN/IEEE AP" }, |
{ 81, "WaveLAN/IEEE AP" }, |
290 |
291 |
{ 83, "WaveLAN/IEEE Ethernet Converter" }, |
{ 83, "WaveLAN/IEEE Ethernet Converter" }, |
291 |
292 |
{ 87, "USB Boot Loader" }, |
{ 87, "USB Boot Loader" }, |
|
293 |
|
{ 0xFF, "Unknown" } |
292 |
294 |
}; |
}; |
293 |
295 |
|
|
294 |
296 |
/* Checking endianess at runtime because performance isn't an issue, |
/* Checking endianess at runtime because performance isn't an issue, |
|
... |
... |
static void copy_fw_data(struct fwtable *firmware, |
710 |
712 |
printf("Segment: %d File offs: 0x%08x Target mem: 0x%08x " |
printf("Segment: %d File offs: 0x%08x Target mem: 0x%08x " |
711 |
713 |
"Length 0x%04x%s\n", |
"Length 0x%04x%s\n", |
712 |
714 |
i, |
i, |
713 |
|
(void *)block.w - data, |
|
|
715 |
|
(void *)(&block.w[i]) - data, |
714 |
716 |
firmware->segarray[i].offset, |
firmware->segarray[i].offset, |
715 |
717 |
firmware->segarray[i].size, |
firmware->segarray[i].size, |
716 |
718 |
(firmware->segarray[i].size == 0) ? " (ignored)" : ""); |
(firmware->segarray[i].size == 0) ? " (ignored)" : ""); |
|
... |
... |
static void print_fw_ident(const struct fwtable *firmware) |
784 |
786 |
{ |
{ |
785 |
787 |
size_t i; |
size_t i; |
786 |
788 |
|
|
787 |
|
if (firmware->ident->code == 0xFD20u) |
|
|
789 |
|
if ((firmware->ident->code == 0xFD20u) || /* FW_IDENTITY */ |
|
790 |
|
(firmware->ident->code == 0x014Bu)) /* AP_IDENTITY */ |
788 |
791 |
{ |
{ |
789 |
792 |
for (i = 0; i < ARRAY_SIZE(compat_table); i++) |
for (i = 0; i < ARRAY_SIZE(compat_table); i++) |
790 |
793 |
{ |
{ |
791 |
794 |
if (compat_table[i].id == firmware->ident->comp_id) |
if (compat_table[i].id == firmware->ident->comp_id) |
792 |
795 |
break; |
break; |
793 |
796 |
} |
} |
|
797 |
|
if (i == ARRAY_SIZE(compat_table)) |
|
798 |
|
i--; |
794 |
799 |
|
|
795 |
800 |
printf("Firmware identity: %s, Variant %d Version %d.%2d\n", |
printf("Firmware identity: %s, Variant %d Version %d.%2d\n", |
796 |
801 |
compat_table[i].comp_string, |
compat_table[i].comp_string, |
|
... |
... |
static int dump_fw(const char *basename, char hexchar, |
1068 |
1073 |
filename = malloc(strlen(basename) + 12); |
filename = malloc(strlen(basename) + 12); |
1069 |
1074 |
strcpy(filename, basename); |
strcpy(filename, basename); |
1070 |
1075 |
strcat(filename, |
strcat(filename, |
1071 |
|
(firmware.ident->comp_id == 32) ? "_ap_fw.bin" : "_sta_fw.bin"); |
|
|
1076 |
|
(firmware.ident->comp_id == 31) ? "_sta_fw.bin" : "_ap_fw.bin"); |
1072 |
1077 |
|
|
1073 |
1078 |
printf("Dumping to %s...\n", filename); |
printf("Dumping to %s...\n", filename); |
1074 |
1079 |
if ((output = fopen(filename, "wb")) == NULL) |
if ((output = fopen(filename, "wb")) == NULL) |
|
... |
... |
struct fw_layout* detect_fw_layout(const void *data, size_t flen) |
1115 |
1120 |
/* restrict search area */ |
/* restrict search area */ |
1116 |
1121 |
layout->max_offset = (size_t) (be32_to_host(fw_section->offset) + |
layout->max_offset = (size_t) (be32_to_host(fw_section->offset) + |
1117 |
1122 |
be32_to_host(fw_section->size)); |
be32_to_host(fw_section->size)); |
1118 |
|
layout->mac = mac; |
|
|
1123 |
|
layout->mac = mac; |
1119 |
1124 |
} |
} |
1120 |
1125 |
else if (macho == -1) |
else if (macho == -1) |
1121 |
1126 |
{ |
{ |
|
... |
... |
struct fw_layout* detect_fw_layout(const void *data, size_t flen) |
1133 |
1138 |
|
|
1134 |
1139 |
layout->addr_delta = (ptrdiff_t) pe_imagebase(data); |
layout->addr_delta = (ptrdiff_t) pe_imagebase(data); |
1135 |
1140 |
layout->max_offset = flen; |
layout->max_offset = flen; |
1136 |
|
layout->mac = mac; |
|
|
1141 |
|
layout->mac = mac; |
1137 |
1142 |
} |
} |
1138 |
1143 |
else if (memcmp(data, "Joy!", 4) == 0) |
else if (memcmp(data, "Joy!", 4) == 0) |
1139 |
1144 |
{ |
{ |