From 214d9984c33a5a0eac1d890d917a054268b98879 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Wed, 25 Sep 2019 02:26:19 +0200 Subject: Add support for 'ftab' file format --- src/ftab.h | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/ftab.h (limited to 'src/ftab.h') diff --git a/src/ftab.h b/src/ftab.h new file mode 100644 index 0000000..2efdac3 --- /dev/null +++ b/src/ftab.h @@ -0,0 +1,69 @@ +/* + * ftab.h + * Functions for handling the ftab format + * + * Copyright (c) 2019 Nikias Bassen. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef IDEVICERESTORE_FTAB_H +#define IDEVICERESTORE_FTAB_H + +#ifdef __cplusplus +extern "C" { +#endif + +struct ftab_header { + uint32_t always_01; // 1 + uint32_t always_ff; // 0xFFFFFFFF + uint32_t unk_0x08; // 0 + uint32_t unk_0x0C; // 0 + uint32_t unk_0x10; // 0 + uint32_t unk_0x14; // 0 + uint32_t unk_0x18; // 0 + uint32_t unk_0x1C; // 0 + uint32_t tag; // e.g. 'rkos' + uint32_t magic; // 'ftab' magic + uint32_t num_entries; + uint32_t pad_0x2C; +}; + +struct ftab_entry { + uint32_t tag; + uint32_t offset; + uint32_t size; + uint32_t pad_0x0C; +}; + +struct ftab_fmt { + struct ftab_header header; + struct ftab_entry *entries; + unsigned char **storage; +}; + +typedef struct ftab_fmt *ftab_t; + +int ftab_parse(unsigned char *data, unsigned int data_size, ftab_t *ftab, uint32_t *tag); +int ftab_get_entry_ptr(ftab_t ftab, uint32_t tag, unsigned char **data, unsigned int *data_size); +int ftab_add_entry(ftab_t ftab, uint32_t tag, unsigned char *data, unsigned int data_size); +int ftab_write(ftab_t ftab, unsigned char **data, unsigned int *data_size); +int ftab_free(ftab_t ftab); + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.1-32-gdbae