summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2016-07-02 09:24:07 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2016-07-02 09:24:07 +0200
commitbda04996bc454ab897785067b8f264326ebbd084 (patch)
tree7af2e9cf23acf5a4a49ed87b8345739c662d9310
parent0b88e301961faffdb2b7fc493d2e4f1c8ec58b8a (diff)
PhotoRec: rename recovered Nintendo DS .nds files
-rw-r--r--src/file_nds.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/file_nds.c b/src/file_nds.c
index ea8ab19..7bc302e 100644
--- a/src/file_nds.c
+++ b/src/file_nds.c
@@ -41,11 +41,29 @@ const file_hint_t file_hint_nds= {
.register_header_check=&register_header_check_nds
};
+static void file_rename_nds(file_recovery_t *file_recovery)
+{
+ FILE *file;
+ unsigned char buffer[12];
+ if((file=fopen(file_recovery->filename, "rb"))==NULL)
+ return;
+ if(fread(&buffer, sizeof(buffer), 1, file) != 1)
+ {
+ fclose(file);
+ return ;
+ }
+ fclose(file);
+ file_rename(file_recovery, &buffer, 12, 0, file_hint_nds.extension, 0);
+}
+
static int header_check_nds(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[0x0c], "NTRJ", 4)==0)
+ return 0;
reset_file_recovery(file_recovery_new);
file_recovery_new->extension=file_hint_nds.extension;
- file_recovery_new->min_filesize=0xc6;
+ file_recovery_new->min_filesize=0x180;
+ file_recovery_new->file_rename=&file_rename_nds;
return 1;
}
@@ -56,4 +74,3 @@ static void register_header_check_nds(file_stat_t *file_stat)
};
register_header_check(0xc0, nds_header, sizeof(nds_header), &header_check_nds, file_stat);
}
-