diff options
author | Christophe Grenier <grenier@cgsecurity.org> | 2009-02-18 20:09:49 +0100 |
---|---|---|
committer | Christophe Grenier <grenier@cgsecurity.org> | 2009-02-18 20:09:49 +0100 |
commit | 2801b7815b8091c482db498051eb43f3a8725ec6 (patch) | |
tree | 60d671779a793c603847928fdaf8fcb2330d0b78 | |
parent | 8ac6a0d4acb85b4cb7d9be0c40a9049b549d918c (diff) |
PhotoRec: recover Diablo II .d2s and .mk5 files generated by a custom CAD-CAM software
-rw-r--r-- | src/Makefile.am | 6 | ||||
-rw-r--r-- | src/file_d2s.c | 68 | ||||
-rw-r--r-- | src/file_list.c | 4 | ||||
-rw-r--r-- | src/file_mk5.c | 63 |
4 files changed, 139 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 14fccdf..50ae8e7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -58,6 +58,7 @@ file_C = filegen.c \ file_crw.c \ file_ctg.c \ file_cwk.c \ + file_d2s.c \ file_dat.c \ file_dbf.c \ file_dim.c \ @@ -120,6 +121,7 @@ file_C = filegen.c \ file_mfa.c \ file_mfg.c \ file_mid.c \ + file_mk5.c \ file_mkv.c \ file_mov.c \ file_mp3.c \ @@ -206,8 +208,8 @@ photorec_C = photorec.c phcfg.c ext2grp.c ext2_dir.c fat_dir.c fatp.c list.c nt photorec_H = photorec.h phcfg.h dir.c dir.h ext2grp.h ext2p.c ext2p.h ext2_dir.h ext2_inc.h fat_dir.h fatp.h memmem.h ntfs_dir.h ntfsp.h ntfs_inc.h sessionp.h -photorec_ncurses_C = addpart.c askloc.c chgtype.c chgtypen.c geometry.c hiddenn.c intrfn.c nodisk.c parti386n.c partgptn.c partmacn.c partsunn.c partxboxn.c pbanner.c pblocksize.c pdisksel.c pfree_whole.c phrecn.c ppartsel.c -photorec_ncurses_H = addpart.h askloc.h chgtype.h chgtypen.h geometry.h hiddenn.h intrfn.h nodisk.h parti386n.h partgptn.h partmacn.h partsunn.h partxboxn.h pblocksize.h pdisksel.h pfree_whole.h pnext.h phrecn.h ppartsel.h +photorec_ncurses_C = addpart.c askloc.c chgtype.c chgtypen.c fat_cluster.c geometry.c hiddenn.c intrfn.c nodisk.c parti386n.c partgptn.c partmacn.c partsunn.c partxboxn.c pbanner.c pblocksize.c pdisksel.c pfree_whole.c phrecn.c ppartsel.c +photorec_ncurses_H = addpart.h askloc.h chgtype.h chgtypen.h fat_cluster.h geometry.h hiddenn.h intrfn.h nodisk.h parti386n.h partgptn.h partmacn.h partsunn.h partxboxn.h pblocksize.h pdisksel.h pfree_whole.h pnext.h phrecn.h ppartsel.h photorec_SOURCES = phmain.c $(photorec_C) $(photorec_H) $(photorec_ncurses_C) $(photorec_ncurses_H) $(file_C) $(file_H) $(base_C) $(base_H) $(fs_C) $(fs_H) $(ICON_PHOTOREC) diff --git a/src/file_d2s.c b/src/file_d2s.c new file mode 100644 index 0000000..5a09343 --- /dev/null +++ b/src/file_d2s.c @@ -0,0 +1,68 @@ +/* + + File: file_d2s.c + + Copyright (C) 2009 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_d2s(file_stat_t *file_stat); +static int header_check_d2s(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 file_hint_t file_hint_d2s= { + .extension="d2s", + .description="Diablo II", + .min_header_distance=0, + .max_filesize=PHOTOREC_MAX_FILE_SIZE, + .recover=1, + .enable_by_default=1, + .register_header_check=®ister_header_check_d2s +}; + +static const unsigned char d2s_header[8]= { + 0x55, 0xaa, 0x55, 0xaa, 0x60, 0x00, 0x00, 0x00 +}; + +static void register_header_check_d2s(file_stat_t *file_stat) +{ + register_header_check(0, d2s_header,sizeof(d2s_header), &header_check_d2s, file_stat); +} + +/* TODO: extract the name from the file */ + +static int header_check_d2s(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) +{ + if(memcmp(buffer,d2s_header,sizeof(d2s_header))==0) + { + reset_file_recovery(file_recovery_new); + file_recovery_new->extension=file_hint_d2s.extension; + file_recovery_new->calculated_file_size=(buffer[8]<<0)+(buffer[9]<<8)+(buffer[10]<<16)+(buffer[11]<<24); + file_recovery_new->data_check=&data_check_size; + file_recovery_new->file_check=&file_check_size; + return 1; + } + return 0; +} diff --git a/src/file_list.c b/src/file_list.c index 53f7daf..a83e2ea 100644 --- a/src/file_list.c +++ b/src/file_list.c @@ -60,6 +60,7 @@ extern const file_hint_t file_hint_compress; extern const file_hint_t file_hint_crw; extern const file_hint_t file_hint_ctg; extern const file_hint_t file_hint_cwk; +extern const file_hint_t file_hint_d2s; extern const file_hint_t file_hint_dat; extern const file_hint_t file_hint_dbf; extern const file_hint_t file_hint_dim; @@ -123,6 +124,7 @@ extern const file_hint_t file_hint_mdf; extern const file_hint_t file_hint_mfa; extern const file_hint_t file_hint_mfg; extern const file_hint_t file_hint_mid; +extern const file_hint_t file_hint_mk5; extern const file_hint_t file_hint_mkv; extern const file_hint_t file_hint_mov; extern const file_hint_t file_hint_mp3; @@ -237,6 +239,7 @@ file_enable_t list_file_enable[]= { .enable=0, .file_hint=&file_hint_crw }, { .enable=0, .file_hint=&file_hint_ctg }, { .enable=0, .file_hint=&file_hint_cwk }, + { .enable=0, .file_hint=&file_hint_d2s }, { .enable=0, .file_hint=&file_hint_dat }, { .enable=0, .file_hint=&file_hint_dbf }, { .enable=0, .file_hint=&file_hint_dim }, @@ -299,6 +302,7 @@ file_enable_t list_file_enable[]= { .enable=0, .file_hint=&file_hint_mfa }, { .enable=0, .file_hint=&file_hint_mfg }, { .enable=0, .file_hint=&file_hint_mid }, + { .enable=0, .file_hint=&file_hint_mk5 }, { .enable=0, .file_hint=&file_hint_mkv }, { .enable=0, .file_hint=&file_hint_mov }, { .enable=0, .file_hint=&file_hint_mp3 }, diff --git a/src/file_mk5.c b/src/file_mk5.c new file mode 100644 index 0000000..44d11fd --- /dev/null +++ b/src/file_mk5.c @@ -0,0 +1,63 @@ +/* + + File: file_mk5.c + + Copyright (C) 2009 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_mk5(file_stat_t *file_stat); +static int header_check_mk5(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 file_hint_t file_hint_mk5= { + .extension="mk5", + .description="Custom CAD-CAM", + .min_header_distance=0, + .max_filesize=PHOTOREC_MAX_FILE_SIZE, + .recover=1, + .enable_by_default=1, + .register_header_check=®ister_header_check_mk5 +}; + +static const unsigned char mk5_header[4]= { 0x36, 0xff, 0xff, 0xff }; +static const unsigned char mk5_header2[4]= { 0x00, 0x40, 0x1c, 0x46 }; + +static void register_header_check_mk5(file_stat_t *file_stat) +{ + register_header_check(0, mk5_header,sizeof(mk5_header), &header_check_mk5, file_stat); +} + +static int header_check_mk5(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) +{ + if(memcmp(buffer,mk5_header,sizeof(mk5_header))==0 && + memcmp(buffer+0x1c,mk5_header2,sizeof(mk5_header2))==0) + { + reset_file_recovery(file_recovery_new); + file_recovery_new->extension=file_hint_mk5.extension; + return 1; + } + return 0; +} |