2002-06-25 22:23:06 +00:00
|
|
|
#ifndef NTFS_H
|
|
|
|
#define NTFS_H
|
|
|
|
|
2005-12-01 21:37:19 +00:00
|
|
|
#include <ntifs.h>
|
2014-12-14 12:24:18 +00:00
|
|
|
#include <pseh/pseh2.h>
|
2018-12-30 11:19:11 +00:00
|
|
|
#include <section_attribs.h>
|
2015-09-03 20:34:47 +00:00
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
#define CACHEPAGESIZE(pDeviceExt) \
|
2006-01-07 06:20:59 +00:00
|
|
|
((pDeviceExt)->NtfsInfo.UCHARsPerCluster > PAGE_SIZE ? \
|
|
|
|
(pDeviceExt)->NtfsInfo.UCHARsPerCluster : PAGE_SIZE)
|
2002-09-08 10:23:54 +00:00
|
|
|
|
2017-12-31 22:11:12 +00:00
|
|
|
#define TAG_NTFS '0ftN'
|
|
|
|
#define TAG_CCB 'CftN'
|
|
|
|
#define TAG_FCB 'FftN'
|
|
|
|
#define TAG_IRP_CTXT 'iftN'
|
|
|
|
#define TAG_ATT_CTXT 'aftN'
|
|
|
|
#define TAG_FILE_REC 'rftN'
|
2008-01-13 11:36:54 +00:00
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
|
2014-11-04 07:56:20 +00:00
|
|
|
#define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2008-01-12 20:54:41 +00:00
|
|
|
#define DEVICE_NAME L"\\Ntfs"
|
|
|
|
|
2006-01-07 06:20:59 +00:00
|
|
|
#include <pshpack1.h>
|
2007-12-28 21:56:19 +00:00
|
|
|
typedef struct _BIOS_PARAMETERS_BLOCK
|
2002-06-25 22:23:06 +00:00
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
USHORT BytesPerSector; // 0x0B
|
|
|
|
UCHAR SectorsPerCluster; // 0x0D
|
|
|
|
UCHAR Unused0[7]; // 0x0E, checked when volume is mounted
|
|
|
|
UCHAR MediaId; // 0x15
|
|
|
|
UCHAR Unused1[2]; // 0x16
|
|
|
|
USHORT SectorsPerTrack; // 0x18
|
|
|
|
USHORT Heads; // 0x1A
|
|
|
|
UCHAR Unused2[4]; // 0x1C
|
|
|
|
UCHAR Unused3[4]; // 0x20, checked when volume is mounted
|
2007-12-28 21:56:19 +00:00
|
|
|
} BIOS_PARAMETERS_BLOCK, *PBIOS_PARAMETERS_BLOCK;
|
|
|
|
|
|
|
|
typedef struct _EXTENDED_BIOS_PARAMETERS_BLOCK
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
USHORT Unknown[2]; // 0x24, always 80 00 80 00
|
|
|
|
ULONGLONG SectorCount; // 0x28
|
|
|
|
ULONGLONG MftLocation; // 0x30
|
|
|
|
ULONGLONG MftMirrLocation; // 0x38
|
|
|
|
CHAR ClustersPerMftRecord; // 0x40
|
|
|
|
UCHAR Unused4[3]; // 0x41
|
|
|
|
CHAR ClustersPerIndexRecord; // 0x44
|
|
|
|
UCHAR Unused5[3]; // 0x45
|
|
|
|
ULONGLONG SerialNumber; // 0x48
|
|
|
|
UCHAR Checksum[4]; // 0x50
|
2007-12-28 21:56:19 +00:00
|
|
|
} EXTENDED_BIOS_PARAMETERS_BLOCK, *PEXTENDED_BIOS_PARAMETERS_BLOCK;
|
|
|
|
|
|
|
|
typedef struct _BOOT_SECTOR
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
UCHAR Jump[3]; // 0x00
|
|
|
|
UCHAR OEMID[8]; // 0x03
|
|
|
|
BIOS_PARAMETERS_BLOCK BPB;
|
|
|
|
EXTENDED_BIOS_PARAMETERS_BLOCK EBPB;
|
|
|
|
UCHAR BootStrap[426]; // 0x54
|
|
|
|
USHORT EndSector; // 0x1FE
|
2006-01-07 06:20:59 +00:00
|
|
|
} BOOT_SECTOR, *PBOOT_SECTOR;
|
|
|
|
#include <poppack.h>
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
//typedef struct _BootSector BootSector;
|
|
|
|
|
|
|
|
typedef struct _NTFS_INFO
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
ULONG BytesPerSector;
|
|
|
|
ULONG SectorsPerCluster;
|
|
|
|
ULONG BytesPerCluster;
|
|
|
|
ULONGLONG SectorCount;
|
2014-12-14 14:38:44 +00:00
|
|
|
ULONGLONG ClusterCount;
|
2013-06-16 12:15:06 +00:00
|
|
|
ULARGE_INTEGER MftStart;
|
|
|
|
ULARGE_INTEGER MftMirrStart;
|
|
|
|
ULONG BytesPerFileRecord;
|
2014-09-25 06:36:14 +00:00
|
|
|
ULONG BytesPerIndexRecord;
|
2013-06-16 12:15:06 +00:00
|
|
|
|
|
|
|
ULONGLONG SerialNumber;
|
|
|
|
USHORT VolumeLabelLength;
|
|
|
|
WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH];
|
|
|
|
UCHAR MajorVersion;
|
|
|
|
UCHAR MinorVersion;
|
|
|
|
USHORT Flags;
|
2003-11-12 15:30:21 +00:00
|
|
|
|
2015-02-14 20:55:47 +00:00
|
|
|
ULONG MftZoneReservation;
|
2002-06-25 22:23:06 +00:00
|
|
|
} NTFS_INFO, *PNTFS_INFO;
|
|
|
|
|
2009-08-24 17:12:25 +00:00
|
|
|
#define NTFS_TYPE_CCB '20SF'
|
|
|
|
#define NTFS_TYPE_FCB '30SF'
|
2016-03-26 13:22:32 +00:00
|
|
|
#define NTFS_TYPE_VCB '50SF'
|
|
|
|
#define NTFS_TYPE_IRP_CONTEXT '60SF'
|
2009-08-24 17:12:25 +00:00
|
|
|
#define NTFS_TYPE_GLOBAL_DATA '70SF'
|
2008-03-15 08:51:47 +00:00
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
ULONG Type;
|
|
|
|
ULONG Size;
|
2008-03-15 08:51:47 +00:00
|
|
|
} NTFSIDENTIFIER, *PNTFSIDENTIFIER;
|
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
NTFSIDENTIFIER Identifier;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
ERESOURCE DirResource;
|
|
|
|
// ERESOURCE FatResource;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
KSPIN_LOCK FcbListLock;
|
|
|
|
LIST_ENTRY FcbListHead;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
PVPB Vpb;
|
|
|
|
PDEVICE_OBJECT StorageDevice;
|
|
|
|
PFILE_OBJECT StreamFileObject;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2014-09-26 13:57:29 +00:00
|
|
|
struct _NTFS_ATTR_CONTEXT* MFTContext;
|
|
|
|
struct _FILE_RECORD_HEADER* MasterFileTable;
|
2014-09-25 20:15:00 +00:00
|
|
|
struct _FCB *VolumeFcb;
|
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
NTFS_INFO NtfsInfo;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2017-12-31 13:14:24 +00:00
|
|
|
NPAGED_LOOKASIDE_LIST FileRecLookasideList;
|
|
|
|
|
2017-06-16 05:43:52 +00:00
|
|
|
ULONG MftDataOffset;
|
2016-02-22 22:20:54 +00:00
|
|
|
ULONG Flags;
|
|
|
|
ULONG OpenHandleCount;
|
|
|
|
|
2008-03-15 08:51:47 +00:00
|
|
|
} DEVICE_EXTENSION, *PDEVICE_EXTENSION, NTFS_VCB, *PNTFS_VCB;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2016-02-22 22:20:54 +00:00
|
|
|
#define VCB_VOLUME_LOCKED 0x0001
|
|
|
|
|
2008-03-15 08:51:47 +00:00
|
|
|
typedef struct
|
2002-06-25 22:23:06 +00:00
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
NTFSIDENTIFIER Identifier;
|
|
|
|
LIST_ENTRY NextCCB;
|
|
|
|
PFILE_OBJECT PtrFileObject;
|
|
|
|
LARGE_INTEGER CurrentByteOffset;
|
|
|
|
/* for DirectoryControl */
|
|
|
|
ULONG Entry;
|
|
|
|
/* for DirectoryControl */
|
|
|
|
PWCHAR DirectorySearchPattern;
|
|
|
|
ULONG LastCluster;
|
|
|
|
ULONG LastOffset;
|
2008-03-15 08:51:47 +00:00
|
|
|
} NTFS_CCB, *PNTFS_CCB;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2008-01-12 20:54:41 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
NTFSIDENTIFIER Identifier;
|
|
|
|
ERESOURCE Resource;
|
|
|
|
PDRIVER_OBJECT DriverObject;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
|
|
|
CACHE_MANAGER_CALLBACKS CacheMgrCallbacks;
|
|
|
|
ULONG Flags;
|
2015-05-01 18:38:10 +00:00
|
|
|
FAST_IO_DISPATCH FastIoDispatch;
|
2015-05-24 15:26:15 +00:00
|
|
|
NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
|
2015-06-11 20:54:01 +00:00
|
|
|
NPAGED_LOOKASIDE_LIST FcbLookasideList;
|
2017-12-31 11:15:17 +00:00
|
|
|
NPAGED_LOOKASIDE_LIST AttrCtxtLookasideList;
|
2017-05-27 19:32:43 +00:00
|
|
|
BOOLEAN EnableWriteSupport;
|
2002-06-25 22:23:06 +00:00
|
|
|
} NTFS_GLOBAL_DATA, *PNTFS_GLOBAL_DATA;
|
|
|
|
|
2002-07-15 15:37:33 +00:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
AttributeStandardInformation = 0x10,
|
|
|
|
AttributeAttributeList = 0x20,
|
|
|
|
AttributeFileName = 0x30,
|
|
|
|
AttributeObjectId = 0x40,
|
|
|
|
AttributeSecurityDescriptor = 0x50,
|
|
|
|
AttributeVolumeName = 0x60,
|
|
|
|
AttributeVolumeInformation = 0x70,
|
|
|
|
AttributeData = 0x80,
|
|
|
|
AttributeIndexRoot = 0x90,
|
|
|
|
AttributeIndexAllocation = 0xA0,
|
|
|
|
AttributeBitmap = 0xB0,
|
|
|
|
AttributeReparsePoint = 0xC0,
|
|
|
|
AttributeEAInformation = 0xD0,
|
|
|
|
AttributeEA = 0xE0,
|
|
|
|
AttributePropertySet = 0xF0,
|
2014-09-26 13:57:29 +00:00
|
|
|
AttributeLoggedUtilityStream = 0x100,
|
|
|
|
AttributeEnd = 0xFFFFFFFF
|
2002-07-15 15:37:33 +00:00
|
|
|
} ATTRIBUTE_TYPE, *PATTRIBUTE_TYPE;
|
|
|
|
|
2016-07-05 07:00:43 +00:00
|
|
|
// FILE_RECORD_END seems to follow AttributeEnd in every file record starting with $Quota.
|
|
|
|
// No clue what data is being represented here.
|
2021-06-11 12:29:21 +00:00
|
|
|
#define FILE_RECORD_END 0x11477982
|
2016-07-05 07:00:43 +00:00
|
|
|
|
2014-09-26 13:57:29 +00:00
|
|
|
#define NTFS_FILE_MFT 0
|
|
|
|
#define NTFS_FILE_MFTMIRR 1
|
|
|
|
#define NTFS_FILE_LOGFILE 2
|
|
|
|
#define NTFS_FILE_VOLUME 3
|
|
|
|
#define NTFS_FILE_ATTRDEF 4
|
|
|
|
#define NTFS_FILE_ROOT 5
|
|
|
|
#define NTFS_FILE_BITMAP 6
|
|
|
|
#define NTFS_FILE_BOOT 7
|
|
|
|
#define NTFS_FILE_BADCLUS 8
|
|
|
|
#define NTFS_FILE_QUOTA 9
|
|
|
|
#define NTFS_FILE_UPCASE 10
|
|
|
|
#define NTFS_FILE_EXTEND 11
|
2017-07-18 19:59:36 +00:00
|
|
|
#define NTFS_FILE_FIRST_USER_FILE 16
|
2014-09-26 13:57:29 +00:00
|
|
|
|
2014-10-17 22:17:59 +00:00
|
|
|
#define NTFS_MFT_MASK 0x0000FFFFFFFFFFFFULL
|
|
|
|
|
2014-09-22 19:59:45 +00:00
|
|
|
#define COLLATION_BINARY 0x00
|
|
|
|
#define COLLATION_FILE_NAME 0x01
|
|
|
|
#define COLLATION_UNICODE_STRING 0x02
|
|
|
|
#define COLLATION_NTOFS_ULONG 0x10
|
|
|
|
#define COLLATION_NTOFS_SID 0x11
|
|
|
|
#define COLLATION_NTOFS_SECURITY_HASH 0x12
|
|
|
|
#define COLLATION_NTOFS_ULONGS 0x13
|
|
|
|
|
2014-09-22 20:26:21 +00:00
|
|
|
#define INDEX_ROOT_SMALL 0x0
|
|
|
|
#define INDEX_ROOT_LARGE 0x1
|
2002-07-15 15:37:33 +00:00
|
|
|
|
2017-07-27 18:22:24 +00:00
|
|
|
#define INDEX_NODE_SMALL 0x0
|
|
|
|
#define INDEX_NODE_LARGE 0x1
|
|
|
|
|
2014-09-26 13:57:29 +00:00
|
|
|
#define NTFS_INDEX_ENTRY_NODE 1
|
|
|
|
#define NTFS_INDEX_ENTRY_END 2
|
|
|
|
|
|
|
|
#define NTFS_FILE_NAME_POSIX 0
|
|
|
|
#define NTFS_FILE_NAME_WIN32 1
|
|
|
|
#define NTFS_FILE_NAME_DOS 2
|
|
|
|
#define NTFS_FILE_NAME_WIN32_AND_DOS 3
|
|
|
|
|
2014-10-08 19:45:33 +00:00
|
|
|
#define NTFS_FILE_TYPE_READ_ONLY 0x1
|
|
|
|
#define NTFS_FILE_TYPE_HIDDEN 0x2
|
|
|
|
#define NTFS_FILE_TYPE_SYSTEM 0x4
|
|
|
|
#define NTFS_FILE_TYPE_ARCHIVE 0x20
|
2021-08-04 06:01:42 +00:00
|
|
|
#define NTFS_FILE_TYPE_TEMPORARY 0x100
|
|
|
|
#define NTFS_FILE_TYPE_SPARSE 0x200
|
2014-11-23 20:52:59 +00:00
|
|
|
#define NTFS_FILE_TYPE_REPARSE 0x400
|
2014-10-08 19:45:33 +00:00
|
|
|
#define NTFS_FILE_TYPE_COMPRESSED 0x800
|
2021-08-04 06:01:42 +00:00
|
|
|
#define NTFS_FILE_TYPE_OFFLINE 0x1000
|
|
|
|
#define NTFS_FILE_TYPE_ENCRYPTED 0x4000
|
2014-10-08 19:45:33 +00:00
|
|
|
#define NTFS_FILE_TYPE_DIRECTORY 0x10000000
|
|
|
|
|
2017-07-18 19:59:36 +00:00
|
|
|
/* Indexed Flag in Resident attributes - still somewhat speculative */
|
|
|
|
#define RA_INDEXED 0x01
|
|
|
|
|
2002-07-15 15:37:33 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
ULONG Type; /* Magic number 'FILE' */
|
|
|
|
USHORT UsaOffset; /* Offset to the update sequence */
|
|
|
|
USHORT UsaCount; /* Size in words of Update Sequence Number & Array (S) */
|
|
|
|
ULONGLONG Lsn; /* $LogFile Sequence Number (LSN) */
|
2002-07-15 15:37:33 +00:00
|
|
|
} NTFS_RECORD_HEADER, *PNTFS_RECORD_HEADER;
|
|
|
|
|
2003-11-12 15:30:21 +00:00
|
|
|
/* NTFS_RECORD_HEADER.Type */
|
|
|
|
#define NRH_FILE_TYPE 0x454C4946 /* 'FILE' */
|
2014-11-06 21:12:54 +00:00
|
|
|
#define NRH_INDX_TYPE 0x58444E49 /* 'INDX' */
|
2003-11-12 15:30:21 +00:00
|
|
|
|
|
|
|
|
2014-09-26 13:57:29 +00:00
|
|
|
typedef struct _FILE_RECORD_HEADER
|
2002-07-15 15:37:33 +00:00
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
NTFS_RECORD_HEADER Ntfs;
|
|
|
|
USHORT SequenceNumber; /* Sequence number */
|
|
|
|
USHORT LinkCount; /* Hard link count */
|
|
|
|
USHORT AttributeOffset; /* Offset to the first Attribute */
|
|
|
|
USHORT Flags; /* Flags */
|
|
|
|
ULONG BytesInUse; /* Real size of the FILE record */
|
|
|
|
ULONG BytesAllocated; /* Allocated size of the FILE record */
|
|
|
|
ULONGLONG BaseFileRecord; /* File reference to the base FILE record */
|
|
|
|
USHORT NextAttributeNumber; /* Next Attribute Id */
|
2016-11-13 15:31:39 +00:00
|
|
|
USHORT Padding; /* Align to 4 UCHAR boundary (XP) */
|
2013-06-16 12:15:06 +00:00
|
|
|
ULONG MFTRecordNumber; /* Number of this MFT Record (XP) */
|
2002-07-15 15:37:33 +00:00
|
|
|
} FILE_RECORD_HEADER, *PFILE_RECORD_HEADER;
|
|
|
|
|
2003-07-17 13:31:39 +00:00
|
|
|
/* Flags in FILE_RECORD_HEADER */
|
|
|
|
|
2003-11-12 15:30:21 +00:00
|
|
|
#define FRH_IN_USE 0x0001 /* Record is in use */
|
|
|
|
#define FRH_DIRECTORY 0x0002 /* Record is a directory */
|
|
|
|
#define FRH_UNKNOWN1 0x0004 /* Don't know */
|
|
|
|
#define FRH_UNKNOWN2 0x0008 /* Don't know */
|
2003-07-17 13:31:39 +00:00
|
|
|
|
2002-07-15 15:37:33 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2014-09-26 13:57:29 +00:00
|
|
|
ULONG Type;
|
|
|
|
ULONG Length;
|
|
|
|
UCHAR IsNonResident;
|
|
|
|
UCHAR NameLength;
|
|
|
|
USHORT NameOffset;
|
|
|
|
USHORT Flags;
|
|
|
|
USHORT Instance;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
// Resident attributes
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
ULONG ValueLength;
|
|
|
|
USHORT ValueOffset;
|
|
|
|
UCHAR Flags;
|
|
|
|
UCHAR Reserved;
|
|
|
|
} Resident;
|
|
|
|
// Non-resident attributes
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
ULONGLONG LowestVCN;
|
|
|
|
ULONGLONG HighestVCN;
|
|
|
|
USHORT MappingPairsOffset;
|
|
|
|
USHORT CompressionUnit;
|
|
|
|
UCHAR Reserved[4];
|
|
|
|
LONGLONG AllocatedSize;
|
|
|
|
LONGLONG DataSize;
|
|
|
|
LONGLONG InitializedSize;
|
|
|
|
LONGLONG CompressedSize;
|
|
|
|
} NonResident;
|
|
|
|
};
|
|
|
|
} NTFS_ATTR_RECORD, *PNTFS_ATTR_RECORD;
|
2002-07-15 15:37:33 +00:00
|
|
|
|
2019-08-08 20:09:13 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ULONG Type;
|
|
|
|
USHORT Length;
|
|
|
|
UCHAR NameLength;
|
|
|
|
UCHAR NameOffset;
|
|
|
|
ULONGLONG StartingVCN;
|
|
|
|
ULONGLONG MFTIndex;
|
|
|
|
USHORT Instance;
|
|
|
|
} NTFS_ATTRIBUTE_LIST_ITEM, *PNTFS_ATTRIBUTE_LIST_ITEM;
|
|
|
|
|
2017-07-05 16:29:16 +00:00
|
|
|
// The beginning and length of an attribute record are always aligned to an 8-byte boundary,
|
|
|
|
// relative to the beginning of the file record.
|
|
|
|
#define ATTR_RECORD_ALIGNMENT 8
|
|
|
|
|
2017-08-27 14:37:17 +00:00
|
|
|
// Data runs are aligned to a 4-byte boundary, relative to the start of the attribute record
|
|
|
|
#define DATA_RUN_ALIGNMENT 4
|
|
|
|
|
|
|
|
// Value offset is aligned to a 4-byte boundary, relative to the start of the attribute record
|
|
|
|
#define VALUE_OFFSET_ALIGNMENT 4
|
|
|
|
|
2002-07-15 15:37:33 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
ULONGLONG CreationTime;
|
|
|
|
ULONGLONG ChangeTime;
|
|
|
|
ULONGLONG LastWriteTime;
|
|
|
|
ULONGLONG LastAccessTime;
|
|
|
|
ULONG FileAttribute;
|
|
|
|
ULONG AlignmentOrReserved[3];
|
2002-07-15 15:37:33 +00:00
|
|
|
#if 0
|
2013-06-16 12:15:06 +00:00
|
|
|
ULONG QuotaId;
|
|
|
|
ULONG SecurityId;
|
|
|
|
ULONGLONG QuotaCharge;
|
|
|
|
USN Usn;
|
2002-07-15 15:37:33 +00:00
|
|
|
#endif
|
|
|
|
} STANDARD_INFORMATION, *PSTANDARD_INFORMATION;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
ATTRIBUTE_TYPE AttributeType;
|
|
|
|
USHORT Length;
|
|
|
|
UCHAR NameLength;
|
|
|
|
UCHAR NameOffset;
|
|
|
|
ULONGLONG StartVcn; // LowVcn
|
|
|
|
ULONGLONG FileReferenceNumber;
|
|
|
|
USHORT AttributeNumber;
|
|
|
|
USHORT AlignmentOrReserved[3];
|
2002-07-15 15:37:33 +00:00
|
|
|
} ATTRIBUTE_LIST, *PATTRIBUTE_LIST;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
ULONGLONG DirectoryFileReferenceNumber;
|
|
|
|
ULONGLONG CreationTime;
|
|
|
|
ULONGLONG ChangeTime;
|
|
|
|
ULONGLONG LastWriteTime;
|
|
|
|
ULONGLONG LastAccessTime;
|
|
|
|
ULONGLONG AllocatedSize;
|
|
|
|
ULONGLONG DataSize;
|
|
|
|
ULONG FileAttributes;
|
2014-11-23 20:52:59 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
USHORT PackedEaSize;
|
|
|
|
USHORT AlignmentOrReserved;
|
|
|
|
} EaInfo;
|
|
|
|
ULONG ReparseTag;
|
|
|
|
} Extended;
|
2013-06-16 12:15:06 +00:00
|
|
|
UCHAR NameLength;
|
|
|
|
UCHAR NameType;
|
|
|
|
WCHAR Name[1];
|
2002-07-15 15:37:33 +00:00
|
|
|
} FILENAME_ATTRIBUTE, *PFILENAME_ATTRIBUTE;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2014-09-22 20:26:21 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ULONG FirstEntryOffset;
|
|
|
|
ULONG TotalSizeOfEntries;
|
|
|
|
ULONG AllocatedSize;
|
|
|
|
UCHAR Flags;
|
|
|
|
UCHAR Padding[3];
|
|
|
|
} INDEX_HEADER_ATTRIBUTE, *PINDEX_HEADER_ATTRIBUTE;
|
|
|
|
|
2014-09-22 19:59:45 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
ULONG AttributeType;
|
|
|
|
ULONG CollationRule;
|
|
|
|
ULONG SizeOfEntry;
|
|
|
|
UCHAR ClustersPerIndexRecord;
|
|
|
|
UCHAR Padding[3];
|
2014-09-22 20:26:21 +00:00
|
|
|
INDEX_HEADER_ATTRIBUTE Header;
|
2014-09-22 19:59:45 +00:00
|
|
|
} INDEX_ROOT_ATTRIBUTE, *PINDEX_ROOT_ATTRIBUTE;
|
|
|
|
|
2014-10-16 21:37:27 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
NTFS_RECORD_HEADER Ntfs;
|
|
|
|
ULONGLONG VCN;
|
|
|
|
INDEX_HEADER_ATTRIBUTE Header;
|
|
|
|
} INDEX_BUFFER, *PINDEX_BUFFER;
|
|
|
|
|
2014-09-26 13:57:29 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
ULONGLONG IndexedFile;
|
|
|
|
} Directory;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
USHORT DataOffset;
|
|
|
|
USHORT DataLength;
|
|
|
|
ULONG Reserved;
|
|
|
|
} ViewIndex;
|
|
|
|
} Data;
|
|
|
|
USHORT Length;
|
|
|
|
USHORT KeyLength;
|
|
|
|
USHORT Flags;
|
|
|
|
USHORT Reserved;
|
|
|
|
FILENAME_ATTRIBUTE FileName;
|
|
|
|
} INDEX_ENTRY_ATTRIBUTE, *PINDEX_ENTRY_ATTRIBUTE;
|
|
|
|
|
2017-07-27 19:52:33 +00:00
|
|
|
struct _B_TREE_FILENAME_NODE;
|
|
|
|
typedef struct _B_TREE_FILENAME_NODE B_TREE_FILENAME_NODE;
|
|
|
|
|
2017-06-28 03:45:52 +00:00
|
|
|
// Keys are arranged in nodes as an ordered, linked list
|
|
|
|
typedef struct _B_TREE_KEY
|
|
|
|
{
|
|
|
|
struct _B_TREE_KEY *NextKey;
|
2017-07-27 19:52:33 +00:00
|
|
|
B_TREE_FILENAME_NODE *LesserChild; // Child-Node. All the keys in this node will be sorted before IndexEntry
|
|
|
|
PINDEX_ENTRY_ATTRIBUTE IndexEntry; // must be last member for FIELD_OFFSET
|
2017-06-28 03:45:52 +00:00
|
|
|
}B_TREE_KEY, *PB_TREE_KEY;
|
|
|
|
|
|
|
|
// Every Node is just an ordered list of keys.
|
|
|
|
// Sub-nodes can be found attached to a key (if they exist).
|
|
|
|
// A key's sub-node precedes that key in the ordered list.
|
2017-07-27 19:52:33 +00:00
|
|
|
typedef struct _B_TREE_FILENAME_NODE
|
2017-06-28 03:45:52 +00:00
|
|
|
{
|
2017-07-05 16:29:16 +00:00
|
|
|
ULONG KeyCount;
|
2017-08-27 14:37:17 +00:00
|
|
|
BOOLEAN HasValidVCN;
|
2017-07-27 19:52:33 +00:00
|
|
|
BOOLEAN DiskNeedsUpdating;
|
2017-08-27 14:37:17 +00:00
|
|
|
ULONGLONG VCN;
|
2017-06-28 03:45:52 +00:00
|
|
|
PB_TREE_KEY FirstKey;
|
|
|
|
} B_TREE_FILENAME_NODE, *PB_TREE_FILENAME_NODE;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
PB_TREE_FILENAME_NODE RootNode;
|
|
|
|
} B_TREE, *PB_TREE;
|
|
|
|
|
2003-01-17 19:57:31 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
ULONGLONG Unknown1;
|
|
|
|
UCHAR MajorVersion;
|
|
|
|
UCHAR MinorVersion;
|
|
|
|
USHORT Flags;
|
|
|
|
ULONG Unknown2;
|
2003-01-17 19:57:31 +00:00
|
|
|
} VOLINFO_ATTRIBUTE, *PVOLINFO_ATTRIBUTE;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2014-11-24 20:02:40 +00:00
|
|
|
typedef struct {
|
|
|
|
ULONG ReparseTag;
|
|
|
|
USHORT DataLength;
|
|
|
|
USHORT Reserved;
|
|
|
|
UCHAR Data[1];
|
|
|
|
} REPARSE_POINT_ATTRIBUTE, *PREPARSE_POINT_ATTRIBUTE;
|
|
|
|
|
2015-05-03 18:17:39 +00:00
|
|
|
#define IRPCONTEXT_CANWAIT 0x1
|
2015-05-10 20:47:44 +00:00
|
|
|
#define IRPCONTEXT_COMPLETE 0x2
|
|
|
|
#define IRPCONTEXT_QUEUE 0x4
|
2015-05-03 18:17:39 +00:00
|
|
|
|
2008-02-10 11:20:29 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-06-16 12:15:06 +00:00
|
|
|
NTFSIDENTIFIER Identifier;
|
|
|
|
ULONG Flags;
|
2015-05-03 18:25:55 +00:00
|
|
|
PIO_STACK_LOCATION Stack;
|
2013-06-16 12:15:06 +00:00
|
|
|
UCHAR MajorFunction;
|
|
|
|
UCHAR MinorFunction;
|
|
|
|
WORK_QUEUE_ITEM WorkQueueItem;
|
|
|
|
PIRP Irp;
|
|
|
|
BOOLEAN IsTopLevel;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
2015-05-03 18:25:55 +00:00
|
|
|
PFILE_OBJECT FileObject;
|
2013-06-16 12:15:06 +00:00
|
|
|
NTSTATUS SavedExceptionCode;
|
2015-05-10 14:36:00 +00:00
|
|
|
CCHAR PriorityBoost;
|
2008-02-10 11:20:29 +00:00
|
|
|
} NTFS_IRP_CONTEXT, *PNTFS_IRP_CONTEXT;
|
|
|
|
|
2014-09-26 13:57:29 +00:00
|
|
|
typedef struct _NTFS_ATTR_CONTEXT
|
|
|
|
{
|
|
|
|
PUCHAR CacheRun;
|
|
|
|
ULONGLONG CacheRunOffset;
|
|
|
|
LONGLONG CacheRunStartLCN;
|
|
|
|
ULONGLONG CacheRunLength;
|
|
|
|
LONGLONG CacheRunLastLCN;
|
|
|
|
ULONGLONG CacheRunCurrentOffset;
|
2017-05-12 22:16:20 +00:00
|
|
|
LARGE_MCB DataRunsMCB;
|
2016-07-05 07:00:43 +00:00
|
|
|
ULONGLONG FileMFTIndex;
|
2019-08-08 20:09:13 +00:00
|
|
|
ULONGLONG FileOwnerMFTIndex; /* If attribute list attribute, reference the original file */
|
2017-08-06 02:54:15 +00:00
|
|
|
PNTFS_ATTR_RECORD pRecord;
|
2014-09-26 13:57:29 +00:00
|
|
|
} NTFS_ATTR_CONTEXT, *PNTFS_ATTR_CONTEXT;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2014-10-08 19:32:21 +00:00
|
|
|
#define FCB_CACHE_INITIALIZED 0x0001
|
|
|
|
#define FCB_IS_VOLUME_STREAM 0x0002
|
|
|
|
#define FCB_IS_VOLUME 0x0004
|
|
|
|
#define MAX_PATH 260
|
|
|
|
|
|
|
|
typedef struct _FCB
|
|
|
|
{
|
|
|
|
NTFSIDENTIFIER Identifier;
|
|
|
|
|
|
|
|
FSRTL_COMMON_FCB_HEADER RFCB;
|
|
|
|
SECTION_OBJECT_POINTERS SectionObjectPointers;
|
|
|
|
|
|
|
|
PFILE_OBJECT FileObject;
|
|
|
|
PNTFS_VCB Vcb;
|
|
|
|
|
2015-06-28 13:14:07 +00:00
|
|
|
WCHAR Stream[MAX_PATH];
|
2014-10-08 19:32:21 +00:00
|
|
|
WCHAR *ObjectName; /* point on filename (250 chars max) in PathName */
|
|
|
|
WCHAR PathName[MAX_PATH]; /* path+filename 260 max */
|
|
|
|
|
|
|
|
ERESOURCE PagingIoResource;
|
|
|
|
ERESOURCE MainResource;
|
|
|
|
|
|
|
|
LIST_ENTRY FcbListEntry;
|
|
|
|
struct _FCB* ParentFcb;
|
|
|
|
|
|
|
|
ULONG DirIndex;
|
|
|
|
|
|
|
|
LONG RefCount;
|
|
|
|
ULONG Flags;
|
2016-02-22 22:20:54 +00:00
|
|
|
ULONG OpenHandleCount;
|
2014-10-08 19:32:21 +00:00
|
|
|
|
|
|
|
ULONGLONG MFTIndex;
|
2014-12-15 21:28:06 +00:00
|
|
|
USHORT LinkCount;
|
2014-10-08 19:32:21 +00:00
|
|
|
|
|
|
|
FILENAME_ATTRIBUTE Entry;
|
|
|
|
|
|
|
|
} NTFS_FCB, *PNTFS_FCB;
|
|
|
|
|
[NTFS]
Totally rewrite the way MFT records attributes are handled.
Up to now, we were having really similar loops, only looking at the resident part of the attribute list, not really caring about how the loop was going.
This was leading to some issues:
- In case the attribute we were looking for was stored in the non-resident part of the attribute list, we would miss it (excepted in the case of FindAttribute() which was properly browsing the whole attribute list).
- In the specific case of FindAttribute(), one would have been able to setup a broken MFT record with the resident attribute list pointing on the non resident attribute list which itself would point to the resident attribute list. In such case, the driver would loop forever caught on the loop, allocating tones of memory. It was possible to trigger this by user space, from a non-privileged user, just by browsing the right directory entry.
- In the case of the other loops (non FindAttribute()), another issue (other than missing attributes) was present, one would have been able to setup a broken MFT record with an attribute of null-length. This would have caused the driver to loop forever on the attribute list. This could be triggered from usermode too. And could be triggered by a non-privileged user.
This commit introduces a new set of functions for attributes browsing: FindFirstAttribute(), FindNextAttribute(), FindCloseAttribute(). It allows safely browsing attributes and handles broken cases. It also performs reading of the attribute list when present and makes sure there's only one read. This method should be the only one to use to browse the attributes.
The whole NTFS code base has been converted to use this newly set of functions. This really simplifies the implementation of FindAttribute(), and prevent unsafe code duplication.
CORE-10037 #resolve #comment Fixed with r68829
svn path=/trunk/; revision=68829
2015-08-26 18:20:04 +00:00
|
|
|
typedef struct _FIND_ATTR_CONTXT
|
|
|
|
{
|
|
|
|
PDEVICE_EXTENSION Vcb;
|
|
|
|
BOOLEAN OnlyResident;
|
|
|
|
PNTFS_ATTR_RECORD FirstAttr;
|
|
|
|
PNTFS_ATTR_RECORD CurrAttr;
|
|
|
|
PNTFS_ATTR_RECORD LastAttr;
|
2019-08-08 20:09:13 +00:00
|
|
|
PNTFS_ATTRIBUTE_LIST_ITEM NonResidentStart;
|
|
|
|
PNTFS_ATTRIBUTE_LIST_ITEM NonResidentEnd;
|
|
|
|
PNTFS_ATTRIBUTE_LIST_ITEM NonResidentCur;
|
2016-06-22 21:20:50 +00:00
|
|
|
ULONG Offset;
|
[NTFS]
Totally rewrite the way MFT records attributes are handled.
Up to now, we were having really similar loops, only looking at the resident part of the attribute list, not really caring about how the loop was going.
This was leading to some issues:
- In case the attribute we were looking for was stored in the non-resident part of the attribute list, we would miss it (excepted in the case of FindAttribute() which was properly browsing the whole attribute list).
- In the specific case of FindAttribute(), one would have been able to setup a broken MFT record with the resident attribute list pointing on the non resident attribute list which itself would point to the resident attribute list. In such case, the driver would loop forever caught on the loop, allocating tones of memory. It was possible to trigger this by user space, from a non-privileged user, just by browsing the right directory entry.
- In the case of the other loops (non FindAttribute()), another issue (other than missing attributes) was present, one would have been able to setup a broken MFT record with an attribute of null-length. This would have caused the driver to loop forever on the attribute list. This could be triggered from usermode too. And could be triggered by a non-privileged user.
This commit introduces a new set of functions for attributes browsing: FindFirstAttribute(), FindNextAttribute(), FindCloseAttribute(). It allows safely browsing attributes and handles broken cases. It also performs reading of the attribute list when present and makes sure there's only one read. This method should be the only one to use to browse the attributes.
The whole NTFS code base has been converted to use this newly set of functions. This really simplifies the implementation of FindAttribute(), and prevent unsafe code duplication.
CORE-10037 #resolve #comment Fixed with r68829
svn path=/trunk/; revision=68829
2015-08-26 18:20:04 +00:00
|
|
|
} FIND_ATTR_CONTXT, *PFIND_ATTR_CONTXT;
|
|
|
|
|
2016-06-22 21:20:50 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
USHORT USN;
|
|
|
|
USHORT Array[];
|
|
|
|
} FIXUP_ARRAY, *PFIXUP_ARRAY;
|
|
|
|
|
2002-07-15 15:37:33 +00:00
|
|
|
extern PNTFS_GLOBAL_DATA NtfsGlobalData;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2015-05-25 16:52:02 +00:00
|
|
|
FORCEINLINE
|
|
|
|
NTSTATUS
|
|
|
|
NtfsMarkIrpContextForQueue(PNTFS_IRP_CONTEXT IrpContext)
|
|
|
|
{
|
|
|
|
PULONG Flags = &IrpContext->Flags;
|
|
|
|
|
|
|
|
*Flags &= ~IRPCONTEXT_COMPLETE;
|
|
|
|
*Flags |= IRPCONTEXT_QUEUE;
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2015-05-25 16:52:02 +00:00
|
|
|
return STATUS_PENDING;
|
|
|
|
}
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2002-07-15 15:37:33 +00:00
|
|
|
/* attrib.c */
|
|
|
|
|
2003-11-12 15:30:21 +00:00
|
|
|
//VOID
|
|
|
|
//NtfsDumpAttribute(PATTRIBUTE Attribute);
|
2002-07-15 15:37:33 +00:00
|
|
|
|
2017-08-29 15:51:14 +00:00
|
|
|
NTSTATUS
|
|
|
|
AddBitmap(PNTFS_VCB Vcb,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PNTFS_ATTR_RECORD AttributeAddress,
|
|
|
|
PCWSTR Name,
|
|
|
|
USHORT NameLength);
|
|
|
|
|
2017-04-16 00:17:07 +00:00
|
|
|
NTSTATUS
|
|
|
|
AddData(PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PNTFS_ATTR_RECORD AttributeAddress);
|
|
|
|
|
2016-06-29 16:35:36 +00:00
|
|
|
NTSTATUS
|
2016-07-14 15:20:48 +00:00
|
|
|
AddRun(PNTFS_VCB Vcb,
|
|
|
|
PNTFS_ATTR_CONTEXT AttrContext,
|
|
|
|
ULONG AttrOffset,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
2016-06-29 16:35:36 +00:00
|
|
|
ULONGLONG NextAssignedCluster,
|
|
|
|
ULONG RunLength);
|
|
|
|
|
2017-08-29 15:51:14 +00:00
|
|
|
NTSTATUS
|
|
|
|
AddIndexAllocation(PNTFS_VCB Vcb,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PNTFS_ATTR_RECORD AttributeAddress,
|
|
|
|
PCWSTR Name,
|
|
|
|
USHORT NameLength);
|
|
|
|
|
2017-08-27 14:37:17 +00:00
|
|
|
NTSTATUS
|
|
|
|
AddIndexRoot(PNTFS_VCB Vcb,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PNTFS_ATTR_RECORD AttributeAddress,
|
|
|
|
PINDEX_ROOT_ATTRIBUTE NewIndexRoot,
|
|
|
|
ULONG RootLength,
|
|
|
|
PCWSTR Name,
|
|
|
|
USHORT NameLength);
|
|
|
|
|
2017-04-16 00:17:07 +00:00
|
|
|
NTSTATUS
|
|
|
|
AddFileName(PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PNTFS_ATTR_RECORD AttributeAddress,
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
2017-06-09 03:14:30 +00:00
|
|
|
PFILE_OBJECT FileObject,
|
2017-06-25 02:38:15 +00:00
|
|
|
BOOLEAN CaseSensitive,
|
2017-06-09 03:14:30 +00:00
|
|
|
PULONGLONG ParentMftIndex);
|
2017-04-16 00:17:07 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
AddStandardInformation(PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PNTFS_ATTR_RECORD AttributeAddress);
|
|
|
|
|
2016-07-14 15:20:48 +00:00
|
|
|
NTSTATUS
|
|
|
|
ConvertDataRunsToLargeMCB(PUCHAR DataRun,
|
|
|
|
PLARGE_MCB DataRunsMCB,
|
|
|
|
PULONGLONG pNextVBN);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
ConvertLargeMCBToDataRuns(PLARGE_MCB DataRunsMCB,
|
|
|
|
PUCHAR RunBuffer,
|
|
|
|
ULONG MaxBufferSize,
|
|
|
|
PULONG UsedBufferSize);
|
|
|
|
|
2014-09-26 13:57:29 +00:00
|
|
|
PUCHAR
|
|
|
|
DecodeRun(PUCHAR DataRun,
|
|
|
|
LONGLONG *DataRunOffset,
|
|
|
|
ULONGLONG *DataRunLength);
|
2003-11-13 15:26:34 +00:00
|
|
|
|
2017-06-28 03:45:52 +00:00
|
|
|
ULONG GetFileNameAttributeLength(PFILENAME_ATTRIBUTE FileNameAttribute);
|
|
|
|
|
2016-07-13 11:51:16 +00:00
|
|
|
VOID
|
|
|
|
NtfsDumpDataRuns(PVOID StartOfRun,
|
|
|
|
ULONGLONG CurrentLCN);
|
|
|
|
|
2003-11-12 15:30:21 +00:00
|
|
|
VOID
|
[NTFS]
Totally rewrite the way MFT records attributes are handled.
Up to now, we were having really similar loops, only looking at the resident part of the attribute list, not really caring about how the loop was going.
This was leading to some issues:
- In case the attribute we were looking for was stored in the non-resident part of the attribute list, we would miss it (excepted in the case of FindAttribute() which was properly browsing the whole attribute list).
- In the specific case of FindAttribute(), one would have been able to setup a broken MFT record with the resident attribute list pointing on the non resident attribute list which itself would point to the resident attribute list. In such case, the driver would loop forever caught on the loop, allocating tones of memory. It was possible to trigger this by user space, from a non-privileged user, just by browsing the right directory entry.
- In the case of the other loops (non FindAttribute()), another issue (other than missing attributes) was present, one would have been able to setup a broken MFT record with an attribute of null-length. This would have caused the driver to loop forever on the attribute list. This could be triggered from usermode too. And could be triggered by a non-privileged user.
This commit introduces a new set of functions for attributes browsing: FindFirstAttribute(), FindNextAttribute(), FindCloseAttribute(). It allows safely browsing attributes and handles broken cases. It also performs reading of the attribute list when present and makes sure there's only one read. This method should be the only one to use to browse the attributes.
The whole NTFS code base has been converted to use this newly set of functions. This really simplifies the implementation of FindAttribute(), and prevent unsafe code duplication.
CORE-10037 #resolve #comment Fixed with r68829
svn path=/trunk/; revision=68829
2015-08-26 18:20:04 +00:00
|
|
|
NtfsDumpFileAttributes(PDEVICE_EXTENSION Vcb,
|
|
|
|
PFILE_RECORD_HEADER FileRecord);
|
2013-06-16 12:15:06 +00:00
|
|
|
|
2014-12-08 19:19:30 +00:00
|
|
|
PSTANDARD_INFORMATION
|
[NTFS]
Totally rewrite the way MFT records attributes are handled.
Up to now, we were having really similar loops, only looking at the resident part of the attribute list, not really caring about how the loop was going.
This was leading to some issues:
- In case the attribute we were looking for was stored in the non-resident part of the attribute list, we would miss it (excepted in the case of FindAttribute() which was properly browsing the whole attribute list).
- In the specific case of FindAttribute(), one would have been able to setup a broken MFT record with the resident attribute list pointing on the non resident attribute list which itself would point to the resident attribute list. In such case, the driver would loop forever caught on the loop, allocating tones of memory. It was possible to trigger this by user space, from a non-privileged user, just by browsing the right directory entry.
- In the case of the other loops (non FindAttribute()), another issue (other than missing attributes) was present, one would have been able to setup a broken MFT record with an attribute of null-length. This would have caused the driver to loop forever on the attribute list. This could be triggered from usermode too. And could be triggered by a non-privileged user.
This commit introduces a new set of functions for attributes browsing: FindFirstAttribute(), FindNextAttribute(), FindCloseAttribute(). It allows safely browsing attributes and handles broken cases. It also performs reading of the attribute list when present and makes sure there's only one read. This method should be the only one to use to browse the attributes.
The whole NTFS code base has been converted to use this newly set of functions. This really simplifies the implementation of FindAttribute(), and prevent unsafe code duplication.
CORE-10037 #resolve #comment Fixed with r68829
svn path=/trunk/; revision=68829
2015-08-26 18:20:04 +00:00
|
|
|
GetStandardInformationFromRecord(PDEVICE_EXTENSION Vcb,
|
|
|
|
PFILE_RECORD_HEADER FileRecord);
|
2014-12-08 19:19:30 +00:00
|
|
|
|
2014-10-08 19:12:48 +00:00
|
|
|
PFILENAME_ATTRIBUTE
|
[NTFS]
Totally rewrite the way MFT records attributes are handled.
Up to now, we were having really similar loops, only looking at the resident part of the attribute list, not really caring about how the loop was going.
This was leading to some issues:
- In case the attribute we were looking for was stored in the non-resident part of the attribute list, we would miss it (excepted in the case of FindAttribute() which was properly browsing the whole attribute list).
- In the specific case of FindAttribute(), one would have been able to setup a broken MFT record with the resident attribute list pointing on the non resident attribute list which itself would point to the resident attribute list. In such case, the driver would loop forever caught on the loop, allocating tones of memory. It was possible to trigger this by user space, from a non-privileged user, just by browsing the right directory entry.
- In the case of the other loops (non FindAttribute()), another issue (other than missing attributes) was present, one would have been able to setup a broken MFT record with an attribute of null-length. This would have caused the driver to loop forever on the attribute list. This could be triggered from usermode too. And could be triggered by a non-privileged user.
This commit introduces a new set of functions for attributes browsing: FindFirstAttribute(), FindNextAttribute(), FindCloseAttribute(). It allows safely browsing attributes and handles broken cases. It also performs reading of the attribute list when present and makes sure there's only one read. This method should be the only one to use to browse the attributes.
The whole NTFS code base has been converted to use this newly set of functions. This really simplifies the implementation of FindAttribute(), and prevent unsafe code duplication.
CORE-10037 #resolve #comment Fixed with r68829
svn path=/trunk/; revision=68829
2015-08-26 18:20:04 +00:00
|
|
|
GetFileNameFromRecord(PDEVICE_EXTENSION Vcb,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
UCHAR NameType);
|
2002-07-15 15:37:33 +00:00
|
|
|
|
2016-07-13 11:51:16 +00:00
|
|
|
UCHAR
|
|
|
|
GetPackedByteCount(LONGLONG NumberToPack,
|
|
|
|
BOOLEAN IsSigned);
|
|
|
|
|
2016-06-29 16:35:36 +00:00
|
|
|
NTSTATUS
|
|
|
|
GetLastClusterInDataRun(PDEVICE_EXTENSION Vcb,
|
|
|
|
PNTFS_ATTR_RECORD Attribute,
|
|
|
|
PULONGLONG LastCluster);
|
|
|
|
|
2014-11-23 14:07:08 +00:00
|
|
|
PFILENAME_ATTRIBUTE
|
[NTFS]
Totally rewrite the way MFT records attributes are handled.
Up to now, we were having really similar loops, only looking at the resident part of the attribute list, not really caring about how the loop was going.
This was leading to some issues:
- In case the attribute we were looking for was stored in the non-resident part of the attribute list, we would miss it (excepted in the case of FindAttribute() which was properly browsing the whole attribute list).
- In the specific case of FindAttribute(), one would have been able to setup a broken MFT record with the resident attribute list pointing on the non resident attribute list which itself would point to the resident attribute list. In such case, the driver would loop forever caught on the loop, allocating tones of memory. It was possible to trigger this by user space, from a non-privileged user, just by browsing the right directory entry.
- In the case of the other loops (non FindAttribute()), another issue (other than missing attributes) was present, one would have been able to setup a broken MFT record with an attribute of null-length. This would have caused the driver to loop forever on the attribute list. This could be triggered from usermode too. And could be triggered by a non-privileged user.
This commit introduces a new set of functions for attributes browsing: FindFirstAttribute(), FindNextAttribute(), FindCloseAttribute(). It allows safely browsing attributes and handles broken cases. It also performs reading of the attribute list when present and makes sure there's only one read. This method should be the only one to use to browse the attributes.
The whole NTFS code base has been converted to use this newly set of functions. This really simplifies the implementation of FindAttribute(), and prevent unsafe code duplication.
CORE-10037 #resolve #comment Fixed with r68829
svn path=/trunk/; revision=68829
2015-08-26 18:20:04 +00:00
|
|
|
GetBestFileNameFromRecord(PDEVICE_EXTENSION Vcb,
|
|
|
|
PFILE_RECORD_HEADER FileRecord);
|
|
|
|
|
2019-08-08 20:09:13 +00:00
|
|
|
NTSTATUS
|
|
|
|
FindFirstAttributeListItem(PFIND_ATTR_CONTXT Context,
|
|
|
|
PNTFS_ATTRIBUTE_LIST_ITEM *Item);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
FindNextAttributeListItem(PFIND_ATTR_CONTXT Context,
|
|
|
|
PNTFS_ATTRIBUTE_LIST_ITEM *Item);
|
|
|
|
|
[NTFS]
Totally rewrite the way MFT records attributes are handled.
Up to now, we were having really similar loops, only looking at the resident part of the attribute list, not really caring about how the loop was going.
This was leading to some issues:
- In case the attribute we were looking for was stored in the non-resident part of the attribute list, we would miss it (excepted in the case of FindAttribute() which was properly browsing the whole attribute list).
- In the specific case of FindAttribute(), one would have been able to setup a broken MFT record with the resident attribute list pointing on the non resident attribute list which itself would point to the resident attribute list. In such case, the driver would loop forever caught on the loop, allocating tones of memory. It was possible to trigger this by user space, from a non-privileged user, just by browsing the right directory entry.
- In the case of the other loops (non FindAttribute()), another issue (other than missing attributes) was present, one would have been able to setup a broken MFT record with an attribute of null-length. This would have caused the driver to loop forever on the attribute list. This could be triggered from usermode too. And could be triggered by a non-privileged user.
This commit introduces a new set of functions for attributes browsing: FindFirstAttribute(), FindNextAttribute(), FindCloseAttribute(). It allows safely browsing attributes and handles broken cases. It also performs reading of the attribute list when present and makes sure there's only one read. This method should be the only one to use to browse the attributes.
The whole NTFS code base has been converted to use this newly set of functions. This really simplifies the implementation of FindAttribute(), and prevent unsafe code duplication.
CORE-10037 #resolve #comment Fixed with r68829
svn path=/trunk/; revision=68829
2015-08-26 18:20:04 +00:00
|
|
|
NTSTATUS
|
|
|
|
FindFirstAttribute(PFIND_ATTR_CONTXT Context,
|
|
|
|
PDEVICE_EXTENSION Vcb,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
BOOLEAN OnlyResident,
|
|
|
|
PNTFS_ATTR_RECORD * Attribute);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
FindNextAttribute(PFIND_ATTR_CONTXT Context,
|
|
|
|
PNTFS_ATTR_RECORD * Attribute);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
FindCloseAttribute(PFIND_ATTR_CONTXT Context);
|
2014-11-23 14:07:08 +00:00
|
|
|
|
2016-07-19 15:31:22 +00:00
|
|
|
NTSTATUS
|
|
|
|
FreeClusters(PNTFS_VCB Vcb,
|
|
|
|
PNTFS_ATTR_CONTEXT AttrContext,
|
|
|
|
ULONG AttrOffset,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
ULONG ClustersToFree);
|
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
/* blockdev.c */
|
|
|
|
|
2014-09-26 06:41:51 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsReadDisk(IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN LONGLONG StartingOffset,
|
|
|
|
IN ULONG Length,
|
2014-11-04 07:56:20 +00:00
|
|
|
IN ULONG SectorSize,
|
2014-09-26 06:41:51 +00:00
|
|
|
IN OUT PUCHAR Buffer,
|
|
|
|
IN BOOLEAN Override);
|
|
|
|
|
2016-05-01 16:21:53 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsWriteDisk(IN PDEVICE_OBJECT DeviceObject,
|
|
|
|
IN LONGLONG StartingOffset,
|
|
|
|
IN ULONG Length,
|
|
|
|
IN ULONG SectorSize,
|
2016-06-22 21:20:50 +00:00
|
|
|
IN const PUCHAR Buffer);
|
2016-05-01 16:21:53 +00:00
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject,
|
2013-06-16 12:15:06 +00:00
|
|
|
IN ULONG DiskSector,
|
|
|
|
IN ULONG SectorCount,
|
|
|
|
IN ULONG SectorSize,
|
|
|
|
IN OUT PUCHAR Buffer,
|
|
|
|
IN BOOLEAN Override);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject,
|
2013-06-16 12:15:06 +00:00
|
|
|
IN ULONG ControlCode,
|
|
|
|
IN PVOID InputBuffer,
|
|
|
|
IN ULONG InputBufferSize,
|
|
|
|
IN OUT PVOID OutputBuffer,
|
|
|
|
IN OUT PULONG OutputBufferSize,
|
|
|
|
IN BOOLEAN Override);
|
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2017-06-28 03:45:52 +00:00
|
|
|
/* btree.c */
|
|
|
|
|
|
|
|
LONG
|
|
|
|
CompareTreeKeys(PB_TREE_KEY Key1,
|
|
|
|
PB_TREE_KEY Key2,
|
|
|
|
BOOLEAN CaseSensitive);
|
|
|
|
|
|
|
|
NTSTATUS
|
2017-07-27 19:52:33 +00:00
|
|
|
CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb,
|
|
|
|
PFILE_RECORD_HEADER FileRecordWithIndex,
|
|
|
|
/*PCWSTR IndexName,*/
|
2017-06-28 03:45:52 +00:00
|
|
|
PNTFS_ATTR_CONTEXT IndexRootContext,
|
|
|
|
PINDEX_ROOT_ATTRIBUTE IndexRoot,
|
|
|
|
PB_TREE *NewTree);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
CreateIndexRootFromBTree(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PB_TREE Tree,
|
|
|
|
ULONG MaxIndexSize,
|
|
|
|
PINDEX_ROOT_ATTRIBUTE *IndexRoot,
|
|
|
|
ULONG *Length);
|
|
|
|
|
2017-08-29 15:51:14 +00:00
|
|
|
NTSTATUS
|
|
|
|
DemoteBTreeRoot(PB_TREE Tree);
|
|
|
|
|
2017-06-28 03:45:52 +00:00
|
|
|
VOID
|
|
|
|
DestroyBTree(PB_TREE Tree);
|
|
|
|
|
2017-07-27 18:22:24 +00:00
|
|
|
VOID
|
|
|
|
DestroyBTreeNode(PB_TREE_FILENAME_NODE Node);
|
|
|
|
|
2017-06-28 03:45:52 +00:00
|
|
|
VOID
|
|
|
|
DumpBTree(PB_TREE Tree);
|
|
|
|
|
2017-07-27 18:22:24 +00:00
|
|
|
VOID
|
2017-08-27 14:37:17 +00:00
|
|
|
DumpBTreeKey(PB_TREE Tree,
|
|
|
|
PB_TREE_KEY Key,
|
|
|
|
ULONG Number,
|
|
|
|
ULONG Depth);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
DumpBTreeNode(PB_TREE Tree,
|
|
|
|
PB_TREE_FILENAME_NODE Node,
|
2017-07-27 18:22:24 +00:00
|
|
|
ULONG Number,
|
|
|
|
ULONG Depth);
|
|
|
|
|
2017-08-27 14:37:17 +00:00
|
|
|
NTSTATUS
|
|
|
|
CreateEmptyBTree(PB_TREE *NewTree);
|
|
|
|
|
2017-07-27 18:22:24 +00:00
|
|
|
ULONGLONG
|
|
|
|
GetAllocationOffsetFromVCN(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG IndexBufferSize,
|
|
|
|
ULONGLONG Vcn);
|
|
|
|
|
2017-09-09 23:10:52 +00:00
|
|
|
ULONGLONG
|
|
|
|
GetIndexEntryVCN(PINDEX_ENTRY_ATTRIBUTE IndexEntry);
|
|
|
|
|
2017-08-29 15:51:14 +00:00
|
|
|
ULONG
|
|
|
|
GetSizeOfIndexEntries(PB_TREE_FILENAME_NODE Node);
|
|
|
|
|
2017-06-28 03:45:52 +00:00
|
|
|
NTSTATUS
|
2017-08-15 19:57:55 +00:00
|
|
|
NtfsInsertKey(PB_TREE Tree,
|
|
|
|
ULONGLONG FileReference,
|
2017-06-28 03:45:52 +00:00
|
|
|
PFILENAME_ATTRIBUTE FileNameAttribute,
|
|
|
|
PB_TREE_FILENAME_NODE Node,
|
2017-08-15 19:57:55 +00:00
|
|
|
BOOLEAN CaseSensitive,
|
2017-08-29 15:51:14 +00:00
|
|
|
ULONG MaxIndexRootSize,
|
|
|
|
ULONG IndexRecordSize,
|
|
|
|
PB_TREE_KEY *MedianKey,
|
|
|
|
PB_TREE_FILENAME_NODE *NewRightHandSibling);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
SplitBTreeNode(PB_TREE Tree,
|
|
|
|
PB_TREE_FILENAME_NODE Node,
|
|
|
|
PB_TREE_KEY *MedianKey,
|
|
|
|
PB_TREE_FILENAME_NODE *NewRightHandSibling,
|
|
|
|
BOOLEAN CaseSensitive);
|
2017-06-28 03:45:52 +00:00
|
|
|
|
2017-07-27 19:52:33 +00:00
|
|
|
NTSTATUS
|
|
|
|
UpdateIndexAllocation(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PB_TREE Tree,
|
|
|
|
ULONG IndexBufferSize,
|
|
|
|
PFILE_RECORD_HEADER FileRecord);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
UpdateIndexNode(PDEVICE_EXTENSION DeviceExt,
|
2017-08-15 19:57:55 +00:00
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
2017-07-27 19:52:33 +00:00
|
|
|
PB_TREE_FILENAME_NODE Node,
|
|
|
|
ULONG IndexBufferSize,
|
|
|
|
PNTFS_ATTR_CONTEXT IndexAllocationContext,
|
2017-08-29 15:51:14 +00:00
|
|
|
ULONG IndexAllocationOffset);
|
2017-07-27 19:52:33 +00:00
|
|
|
|
2016-02-22 22:20:54 +00:00
|
|
|
/* close.c */
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NtfsCleanup(PNTFS_IRP_CONTEXT IrpContext);
|
|
|
|
|
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
/* close.c */
|
|
|
|
|
2014-10-12 11:50:08 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsCloseFile(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_OBJECT FileObject);
|
|
|
|
|
2015-05-24 21:29:34 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsClose(PNTFS_IRP_CONTEXT IrpContext);
|
2013-06-16 12:15:06 +00:00
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
/* create.c */
|
|
|
|
|
2015-05-25 11:58:23 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsCreate(PNTFS_IRP_CONTEXT IrpContext);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2017-08-27 14:37:17 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsCreateDirectory(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_OBJECT FileObject,
|
|
|
|
BOOLEAN CaseSensitive,
|
|
|
|
BOOLEAN CanWait);
|
|
|
|
|
|
|
|
PFILE_RECORD_HEADER
|
|
|
|
NtfsCreateEmptyFileRecord(PDEVICE_EXTENSION DeviceExt);
|
|
|
|
|
2017-04-16 00:17:07 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt,
|
2017-06-23 17:30:13 +00:00
|
|
|
PFILE_OBJECT FileObject,
|
2017-06-25 02:38:15 +00:00
|
|
|
BOOLEAN CaseSensitive,
|
2017-06-23 17:30:13 +00:00
|
|
|
BOOLEAN CanWait);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2014-12-07 14:16:13 +00:00
|
|
|
/* devctl.c */
|
|
|
|
|
2015-05-11 21:11:48 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsDeviceControl(PNTFS_IRP_CONTEXT IrpContext);
|
2014-12-07 14:16:13 +00:00
|
|
|
|
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
/* dirctl.c */
|
|
|
|
|
2015-07-05 19:04:05 +00:00
|
|
|
ULONGLONG
|
|
|
|
NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PCWSTR Stream,
|
|
|
|
ULONG StreamLength,
|
|
|
|
PULONGLONG AllocatedSize);
|
|
|
|
|
2015-05-10 10:17:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsDirectoryControl(PNTFS_IRP_CONTEXT IrpContext);
|
2013-06-16 12:15:06 +00:00
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2008-02-10 11:20:29 +00:00
|
|
|
/* dispatch.c */
|
2013-06-16 12:15:06 +00:00
|
|
|
|
2008-02-10 11:20:29 +00:00
|
|
|
DRIVER_DISPATCH NtfsFsdDispatch;
|
|
|
|
NTSTATUS NTAPI
|
|
|
|
NtfsFsdDispatch(PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIRP Irp);
|
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
|
2008-03-08 13:17:48 +00:00
|
|
|
/* fastio.c */
|
2013-06-16 12:15:06 +00:00
|
|
|
|
2008-03-08 13:17:48 +00:00
|
|
|
BOOLEAN NTAPI
|
|
|
|
NtfsAcqLazyWrite(PVOID Context,
|
|
|
|
BOOLEAN Wait);
|
|
|
|
|
|
|
|
VOID NTAPI
|
|
|
|
NtfsRelLazyWrite(PVOID Context);
|
|
|
|
|
|
|
|
BOOLEAN NTAPI
|
|
|
|
NtfsAcqReadAhead(PVOID Context,
|
|
|
|
BOOLEAN Wait);
|
|
|
|
|
|
|
|
VOID NTAPI
|
|
|
|
NtfsRelReadAhead(PVOID Context);
|
|
|
|
|
2015-05-01 18:38:10 +00:00
|
|
|
FAST_IO_CHECK_IF_POSSIBLE NtfsFastIoCheckIfPossible;
|
|
|
|
FAST_IO_READ NtfsFastIoRead;
|
|
|
|
FAST_IO_WRITE NtfsFastIoWrite;
|
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
/* fcb.c */
|
|
|
|
|
2008-03-15 08:51:47 +00:00
|
|
|
PNTFS_FCB
|
2013-06-16 12:15:06 +00:00
|
|
|
NtfsCreateFCB(PCWSTR FileName,
|
2015-06-28 13:14:07 +00:00
|
|
|
PCWSTR Stream,
|
2013-06-16 12:15:06 +00:00
|
|
|
PNTFS_VCB Vcb);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
VOID
|
2008-03-15 08:51:47 +00:00
|
|
|
NtfsDestroyFCB(PNTFS_FCB Fcb);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
BOOLEAN
|
2008-03-15 08:51:47 +00:00
|
|
|
NtfsFCBIsDirectory(PNTFS_FCB Fcb);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2014-12-07 13:30:13 +00:00
|
|
|
BOOLEAN
|
|
|
|
NtfsFCBIsReparsePoint(PNTFS_FCB Fcb);
|
|
|
|
|
2016-02-14 22:44:54 +00:00
|
|
|
BOOLEAN
|
|
|
|
NtfsFCBIsCompressed(PNTFS_FCB Fcb);
|
|
|
|
|
2021-08-04 06:03:39 +00:00
|
|
|
BOOLEAN
|
|
|
|
NtfsFCBIsEncrypted(PNTFS_FCB Fcb);
|
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
BOOLEAN
|
2008-03-15 08:51:47 +00:00
|
|
|
NtfsFCBIsRoot(PNTFS_FCB Fcb);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
VOID
|
2008-03-15 08:51:47 +00:00
|
|
|
NtfsGrabFCB(PNTFS_VCB Vcb,
|
2013-06-16 12:15:06 +00:00
|
|
|
PNTFS_FCB Fcb);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
VOID
|
2008-03-15 08:51:47 +00:00
|
|
|
NtfsReleaseFCB(PNTFS_VCB Vcb,
|
2013-06-16 12:15:06 +00:00
|
|
|
PNTFS_FCB Fcb);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
VOID
|
2008-03-15 08:51:47 +00:00
|
|
|
NtfsAddFCBToTable(PNTFS_VCB Vcb,
|
2013-06-16 12:15:06 +00:00
|
|
|
PNTFS_FCB Fcb);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2008-03-15 08:51:47 +00:00
|
|
|
PNTFS_FCB
|
|
|
|
NtfsGrabFCBFromTable(PNTFS_VCB Vcb,
|
2013-06-16 12:15:06 +00:00
|
|
|
PCWSTR FileName);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
2008-03-15 08:51:47 +00:00
|
|
|
NtfsFCBInitializeCache(PNTFS_VCB Vcb,
|
2013-06-16 12:15:06 +00:00
|
|
|
PNTFS_FCB Fcb);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2008-03-15 08:51:47 +00:00
|
|
|
PNTFS_FCB
|
|
|
|
NtfsMakeRootFCB(PNTFS_VCB Vcb);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2008-03-15 08:51:47 +00:00
|
|
|
PNTFS_FCB
|
|
|
|
NtfsOpenRootFCB(PNTFS_VCB Vcb);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
2008-03-15 08:51:47 +00:00
|
|
|
NtfsAttachFCBToFileObject(PNTFS_VCB Vcb,
|
2013-06-16 12:15:06 +00:00
|
|
|
PNTFS_FCB Fcb,
|
|
|
|
PFILE_OBJECT FileObject);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
2008-03-15 08:51:47 +00:00
|
|
|
NtfsGetFCBForFile(PNTFS_VCB Vcb,
|
2013-06-16 12:15:06 +00:00
|
|
|
PNTFS_FCB *pParentFCB,
|
|
|
|
PNTFS_FCB *pFCB,
|
2017-07-04 22:34:17 +00:00
|
|
|
PCWSTR pFileName,
|
2017-06-24 04:36:28 +00:00
|
|
|
BOOLEAN CaseSensitive);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2014-12-07 20:59:45 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsReadFCBAttribute(PNTFS_VCB Vcb,
|
|
|
|
PNTFS_FCB pFCB,
|
2021-06-11 12:29:21 +00:00
|
|
|
ULONG Type,
|
2014-12-07 20:59:45 +00:00
|
|
|
PCWSTR Name,
|
|
|
|
ULONG NameLength,
|
|
|
|
PVOID * Data);
|
|
|
|
|
2015-05-31 21:28:52 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
|
|
|
|
PNTFS_FCB DirectoryFCB,
|
|
|
|
PUNICODE_STRING Name,
|
2015-06-28 13:14:07 +00:00
|
|
|
PCWSTR Stream,
|
2015-05-31 21:28:52 +00:00
|
|
|
PFILE_RECORD_HEADER Record,
|
|
|
|
ULONGLONG MFTIndex,
|
|
|
|
PNTFS_FCB * fileFCB);
|
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
/* finfo.c */
|
|
|
|
|
2015-05-03 18:36:58 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsQueryInformation(PNTFS_IRP_CONTEXT IrpContext);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2017-05-27 03:20:31 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsSetEndOfFile(PNTFS_FCB Fcb,
|
|
|
|
PFILE_OBJECT FileObject,
|
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG IrpFlags,
|
2017-06-24 04:36:28 +00:00
|
|
|
BOOLEAN CaseSensitive,
|
2017-05-27 03:20:31 +00:00
|
|
|
PLARGE_INTEGER NewFileSize);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NtfsSetInformation(PNTFS_IRP_CONTEXT IrpContext);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
/* fsctl.c */
|
|
|
|
|
2015-05-25 12:55:51 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsFileSystemControl(PNTFS_IRP_CONTEXT IrpContext);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2002-07-15 15:37:33 +00:00
|
|
|
|
|
|
|
/* mft.c */
|
2017-07-18 19:59:36 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONGLONG DirectoryMftIndex,
|
|
|
|
ULONGLONG FileReferenceNumber,
|
|
|
|
PFILENAME_ATTRIBUTE FilenameAttribute,
|
|
|
|
BOOLEAN CaseSensitive);
|
|
|
|
|
2017-04-16 00:17:07 +00:00
|
|
|
NTSTATUS
|
|
|
|
AddNewMftEntry(PFILE_RECORD_HEADER FileRecord,
|
2017-06-09 03:14:30 +00:00
|
|
|
PDEVICE_EXTENSION DeviceExt,
|
2017-06-23 17:30:13 +00:00
|
|
|
PULONGLONG DestinationIndex,
|
|
|
|
BOOLEAN CanWait);
|
2017-04-16 00:17:07 +00:00
|
|
|
|
2017-09-09 23:10:52 +00:00
|
|
|
VOID
|
|
|
|
NtfsDumpData(ULONG_PTR Buffer, ULONG Length);
|
|
|
|
|
2015-06-27 15:06:25 +00:00
|
|
|
PNTFS_ATTR_CONTEXT
|
|
|
|
PrepareAttributeContext(PNTFS_ATTR_RECORD AttrRecord);
|
|
|
|
|
2014-10-28 10:26:47 +00:00
|
|
|
VOID
|
|
|
|
ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context);
|
|
|
|
|
2003-11-12 15:30:21 +00:00
|
|
|
ULONG
|
2014-09-26 13:57:29 +00:00
|
|
|
ReadAttribute(PDEVICE_EXTENSION Vcb,
|
|
|
|
PNTFS_ATTR_CONTEXT Context,
|
|
|
|
ULONGLONG Offset,
|
|
|
|
PCHAR Buffer,
|
|
|
|
ULONG Length);
|
|
|
|
|
2016-05-01 16:21:53 +00:00
|
|
|
NTSTATUS
|
|
|
|
WriteAttribute(PDEVICE_EXTENSION Vcb,
|
|
|
|
PNTFS_ATTR_CONTEXT Context,
|
|
|
|
ULONGLONG Offset,
|
|
|
|
const PUCHAR Buffer,
|
|
|
|
ULONG Length,
|
2017-08-15 19:32:20 +00:00
|
|
|
PULONG LengthWritten,
|
|
|
|
PFILE_RECORD_HEADER FileRecord);
|
2016-05-01 16:21:53 +00:00
|
|
|
|
2014-09-26 13:57:29 +00:00
|
|
|
ULONGLONG
|
|
|
|
AttributeDataLength(PNTFS_ATTR_RECORD AttrRecord);
|
2003-09-15 16:01:16 +00:00
|
|
|
|
2017-08-06 02:54:15 +00:00
|
|
|
NTSTATUS
|
2017-08-15 19:32:20 +00:00
|
|
|
InternalSetResidentAttributeLength(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PNTFS_ATTR_CONTEXT AttrContext,
|
2017-06-09 03:14:30 +00:00
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
ULONG AttrOffset,
|
|
|
|
ULONG DataSize);
|
|
|
|
|
2017-08-15 19:32:20 +00:00
|
|
|
PNTFS_ATTR_RECORD
|
|
|
|
MoveAttributes(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
PNTFS_ATTR_RECORD FirstAttributeToMove,
|
|
|
|
ULONG FirstAttributeOffset,
|
|
|
|
ULONG_PTR MoveTo);
|
|
|
|
|
2016-06-22 21:20:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
SetAttributeDataLength(PFILE_OBJECT FileObject,
|
|
|
|
PNTFS_FCB Fcb,
|
|
|
|
PNTFS_ATTR_CONTEXT AttrContext,
|
|
|
|
ULONG AttrOffset,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PLARGE_INTEGER DataSize);
|
|
|
|
|
2017-04-16 00:17:07 +00:00
|
|
|
VOID
|
|
|
|
SetFileRecordEnd(PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PNTFS_ATTR_RECORD AttrEnd,
|
|
|
|
ULONG EndMarker);
|
|
|
|
|
2017-06-16 05:43:52 +00:00
|
|
|
NTSTATUS
|
|
|
|
SetNonResidentAttributeDataLength(PDEVICE_EXTENSION Vcb,
|
|
|
|
PNTFS_ATTR_CONTEXT AttrContext,
|
|
|
|
ULONG AttrOffset,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PLARGE_INTEGER DataSize);
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
SetResidentAttributeDataLength(PDEVICE_EXTENSION Vcb,
|
|
|
|
PNTFS_ATTR_CONTEXT AttrContext,
|
|
|
|
ULONG AttrOffset,
|
|
|
|
PFILE_RECORD_HEADER FileRecord,
|
|
|
|
PLARGE_INTEGER DataSize);
|
|
|
|
|
2016-06-29 16:35:36 +00:00
|
|
|
ULONGLONG
|
2014-09-26 13:57:29 +00:00
|
|
|
AttributeAllocatedLength(PNTFS_ATTR_RECORD AttrRecord);
|
2005-10-06 21:39:18 +00:00
|
|
|
|
2016-06-23 18:02:03 +00:00
|
|
|
BOOLEAN
|
|
|
|
CompareFileName(PUNICODE_STRING FileName,
|
|
|
|
PINDEX_ENTRY_ATTRIBUTE IndexEntry,
|
2017-06-24 04:36:28 +00:00
|
|
|
BOOLEAN DirSearch,
|
|
|
|
BOOLEAN CaseSensitive);
|
2016-06-23 18:02:03 +00:00
|
|
|
|
2017-08-28 03:11:38 +00:00
|
|
|
NTSTATUS
|
|
|
|
UpdateMftMirror(PNTFS_VCB Vcb);
|
|
|
|
|
2004-06-05 08:28:37 +00:00
|
|
|
NTSTATUS
|
2013-06-16 12:15:06 +00:00
|
|
|
ReadFileRecord(PDEVICE_EXTENSION Vcb,
|
2014-09-26 13:57:29 +00:00
|
|
|
ULONGLONG index,
|
|
|
|
PFILE_RECORD_HEADER file);
|
2003-09-15 16:01:16 +00:00
|
|
|
|
2016-06-23 18:02:03 +00:00
|
|
|
NTSTATUS
|
|
|
|
UpdateIndexEntryFileNameSize(PDEVICE_EXTENSION Vcb,
|
|
|
|
PFILE_RECORD_HEADER MftRecord,
|
|
|
|
PCHAR IndexRecord,
|
|
|
|
ULONG IndexBlockSize,
|
|
|
|
PINDEX_ENTRY_ATTRIBUTE FirstEntry,
|
|
|
|
PINDEX_ENTRY_ATTRIBUTE LastEntry,
|
|
|
|
PUNICODE_STRING FileName,
|
|
|
|
PULONG StartEntry,
|
|
|
|
PULONG CurrentEntry,
|
|
|
|
BOOLEAN DirSearch,
|
|
|
|
ULONGLONG NewDataSize,
|
2017-06-24 04:36:28 +00:00
|
|
|
ULONGLONG NewAllocatedSize,
|
|
|
|
BOOLEAN CaseSensitive);
|
2016-06-23 18:02:03 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
|
|
|
|
ULONGLONG ParentMFTIndex,
|
|
|
|
PUNICODE_STRING FileName,
|
|
|
|
BOOLEAN DirSearch,
|
|
|
|
ULONGLONG NewDataSize,
|
2017-06-24 04:36:28 +00:00
|
|
|
ULONGLONG NewAllocationSize,
|
|
|
|
BOOLEAN CaseSensitive);
|
2016-06-23 18:02:03 +00:00
|
|
|
|
2016-06-22 21:20:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
UpdateFileRecord(PDEVICE_EXTENSION Vcb,
|
2017-04-16 00:17:07 +00:00
|
|
|
ULONGLONG MftIndex,
|
|
|
|
PFILE_RECORD_HEADER FileRecord);
|
2016-06-22 21:20:50 +00:00
|
|
|
|
2014-09-26 13:57:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
FindAttribute(PDEVICE_EXTENSION Vcb,
|
|
|
|
PFILE_RECORD_HEADER MftRecord,
|
|
|
|
ULONG Type,
|
2014-10-16 20:05:36 +00:00
|
|
|
PCWSTR Name,
|
|
|
|
ULONG NameLength,
|
2016-06-22 21:20:50 +00:00
|
|
|
PNTFS_ATTR_CONTEXT * AttrCtx,
|
|
|
|
PULONG Offset);
|
2003-09-15 16:01:16 +00:00
|
|
|
|
2003-11-12 15:30:21 +00:00
|
|
|
VOID
|
2013-06-16 12:15:06 +00:00
|
|
|
ReadVCN(PDEVICE_EXTENSION Vcb,
|
|
|
|
PFILE_RECORD_HEADER file,
|
|
|
|
ATTRIBUTE_TYPE type,
|
|
|
|
ULONGLONG vcn,
|
|
|
|
ULONG count,
|
|
|
|
PVOID buffer);
|
2003-09-15 16:01:16 +00:00
|
|
|
|
2021-06-11 12:29:21 +00:00
|
|
|
NTSTATUS
|
2014-09-26 13:57:29 +00:00
|
|
|
FixupUpdateSequenceArray(PDEVICE_EXTENSION Vcb,
|
|
|
|
PNTFS_RECORD_HEADER Record);
|
2003-09-15 16:01:16 +00:00
|
|
|
|
2016-06-22 21:20:50 +00:00
|
|
|
NTSTATUS
|
|
|
|
AddFixupArray(PDEVICE_EXTENSION Vcb,
|
2016-06-23 15:37:19 +00:00
|
|
|
PNTFS_RECORD_HEADER Record);
|
2016-06-22 21:20:50 +00:00
|
|
|
|
2003-11-12 15:30:21 +00:00
|
|
|
NTSTATUS
|
2013-06-16 12:15:06 +00:00
|
|
|
ReadLCN(PDEVICE_EXTENSION Vcb,
|
|
|
|
ULONGLONG lcn,
|
|
|
|
ULONG count,
|
|
|
|
PVOID buffer);
|
2003-09-15 16:01:16 +00:00
|
|
|
|
2003-11-12 15:30:21 +00:00
|
|
|
VOID
|
|
|
|
EnumerAttribute(PFILE_RECORD_HEADER file,
|
2013-06-16 12:15:06 +00:00
|
|
|
PDEVICE_EXTENSION Vcb,
|
|
|
|
PDEVICE_OBJECT DeviceObject);
|
|
|
|
|
2014-09-26 13:57:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsLookupFile(PDEVICE_EXTENSION Vcb,
|
|
|
|
PUNICODE_STRING PathName,
|
2017-06-25 02:38:15 +00:00
|
|
|
BOOLEAN CaseSensitive,
|
2014-09-26 13:57:29 +00:00
|
|
|
PFILE_RECORD_HEADER *FileRecord,
|
2014-10-08 19:12:48 +00:00
|
|
|
PULONGLONG MFTIndex);
|
2003-09-15 16:01:16 +00:00
|
|
|
|
2014-09-26 18:12:24 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
|
|
|
|
PUNICODE_STRING PathName,
|
2017-06-25 02:38:15 +00:00
|
|
|
BOOLEAN CaseSensitive,
|
2014-09-26 18:12:24 +00:00
|
|
|
PFILE_RECORD_HEADER *FileRecord,
|
2014-10-08 19:12:48 +00:00
|
|
|
PULONGLONG MFTIndex,
|
2017-06-25 02:38:15 +00:00
|
|
|
ULONGLONG CurrentMFTIndex);
|
2014-09-26 18:12:24 +00:00
|
|
|
|
2016-08-22 11:08:22 +00:00
|
|
|
VOID
|
|
|
|
NtfsDumpFileRecord(PDEVICE_EXTENSION Vcb,
|
|
|
|
PFILE_RECORD_HEADER FileRecord);
|
|
|
|
|
2014-10-14 19:11:49 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsFindFileAt(PDEVICE_EXTENSION Vcb,
|
|
|
|
PUNICODE_STRING SearchPattern,
|
2014-10-14 20:34:38 +00:00
|
|
|
PULONG FirstEntry,
|
2014-10-14 19:11:49 +00:00
|
|
|
PFILE_RECORD_HEADER *FileRecord,
|
|
|
|
PULONGLONG MFTIndex,
|
2017-06-24 04:36:28 +00:00
|
|
|
ULONGLONG CurrentMFTIndex,
|
|
|
|
BOOLEAN CaseSensitive);
|
2014-10-14 19:11:49 +00:00
|
|
|
|
2017-04-16 00:17:07 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
|
|
|
|
ULONGLONG MFTIndex,
|
|
|
|
PUNICODE_STRING FileName,
|
|
|
|
PULONG FirstEntry,
|
|
|
|
BOOLEAN DirSearch,
|
2017-06-26 05:17:08 +00:00
|
|
|
BOOLEAN CaseSensitive,
|
|
|
|
ULONGLONG *OutMFTIndex);
|
2017-04-16 00:17:07 +00:00
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
/* misc.c */
|
2013-06-16 12:15:06 +00:00
|
|
|
|
2008-02-10 11:20:29 +00:00
|
|
|
BOOLEAN
|
|
|
|
NtfsIsIrpTopLevel(PIRP Irp);
|
|
|
|
|
|
|
|
PNTFS_IRP_CONTEXT
|
|
|
|
NtfsAllocateIrpContext(PDEVICE_OBJECT DeviceObject,
|
|
|
|
PIRP Irp);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2014-12-14 12:24:18 +00:00
|
|
|
PVOID
|
2015-05-25 17:43:04 +00:00
|
|
|
NtfsGetUserBuffer(PIRP Irp,
|
|
|
|
BOOLEAN Paging);
|
2014-12-14 12:24:18 +00:00
|
|
|
|
2016-05-01 16:21:53 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsLockUserBuffer(IN PIRP Irp,
|
|
|
|
IN ULONG Length,
|
|
|
|
IN LOCK_OPERATION Operation);
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
BOOLEAN
|
|
|
|
wstrcmpjoki(PWSTR s1, PWSTR s2);
|
|
|
|
|
|
|
|
VOID
|
|
|
|
CdfsSwapString(PWCHAR Out,
|
|
|
|
PUCHAR In,
|
|
|
|
ULONG Count);
|
|
|
|
#endif
|
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
VOID
|
2014-10-15 20:36:30 +00:00
|
|
|
NtfsFileFlagsToAttributes(ULONG NtfsAttributes,
|
|
|
|
PULONG FileAttributes);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
/* rw.c */
|
|
|
|
|
2015-05-10 20:35:40 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsRead(PNTFS_IRP_CONTEXT IrpContext);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2015-05-24 12:17:43 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsWrite(PNTFS_IRP_CONTEXT IrpContext);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* volinfo.c */
|
|
|
|
|
2016-06-29 16:35:36 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
|
|
|
|
ULONG FirstDesiredCluster,
|
|
|
|
ULONG DesiredClusters,
|
|
|
|
PULONG FirstAssignedCluster,
|
|
|
|
PULONG AssignedClusters);
|
|
|
|
|
2014-10-29 22:40:16 +00:00
|
|
|
ULONGLONG
|
|
|
|
NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt);
|
|
|
|
|
2008-02-10 11:20:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2008-02-10 11:20:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
NtfsSetVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
|
2002-06-25 22:23:06 +00:00
|
|
|
|
2013-06-16 12:15:06 +00:00
|
|
|
|
2005-10-06 21:39:18 +00:00
|
|
|
/* ntfs.c */
|
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2008-01-12 20:54:41 +00:00
|
|
|
DRIVER_INITIALIZE DriverEntry;
|
2005-10-06 21:39:18 +00:00
|
|
|
|
2021-05-11 15:13:14 +00:00
|
|
|
CODE_SEG("INIT")
|
2013-06-16 12:15:06 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject);
|
|
|
|
|
2002-06-25 22:23:06 +00:00
|
|
|
#endif /* NTFS_H */
|