ReactOS  0.4.15-dev-4570-g4f8bbd1
ntfs.h
Go to the documentation of this file.
1 /*
2  * FreeLoader NTFS support
3  * Copyright (C) 2004 Filip Navara <xnavara@volny.cz>
4  * Copyright (C) 2011 Pierre Schweitzer <pierre.schweitzer@reactos.org>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #pragma once
22 
23 #define NTFS_FILE_MFT 0
24 #define NTFS_FILE_MFTMIRR 1
25 #define NTFS_FILE_LOGFILE 2
26 #define NTFS_FILE_VOLUME 3
27 #define NTFS_FILE_ATTRDEF 4
28 #define NTFS_FILE_ROOT 5
29 #define NTFS_FILE_BITMAP 6
30 #define NTFS_FILE_BOOT 7
31 #define NTFS_FILE_BADCLUS 8
32 #define NTFS_FILE_QUOTA 9
33 #define NTFS_FILE_UPCASE 10
34 #define NTFS_FILE_EXTEND 11
35 
36 #define NTFS_ATTR_TYPE_STANDARD_INFORMATION 0x10
37 #define NTFS_ATTR_TYPE_ATTRIBUTE_LIST 0x20
38 #define NTFS_ATTR_TYPE_FILENAME 0x30
39 #define NTFS_ATTR_TYPE_OBJECT_ID 0x40
40 #define NTFS_ATTR_TYPE_SECURITY_DESCRIPTOR 0x50
41 #define NTFS_ATTR_TYPE_VOLUME_NAME 0x60
42 #define NTFS_ATTR_TYPE_VOLUME_INFORMATION 0x70
43 #define NTFS_ATTR_TYPE_DATA 0x80
44 #define NTFS_ATTR_TYPE_INDEX_ROOT 0x90
45 #define NTFS_ATTR_TYPE_INDEX_ALLOCATION 0xa0
46 #define NTFS_ATTR_TYPE_BITMAP 0xb0
47 #define NTFS_ATTR_TYPE_REPARSE_POINT 0xc0
48 #define NTFS_ATTR_TYPE_EA_INFORMATION 0xd0
49 #define NTFS_ATTR_TYPE_EA 0xe0
50 #define NTFS_ATTR_TYPE_END 0xffffffff
51 
52 #define NTFS_ATTR_NORMAL 0
53 #define NTFS_ATTR_COMPRESSED 1
54 #define NTFS_ATTR_RESIDENT 2
55 #define NTFS_ATTR_ENCRYPTED 0x4000
56 
57 #define NTFS_SMALL_INDEX 0
58 #define NTFS_LARGE_INDEX 1
59 
60 #define NTFS_INDEX_ENTRY_NODE 1
61 #define NTFS_INDEX_ENTRY_END 2
62 
63 #define NTFS_FILE_NAME_POSIX 0
64 #define NTFS_FILE_NAME_WIN32 1
65 #define NTFS_FILE_NAME_DOS 2
66 #define NTFS_FILE_NAME_WIN32_AND_DOS 3
67 
68 #define NTFS_MFT_MASK 0x0000FFFFFFFFFFFFULL
69 
70 #include <pshpack1.h>
71 typedef struct
72 {
73  UCHAR JumpBoot[3]; // Jump to the boot loader routine
74  CHAR SystemId[8]; // System Id ("NTFS ")
75  USHORT BytesPerSector; // Bytes per sector
76  UCHAR SectorsPerCluster; // Number of sectors in a cluster
77  UCHAR Unused1[7];
78  UCHAR MediaDescriptor; // Media descriptor byte
79  UCHAR Unused2[2];
80  USHORT SectorsPerTrack; // Number of sectors in a track
81  USHORT NumberOfHeads; // Number of heads on the disk
82  UCHAR Unused3[8];
83  UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
85  UCHAR BootSignature; // Extended boot signature (0x80)
87  ULONGLONG VolumeSectorCount; // Number of sectors in the volume
90  CHAR ClustersPerMftRecord; // Clusters per MFT Record
91  UCHAR Unused5[3];
92  CHAR ClustersPerIndexRecord; // Clusters per Index Record
93  UCHAR Unused6[3];
94  ULONGLONG VolumeSerialNumber; // Volume serial number
95  UCHAR BootCodeAndData[430]; // The remainder of the boot sector
98 
99 typedef struct
100 {
102  USHORT USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
105 
106 typedef struct
107 {
109  USHORT USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
116  ULONG BytesInUse; // Number of bytes used in this mft record.
120  USHORT Padding; // Align to 4 UCHAR boundary (NTFS 3.1+ (Windows XP and above))
121  ULONG MFTRecordNumber; // Number of this MFT Record (NTFS 3.1+ (Windows XP and above))
123 
124 typedef struct
125 {
133  union
134  {
135  // Resident attributes
136  struct
137  {
142  } Resident;
143  // Non-resident attributes
144  struct
145  {
150  UCHAR Reserved[4];
155  } NonResident;
156  };
158 
159 typedef struct
160 {
167 
168 typedef struct
169 {
177 
178 typedef struct
179 {
194 
195 typedef struct
196 {
206 
207 typedef struct
208 {
209  union
210  {
211  struct
212  {
214  } Directory;
215  struct
216  {
220  } ViewIndex;
221  } Data;
228 #include <poppack.h>
229 
230 typedef struct
231 {
240 
242 
243 #include <pshpack1.h>
244 typedef struct
245 {
250 #include <poppack.h>
251 
USHORT Flags
Definition: ntfs.h:115
UCHAR NameOffset
Definition: ntfs.h:200
LONGLONG AllocatedSize
Definition: ntfs.h:151
UCHAR Flags
Definition: ntfs.h:164
USHORT USAOffset
Definition: ntfs.h:102
UCHAR SectorsPerCluster
Definition: ntfs.h:76
UCHAR FileNameType
Definition: ntfs.h:191
ULONG AllocatedSize
Definition: ntfs.h:163
ULONGLONG LogSequenceNumber
Definition: ntfs.h:111
struct NTFS_MFT_RECORD * PNTFS_MFT_RECORD
LONGLONG LastDataChangeTime
Definition: ntfs.h:182
USHORT NameOffset
Definition: ntfs.h:130
ULONGLONG LowestVCN
Definition: ntfs.h:146
USHORT NextAttributeInstance
Definition: ntfs.h:119
struct NTFS_ATTR_RECORD * PNTFS_ATTR_RECORD
NTFS_INDEX_HEADER IndexHeader
Definition: ntfs.h:175
USHORT KeyLength
Definition: ntfs.h:223
PNTFS_VOLUME_INFO Volume
Definition: ntfs.h:248
USHORT MappingPairsOffset
Definition: ntfs.h:148
UCHAR Flags
Definition: ntfs.h:140
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG _In_opt_ PVOID Data
Definition: wdfdevice.h:4527
char CHAR
Definition: xmlstorage.h:175
struct NTFS_ATTR_CONTEXT * PNTFS_ATTR_CONTEXT
ULONGLONG MftLocation
Definition: ntfs.h:88
NTFS_ATTR_RECORD Record
Definition: ntfs.h:238
LONGLONG CreationTime
Definition: ntfs.h:181
Definition: fs.h:24
USHORT AttributesOffset
Definition: ntfs.h:114
ULONGLONG CacheRunOffset
Definition: ntfs.h:233
ULONG Type
Definition: ntfs.h:126
ULONG EntriesOffset
Definition: ntfs.h:161
ULONGLONG HighestVCN
Definition: ntfs.h:147
LONGLONG CacheRunStartLCN
Definition: ntfs.h:234
ULONGLONG BaseMFTRecord
Definition: ntfs.h:118
PNTFS_ATTR_CONTEXT DataContext
Definition: ntfs.h:246
USHORT CompressionUnit
Definition: ntfs.h:149
NTFS_FILE_NAME_ATTR FileName
Definition: ntfs.h:226
LONGLONG InitializedSize
Definition: ntfs.h:153
struct NTFS_INDEX_HEADER * PNTFS_INDEX_HEADER
const DEVVTBL * NtfsMount(ULONG DeviceId)
Definition: ntfs.c:881
ULONGLONG IndexedFile
Definition: ntfs.h:213
struct NTFS_FILE_NAME_ATTR * PNTFS_FILE_NAME_ATTR
USHORT AttrId
Definition: ntfs.h:203
struct NTFS_ATTR_LIST_ATTR * PNTFS_ATTR_LIST_ATTR
USHORT Reserved
Definition: ntfs.h:225
USHORT USACount
Definition: ntfs.h:103
struct NTFS_RECORD * PNTFS_RECORD
ULONG Length
Definition: ntfs.h:127
ULONGLONG MftMirrorLocation
Definition: ntfs.h:89
LONGLONG AllocatedSize
Definition: ntfs.h:185
USHORT Instance
Definition: ntfs.h:132
ULONG CollationRule
Definition: ntfs.h:171
USHORT SequenceNumber
Definition: ntfs.h:112
ULONG BytesInUse
Definition: ntfs.h:116
USHORT LinkCount
Definition: ntfs.h:113
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
USHORT USAOffset
Definition: ntfs.h:109
USHORT DataOffset
Definition: ntfs.h:217
ULONG FileAttributes
Definition: ntfs.h:187
UCHAR MediaDescriptor
Definition: ntfs.h:78
ULONGLONG CacheRunCurrentOffset
Definition: ntfs.h:237
struct NTFS_FILE_HANDLE * PNTFS_FILE_HANDLE
ULONG IndexLength
Definition: ntfs.h:162
int64_t LONGLONG
Definition: typedefs.h:68
ULONGLONG BaseFileRef
Definition: ntfs.h:202
USHORT Flags
Definition: ntfs.h:224
USHORT PackedExtendedAttributeSize
Definition: ntfs.h:188
ULONGLONG VolumeSerialNumber
Definition: ntfs.h:94
struct NTFS_INDEX_ROOT * PNTFS_INDEX_ROOT
LONGLONG CompressedSize
Definition: ntfs.h:154
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONGLONG DataSize
Definition: ntfs.h:186
uint64_t ULONGLONG
Definition: typedefs.h:67
LONGLONG CacheRunLastLCN
Definition: ntfs.h:236
USHORT DataLength
Definition: ntfs.h:218
ULONGLONG Offset
Definition: ntfs.h:247
struct _NTFS_ATTR_CONTEXT NTFS_ATTR_CONTEXT
ULONG Type
Definition: ntfs.h:170
UCHAR NameLength
Definition: ntfs.h:199
USHORT RecLength
Definition: ntfs.h:198
LONGLONG LastAccessTime
Definition: ntfs.h:184
unsigned char UCHAR
Definition: xmlstorage.h:181
UCHAR DriveNumber
Definition: ntfs.h:83
LONGLONG LastMftChangeTime
Definition: ntfs.h:183
Definition: ntfs.h:207
UCHAR BootSignature
Definition: ntfs.h:85
UCHAR IsNonResident
Definition: ntfs.h:128
USHORT ValueOffset
Definition: ntfs.h:139
ULONGLONG ParentDirectory
Definition: ntfs.h:180
CHAR ClustersPerIndexRecord
Definition: ntfs.h:92
USHORT BootSectorMagic
Definition: ntfs.h:96
ULONG ValueLength
Definition: ntfs.h:138
LONGLONG DataSize
Definition: ntfs.h:152
ULONG MFTRecordNumber
Definition: ntfs.h:121
UCHAR NameLength
Definition: ntfs.h:129
unsigned short USHORT
Definition: pedump.c:61
UCHAR ClustersPerIndexBlock
Definition: ntfs.h:173
USHORT BytesPerSector
Definition: ntfs.h:75
USHORT Flags
Definition: ntfs.h:131
ULONG Reserved
Definition: ntfs.h:219
PUCHAR CacheRun
Definition: ntfs.h:232
ULONG BytesAllocated
Definition: ntfs.h:117
USHORT USACount
Definition: ntfs.h:110
USHORT SectorsPerTrack
Definition: ntfs.h:80
struct _NTFS_VOLUME_INFO * PNTFS_VOLUME_INFO
Definition: ntfs.h:241
struct NTFS_BOOTSECTOR * PNTFS_BOOTSECTOR
UCHAR CurrentHead
Definition: ntfs.h:84
UCHAR Unused4
Definition: ntfs.h:86
ULONGLONG VolumeSectorCount
Definition: ntfs.h:87
ULONG DeviceId
Definition: ntfs.c:51
CHAR ClustersPerMftRecord
Definition: ntfs.h:90
unsigned int ULONG
Definition: retypes.h:1
ULONG Magic
Definition: ntfs.h:101
ULONGLONG StartingVCN
Definition: ntfs.h:201
USHORT Padding
Definition: ntfs.h:120
ULONG Magic
Definition: ntfs.h:108
UCHAR Reserved
Definition: ntfs.h:141
struct NTFS_INDEX_ENTRY * PNTFS_INDEX_ENTRY
UCHAR FileNameLength
Definition: ntfs.h:190
_In_ BOOLEAN _In_ USHORT Directory
Definition: rtlfuncs.h:3885
ULONGLONG CacheRunLength
Definition: ntfs.h:235
USHORT Length
Definition: ntfs.h:222
USHORT NumberOfHeads
Definition: ntfs.h:81
USHORT Reserved
Definition: ntfs.h:189
ULONG IndexBlockSize
Definition: ntfs.h:172
CHAR SystemId[32]
Definition: iso.h:65