diff options
author | Christophe Grenier <[email protected]> | 2017-07-05 09:37:42 +0200 |
---|---|---|
committer | Christophe Grenier <[email protected]> | 2017-07-05 09:37:42 +0200 |
commit | 487579f04c7758741d8a65ca3cd516641d57baf3 (patch) | |
tree | bccb0c9398e425c66dfbbbc2cb880cb6280d5de5 | |
parent | 193dea80a28e19bfcabf3508872350d1895734ca (diff) |
PhotoRec: recover afdesign files
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/file_afdesign.c | 78 | ||||
-rw-r--r-- | src/file_list.c | 2 |
3 files changed, 81 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 767991ad..0a043e53 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -37,6 +37,7 @@ file_C = filegen.c \ file_acb.c \ file_ace.c \ file_ado.c \ + file_afdesign.c \ file_ahn.c \ file_aif.c \ file_all.c \ diff --git a/src/file_afdesign.c b/src/file_afdesign.c new file mode 100644 index 00000000..af93b7c2 --- /dev/null +++ b/src/file_afdesign.c @@ -0,0 +1,78 @@ +/* + + File: file_afdesign.c + + Copyright (C) 2017 Christophe GRENIER <[email protected]> + + This software is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write the Free Software Foundation, Inc., 51 + Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#ifdef HAVE_STRING_H +#include <string.h> +#endif +#include <stdio.h> +#include "types.h" +#include "filegen.h" +#include "common.h" +#include "log.h" + +static void register_header_check_afdesign(file_stat_t *file_stat); + +const file_hint_t file_hint_afdesign= { + .extension="afdesign", + .description="afdesign", + .max_filesize=PHOTOREC_MAX_FILE_SIZE, + .recover=1, + .enable_by_default=1, + .register_header_check=®ister_header_check_afdesign +}; + +/* http://nickbeeuwsaert.github.io/AFDesignLoad/file_format.html */ +struct afdesign_header +{ + uint32_t signature; + uint32_t version; + char prsn[4]; + char info[4]; + uint64_t fat_offset; + uint64_t fat_length; + uint64_t zlib_length; + uint64_t unused1; + uint32_t creation; + uint32_t unused2; + uint64_t fat_entries; + uint64_t fil_entries; +}; + +static int header_check_afdesign(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new) +{ + const struct afdesign_header *hdr=(const struct afdesign_header*)buffer; + if(memcmp(hdr->prsn, "nsrP", 4)!=0) + return 0; + reset_file_recovery(file_recovery_new); + file_recovery_new->extension=file_hint_afdesign.extension; + file_recovery_new->min_filesize=le64(hdr->zlib_length); + return 1; +} + +static void register_header_check_afdesign(file_stat_t *file_stat) +{ + static const unsigned char afdesign_header[4]= { 0x00, 0xff, 'K' , 'A' }; + register_header_check(0, afdesign_header, sizeof(afdesign_header), &header_check_afdesign, file_stat); +} diff --git a/src/file_list.c b/src/file_list.c index e10aaa83..c07d9c86 100644 --- a/src/file_list.c +++ b/src/file_list.c @@ -38,6 +38,7 @@ extern const file_hint_t file_hint_accdb; extern const file_hint_t file_hint_ace; extern const file_hint_t file_hint_addressbook; extern const file_hint_t file_hint_ado; +extern const file_hint_t file_hint_afdesign; extern const file_hint_t file_hint_ahn; extern const file_hint_t file_hint_aif; extern const file_hint_t file_hint_all; @@ -365,6 +366,7 @@ file_enable_t list_file_enable[]= { .enable=0, .file_hint=&file_hint_ace }, { .enable=0, .file_hint=&file_hint_addressbook}, { .enable=0, .file_hint=&file_hint_ado }, + { .enable=0, .file_hint=&file_hint_afdesign }, { .enable=0, .file_hint=&file_hint_ahn }, { .enable=0, .file_hint=&file_hint_aif }, { .enable=0, .file_hint=&file_hint_all }, |