54 PWSTR pRelativeFileName,
55 PWSTR *pAbsoluteFilename)
60 DPRINT(
"try related for %S\n", pRelativeFileName);
61 Fcb = pFileObject->FsContext;
67 if (pRelativeFileName[0] ==
L'\\')
69 *pAbsoluteFilename =
NULL;
79 pRelativeFileName[0] ==
L'\\')
95 wcscat (rcName, pRelativeFileName);
96 *pAbsoluteFilename = rcName;
114 DPRINT(
"NtfsMoonWalkID(%p, %I64x, %p)\n", DeviceExt,
Id, OutPath);
117 MftRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
118 if (MftRecord ==
NULL)
139 DPRINT1(
"$FILE_NAME attribute not found for %I64x\n",
Id);
144 WritePosition -=
FileName->NameLength;
149 FullPath[WritePosition] =
L'\\';
156 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, MftRecord);
184 DPRINT(
"NtfsOpenFileById(%p, %p, %I64x, %p)\n", DeviceExt,
FileObject, MftId, FoundFCB);
192 MftRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
193 if (MftRecord ==
NULL)
201 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, MftRecord);
207 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, MftRecord);
220 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, MftRecord);
227 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, MftRecord);
253 DPRINT(
"NtfsOpenFile(%p, %p, %S, %s, %p)\n",
257 CaseSensitive ?
"TRUE" :
"FALSE",
264 DPRINT(
"Converting relative filename to absolute filename\n");
269 if (AbsFileName)
FileName = AbsFileName;
281 DPRINT(
"Checking for existing FCB in memory\n");
286 DPRINT(
"No existing FCB found, making a new one if file exists.\n");
300 DPRINT(
"Could not make a new FCB, status: %x\n",
Status);
309 DPRINT(
"Attaching FCB to fileObject\n");
334 ULONG RequestedDisposition;
335 ULONG RequestedOptions;
349 RequestedDisposition = ((
Stack->Parameters.Create.Options >> 24) & 0xff);
407 DeviceExt->VolumeFcb->RefCount++;
463 (
PVOID *)&
Irp->Tail.Overlay.AuxiliaryBuffer);
490 ULONG DataAttributeOffset;
496 DPRINT1(
"NTFS write-support is EXPERIMENTAL and is disabled by default!\n");
505 fileRecord = ExAllocateFromNPagedLookasideList(&
Fcb->
Vcb->FileRecLookasideList);
513 goto DoneOverwriting;
518 goto DoneOverwriting;
529 ExFreeToNPagedLookasideList(&
Fcb->
Vcb->FileRecLookasideList, fileRecord);
561 DPRINT1(
"NTFS write-support is EXPERIMENTAL and is disabled by default!\n");
586 DPRINT1(
"ERROR: Couldn't create file record!\n");
608 DeviceExt->OpenHandleCount++;
632 DPRINT(
"Opening file system\n");
695 ULONG MaxIndexRootSize;
698 DPRINT(
"NtfsCreateFileRecord(%p, %p, %s, %s)\n",
701 CaseSensitive ?
"TRUE" :
"FALSE",
702 CanWait ?
"TRUE" :
"FALSE");
708 DPRINT1(
"ERROR: Unable to allocate memory for file record!\n");
737 DPRINT1(
"ERROR: Failed to create empty B-Tree!\n");
738 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
743 MaxIndexRootSize = DeviceExt->NtfsInfo.BytesPerFileRecord
755 DPRINT1(
"ERROR: Unable to create empty index root!\n");
757 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
765 Status =
AddIndexRoot(DeviceExt, FileRecord, NextAttribute, NewIndexRoot, RootLength,
L"$I30", 4);
768 DPRINT1(
"ERROR: Failed to add index root to new file record!\n");
770 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
789 DPRINT1(
"New File Reference: 0x%016I64x\n", FileMftIndex);
800 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
823 DPRINT(
"NtfsCreateEmptyFileRecord(%p)\n", DeviceExt);
826 FileRecord = ExAllocateFromNPagedLookasideList(&DeviceExt->FileRecLookasideList);
829 DPRINT1(
"ERROR: Unable to allocate memory for file record!\n");
833 RtlZeroMemory(FileRecord, DeviceExt->NtfsInfo.BytesPerFileRecord);
841 FileRecord->
BytesAllocated = DeviceExt->NtfsInfo.BytesPerFileRecord;
898 DPRINT(
"NtfsCreateFileRecord(%p, %p, %s, %s)\n",
901 CaseSensitive ?
"TRUE" :
"FALSE",
902 CanWait ?
"TRUE" :
"FALSE");
908 DPRINT1(
"ERROR: Unable to allocate memory for file record!\n");
931 AddData(FileRecord, NextAttribute);
948 DPRINT1(
"New File Reference: 0x%016I64x\n", FileMftIndex);
958 ExFreeToNPagedLookasideList(&DeviceExt->FileRecLookasideList, FileRecord);
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define ALIGN_UP_BY(size, align)
#define FILE_DIRECTORY_FILE
#define FILE_NON_DIRECTORY_FILE
struct NTFS_ATTR_RECORD * PNTFS_ATTR_RECORD
VOID DestroyBTree(PB_TREE Tree)
NTSTATUS CreateEmptyBTree(PB_TREE *NewTree)
NTSTATUS CreateIndexRootFromBTree(PDEVICE_EXTENSION DeviceExt, PB_TREE Tree, ULONG MaxIndexSize, PINDEX_ROOT_ATTRIBUTE *IndexRoot, ULONG *Length)
#define STATUS_NOT_IMPLEMENTED
#define NT_SUCCESS(StatCode)
NTSTATUS AddIndexRoot(PNTFS_VCB Vcb, PFILE_RECORD_HEADER FileRecord, PNTFS_ATTR_RECORD AttributeAddress, PINDEX_ROOT_ATTRIBUTE NewIndexRoot, ULONG RootLength, PCWSTR Name, USHORT NameLength)
NTSTATUS AddFileName(PFILE_RECORD_HEADER FileRecord, PNTFS_ATTR_RECORD AttributeAddress, PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, BOOLEAN CaseSensitive, PULONGLONG ParentMftIndex)
NTSTATUS AddData(PFILE_RECORD_HEADER FileRecord, PNTFS_ATTR_RECORD AttributeAddress)
PFILENAME_ATTRIBUTE GetBestFileNameFromRecord(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER FileRecord)
NTSTATUS AddStandardInformation(PFILE_RECORD_HEADER FileRecord, PNTFS_ATTR_RECORD AttributeAddress)
NTSTATUS NtfsCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
static NTSTATUS NtfsCreateFile(PDEVICE_OBJECT DeviceObject, PNTFS_IRP_CONTEXT IrpContext)
static NTSTATUS NtfsOpenFileById(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, ULONGLONG MftId, PNTFS_FCB *FoundFCB)
static NTSTATUS NtfsOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, PWSTR FileName, BOOLEAN CaseSensitive, PNTFS_FCB *FoundFCB)
static NTSTATUS NtfsMoonWalkID(PDEVICE_EXTENSION DeviceExt, ULONGLONG Id, PUNICODE_STRING OutPath)
static NTSTATUS NtfsMakeAbsoluteFilename(PFILE_OBJECT pFileObject, PWSTR pRelativeFileName, PWSTR *pAbsoluteFilename)
NTSTATUS NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, BOOLEAN CaseSensitive, BOOLEAN CanWait)
NTSTATUS NtfsCreateDirectory(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, BOOLEAN CaseSensitive, BOOLEAN CanWait)
NTSTATUS NtfsCreate(PNTFS_IRP_CONTEXT IrpContext)
static PCWSTR MftIdToName[]
PFILE_RECORD_HEADER NtfsCreateEmptyFileRecord(PDEVICE_EXTENSION DeviceExt)
PNTFS_GLOBAL_DATA NtfsGlobalData
FORCEINLINE NTSTATUS NtfsMarkIrpContextForQueue(PNTFS_IRP_CONTEXT IrpContext)
struct FILENAME_ATTRIBUTE * PFILENAME_ATTRIBUTE
#define NTFS_FILE_FIRST_USER_FILE
#define IRPCONTEXT_CANWAIT
#define ATTR_RECORD_ALIGNMENT
#define ExAllocatePoolWithTag(hernya, size, tag)
#define ExAcquireResourceExclusiveLite(res, wait)
#define VCB_VOLUME_LOCKED
#define BooleanFlagOn(F, SF)
IN PVCB IN VBO IN ULONG OUT PBCB OUT PVOID IN BOOLEAN IN BOOLEAN Zero
struct _FileName FileName
#define FILE_OPEN_BY_FILE_ID
#define FILE_OVERWRITE_IF
#define FILE_OPEN_REPARSE_POINT
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSTATUS ReadFileRecord(PDEVICE_EXTENSION Vcb, ULONGLONG index, PFILE_RECORD_HEADER file)
VOID ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context)
NTSTATUS FindAttribute(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER MftRecord, ULONG Type, PCWSTR Name, ULONG NameLength, PNTFS_ATTR_CONTEXT *AttrCtx, PULONG Offset)
NTSTATUS NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt, ULONGLONG DirectoryMftIndex, ULONGLONG FileReferenceNumber, PFILENAME_ATTRIBUTE FilenameAttribute, BOOLEAN CaseSensitive)
NTSTATUS AddNewMftEntry(PFILE_RECORD_HEADER FileRecord, PDEVICE_EXTENSION DeviceExt, PULONGLONG DestinationIndex, BOOLEAN CanWait)
VOID NtfsDumpFileRecord(PDEVICE_EXTENSION Vcb, PFILE_RECORD_HEADER FileRecord)
NTSTATUS SetAttributeDataLength(PFILE_OBJECT FileObject, PNTFS_FCB Fcb, PNTFS_ATTR_CONTEXT AttrContext, ULONG AttrOffset, PFILE_RECORD_HEADER FileRecord, PLARGE_INTEGER DataSize)
#define ExFreePoolWithTag(_P, _T)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define FILE_VALID_OPTION_FLAGS
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
BOOLEAN NtfsFCBIsDirectory(PNTFS_FCB Fcb)
NTSTATUS NtfsReadFCBAttribute(PNTFS_VCB Vcb, PNTFS_FCB pFCB, ULONG Type, PCWSTR Name, ULONG NameLength, PVOID *Data)
PNTFS_FCB NtfsGrabFCBFromTable(PNTFS_VCB Vcb, PCWSTR FileName)
BOOLEAN NtfsFCBIsRoot(PNTFS_FCB Fcb)
BOOLEAN NtfsFCBIsReparsePoint(PNTFS_FCB Fcb)
NTSTATUS NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb, PNTFS_FCB DirectoryFCB, PUNICODE_STRING Name, PCWSTR Stream, PFILE_RECORD_HEADER Record, ULONGLONG MFTIndex, PNTFS_FCB *fileFCB)
NTSTATUS NtfsAttachFCBToFileObject(PNTFS_VCB Vcb, PNTFS_FCB Fcb, PFILE_OBJECT FileObject)
NTSTATUS NtfsGetFCBForFile(PNTFS_VCB Vcb, PNTFS_FCB *pParentFCB, PNTFS_FCB *pFCB, PCWSTR pFileName, BOOLEAN CaseSensitive)
VOID NtfsReleaseFCB(PNTFS_VCB Vcb, PNTFS_FCB Fcb)
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
struct _REPARSE_DATA_BUFFER * PREPARSE_DATA_BUFFER
struct NTFS_ATTR_RECORD::@169::@171 Resident
BOOLEAN EnableWriteSupport
PDEVICE_OBJECT DeviceObject
PDEVICE_OBJECT DeviceObject
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_FILE_IS_A_DIRECTORY
#define STATUS_NOT_A_DIRECTORY
#define STATUS_ACCESS_DENIED
#define STATUS_OBJECT_PATH_NOT_FOUND
#define STATUS_INVALID_PARAMETER
#define STATUS_OBJECT_NAME_COLLISION
#define STATUS_INSUFFICIENT_RESOURCES
#define STATUS_OBJECT_NAME_NOT_FOUND
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
#define IO_REPARSE_TAG_MOUNT_POINT
#define SL_CASE_SENSITIVE