summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-07-14 10:45:29 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2012-07-14 10:45:29 +0200
commite27faf2a246b5dbb3fbbd7b65c1343d96c9fc9b7 (patch)
tree80dcaaf3f4b182f83a25702f1365782d36d4fca3
parent65bfbc1a7b54713186e062dd332c5fe6c9660d5d (diff)
TestDisk: always search for partition aligned on 1 MB boundaries
-rw-r--r--src/godmode.c20
-rw-r--r--src/godmode.h2
-rw-r--r--src/next.c29
-rw-r--r--src/next.h2
-rw-r--r--src/tdiskop.c40
5 files changed, 24 insertions, 69 deletions
diff --git a/src/godmode.c b/src/godmode.c
index 1b3fede..561cf38 100644
--- a/src/godmode.c
+++ b/src/godmode.c
@@ -72,7 +72,7 @@ static list_part_t *add_ext_part_i386(disk_t *disk_car, list_part_t *list_part,
static unsigned int tab_insert(uint64_t *tab, const uint64_t offset, unsigned int tab_nbr);
/* Optimization */
static inline uint64_t CHS2offset_inline(const disk_t *disk_car,const CHS_t*CHS);
-static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_org, const int verbose, const int dump_ind, const int fast_mode, const int interface, const int search_vista_part, char **current_cmd);
+static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_org, const int verbose, const int dump_ind, const int fast_mode, const int interface, char **current_cmd);
static inline void offset2CHS_inline(const disk_t *disk_car,const uint64_t offset, CHS_t*CHS);
static inline void offset2CHS_inline(const disk_t *disk_car,const uint64_t offset, CHS_t*CHS)
@@ -409,7 +409,7 @@ static unsigned int tab_insert(uint64_t *tab, const uint64_t offset, unsigned in
- Geometry: don't care
*/
-static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_org, const int verbose, const int dump_ind, const int fast_mode, const int interface, const int search_vista_part, char **current_cmd)
+static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_org, const int verbose, const int dump_ind, const int fast_mode, const int interface, char **current_cmd)
{
unsigned char *buffer_disk;
unsigned char *buffer_disk0;
@@ -514,7 +514,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
}
search_location=min_location;
/* Not every sector will be examined */
- search_location_init(disk_car, location_boundary, fast_mode, search_vista_part);
+ search_location_init(disk_car, location_boundary, fast_mode);
/* Scan the disk */
while(ind_stop==0 && search_location < search_location_max)
{
@@ -553,7 +553,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
if(disk_car->arch==&arch_i386)
search_now|= (start.sector==1 && fast_mode>1) ||
(start.sector==1 && start.head<=2) ||
- (search_vista_part>0 && search_location%(2048*512)==0);
+ search_location%(2048*512)==0;
else
search_now|= (search_location%location_boundary==0);
while(try_offset_raid_nbr>0 && try_offset_raid[0]<=search_location)
@@ -610,7 +610,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
{
if((disk_car->arch==&arch_i386 &&
((start.sector==7 && (start.head<=2 || fast_mode>1)) ||
- (search_vista_part>0 && search_location%(2048*512)==(7-1)*512))) ||
+ search_location%(2048*512)==(7-1)*512)) ||
(disk_car->arch!=&arch_i386 && (search_location%location_boundary==(7-1)*512)))
res=search_FAT_backup(buffer_disk,disk_car,partition,verbose,dump_ind);
test_nbr++;
@@ -620,7 +620,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
{
if((disk_car->arch==&arch_i386 &&
((start.sector==13 && (start.head<=2 || fast_mode>1)) ||
- (search_vista_part>0 && search_location%(2048*512)==(13-1)*disk_car->sector_size))) ||
+ search_location%(2048*512)==(13-1)*disk_car->sector_size)) ||
(disk_car->arch!=&arch_i386 && (search_location%location_boundary==(13-1)*disk_car->sector_size)))
res=search_EXFAT_backup(buffer_disk, disk_car, partition);
test_nbr++;
@@ -630,7 +630,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
if((disk_car->arch==&arch_i386 &&
((start.sector==disk_car->geom.sectors_per_head &&
(start.head==disk_car->geom.heads_per_cylinder-1 || fast_mode>1)) ||
- (search_vista_part>0 && search_location%(2048*512)==(2048-1)*512))) ||
+ search_location%(2048*512)==(2048-1)*512)) ||
(disk_car->arch!=&arch_i386 && search_location%location_boundary==(location_boundary-512) &&
search_location>0))
res=search_NTFS_backup(buffer_disk,disk_car,partition,verbose,dump_ind);
@@ -641,7 +641,7 @@ static list_part_t *search_part(disk_t *disk_car, const list_part_t *list_part_o
if((disk_car->arch==&arch_i386 &&
((start.sector==disk_car->geom.sectors_per_head &&
(start.head==disk_car->geom.heads_per_cylinder-1 || fast_mode>1)) ||
- (search_vista_part>0 && search_location%(2048*512)==(2048-1)*512))) ||
+ search_location%(2048*512)==(2048-1)*512)) ||
(disk_car->arch!=&arch_i386 && search_location%location_boundary==(location_boundary-512) &&
search_location>0))
res=search_HFS_backup(buffer_disk,disk_car,partition,verbose,dump_ind);
@@ -1288,7 +1288,7 @@ static int use_backup(disk_t *disk_car, const list_part_t *list_part, const int
return 0;
}
-int interface_recovery(disk_t *disk_car, const list_part_t * list_part_org, const int verbose, const int dump_ind, const int align, const int ask_part_order, const unsigned int expert, const int search_vista_part, char **current_cmd)
+int interface_recovery(disk_t *disk_car, const list_part_t * list_part_org, const int verbose, const int dump_ind, const int align, const int ask_part_order, const unsigned int expert, char **current_cmd)
{
int res_interface_write;
int fast_mode=0;
@@ -1306,7 +1306,7 @@ int interface_recovery(disk_t *disk_car, const list_part_t * list_part_org, cons
wmove(stdscr,5,0);
#endif
res_interface_write=0;
- list_part=search_part(disk_car, list_part_org, verbose, dump_ind, fast_mode, 1, search_vista_part, current_cmd);
+ list_part=search_part(disk_car, list_part_org, verbose, dump_ind, fast_mode, 1, current_cmd);
if(list_part!=NULL && (disk_car->arch==&arch_i386 || disk_car->arch==&arch_sun))
{ /* Correct disk geometry is necessary for successfull Intel and Sun partition recovery */
unsigned int heads_per_cylinder;
diff --git a/src/godmode.h b/src/godmode.h
index 990a365..1af7448 100644
--- a/src/godmode.h
+++ b/src/godmode.h
@@ -24,7 +24,7 @@ extern "C" {
#endif
typedef enum part_offset part_offset_t;
-int interface_recovery(disk_t *disk_car, const list_part_t * list_part_org, const int verbose, const int dump_ind, const int align, const int ask_part_order, const unsigned int expert, const int search_vista_part, char **current_cmd);
+int interface_recovery(disk_t *disk_car, const list_part_t * list_part_org, const int verbose, const int dump_ind, const int align, const int ask_part_order, const unsigned int expert, char **current_cmd);
void only_one_bootable( list_part_t *list_part, list_part_t *part_boot);
#ifdef __cplusplus
diff --git a/src/next.c b/src/next.c
index fd7c0b4..e5f03bb 100644
--- a/src/next.c
+++ b/src/next.c
@@ -90,7 +90,7 @@ static void update_location(void)
search_location_nbr++;
}
-void search_location_init(const disk_t *disk_car, const unsigned int location_boundary, const int fast_mode, const int search_vista_part)
+void search_location_init(const disk_t *disk_car, const unsigned int location_boundary, const int fast_mode)
{
/* test_nbr==1... */
if(disk_car->arch==&arch_i386)
@@ -113,12 +113,9 @@ void search_location_init(const disk_t *disk_car, const unsigned int location_bo
search_location_info[search_location_nbr].offset=CHS_to_offset(0,2,1,disk_car);
search_location_info[search_location_nbr].inc=CHS_to_offset(1,0,0,disk_car);
}
- if(search_vista_part>0)
- {
- search_location_info[search_location_nbr].offset=0;
- search_location_info[search_location_nbr].inc=2048*512;
- update_location();
- }
+ search_location_info[search_location_nbr].offset=0;
+ search_location_info[search_location_nbr].inc=2048*512;
+ update_location();
}
else
{
@@ -148,12 +145,9 @@ void search_location_init(const disk_t *disk_car, const unsigned int location_bo
search_location_info[search_location_nbr].inc=location_boundary;
update_location();
}
- if(search_vista_part>0)
- {
- search_location_info[search_location_nbr].offset=CHS_to_offset(0,0,7,disk_car);
- search_location_info[search_location_nbr].inc=2048*512;
- update_location();
- }
+ search_location_info[search_location_nbr].offset=CHS_to_offset(0,0,7,disk_car);
+ search_location_info[search_location_nbr].inc=2048*512;
+ update_location();
/* test_nbr==3 ou test_nbr==4, NTFS or HFS backup boot sector */
if(disk_car->arch==&arch_i386)
{
@@ -167,12 +161,9 @@ void search_location_init(const disk_t *disk_car, const unsigned int location_bo
search_location_info[search_location_nbr].inc=location_boundary;
update_location();
}
- if(search_vista_part>0)
- {
- search_location_info[search_location_nbr].offset=(2048-1)*512;
- search_location_info[search_location_nbr].inc=2048*512;
- update_location();
- }
+ search_location_info[search_location_nbr].offset=(2048-1)*512;
+ search_location_info[search_location_nbr].inc=2048*512;
+ update_location();
/* test_nbr==5*/
{
int s_log_block_size;
diff --git a/src/next.h b/src/next.h
index a31d0be..f7af29c 100644
--- a/src/next.h
+++ b/src/next.h
@@ -2,7 +2,7 @@
extern "C" {
#endif
-void search_location_init(const disk_t *disk_car, const unsigned int location_boundary, const int fast_mode, const int search_vista_part);
+void search_location_init(const disk_t *disk_car, const unsigned int location_boundary, const int fast_mode);
uint64_t search_location_update(const uint64_t location);
#ifdef __cplusplus
diff --git a/src/tdiskop.c b/src/tdiskop.c
index 9bed5ce..374f4d6 100644
--- a/src/tdiskop.c
+++ b/src/tdiskop.c
@@ -67,27 +67,9 @@ static int menu_disk_cli(disk_t *disk_car, const int verbose,int dump_ind, const
{
(*current_cmd)+=7;
{
- int search_vista_part=0;
list_part_t *list_part;
list_part=interface_analyse(disk_car, verbose, saveheader, current_cmd);
- if(disk_car->arch==&arch_i386)
- {
- const list_part_t *element;
- for(element=list_part;element!=NULL;element=element->next)
- {
- if(element->part->part_offset%(2048*512)==0 && element->part->part_size%(2048*512)==0)
- search_vista_part=1;
- }
- while(*current_cmd[0]==',')
- (*current_cmd)++;
- if(strncmp(*current_cmd,"mode_vista",10)==0)
- {
- (*current_cmd)+=10;
- search_vista_part=1;
- }
- log_info("search_vista_part: %d\n", search_vista_part);
- }
- interface_recovery(disk_car, list_part, verbose, dump_ind, align, ask_part_order, expert, search_vista_part, current_cmd);
+ interface_recovery(disk_car, list_part, verbose, dump_ind, align, ask_part_order, expert, current_cmd);
part_free_list(list_part);
}
}
@@ -167,27 +149,9 @@ static int menu_disk_ncurses(disk_t *disk_car, const int verbose,int dump_ind, c
case 'a':
case 'A':
{
- int search_vista_part=0;
list_part_t *list_part;
list_part=interface_analyse(disk_car, verbose, saveheader, current_cmd);
- if(disk_car->arch==&arch_i386)
- {
- const list_part_t *element;
- for(element=list_part;element!=NULL;element=element->next)
- {
- if(element->part->part_offset%(2048*512)==0 && element->part->part_size%(2048*512)==0)
- search_vista_part=1;
- }
- if(search_vista_part==0)
- {
- log_info("Ask the user for vista mode\n");
- if(ask_confirmation_with_default('Y',
- "Should TestDisk search for partition created under Vista or later ? [Y/N] (answer Yes if unsure)")!=0)
- search_vista_part=1;
- }
- log_info("search_vista_part: %d\n", search_vista_part);
- }
- interface_recovery(disk_car, list_part, verbose, dump_ind, align, ask_part_order, expert, search_vista_part, current_cmd);
+ interface_recovery(disk_car, list_part, verbose, dump_ind, align, ask_part_order, expert, current_cmd);
part_free_list(list_part);
}
break;