summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2018-02-07 18:16:58 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2018-02-07 18:16:58 +0100
commitf2cbb4f7bef028de1d1ac4057ce0ec0c81ed1675 (patch)
treea51d0ed2c00504f9a0cf75c792256fb1a3ca7e0a /src
parentfe85fa7807957b5ede984ba351020ab96c47504a (diff)
PhotoRec: recover Mensura .msa files (not enabled by default)
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/file_list.c2
-rw-r--r--src/file_msa.c74
3 files changed, 77 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index e60a2f9..b2bfd88 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -213,6 +213,7 @@ file_C = filegen.c \
file_mpg.c \
file_mpl.c \
file_mrw.c \
+ file_msa.c \
file_mus.c \
file_mxf.c \
file_myo.c \
diff --git a/src/file_list.c b/src/file_list.c
index 5e0cb38..aee0015 100644
--- a/src/file_list.c
+++ b/src/file_list.c
@@ -216,6 +216,7 @@ extern const file_hint_t file_hint_mp3;
extern const file_hint_t file_hint_mpg;
extern const file_hint_t file_hint_mpl;
extern const file_hint_t file_hint_mrw;
+extern const file_hint_t file_hint_msa;
extern const file_hint_t file_hint_mus;
extern const file_hint_t file_hint_mxf;
extern const file_hint_t file_hint_myo;
@@ -545,6 +546,7 @@ file_enable_t list_file_enable[]=
{ .enable=0, .file_hint=&file_hint_mpg },
{ .enable=0, .file_hint=&file_hint_mpl },
{ .enable=0, .file_hint=&file_hint_mrw },
+ { .enable=0, .file_hint=&file_hint_msa },
{ .enable=0, .file_hint=&file_hint_mus },
{ .enable=0, .file_hint=&file_hint_myo },
{ .enable=0, .file_hint=&file_hint_mysql },
diff --git a/src/file_msa.c b/src/file_msa.c
new file mode 100644
index 0000000..7d9f558
--- /dev/null
+++ b/src/file_msa.c
@@ -0,0 +1,74 @@
+/*
+
+ File: file_msa.c
+
+ Copyright (C) 2017 Christophe GRENIER <grenier@cgsecurity.org>
+
+ 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"
+
+static void register_header_check_msa(file_stat_t *file_stat);
+
+const file_hint_t file_hint_msa= {
+ .extension="msa",
+ .description="Mensura",
+ .max_filesize=PHOTOREC_MAX_FILE_SIZE,
+ .recover=1,
+ .enable_by_default=0,
+ .register_header_check=&register_header_check_msa
+};
+
+struct msa_header
+{
+ uint32_t magic;
+ uint32_t size;
+} __attribute__ ((gcc_struct, __packed__));
+
+static int header_check_msa(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 msa_header *msa=(const struct msa_header *)buffer;
+ if(buffer[0x13]!=0x40)
+ return 0;
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_msa.extension;
+ file_recovery_new->calculated_file_size=(uint64_t)le32(msa->size);
+ file_recovery_new->data_check=&data_check_size;
+ file_recovery_new->file_check=&file_check_size;
+ return 1;
+}
+
+static void register_header_check_msa(file_stat_t *file_stat)
+{
+ static const unsigned char msa_header_fb[4]= {
+ 0xfb, 0xff, 0xff, 0xff
+ };
+ static const unsigned char msa_header_fc[4]= {
+ 0xfc, 0xff, 0xff, 0xff
+ };
+ register_header_check(0, msa_header_fb, sizeof(msa_header_fb), &header_check_msa, file_stat);
+ register_header_check(0, msa_header_fc, sizeof(msa_header_fc), &header_check_msa, file_stat);
+}