1 /*
2 
3     File: file_xsv.c
4 
5     Copyright (C) 2008 Christophe GRENIER <grenier@cgsecurity.org>
6     Thanks to Günter Schäffler
7 
8     This software is free software; you can redistribute it and/or modify
9     it under the terms of the GNU General Public License as published by
10     the Free Software Foundation; either version 2 of the License, or
11     (at your option) any later version.
12 
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License along
19     with this program; if not, write the Free Software Foundation, Inc., 51
20     Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 
22  */
23 
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 #ifdef HAVE_STRING_H
28 #include <string.h>
29 #endif
30 #include <stdio.h>
31 #include "types.h"
32 #include "filegen.h"
33 
34 static void register_header_check_xsv(file_stat_t *file_stat);
35 static int header_check_xsv(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);
36 
37 const file_hint_t file_hint_xsv= {
38   .extension="xsv",
39   .description="XBOX GTA San Andreas Save File",
40   .max_filesize=PHOTOREC_MAX_FILE_SIZE,
41   .recover=1,
42   .enable_by_default=1,
43   .register_header_check=&register_header_check_xsv
44 };
45 
header_check_xsv(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)46 static int header_check_xsv(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)
47 {
48   reset_file_recovery(file_recovery_new);
49   file_recovery_new->extension=file_hint_xsv.extension;
50   file_recovery_new->calculated_file_size=202772;
51   file_recovery_new->data_check=&data_check_size;
52   file_recovery_new->file_check=&file_check_size;
53   return 1;
54 }
55 
register_header_check_xsv(file_stat_t * file_stat)56 static void register_header_check_xsv(file_stat_t *file_stat)
57 {
58   static const unsigned char xsv_header[9]= {'B','L','O','C', 'K', 'L', 0xDC, 0x1D, 'd'};
59   register_header_check(20, xsv_header,sizeof(xsv_header), &header_check_xsv, file_stat);
60 }
61