YourDefrag
SVN
|
00001 00002 00003 00004 #pragma pack(push,1) /* Align to bytes. */ 00005 00006 struct FatBootSectorStruct { 00007 UCHAR BS_jmpBoot[3]; // 0 00008 UCHAR BS_OEMName[8]; // 3 00009 USHORT BPB_BytsPerSec; // 11 00010 UCHAR BPB_SecPerClus; // 13 00011 USHORT BPB_RsvdSecCnt; // 14 00012 UCHAR BPB_NumFATs; // 16 00013 USHORT BPB_RootEntCnt; // 17 00014 USHORT BPB_TotSec16; // 19 00015 UCHAR BPB_Media; // 21 00016 USHORT BPB_FATSz16; // 22 00017 USHORT BPB_SecPerTrk; // 24 00018 USHORT BPB_NumHeads; // 26 00019 ULONG BPB_HiddSec; // 28 00020 ULONG BPB_TotSec32; // 32 00021 union { 00022 struct { 00023 UCHAR BS_DrvNum; // 36 00024 UCHAR BS_Reserved1; // 37 00025 UCHAR BS_BootSig; // 38 00026 ULONG BS_VolID; // 39 00027 UCHAR BS_VolLab[11]; // 43 00028 UCHAR BS_FilSysType[8]; // 54 00029 UCHAR BS_Reserved2[448]; // 62 00030 } Fat16; 00031 struct { 00032 ULONG BPB_FATSz32; // 36 00033 USHORT BPB_ExtFlags; // 40 00034 USHORT BPB_FSVer; // 42 00035 ULONG BPB_RootClus; // 44 00036 USHORT BPB_FSInfo; // 48 00037 USHORT BPB_BkBootSec; // 50 00038 UCHAR BPB_Reserved[12]; // 52 00039 UCHAR BS_DrvNum; // 64 00040 UCHAR BS_Reserved1; // 65 00041 UCHAR BS_BootSig; // 66 00042 ULONG BS_VolID; // 67 00043 UCHAR BS_VolLab[11]; // 71 00044 UCHAR BS_FilSysType[8]; // 82 00045 UCHAR BPB_Reserved2[420]; // 90 00046 } Fat32; 00047 }; 00048 USHORT Signature; // 510 00049 }; 00050 00051 struct FatDirStruct { 00052 UCHAR DIR_Name[11]; // 0 File name, 8 + 3. 00053 UCHAR DIR_Attr; // 11 File attributes. 00054 UCHAR DIR_NTRes; // 12 Reserved. 00055 UCHAR DIR_CrtTimeTenth; // 13 Creation time, tenths of a second, 0...199. 00056 USHORT DIR_CrtTime; // 14 Creation time. 00057 USHORT DIR_CrtDate; // 16 Creation date. 00058 USHORT DIR_LstAccDate; // 18 Last access date. 00059 USHORT DIR_FstClusHI; // 20 First cluster number, high word. 00060 USHORT DIR_WrtTime; // 22 Last write time. 00061 USHORT DIR_WrtDate; // 24 Last write date. 00062 USHORT DIR_FstClusLO; // 26 First cluster number, low word. 00063 ULONG DIR_FileSize; // 28 File size in bytes. 00064 }; 00065 struct FatLongNameDirStruct { 00066 UCHAR LDIR_Ord; // 0 Sequence number 00067 WCHAR LDIR_Name1[5]; // 1 Characters 1-5 in name 00068 UCHAR LDIR_Attr; // 11 Attribute, must be ATTR_LONG_NAME 00069 UCHAR LDIR_Type; // 12 Always zero 00070 UCHAR LDIR_Chksum; // 13 Checksum 00071 WCHAR LDIR_Name2[6]; // 14 Characters 6-11 00072 UCHAR LDIR_FstClusLO[2]; // 26 Always zero 00073 WCHAR LDIR_Name3[2]; // 28 Characters 12-13 00074 }; 00075 00076 #pragma pack(pop) /* Reset byte alignment. */ 00077 00078 00079 00080 /* The attribute flags. */ 00081 #define ATTR_READ_ONLY 0x01 00082 #define ATTR_HIDDEN 0x02 00083 #define ATTR_SYSTEM 0x04 00084 #define ATTR_VOLUME_ID 0x08 00085 #define ATTR_DIRECTORY 0x10 00086 #define ATTR_ARCHIVE 0x20 00087 #define ATTR_LONG_NAME (ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID) 00088 #define ATTR_LONG_NAME_MASK (ATTR_READ_ONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUME_ID | ATTR_DIRECTORY | ATTR_ARCHIVE) 00089 00090 00091 00092 /* Struct used by the scanner to store disk information from the bootblock. */ 00093 struct FatDiskInfoStruct { 00094 ULONG64 BytesPerSector; 00095 ULONG64 SectorsPerCluster; 00096 ULONG64 TotalSectors; 00097 ULONG64 RootDirSectors; 00098 ULONG64 FirstDataSector; 00099 ULONG64 FATSz; 00100 ULONG64 DataSec; 00101 ULONG64 CountofClusters; 00102 union { 00103 BYTE *FAT12; 00104 USHORT *FAT16; 00105 ULONG *FAT32; 00106 } FatData; 00107 }; 00108 00109 00110 00111 00112 00113 BOOL AnalyzeFatVolume(struct DefragDataStruct *Data);