This repository has been archived by the owner on Sep 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 94
/
fssup.h
83 lines (72 loc) · 2.18 KB
/
fssup.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// BK driver loader project. Version 2.9.2.
//
// module: fssup.h
// $Revision: 39 $
// $Date: 2012-05-02 15:38:09 +0400 (Ср, 02 май 2012) $
// description:
// Disk and file systems support library.
// BIOS constants
#define BIOS_DEFAULT_SECTOR_SIZE 0x200 // 512 bytes
#define BIOS_MBR_MAGIC 0xaa55
#define BIOS_PARTITION_TABLE_OFFSET 0x1be
#define BIOS_MAX_PARTITION_COUNT 4
#define BIOS_PARTITION_ACTIVE_FLAG 0x80
#define BIOS_PARTITION_TYPE_INSTALLABLE 7
// BIOS structures
typedef struct _PARTITION_TABLE_ENTRY
{
ULONG ActiveFlag : 8;
ULONG CHSStartSector : 24;
ULONG Descriptor : 8;
ULONG CHSEndSector : 24;
ULONG LBAStartSector;
ULONG PartitionSize;
}PARTITION_TABLE_ENTRY, *PPARTITION_TABLE_ENTRY;
typedef struct _PARTITION_TABLE
{
PARTITION_TABLE_ENTRY Entry[BIOS_MAX_PARTITION_COUNT];
}PARTITION_TABLE, *PPARTITION_TABLE;
#pragma pack (push)
#pragma pack(1)
// BIOS Parameter block
typedef struct _BPB
{
USHORT SectorSize;
UCHAR SectorsPerCluster;
USHORT RecervedSectors;
UCHAR NumberOfFats; // for FAT only
union {
USHORT MaxRDEntries; // for FAT only
USHORT FirstRDSector; // for VFAT
};
USHORT SmallSectorsCount; // for FAT12/16 only
UCHAR MediaDescriptorId;
USHORT SectorsPerFat; // for FAT only
USHORT SectorsPerTrack;
USHORT NumberOfHeads;
ULONG NumberOfHiddenSectors;
ULONG FatTotalSectors; // for FAT only
union {
ULONG DriveNumber;
ULONG RDSize; // for VFAT
};
ULONGLONG VolumeTotalSectors; // NTFS only
ULONGLONG MftStartingCluster; // NTFS only
ULONGLONG MftMirrowCluster; // NTFS only
LONG ClustersPerRecord; // NTFS only
ULONG ClustersPerIndex; // NTFS only
ULONGLONG VolumeSerialNumber; // NTFS only
ULONG Checksum;
} BPB, *PBPB;
// Volume Boot Record
typedef struct _VBR
{
CHAR JumpInstruction[3];
CHAR VolumeOemId[8];
BPB Bpb;
} VBR, *PVBR;
#pragma pack(pop)
#define NTFS_OEM_ID "NTFS "
#define NTFS_LOADER_SIZE 16 // sectors
#define NTFS_LDR_HEADER_SIZE 0x20 // bytes