ReactOS 0.4.16-dev-1946-g52006dd
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_FILE_ATTR_NORMAL 0x00
69#define NTFS_FILE_ATTR_READONLY 0x01
70#define NTFS_FILE_ATTR_HIDDEN 0x02
71#define NTFS_FILE_ATTR_SYSTEM 0x04
72// 0x08, 0x10 are unused.
73#define NTFS_FILE_ATTR_ARCHIVE 0x20
74#define NTFS_FILE_ATTR_DIRECTORY 0x10000000
75
76#define NTFS_MFT_MASK 0x0000FFFFFFFFFFFFULL
77
78#include <pshpack1.h>
79typedef struct
80{
81 UCHAR JumpBoot[3]; // Jump to the boot loader routine
82 CHAR SystemId[8]; // System Id ("NTFS ")
83 USHORT BytesPerSector; // Bytes per sector
84 UCHAR SectorsPerCluster; // Number of sectors in a cluster
85 UCHAR Unused1[7];
86 UCHAR MediaDescriptor; // Media descriptor byte
87 UCHAR Unused2[2];
88 USHORT SectorsPerTrack; // Number of sectors in a track
89 USHORT NumberOfHeads; // Number of heads on the disk
90 UCHAR Unused3[8];
91 UCHAR DriveNumber; // Int 0x13 drive number (e.g. 0x80)
93 UCHAR BootSignature; // Extended boot signature (0x80)
95 ULONGLONG VolumeSectorCount; // Number of sectors in the volume
98 CHAR ClustersPerMftRecord; // Clusters per MFT Record
99 UCHAR Unused5[3];
100 CHAR ClustersPerIndexRecord; // Clusters per Index Record
101 UCHAR Unused6[3];
102 ULONGLONG VolumeSerialNumber; // Volume serial number
103 UCHAR BootCodeAndData[430]; // The remainder of the boot sector
106
107typedef struct
108{
110 USHORT USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
113
114typedef struct
115{
117 USHORT USAOffset; // Offset to the Update Sequence Array from the start of the ntfs record
124 ULONG BytesInUse; // Number of bytes used in this mft record.
128 USHORT Padding; // Align to 4 UCHAR boundary (NTFS 3.1+ (Windows XP and above))
129 ULONG MFTRecordNumber; // Number of this MFT Record (NTFS 3.1+ (Windows XP and above))
131
132typedef struct
133{
141 union
142 {
143 // Resident attributes
144 struct
145 {
150 } Resident;
151 // Non-resident attributes
152 struct
153 {
158 UCHAR Reserved[4];
163 } NonResident;
164 };
166
167typedef struct
168{
175
176typedef struct
177{
185
186typedef struct
187{
202
203typedef struct
204{
214
215typedef struct
216{
217 union
218 {
219 struct
220 {
223 struct
224 {
228 } ViewIndex;
236#include <poppack.h>
237
238typedef struct
239{
248
250
251typedef struct _NTFS_FILE_HANDLE
252{
260
263 _In_ ULONG DeviceId);
264
265const DEVVTBL* NtfsMount(ULONG DeviceId);
struct NTFS_ATTR_RECORD * PNTFS_ATTR_RECORD
struct _NTFS_FILE_HANDLE NTFS_FILE_HANDLE
struct NTFS_INDEX_ENTRY * PNTFS_INDEX_ENTRY
struct NTFS_INDEX_HEADER * PNTFS_INDEX_HEADER
ULONGLONG NtfsGetVolumeSize(_In_ ULONG DeviceId)
Returns the size of the NTFS volume laid on the storage media device opened via DeviceId.
Definition: ntfs.c:919
struct NTFS_ATTR_CONTEXT * PNTFS_ATTR_CONTEXT
struct NTFS_RECORD * PNTFS_RECORD
struct _NTFS_FILE_HANDLE * PNTFS_FILE_HANDLE
struct NTFS_FILE_NAME_ATTR * PNTFS_FILE_NAME_ATTR
struct NTFS_BOOTSECTOR * PNTFS_BOOTSECTOR
struct NTFS_MFT_RECORD * PNTFS_MFT_RECORD
struct NTFS_ATTR_LIST_ATTR * PNTFS_ATTR_LIST_ATTR
struct _NTFS_VOLUME_INFO * PNTFS_VOLUME_INFO
Definition: ntfs.h:249
struct NTFS_INDEX_ROOT * PNTFS_INDEX_ROOT
const DEVVTBL * NtfsMount(ULONG DeviceId)
Definition: ntfs.c:938
LPWSTR Name
Definition: desk.c:124
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:86
#define _In_
Definition: no_sal2.h:158
unsigned short USHORT
Definition: pedump.c:61
base for all directory entries
Definition: entries.h:138
ULONGLONG CacheRunLength
Definition: ntfs.h:243
LONGLONG CacheRunStartLCN
Definition: ntfs.h:242
ULONGLONG CacheRunCurrentOffset
Definition: ntfs.h:245
PUCHAR CacheRun
Definition: ntfs.h:240
ULONGLONG CacheRunOffset
Definition: ntfs.h:241
LONGLONG CacheRunLastLCN
Definition: ntfs.h:244
NTFS_ATTR_RECORD Record
Definition: ntfs.h:246
UCHAR NameOffset
Definition: ntfs.h:208
ULONGLONG BaseFileRef
Definition: ntfs.h:210
USHORT AttrId
Definition: ntfs.h:211
USHORT RecLength
Definition: ntfs.h:206
UCHAR NameLength
Definition: ntfs.h:207
ULONGLONG StartingVCN
Definition: ntfs.h:209
USHORT Flags
Definition: ntfs.h:139
USHORT CompressionUnit
Definition: ntfs.h:157
LONGLONG AllocatedSize
Definition: ntfs.h:159
ULONG ValueLength
Definition: ntfs.h:146
USHORT ValueOffset
Definition: ntfs.h:147
UCHAR Reserved
Definition: ntfs.h:149
ULONG Length
Definition: ntfs.h:135
LONGLONG CompressedSize
Definition: ntfs.h:162
USHORT MappingPairsOffset
Definition: ntfs.h:156
USHORT NameOffset
Definition: ntfs.h:138
USHORT Instance
Definition: ntfs.h:140
LONGLONG InitializedSize
Definition: ntfs.h:161
ULONGLONG LowestVCN
Definition: ntfs.h:154
UCHAR NameLength
Definition: ntfs.h:137
UCHAR IsNonResident
Definition: ntfs.h:136
ULONGLONG HighestVCN
Definition: ntfs.h:155
UCHAR Flags
Definition: ntfs.h:148
ULONG Type
Definition: ntfs.h:134
LONGLONG DataSize
Definition: ntfs.h:160
UCHAR DriveNumber
Definition: ntfs.h:91
UCHAR CurrentHead
Definition: ntfs.h:92
UCHAR BootSignature
Definition: ntfs.h:93
ULONGLONG VolumeSectorCount
Definition: ntfs.h:95
ULONGLONG VolumeSerialNumber
Definition: ntfs.h:102
USHORT BytesPerSector
Definition: ntfs.h:83
ULONGLONG MftLocation
Definition: ntfs.h:96
ULONGLONG MftMirrorLocation
Definition: ntfs.h:97
CHAR ClustersPerIndexRecord
Definition: ntfs.h:100
UCHAR SectorsPerCluster
Definition: ntfs.h:84
USHORT NumberOfHeads
Definition: ntfs.h:89
CHAR ClustersPerMftRecord
Definition: ntfs.h:98
USHORT BootSectorMagic
Definition: ntfs.h:104
USHORT SectorsPerTrack
Definition: ntfs.h:88
UCHAR MediaDescriptor
Definition: ntfs.h:86
UCHAR Unused4
Definition: ntfs.h:94
LONGLONG DataSize
Definition: ntfs.h:194
LONGLONG LastAccessTime
Definition: ntfs.h:192
UCHAR FileNameLength
Definition: ntfs.h:198
LONGLONG CreationTime
Definition: ntfs.h:189
ULONGLONG ParentDirectory
Definition: ntfs.h:188
ULONG FileAttributes
Definition: ntfs.h:195
USHORT Reserved
Definition: ntfs.h:197
USHORT PackedExtendedAttributeSize
Definition: ntfs.h:196
LONGLONG LastDataChangeTime
Definition: ntfs.h:190
UCHAR FileNameType
Definition: ntfs.h:199
LONGLONG LastMftChangeTime
Definition: ntfs.h:191
LONGLONG AllocatedSize
Definition: ntfs.h:193
Definition: ntfs.h:216
USHORT DataOffset
Definition: ntfs.h:225
NTFS_FILE_NAME_ATTR FileName
Definition: ntfs.h:234
USHORT Reserved
Definition: ntfs.h:233
USHORT Flags
Definition: ntfs.h:232
USHORT KeyLength
Definition: ntfs.h:231
USHORT DataLength
Definition: ntfs.h:226
ULONGLONG IndexedFile
Definition: ntfs.h:221
USHORT Length
Definition: ntfs.h:230
ULONG Reserved
Definition: ntfs.h:227
ULONG IndexLength
Definition: ntfs.h:170
UCHAR Flags
Definition: ntfs.h:172
ULONG AllocatedSize
Definition: ntfs.h:171
ULONG EntriesOffset
Definition: ntfs.h:169
NTFS_INDEX_HEADER IndexHeader
Definition: ntfs.h:183
ULONG IndexBlockSize
Definition: ntfs.h:180
ULONG Type
Definition: ntfs.h:178
UCHAR ClustersPerIndexBlock
Definition: ntfs.h:181
ULONG CollationRule
Definition: ntfs.h:179
USHORT USAOffset
Definition: ntfs.h:117
ULONG Magic
Definition: ntfs.h:116
USHORT NextAttributeInstance
Definition: ntfs.h:127
ULONGLONG LogSequenceNumber
Definition: ntfs.h:119
ULONG BytesAllocated
Definition: ntfs.h:125
USHORT Flags
Definition: ntfs.h:123
USHORT LinkCount
Definition: ntfs.h:121
USHORT Padding
Definition: ntfs.h:128
USHORT AttributesOffset
Definition: ntfs.h:122
USHORT SequenceNumber
Definition: ntfs.h:120
USHORT USACount
Definition: ntfs.h:118
ULONG MFTRecordNumber
Definition: ntfs.h:129
ULONGLONG BaseMFTRecord
Definition: ntfs.h:126
ULONG BytesInUse
Definition: ntfs.h:124
ULONG Magic
Definition: ntfs.h:109
USHORT USACount
Definition: ntfs.h:111
USHORT USAOffset
Definition: ntfs.h:110
PNTFS_VOLUME_INFO Volume
Definition: ntfs.h:253
ULONGLONG Offset
Definition: ntfs.h:255
UCHAR Attributes
Definition: ntfs.h:257
ULONG FileNameLength
Definition: ntfs.h:256
PNTFS_ATTR_CONTEXT DataContext
Definition: ntfs.h:254
Definition: fs.h:25
int64_t LONGLONG
Definition: typedefs.h:68
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175