格式化后的数据恢复源码(C++)
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
/* Buffers */
unsigned char mirror_map[5120];
unsigned char control_buffer[512];
unsigned char sector_buffer[512];
/*
/////////////////////////////////////////////////////////////////////////////
void Copy_Sector_Into_Control_Buffer();
void Display_Help_Screen();
void List_Names();
void Read_Mirror_Map();
void Restore_Partition_Tables(int list);
unsigned long g_cylinder;
unsigned long g_sector;
/* Partition Information */
int numeric_partition_type[24];
unsigned long starting_cylinder[24];
long sectors_in_root_dir;
int type_of_fat;
unsigned long number_of_logical_sectors_on_drive;
long number_of_root_directory_entries;
/* Extracted cylinder & sector from partition table */
//
// Note: This program is free and is without a warranty of any kind.
//
*/
/*
/////////////////////////////////////////////////////////////////////////////
*/
#define FOUND 1
#define LIST 1
#define TRUE 1
#define FALSE 0
#define NULL 0
#defifine PRIMARY 0
#define EXTENDED 1
#define HARD 0
unsigned long translated_sector;
/* Misc variables */
unsigned long integer1;
unsigned long integer2;
unsigned long integer3;
unsigned long integer4;
// PROTOTYPES
/////////////////////////////////////////////////////////////////////////////
*/
int Compare_Sector_Buffers();
unsigned long Decimal_Number(unsigned long hex1, unsigned long hex2, unsigned long hex3, unsigned long hex4);
int partition_on_hard_disk;
/* Translated values from "void Convert_Logical_To_Physical" */
unsigned long translated_head;
unsigned long translated_cylinder;
#include <string.h>
/*
/////////////////////////////////////////////////////////////////////////////
// DEFINES
/////////////////////////////////////////////////////////////////////////////
#define FLOPPY 1
#define FAT12 0
#define FAT16 1
#define FAT32 2
/*
/////////////////////////////////////////////////////////////////////////////
// GLOBAL VARIABLES
int partition_size_3[24];
int partition_size_4[24];
unsigned long partition_size[24];
int number_of_partitions;
/* "Logical Drive to Format" translation information */
int relative_sectors_1[24];
int relative_sectors_2[24];
int relative_sectors_3[24];
int relative_sectors_4[24];
int partition_size_1[24];
int partition_size_2[24];
unsigned long starting_head[24];
unsigned long starting_sector[24];
unsigned long ending_cylinder[24];
unsigned long ending_head[24];
unsigned long ending_sector[24];
unsigned long drive_maximum_heads;
unsigned long drive_maximum_sectors;
unsigned long total_logical_sectors;
unsigned long total_physical_sectors;
int number_of_sectors_per_cluster;
void Unformat_Drive();
void Verify_Drive_Mirror();
//////////////
void Clear_Sector_Buffer();
void Convert_Huge_To_Integers(unsigned long number);
void Convert_Logical_To_Physical(unsigned long sector);
void Extract_Cylinder_and_Sector(unsigned long hex1, unsigned long hex2);
void Get_Drive_Parameters();
void Get_Physical_Floppy_Drive_Parameters();
void Get_Physical_Hard_Drive_Parameters();
/////////////////////////////////////////////////////////////////////////////
*/
int list_file_and_directory_names = 0;
int print_output = 0;
int test = 0;
int physical_drive_number;
unsigned long partition_starting_cylinder;
unsigned long partition_starting_head;
unsigned long partition_starting_sector;
// INCLUDES
/////////////////////////////////////////////////////////////////////////////
*/
#include <bios.h>
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
// FUNCTIONS
/////////////////////////////////////////////////////////////////////////////
*/
/* Clear Sector Buffer */
void Clear_Sector_Buffer()
{
void Convert_Logical_To_Physical(unsigned long sector)
{
unsigned long remaining;
if(drive_type==HARD) sector=sector+logical_sector_offset;
translated_cylinder=sector/(total_sectors*(total_heads+1));
int unformat_without_mirror_file = 0;
long sectors_per_fat;
/* Physical Drive Parameters */
int physical_drive;
int logical_drive;
unsigned long logical_sector_offset;
remaining=sector % (total_sectors*(total_heads+1));
unsigned long partition_ending_cylinder;
unsigned long partition_ending_head;
unsigned long partition_ending_sector;
unsigned long drive_maximum_cylinders;
long total_cylinders;
long total_heads;
long total_sectors;
long floppy_drive_type;
int drive_type;
int media_descriptor;
/* Logical drive information */
/*
// Program: Free Unformat
// Version: 0.8
// Written By: Brian E. Reifsnyder
// Copyright 1999 under the terms of the GNU GPL by Brian E. Reifsnyder
long loop=0;
do
{
sector_buffer[loop]=0;
loop++;
}while(loop<512);
}
/* Convert a logical sector to a physical drive location */
void Read_Partition_Table();
void Read_Physical_Sector(int drive, int head, long cyl, int sector);
void Read_Sector(unsigned long sector);
void Reset_Drive();
void Write_Physical_Sector(int drive, int head, long cyl, int sector);
void Write_Sector(unsigned long sector);
/*
/////////////////////////////////////////////////////////////////////////////