[NTFS] - Fix a mistake with AddFileName() from my last commit. Also, move CaseSensitive parameter before output parameters in the parameter list of several functions.

svn path=/branches/GSoC_2016/NTFS/; revision=75191
This commit is contained in:
Trevor Thompson 2017-06-25 02:38:15 +00:00 committed by Thomas Faber
parent 032be02954
commit 948e91907a
5 changed files with 34 additions and 17 deletions

View file

@ -112,13 +112,13 @@ AddData(PFILE_RECORD_HEADER FileRecord,
* Pointer to the FILE_OBJECT which represents the new name. * Pointer to the FILE_OBJECT which represents the new name.
* This parameter is used to determine the filename and parent directory. * This parameter is used to determine the filename and parent directory.
* *
* @param ParentMftIndex
* Pointer to a ULONGLONG which will receive the index of the parent directory.
*
* @param CaseSensitive * @param CaseSensitive
* Boolean indicating if the function should operate in case-sensitive mode. This will be TRUE * Boolean indicating if the function should operate in case-sensitive mode. This will be TRUE
* if an application opened the file with the FILE_FLAG_POSIX_SEMANTICS flag. * if an application opened the file with the FILE_FLAG_POSIX_SEMANTICS flag.
* *
* @param ParentMftIndex
* Pointer to a ULONGLONG which will receive the index of the parent directory.
*
* @return * @return
* STATUS_SUCCESS on success. STATUS_NOT_IMPLEMENTED if target address isn't at the end * STATUS_SUCCESS on success. STATUS_NOT_IMPLEMENTED if target address isn't at the end
* of the given file record. * of the given file record.
@ -136,8 +136,8 @@ AddFileName(PFILE_RECORD_HEADER FileRecord,
PNTFS_ATTR_RECORD AttributeAddress, PNTFS_ATTR_RECORD AttributeAddress,
PDEVICE_EXTENSION DeviceExt, PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject, PFILE_OBJECT FileObject,
PULONGLONG ParentMftIndex, BOOLEAN CaseSensitive,
BOOLEAN CaseSensitive) PULONGLONG ParentMftIndex)
{ {
ULONG ResidentHeaderLength = FIELD_OFFSET(NTFS_ATTR_RECORD, Resident.Reserved) + sizeof(UCHAR); ULONG ResidentHeaderLength = FIELD_OFFSET(NTFS_ATTR_RECORD, Resident.Reserved) + sizeof(UCHAR);
PFILENAME_ATTRIBUTE FileNameAttribute; PFILENAME_ATTRIBUTE FileNameAttribute;

View file

@ -570,7 +570,10 @@ NtfsCreateFile(PDEVICE_OBJECT DeviceObject,
} }
// Create the file record on disk // Create the file record on disk
Status = NtfsCreateFileRecord(DeviceExt, FileObject, BooleanFlagOn(IrpContext->Flags, IRPCONTEXT_CANWAIT)); Status = NtfsCreateFileRecord(DeviceExt,
FileObject,
(Stack->Flags & SL_CASE_SENSITIVE),
BooleanFlagOn(IrpContext->Flags,IRPCONTEXT_CANWAIT));
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT1("ERROR: Couldn't create file record!\n"); DPRINT1("ERROR: Couldn't create file record!\n");
@ -656,6 +659,7 @@ NtfsCreate(PNTFS_IRP_CONTEXT IrpContext)
NTSTATUS NTSTATUS
NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt, NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject, PFILE_OBJECT FileObject,
BOOLEAN CaseSensitive,
BOOLEAN CanWait) BOOLEAN CanWait)
{ {
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status = STATUS_SUCCESS;
@ -665,7 +669,11 @@ NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt,
ULONGLONG ParentMftIndex; ULONGLONG ParentMftIndex;
ULONGLONG FileMftIndex; ULONGLONG FileMftIndex;
DPRINT1("NtfsCreateFileRecord(%p, %p, %s)\n", DeviceExt, FileObject, CanWait ? "TRUE" : "FALSE"); DPRINT1("NtfsCreateFileRecord(%p, %p, %s, %s)\n",
DeviceExt,
FileObject,
CaseSensitive ? "TRUE" : "FALSE",
CanWait ? "TRUE" : "FALSE");
// allocate memory for file record // allocate memory for file record
FileRecord = ExAllocatePoolWithTag(NonPagedPool, FileRecord = ExAllocatePoolWithTag(NonPagedPool,
@ -709,7 +717,7 @@ NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt,
NextAttribute = (PNTFS_ATTR_RECORD)((ULONG_PTR)NextAttribute + (ULONG_PTR)NextAttribute->Length); NextAttribute = (PNTFS_ATTR_RECORD)((ULONG_PTR)NextAttribute + (ULONG_PTR)NextAttribute->Length);
// Add the $FILE_NAME attribute // Add the $FILE_NAME attribute
AddFileName(FileRecord, NextAttribute, DeviceExt, FileObject, &ParentMftIndex); AddFileName(FileRecord, NextAttribute, DeviceExt, FileObject, CaseSensitive, &ParentMftIndex);
// save a pointer to the filename attribute // save a pointer to the filename attribute
FilenameAttribute = (PFILENAME_ATTRIBUTE)((ULONG_PTR)NextAttribute + NextAttribute->Resident.ValueOffset); FilenameAttribute = (PFILENAME_ATTRIBUTE)((ULONG_PTR)NextAttribute + NextAttribute->Resident.ValueOffset);

View file

@ -557,7 +557,7 @@ NtfsDirFindFile(PNTFS_VCB Vcb,
DPRINT1("Will now look for file '%wZ' with stream '%S'\n", &File, Colon); DPRINT1("Will now look for file '%wZ' with stream '%S'\n", &File, Colon);
} }
Status = NtfsLookupFileAt(Vcb, &File, &FileRecord, &MFTIndex, CurrentDir, CaseSensitive); Status = NtfsLookupFileAt(Vcb, &File, CaseSensitive, &FileRecord, &MFTIndex, CurrentDir);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
return Status; return Status;

View file

@ -2106,16 +2106,22 @@ NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
NTSTATUS NTSTATUS
NtfsLookupFileAt(PDEVICE_EXTENSION Vcb, NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
PUNICODE_STRING PathName, PUNICODE_STRING PathName,
BOOLEAN CaseSensitive,
PFILE_RECORD_HEADER *FileRecord, PFILE_RECORD_HEADER *FileRecord,
PULONGLONG MFTIndex, PULONGLONG MFTIndex,
ULONGLONG CurrentMFTIndex, ULONGLONG CurrentMFTIndex)
BOOLEAN CaseSensitive)
{ {
UNICODE_STRING Current, Remaining; UNICODE_STRING Current, Remaining;
NTSTATUS Status; NTSTATUS Status;
ULONG FirstEntry = 0; ULONG FirstEntry = 0;
DPRINT("NtfsLookupFileAt(%p, %wZ, %p, %I64x)\n", Vcb, PathName, FileRecord, CurrentMFTIndex); DPRINT("NtfsLookupFileAt(%p, %wZ, %s, %p, %p, %I64x)\n",
Vcb,
PathName,
CaseSensitive ? "TRUE" : "FALSE",
FileRecord,
MFTIndex,
CurrentMFTIndex);
FsRtlDissectName(*PathName, &Current, &Remaining); FsRtlDissectName(*PathName, &Current, &Remaining);
@ -2158,11 +2164,11 @@ NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
NTSTATUS NTSTATUS
NtfsLookupFile(PDEVICE_EXTENSION Vcb, NtfsLookupFile(PDEVICE_EXTENSION Vcb,
PUNICODE_STRING PathName, PUNICODE_STRING PathName,
BOOLEAN CaseSensitive,
PFILE_RECORD_HEADER *FileRecord, PFILE_RECORD_HEADER *FileRecord,
PULONGLONG MFTIndex, PULONGLONG MFTIndex)
BOOLEAN CaseSensitive)
{ {
return NtfsLookupFileAt(Vcb, PathName, FileRecord, MFTIndex, NTFS_FILE_ROOT, CaseSensitive); return NtfsLookupFileAt(Vcb, PathName, CaseSensitive, FileRecord, MFTIndex, NTFS_FILE_ROOT);
} }
/** /**

View file

@ -536,6 +536,7 @@ AddFileName(PFILE_RECORD_HEADER FileRecord,
PNTFS_ATTR_RECORD AttributeAddress, PNTFS_ATTR_RECORD AttributeAddress,
PDEVICE_EXTENSION DeviceExt, PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject, PFILE_OBJECT FileObject,
BOOLEAN CaseSensitive,
PULONGLONG ParentMftIndex); PULONGLONG ParentMftIndex);
NTSTATUS NTSTATUS
@ -668,6 +669,7 @@ NtfsCreate(PNTFS_IRP_CONTEXT IrpContext);
NTSTATUS NTSTATUS
NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt, NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt,
PFILE_OBJECT FileObject, PFILE_OBJECT FileObject,
BOOLEAN CaseSensitive,
BOOLEAN CanWait); BOOLEAN CanWait);
/* devctl.c */ /* devctl.c */
@ -970,16 +972,17 @@ EnumerAttribute(PFILE_RECORD_HEADER file,
NTSTATUS NTSTATUS
NtfsLookupFile(PDEVICE_EXTENSION Vcb, NtfsLookupFile(PDEVICE_EXTENSION Vcb,
PUNICODE_STRING PathName, PUNICODE_STRING PathName,
BOOLEAN CaseSensitive,
PFILE_RECORD_HEADER *FileRecord, PFILE_RECORD_HEADER *FileRecord,
PULONGLONG MFTIndex); PULONGLONG MFTIndex);
NTSTATUS NTSTATUS
NtfsLookupFileAt(PDEVICE_EXTENSION Vcb, NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
PUNICODE_STRING PathName, PUNICODE_STRING PathName,
BOOLEAN CaseSensitive,
PFILE_RECORD_HEADER *FileRecord, PFILE_RECORD_HEADER *FileRecord,
PULONGLONG MFTIndex, PULONGLONG MFTIndex,
ULONGLONG CurrentMFTIndex, ULONGLONG CurrentMFTIndex);
BOOLEAN CaseSensitive);
VOID VOID
NtfsDumpFileRecord(PDEVICE_EXTENSION Vcb, NtfsDumpFileRecord(PDEVICE_EXTENSION Vcb,