summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-01-05 15:16:22 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2014-01-05 15:16:22 +0100
commit488d3d328f30da9cd5736227f28b94157f5902ef (patch)
tree6cc38af618781545a1d48a3bce022841cd4f9828 /src
parent82dc685578d5b69b49ba9ca3feb13717e124fed5 (diff)
PhotoRec: recover Digital Imaging and Communications in Medicine (DICOM) .dcm files
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am1
-rw-r--r--src/file_dcm.c58
-rw-r--r--src/file_list.c2
3 files changed, 61 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 25ac8c7..56a7db7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -80,6 +80,7 @@ file_C = filegen.c \
file_dat.c \
file_dbf.c \
file_dbn.c \
+ file_dcm.c \
file_ddf.c \
file_dex.c \
file_dim.c \
diff --git a/src/file_dcm.c b/src/file_dcm.c
new file mode 100644
index 0000000..3c7a7d1
--- /dev/null
+++ b/src/file_dcm.c
@@ -0,0 +1,58 @@
+/*
+
+ File: file_dcm.c
+
+ Copyright (C) 2013 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"
+
+static void register_header_check_dcm(file_stat_t *file_stat);
+
+const file_hint_t file_hint_dcm= {
+ .extension="dcm",
+ .description="Digital Imaging and Communications in Medicine (DICOM)",
+ .min_header_distance=0,
+ .max_filesize=PHOTOREC_MAX_FILE_SIZE,
+ .recover=1,
+ .enable_by_default=1,
+ .register_header_check=&register_header_check_dcm
+};
+
+static int header_check_dcm(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)
+{
+ reset_file_recovery(file_recovery_new);
+ file_recovery_new->extension=file_hint_dcm.extension;
+ return 1;
+}
+
+static void register_header_check_dcm(file_stat_t *file_stat)
+{
+ static const unsigned char dcm_header[10]= {
+ 'D' , 'I' , 'C' , 'M' , 0x02, 0x00, 0x00, 0x00,
+ 'U' , 'L' };
+ register_header_check(0, dcm_header, sizeof(dcm_header), &header_check_dcm, file_stat);
+}
diff --git a/src/file_list.c b/src/file_list.c
index 0d57832..f979da5 100644
--- a/src/file_list.c
+++ b/src/file_list.c
@@ -81,6 +81,7 @@ extern const file_hint_t file_hint_dar;
extern const file_hint_t file_hint_dat;
extern const file_hint_t file_hint_dbf;
extern const file_hint_t file_hint_dbn;
+extern const file_hint_t file_hint_dcm;
extern const file_hint_t file_hint_ddf;
extern const file_hint_t file_hint_dex;
extern const file_hint_t file_hint_dim;
@@ -353,6 +354,7 @@ file_enable_t list_file_enable[]=
{ .enable=0, .file_hint=&file_hint_dat },
{ .enable=0, .file_hint=&file_hint_dbf },
{ .enable=0, .file_hint=&file_hint_dbn },
+ { .enable=0, .file_hint=&file_hint_dcm },
{ .enable=0, .file_hint=&file_hint_ddf },
{ .enable=0, .file_hint=&file_hint_dex },
{ .enable=0, .file_hint=&file_hint_dim },