summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mbn.c11
-rw-r--r--src/mbn.h22
-rw-r--r--src/restore.c9
3 files changed, 41 insertions, 1 deletions
diff --git a/src/mbn.c b/src/mbn.c
index a4f514e..101e29f 100644
--- a/src/mbn.c
+++ b/src/mbn.c
@@ -44,6 +44,17 @@ mbn_file* mbn_parse(unsigned char* data, unsigned int size)
mbn->version = 1;
memcpy(&mbn->header.v1, data, sizeof(mbn_header_v1));
mbn->parsed_size = mbn->header.v1.data_size + sizeof(mbn_header_v1);
+ } else if (memcmp(data, BIN_MAGIC, BIN_MAGIC_SIZE) == 0) {
+ mbn->version = 3;
+ memcpy(&mbn->header.bin, data, sizeof(bin_header));
+ mbn->parsed_size = mbn->header.bin.total_size;
+ } else if (memcmp(data, ELF_MAGIC, ELF_MAGIC_SIZE) == 0) {
+ mbn->version = 4;
+ memcpy(&mbn->header.elf, data, sizeof(elf_header));
+ // we cheat here since we don't parse the actual ELF file
+ mbn->parsed_size = mbn->size;
+ } else {
+ debug("DEBUG: Unknown file format passed to %s\n", __func__);
}
if (mbn->parsed_size != mbn->size) {
info("WARNING: size mismatch when parsing MBN file. Continuing anyway.\n");
diff --git a/src/mbn.h b/src/mbn.h
index f8f138d..008ba61 100644
--- a/src/mbn.h
+++ b/src/mbn.h
@@ -66,11 +66,33 @@ struct _mbn_header_v2 {
} __attribute__((packed));
typedef struct _mbn_header_v2 mbn_header_v2;
+#define BIN_MAGIC "\x7D\x04\x00\xEA\x6C\x69\x48\x55"
+#define BIN_MAGIC_SIZE 8
+
+struct _bin_header {
+ unsigned char magic[8];
+ uint32_t unk_0x08;
+ uint32_t version;
+ uint32_t total_size; // size including header
+ uint32_t unk_0x14; // some offset
+} __attribute__((packed));
+typedef struct _bin_header bin_header;
+
+#define ELF_MAGIC "\x7F\x45\x4C\x46\x01\x01\x01\x00" // ELF magic, 32bit, little endian, SYSV
+#define ELF_MAGIC_SIZE 8
+
+struct _elf_header {
+ unsigned char magic[8];
+} __attribute__((packed));
+typedef struct _elf_header elf_header;
+
typedef struct {
uint32_t version;
union {
mbn_header_v1 v1;
mbn_header_v2 v2;
+ bin_header bin;
+ elf_header elf;
} header;
uint32_t parsed_size;
uint32_t parsed_sig_offset;
diff --git a/src/restore.c b/src/restore.c
index fd7be92..e9813f2 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -1102,6 +1102,9 @@ static const char* restore_get_bbfw_fn_for_element(const char* elem)
// Mav5 firmware files
{ "RestoreSBL1", "restoresbl1.mbn" },
{ "SBL1", "sbl1.mbn" },
+ // ICE16 firmware files
+ { "RestorePSI", "restorepsi.bin", },
+ { "PSI", "psi_ram.bin" },
{ NULL, NULL }
};
@@ -1171,6 +1174,10 @@ static int restore_sign_bbfw(const char* bbfwtmp, plist_t bbtss, const unsigned
if (node && (strcmp(key + (strlen(key) - 5), "-Blob") == 0) && (plist_get_node_type(node) == PLIST_DATA)) {
key[strlen(key)-5] = 0;
const char* signfn = restore_get_bbfw_fn_for_element(key);
+ if (!signfn) {
+ error("ERROR: can't match element name '%s' to baseband firmware file name.\n", key);
+ goto leave;
+ }
char* ext = strrchr(signfn, '.');
if (strcmp(ext, ".fls") == 0) {
is_fls = 1;
@@ -1304,7 +1311,7 @@ static int restore_sign_bbfw(const char* bbfwtmp, plist_t bbtss, const unsigned
const char* fn = zip_get_name(za, i, 0);
if (fn) {
char* ext = strrchr(fn, '.');
- if (ext && (strcmp(ext, ".fls") == 0 || strcmp(ext, ".mbn") == 0)) {
+ if (ext && (!strcmp(ext, ".fls") || !strcmp(ext, ".mbn") || !strcmp(ext, ".elf") || !strcmp(ext, ".bin"))) {
skip = 1;
}
}