📄 filesys.h
字号:
/*____________________________________________________________________________
Copyright (C) 2002 PGP Corporation
All rights reserved.
$Id: FileSys.h,v 1.5 2002/08/06 20:10:18 dallen Exp $
____________________________________________________________________________*/
#ifndef Included_FileSys_h // [
#define Included_FileSys_h
_PGP_BEGIN
//// Align to 1.
#if PGP_WIN32
#pragma pack(push, 1)
#endif
namespace FileSys
{
// Constants
enum Type
{
kFat12FileSys = 0,
kFat16FileSys = 1,
kFat12Or16FileSys = 2,
kFat32FileSys = 3,
kNTFSFileSys = 4,
kUnknownFileSys = 5
};
enum
{
kFloppyMediaId = 0xF0,
kMaxSpts = 64,
kMaxSpt = 63,
kMaxHeads = 256,
kMaxHead = 255,
kMaxCyls = 256,
kMaxCyl = 255,
kSizeSpt = 1,
kSizeHead = kSizeSpt * kMaxSpt,
kSizeCyl = kSizeHead * kMaxHeads,
};
// Constants common to all FAT volumes
enum
{
kFatMediaByte = 0xF8,
kFatHardDriveId = 0x80,
kFat12PartId = 0x01,
kBigFat16PartId = 0x06,
kSmallFat16PartId = 0x04,
kFat32PartId = 0x0B,
kFatFirstBootSig = 0x29,
kFatSecondBootSig = 0xAA55,
kTypicalBlockSize = 512,
kTypicalActiveFat = 1,
kTypicalFatCount = 2,
kTypicalFat12Reserved = 1,
kTypicalFat16Reserved = 1,
kTypicalFat32Reserved = 32,
kTypicalRootDirEnts = 512,
kTypicalRootDirStart = 2,
kTypicalBigFatStart = 1
};
// Constants specific to FAT12 volumes
static const char *kFat12IdStr = "FAT12";
enum
{
kFat12Offset = 0x36,
kMaxFat12Megs = 2,
kFat12ClustBias = 2,
kBitsFat12Clust = 12,
kBytesFat12DirEnt = 32,
kMinFat12Clust = 0x0002,
kMaxFat12Clust = 0x0FEF,
kFat12Sig = 0x00FFFFF8
};
// Constants specific to FAT16 volumes
static const char *kFat16IdStr = "FAT16";
enum
{
kFat16Offset = 0x36,
kMinFat16Megs = 2,
kMaxFat16Megs = 2047,
kFat16ClustBias = 2,
kBitsFat16Clust = 16,
kBytesFat16DirEnt = 32,
kMinFat16Clust = 0x0002,
kMaxFat16Clust = 0xFFEF,
kFat16Sig = 0xFFFFFFF8,
};
// Constants specific to FAT32 volumes
static const char *kFat32IdStr = "FAT32";
enum
{
kFat32Offset = 0x52,
kMinFat32Megs = 260,
kMaxFat32FileMegs = 4095,
kFat32ClustBias = 2,
kBitsFat32Clust = 32,
kBigFatSig = 0x61417272,
kBigFatSecSig = 0x41615252,
kFat32ClustMask = 0x00FFFFFF,
kMinFat32Clust = 0x00000002,
kMaxFat32Clust = 0x00FFFFEF,
kFat32Clust1 = 0x0FFFFFF8,
kFat32Clust2 = 0x0FFFFFFF,
kFat32Clust3 = 0x0FFFFFF8,
BGBPB_F_ActiveFATMsk = 0x000F,
BGBPB_F_NoFATMirror = 0x0080
};
// Constants specific to NTFS volumes
static const char *kNTFSIdStr = "NTFS";
enum
{
kNTFSOffset = 3,
kMinNTFSMegs = 5
};
// Types
struct PartEntry
{
PGPUInt8 peBootable; // 80h = bootable, 00h = not
PGPUInt8 peBeginHead; // beginning head
PGPUInt8 peBeginSector; // beginning sector
PGPUInt8 peBeginCylinder; // beginning cylinder
PGPUInt8 peFileSystem; // ID of filesystem
PGPUInt8 peEndHead; // ending head
PGPUInt8 peEndSector; // ending sector
PGPUInt8 peEndCylinder; // ending cylinder
PGPUInt32 peStartSector; // starting sector
PGPUInt32 peSectors; // total sectors
};
// FvBlock is used by Win98 during int21h 440d 42 calls.
struct FvBlock
{
PGPUInt8 fvSpecFunc; // 'special function'
PGPUInt16 fvHead; // head
PGPUInt16 fvCylinder; // cylinder
PGPUInt16 fvTracks; // track
};
// RwBlock is used by Win98 during int21h 440d 61 calls.
struct RwBlock
{
PGPUInt8 rwSpecFunc; // 'special function'
PGPUInt16 rwHead; // head
PGPUInt16 rwCylinder; // cylinder
PGPUInt16 rwFirstSector; // spt
PGPUInt16 rwSectors; // num sectors
PGPUInt32 rwBuffer; // output buffer
};
// MID is used by Win98 during int21h 440d 66 calls.
struct MID
{
PGPUInt16 midInfoLevel; // information level
PGPUInt32 midSerialNum; // serial number
PGPUInt8 midVolLabel[11]; // volume label
PGPUInt8 midFileSysType[8]; // filesystem type
};
// FAT-specific types
struct DevParamsFat16
{
PGPUInt8 dpSpecFunc; // special functions
PGPUInt8 dpDevType; // device type
PGPUInt16 dpDevAttr; // device attributes
PGPUInt16 dpCylinders; // num cylinders
PGPUInt8 dpMediaType; // media type
// FAT16 BPB begins here.
PGPUInt16 dpBytesPerSec; // bytes per sector
PGPUInt8 dpSecPerClust; // sectors per cluster
PGPUInt16 dpResSectors; // num reserved sectors
PGPUInt8 dpFats; // num FATs
PGPUInt16 dpRootDirEnts; // num root-directory entries
PGPUInt16 dpSectors; // total sectors (<= 32 megs)
PGPUInt8 dpMedia; // media descriptor
PGPUInt16 dpFatSecs; // num sectors per FAT
PGPUInt16 dpSecPerTrack; // sectors per track
PGPUInt16 dpHeads; // num heads
PGPUInt32 dpHiddenSecs; // num hidden sectors
PGPUInt32 dpHugeSectors; // total sectors (> 32 megs)
};
struct DevParamsFat32
{
PGPUInt8 dpSpecFunc; // special functions
PGPUInt8 dpDevType; // device type
PGPUInt16 dpDevAttr; // device attributes
PGPUInt16 dpCylinders; // num cylinders
PGPUInt8 dpMediaType; // media type
// FAT32 BPB begins here
PGPUInt16 dpBytesPerSector; // bytes per sector
PGPUInt8 dpSectorsPerClust; // sectors per cluster
PGPUInt16 dpReservedSectors; // num reserved sectors
PGPUInt8 dpNumberOfFats; // num FATs
PGPUInt16 dpRootEntries; // field ignored on FAT32
PGPUInt16 dpTotalSectors; // total number sectors
PGPUInt8 dpMediaDescriptor; // media descriptor
PGPUInt16 dpSectorsPerFat; // field ignored in FAT32
PGPUInt16 dpSectorsPerTrack; // sectors per track (head)
PGPUInt16 dpHeads; // num heads
PGPUInt32 dpHiddenSectors; // num hidden sectors
PGPUInt32 dpBigTotalSectors; // total sectors on drive
PGPUInt32 dpBigSectorsPerFat; // total sectors per FAT
PGPUInt16 dpExtFlags; // extended flags
PGPUInt16 dpFS_Version; // filesystem version
PGPUInt32 dpRootDirStrtClus; // first cluster of root dir
PGPUInt16 dpFsInfoSec; // sector of FSInfo sec
PGPUInt16 dpBkUpBootSec; // sector of backup boot sec
PGPUInt16 dpReserved; // reserved
// FAT 32 BPB ends here
PGPUInt8 dpPadding[32];
};
struct BootSectorFat16
{
PGPUInt8 bsJump[3]; // jmp to bootstrap instruction
char bsOemName[8]; // OEM name and version
PGPUInt16 bsBytesPerSec; // bytes per sector
PGPUInt8 bsSecPerClust; // sectors per cluster
PGPUInt16 bsResSectors; // num reserved sectors
PGPUInt8 bsFats; // num file allocation tables
PGPUInt16 bsRootDirEnts; // num root-directory entries
PGPUInt16 bsSectors; // total num secs (<= 32 megs)
PGPUInt8 bsMedia; // media descriptor
PGPUInt16 bsFatSecs; // num sectors per FAT
PGPUInt16 bsSecPerTrack; // sectors per track (head)
PGPUInt16 bsHeads; // num heads
PGPUInt32 bsHiddenSecs; // num hidden sectors
PGPUInt32 bsHugeSectors; // total num sectors (> 32 megs)
PGPUInt8 bsDriveNumber; // drive number (80h)
PGPUInt8 bsReserved1; // reserved
PGPUInt8 bsBootSignature; // extended boot signature (29h)
PGPUInt32 bsVolumeId; // volume ID number
char bsVolumeLabel[11]; // volume label
char bsFileSysType[8]; // filesystem type
PGPUInt8 padding[384]; // padding to 512 bytes
PartEntry bsPartEnts[4]; // partition entry table
PGPUInt16 bsSignature; // boot block signature (0xAA55h)
};
typedef BootSectorFat16 BootSectorFat12;
struct BigFatBootFSInfo
{
PGPUInt32 bfSecSig; // sector sig (kBigFatSecSig)
PGPUInt8 bfPadding1[480]; // padding to 512 bytes
PGPUInt32 bfFSInf_Sig; // signature (kBigFatSig)
PGPUInt32 bfFSInf_free_clus_cnt; // num free clusters
PGPUInt32 bfFSInf_next_free_clus; // next free cluster
PGPUInt32 bfFSInf_resvd;
PGPUInt32 bfReserved[2];
PGPUInt8 bfPadding2[2]; // padding to 512 bytes
PGPUInt16 bsSignature; // 0xAA55h as in boot block
};
struct BootSectorFat32
{
PGPUInt8 bsJump[3]; // jmp to bootstrap instruction
char bsOemName[8]; // OEM name and version
PGPUInt16 bsBytesPerSec; // bytes per sector
PGPUInt8 bsSecPerClust; // sectors per cluster
PGPUInt16 bsResSectors; // num reserved sectors
PGPUInt8 bsFats; // num file allocation tables
PGPUInt16 bsRootDirEnts; // num root-directory entries
PGPUInt16 bsSectors; // total num secs (<= 32 megs)
PGPUInt8 bsMedia; // media descriptor
PGPUInt16 bsFatSecs; // num sectors per FAT
PGPUInt16 bsSecPerTrack; // sectors per track (head)
PGPUInt16 bsHeads; // num heads
PGPUInt32 bsHiddenSecs; // num hidden sectors
PGPUInt32 bsHugeSectors; // total num sectors (> 32 megs)
PGPUInt32 bsBigSectorsPerFat; // total sectors per FAT
PGPUInt16 bsExtFlags; // extended flags
PGPUInt16 bsFS_Version; // filesystem version
PGPUInt32 bsRootDirStrtClus; // first cluster of root dir
PGPUInt16 bsFsInfoSec; // sector of FSInfo sec
PGPUInt16 bsBkUpBootSec; // sector of backup boot sec
PGPUInt16 bsReserved2[6]; // reserved
PGPUInt8 bsDriveNumber; // drive number (80h)
PGPUInt8 bsReserved1; // reserved
PGPUInt8 bsBootSignature; // extended boot signature (29h)
PGPUInt32 bsVolumeId; // volume ID number
char bsVolumeLabel[11]; // volume label
char bsFileSysType[8]; // filesystem type
PGPUInt8 padding1[356]; // padding to fill out first sec
PartEntry bsPartEnts[4]; // partition entry table
PGPUInt16 bsSignature; // boot block signature (0xAA55h)
};
}
// Restore alignment.
#if PGP_WIN32
#pragma pack(pop)
#endif
_PGP_END
#endif // Included_FileSys_h
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -