OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
Driver.h File Reference

Go to the source code of this file.

Data Structures

struct  FILE_RECORD_HEADER
 
struct  ATTR_HEADER_RES
 
struct  ATTR_HEADER_NONRES
 
struct  ATTR_LIST_RECORD
 
struct  INDEX_ENTRY
 
struct  INDEX_HEADER
 
struct  INDEX_RECORD_HEADER
 
struct  INDEX_ROOT
 
struct  ATTR_INDEX_ROOT
 
struct  ATTR_FILE_NAME
 
struct  BOOT_FILE_DATA
 
struct  SYMLINK
 
struct  NTFS_ATTR
 
struct  _NTFS_FILE
 
struct  _EFI_NTFS_FILE
 
struct  _EFI_FS
 
struct  UNIT_ELEMENT
 
struct  COMPRESSED
 
struct  RUNLIST
 

Macros

#define NTFS_MAX_MFT   4096
 
#define NTFS_MAX_IDX   16384
 
#define COMPRESSION_BLOCK   4096
 
#define NTFS_DRIVER_VERSION   0x00020000
 
#define MAX_PATH   1024
 
#define MINIMUM_INFO_LENGTH   (sizeof (EFI_FILE_INFO) + MAX_PATH * sizeof(CHAR16))
 
#define MINIMUM_FS_INFO_LENGTH   (sizeof (EFI_FILE_SYSTEM_INFO) + MAX_PATH * sizeof(CHAR16))
 
#define ATTRIBUTES_END_MARKER   0xFFFFFFFF
 
#define MAX_FILE_SIZE   (MAX_UINT32 & ~7ULL)
 
#define S_FILENAME   0x3
 
#define S_SYMLINK   0xC
 

Typedefs

typedef struct _NTFS_FILE NTFS_FILE
 
typedef struct _EFI_NTFS_FILE EFI_NTFS_FILE
 
typedef struct _EFI_FS EFI_FS
 

Enumerations

enum  {
  AT_STANDARD_INFORMATION = 0x10 , AT_ATTRIBUTE_LIST = 0x20 , AT_FILENAME = 0x30 , AT_VOLUME_VERSION = 0x40 ,
  AT_SECURITY_DESCRIPTOR = 0x50 , AT_VOLUME_NAME = 0x60 , AT_VOLUME_INFORMATION = 0x70 , AT_DATA = 0x80 ,
  AT_INDEX_ROOT = 0x90 , AT_INDEX_ALLOCATION = 0xA0 , AT_BITMAP = 0xB0 , AT_SYMLINK = 0xC0 ,
  AT_EA_INFORMATION = 0xD0 , AT_EA = 0xE0 , AT_PROPERTY_SET = 0xF0
}
 
enum  {
  ATTR_READ_ONLY = 0x1 , ATTR_HIDDEN = 0x2 , ATTR_SYSTEM = 0x4 , ATTR_ARCHIVE = 0x20 ,
  ATTR_DEVICE = 0x40 , ATTR_NORMAL = 0x80 , ATTR_TEMPORARY = 0x100 , ATTR_SPARSE = 0x200 ,
  ATTR_REPARSE = 0x400 , ATTR_COMPRESSED = 0x800 , ATTR_OFFLINE = 0x1000 , ATTR_NOT_INDEXED = 0x2000 ,
  ATTR_ENCRYPTED = 0x4000 , ATTR_DIRECTORY = 0x10000000 , ATTR_INDEX_VIEW = 0x20000000
}
 
enum  {
  MFT_FILE = 0 , MFTMIRR_FILE = 1 , LOGFILE_FILE = 2 , VOLUME_FILE = 3 ,
  ATTRDEF_FILE = 4 , ROOT_FILE = 5 , BITMAP_FILE = 6 , BOOT_FILE = 7 ,
  BADCLUS_FILE = 8 , QUOTA_FILE = 9 , UPCASE_FILE = 10
}
 
enum  { NTFS_AF_ALST = 1 , NTFS_AF_MFT_FILE = 2 , NTFS_AF_GPOS = 4 }
 
enum  { FLAG_COMPRESSED = 0x0001 , FLAG_ENCRYPTED = 0x4000 , FLAG_SPARSE = 0x8000 }
 
enum  { IS_IN_USE = 0x01 , IS_A_DIRECTORY = 0x02 }
 
enum  { SUB_NODE = 0x01 , LAST_INDEX_ENTRY = 0x02 }
 
enum  { POSIX = 0 , WINDOWS32 = 1 , DOS = 2 , WIN32_DOS = 3 }
 
enum  {
  IS_ALIAS = 0x20000000 , IS_HIGH_LATENCY = 0x40000000 , IS_MICROSOFT = 0x80000000 , NSS = 0x68000005 ,
  NSS_RECOVER = 0x68000006 , SIS = 0x68000007 , DFS = 0x68000008 , MOUNT_POINT = 0x88000003 ,
  HSM = 0xA8000004 , SYMBOLIC_LINK = 0xE8000000
}
 

Detailed Description

Copyright (c) 2022, Mikhail Krichanov. All rights reserved. SPDX-License-Identifier: BSD-3-Clause

Functional and structural descriptions follow NTFS Documentation by Richard Russon and Yuval Fledel

Definition in file Driver.h.

Macro Definition Documentation

◆ ATTRIBUTES_END_MARKER

#define ATTRIBUTES_END_MARKER   0xFFFFFFFF

Definition at line 19 of file Driver.h.

◆ COMPRESSION_BLOCK

#define COMPRESSION_BLOCK   4096

Definition at line 14 of file Driver.h.

◆ MAX_FILE_SIZE

#define MAX_FILE_SIZE   (MAX_UINT32 & ~7ULL)

Definition at line 20 of file Driver.h.

◆ MAX_PATH

#define MAX_PATH   1024

Definition at line 16 of file Driver.h.

◆ MINIMUM_FS_INFO_LENGTH

#define MINIMUM_FS_INFO_LENGTH   (sizeof (EFI_FILE_SYSTEM_INFO) + MAX_PATH * sizeof(CHAR16))

Definition at line 18 of file Driver.h.

◆ MINIMUM_INFO_LENGTH

#define MINIMUM_INFO_LENGTH   (sizeof (EFI_FILE_INFO) + MAX_PATH * sizeof(CHAR16))

Definition at line 17 of file Driver.h.

◆ NTFS_DRIVER_VERSION

#define NTFS_DRIVER_VERSION   0x00020000

Definition at line 15 of file Driver.h.

◆ NTFS_MAX_IDX

#define NTFS_MAX_IDX   16384

Definition at line 13 of file Driver.h.

◆ NTFS_MAX_MFT

#define NTFS_MAX_MFT   4096

Definition at line 12 of file Driver.h.

◆ S_FILENAME

#define S_FILENAME   0x3

Definition at line 21 of file Driver.h.

◆ S_SYMLINK

#define S_SYMLINK   0xC

Definition at line 22 of file Driver.h.

Typedef Documentation

◆ EFI_FS

typedef struct _EFI_FS EFI_FS

Definition at line 602 of file Driver.h.

◆ EFI_NTFS_FILE

typedef struct _EFI_NTFS_FILE EFI_NTFS_FILE

Definition at line 601 of file Driver.h.

◆ NTFS_FILE

typedef struct _NTFS_FILE NTFS_FILE

Definition at line 600 of file Driver.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

FILE ***

Everything on an NTFS volume is a File. Files are composed of Attributes (usually 4: $STANDARD_INFORMATION, $FILE_NAME, $SECURITY_DESCRIPTOR, $DATA).

Information about all the Attributes available in a volume is stored in a File named $AttrDef.

File named $MFT (Master File Table) is an index of every File on the volume. The description of each File is packed into FILE Records. A FILE Record is built up from a header, several variable length Attributes and an end marker (simply 0xFFFFFFFF). The first FILE Record that describes a given file is called the Base FILE Record and the others are called Extension FILE Records. Only the Base FILE Record is used for referencing the File it describes. Attribute named $ATTRIBUTE_LIST provides the references to all the Extension FILE Records.

The $MFT lists the Boot Sector File ($Boot), located at the beginning of the disk. $Boot also lists where to find the $MFT. The $MFT also lists itself.

Every Attribute has a standard header and specific fields. The header stores information about the Attribute's type, size, name (optional) and whether it is resident (in $MFT), or not.

Non-resident Attributes are stored in intervals of Clusters called Data Runs. Each Data Run is represented by its starting Cluster and its length.

The number of sectors that make up a Cluster is always a power of 2, and this number is fixed when the volume is formatted. The Cluster Size for a volume is stored in a File named $Boot.

Each Cluster in a volume is given a sequential number. This is its Logical Cluster Number. LCN 0 (zero) refers to the first cluster in the volume (the Boot Sector).

Each Cluster of a non-resident stream is given a sequential number. This is its Virtual Cluster Number. VCN 0 (zero) refers to the first cluster of the stream.

INDEX ***

Under NTFS every object on the volume is a file, even directories. A directory is a sequence of Index Entries containing a filename Attribute. An Index Entry is created for each $FILE_NAME Attribute of each file contained in the folder.

$INDEX_ROOT Attribute is the root node of the B+ tree that implements an index (e.g. a directory). This file attribute is always resident.

Every Index Record has a standard header and a set of blocks containing an Index Key and Index Data. The size of an Index Record is defined in $Boot File and always seems to be 4KB.

$INDEX_ALLOCATION Attribute is the storage location for all sub-nodes of the B+ tree that implements an index (e.g. a directory). It is simply a sequence of all Index Records that belong to the Index. This file attribute is never resident.

A sequence of Index Entries follows each INDEX_HEADER structure. Together they make up a complete index. The index follows either an $INDEX_ROOT Attribute or an $INDEX_ALLOCATION Attribute.

RUNLIST ***

Runlist is a table written in the content part of a non-resident file Attribute, which allows to have access to its stream. (Table 4.10.)

The Runlist is a sequence of elements: each element stores an offset to the starting LCN of the previous element and the length in clusters of a Data Run.

The layout of the Runlist must take account of the data compression: the set of VCNs containing the stream of a compressed file attribute is divided in compression units (also called chunks) of 16 clusters.

Data are compressed using a modified LZ77 algorithm. The basic idea is that substrings of the block which have been seen before are compressed by referencing the string rather than mentioning it again.

Only $DATA Attribute can be compressed, or sparse, and only when it is non-resident. Table 2.1. Standard NTFS Attribute Types

Enumerator
AT_STANDARD_INFORMATION 
AT_ATTRIBUTE_LIST 
AT_FILENAME 
AT_VOLUME_VERSION 
AT_SECURITY_DESCRIPTOR 
AT_VOLUME_NAME 
AT_VOLUME_INFORMATION 
AT_DATA 
AT_INDEX_ROOT 
AT_INDEX_ALLOCATION 
AT_BITMAP 
AT_SYMLINK 
AT_EA_INFORMATION 
AT_EA 
AT_PROPERTY_SET 

Definition at line 113 of file Driver.h.

◆ anonymous enum

anonymous enum

Table 2.6. File Flags (Also called attributes in DOS terminology).

Enumerator
ATTR_READ_ONLY 
ATTR_HIDDEN 
ATTR_SYSTEM 
ATTR_ARCHIVE 
ATTR_DEVICE 
ATTR_NORMAL 
ATTR_TEMPORARY 
ATTR_SPARSE 
ATTR_REPARSE 
ATTR_COMPRESSED 
ATTR_OFFLINE 
ATTR_NOT_INDEXED 
ATTR_ENCRYPTED 
ATTR_DIRECTORY 
ATTR_INDEX_VIEW 

Definition at line 134 of file Driver.h.

◆ anonymous enum

anonymous enum

Table 3.1. Layout of files on the Volume (Inodes).

Enumerator
MFT_FILE 
MFTMIRR_FILE 
LOGFILE_FILE 
VOLUME_FILE 
ATTRDEF_FILE 
ROOT_FILE 
BITMAP_FILE 
BOOT_FILE 
BADCLUS_FILE 
QUOTA_FILE 
UPCASE_FILE 

Definition at line 155 of file Driver.h.

◆ anonymous enum

anonymous enum
Enumerator
NTFS_AF_ALST 
NTFS_AF_MFT_FILE 
NTFS_AF_GPOS 

Definition at line 169 of file Driver.h.

◆ anonymous enum

anonymous enum

Table 4.6. Attribute flags

Enumerator
FLAG_COMPRESSED 
FLAG_ENCRYPTED 
FLAG_SPARSE 

Definition at line 178 of file Driver.h.

◆ anonymous enum

anonymous enum

Table 4.22. File record flags

Enumerator
IS_IN_USE 
IS_A_DIRECTORY 

Definition at line 187 of file Driver.h.

◆ anonymous enum

anonymous enum

Table 2.30. Data entry flags

Enumerator
SUB_NODE 
LAST_INDEX_ENTRY 

Definition at line 195 of file Driver.h.

◆ anonymous enum

anonymous enum

13.2. Possible Namespaces

Enumerator
POSIX 
WINDOWS32 
DOS 
WIN32_DOS 

Definition at line 203 of file Driver.h.

◆ anonymous enum

anonymous enum

Table 2.36. Reparse Tag Flags

Enumerator
IS_ALIAS 
IS_HIGH_LATENCY 
IS_MICROSOFT 
NSS 
NSS_RECOVER 
SIS 
DFS 
MOUNT_POINT 
HSM 
SYMBOLIC_LINK 

Definition at line 213 of file Driver.h.