ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
October 2018
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
21 participants
354 discussions
Start a n
N
ew thread
01/02: [NTOSKRNL] When checking for byte offset alignment, tolerate some magic values
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1bd25c5c24047c5d6e4c3…
commit 1bd25c5c24047c5d6e4c387386c38073d551d827 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Thu Oct 4 07:53:12 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Thu Oct 4 07:53:12 2018 +0200 [NTOSKRNL] When checking for byte offset alignment, tolerate some magic values --- ntoskrnl/io/iomgr/iofunc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c index c344b422d8..f3ad7164c2 100644 --- a/ntoskrnl/io/iomgr/iofunc.c +++ b/ntoskrnl/io/iomgr/iofunc.c @@ -3656,9 +3656,15 @@ NtWriteFile(IN HANDLE FileHandle, if ((DeviceObject->SectorSize != 0) && (ByteOffset->QuadPart % DeviceObject->SectorSize != 0)) { - /* Release the file object and and fail */ - ObDereferenceObject(FileObject); - return STATUS_INVALID_PARAMETER; + /* Only if that's not specific values for synchronous IO */ + if ((ByteOffset->QuadPart != FILE_WRITE_TO_END_OF_FILE) && + (ByteOffset->QuadPart != FILE_USE_FILE_POINTER_POSITION || + !BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO))) + { + /* Release the file object and and fail */ + ObDereferenceObject(FileObject); + return STATUS_INVALID_PARAMETER; + } } } }
6 years, 2 months
1
0
0
0
01/01: [NTOSKRNL] NtReadFile/NtWriteFile: If a file has been opened for non-cached access, Length and ByteOffset must be sector size aligned.
by Eric Kohl
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fd334021040e0377816e0…
commit fd334021040e0377816e0ca198c9940ed8135e3a Author: Eric Kohl <eric.kohl(a)reactos.org> AuthorDate: Thu Oct 4 01:16:17 2018 +0200 Commit: Eric Kohl <eric.kohl(a)reactos.org> CommitDate: Thu Oct 4 01:17:58 2018 +0200 [NTOSKRNL] NtReadFile/NtWriteFile: If a file has been opened for non-cached access, Length and ByteOffset must be sector size aligned. This fixed two ntdll apitests. --- ntoskrnl/io/iomgr/iofunc.c | 83 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 16 deletions(-) diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c index 58a6316751..c344b422d8 100644 --- a/ntoskrnl/io/iomgr/iofunc.c +++ b/ntoskrnl/io/iomgr/iofunc.c @@ -2579,6 +2579,18 @@ NtReadFile(IN HANDLE FileHandle, CapturedByteOffset.QuadPart = 0; IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle); + /* Get File Object */ + Status = ObReferenceObjectByHandle(FileHandle, + FILE_READ_DATA, + IoFileObjectType, + PreviousMode, + (PVOID*)&FileObject, + NULL); + if (!NT_SUCCESS(Status)) return Status; + + /* Get the device object */ + DeviceObject = IoGetRelatedDeviceObject(FileObject); + /* Validate User-Mode Buffers */ if (PreviousMode != KernelMode) { @@ -2597,12 +2609,38 @@ NtReadFile(IN HANDLE FileHandle, CapturedByteOffset = ProbeForReadLargeInteger(ByteOffset); } + /* Perform additional checks for non-cached file access */ + if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING) + { + /* Fail if Length is not sector size aligned */ + if ((DeviceObject->SectorSize != 0) && + (Length % DeviceObject->SectorSize != 0)) + { + /* Release the file object and and fail */ + ObDereferenceObject(FileObject); + return STATUS_INVALID_PARAMETER; + } + + if (ByteOffset) + { + /* Fail if ByteOffset is not sector size aligned */ + if ((DeviceObject->SectorSize != 0) && + (ByteOffset->QuadPart % DeviceObject->SectorSize != 0)) + { + /* Release the file object and and fail */ + ObDereferenceObject(FileObject); + return STATUS_INVALID_PARAMETER; + } + } + } + /* Capture and probe the key */ if (Key) CapturedKey = ProbeForReadUlong(Key); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { - /* Return the exception code */ + /* Release the file object and return the exception code */ + ObDereferenceObject(FileObject); _SEH2_YIELD(return _SEH2_GetExceptionCode()); } _SEH2_END; @@ -2614,15 +2652,6 @@ NtReadFile(IN HANDLE FileHandle, if (Key) CapturedKey = *Key; } - /* Get File Object */ - Status = ObReferenceObjectByHandle(FileHandle, - FILE_READ_DATA, - IoFileObjectType, - PreviousMode, - (PVOID*)&FileObject, - NULL); - if (!NT_SUCCESS(Status)) return Status; - /* Check for event */ if (Event) { @@ -2644,9 +2673,6 @@ NtReadFile(IN HANDLE FileHandle, KeClearEvent(EventObject); } - /* Get the device object */ - DeviceObject = IoGetRelatedDeviceObject(FileObject); - /* Check if we should use Sync IO or not */ if (FileObject->Flags & FO_SYNCHRONOUS_IO) { @@ -3591,6 +3617,9 @@ NtWriteFile(IN HANDLE FileHandle, &ObjectHandleInfo); if (!NT_SUCCESS(Status)) return Status; + /* Get the device object */ + DeviceObject = IoGetRelatedDeviceObject(FileObject); + /* Validate User-Mode Buffers */ if (PreviousMode != KernelMode) { @@ -3609,6 +3638,31 @@ NtWriteFile(IN HANDLE FileHandle, CapturedByteOffset = ProbeForReadLargeInteger(ByteOffset); } + /* Perform additional checks for non-cached file access */ + if (FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING) + { + /* Fail if Length is not sector size aligned */ + if ((DeviceObject->SectorSize != 0) && + (Length % DeviceObject->SectorSize != 0)) + { + /* Release the file object and and fail */ + ObDereferenceObject(FileObject); + return STATUS_INVALID_PARAMETER; + } + + if (ByteOffset) + { + /* Fail if ByteOffset is not sector size aligned */ + if ((DeviceObject->SectorSize != 0) && + (ByteOffset->QuadPart % DeviceObject->SectorSize != 0)) + { + /* Release the file object and and fail */ + ObDereferenceObject(FileObject); + return STATUS_INVALID_PARAMETER; + } + } + } + /* Capture and probe the key */ if (Key) CapturedKey = ProbeForReadUlong(Key); } @@ -3657,9 +3711,6 @@ NtWriteFile(IN HANDLE FileHandle, KeClearEvent(EventObject); } - /* Get the device object */ - DeviceObject = IoGetRelatedDeviceObject(FileObject); - /* Check if we should use Sync IO or not */ if (FileObject->Flags & FO_SYNCHRONOUS_IO) {
6 years, 2 months
1
0
0
0
01/01: [NTOSKRNL] In IopQueryNameInternal(), enclose output copy in a SEH statement
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d8f22735ed0895f3f8838…
commit d8f22735ed0895f3f883825f8387bc3d4a6462fb Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Wed Oct 3 22:55:23 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Wed Oct 3 22:55:23 2018 +0200 [NTOSKRNL] In IopQueryNameInternal(), enclose output copy in a SEH statement --- ntoskrnl/io/iomgr/file.c | 229 ++++++++++++++++++++++++----------------------- 1 file changed, 117 insertions(+), 112 deletions(-) diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c index f8afc889fd..68a801fd4f 100644 --- a/ntoskrnl/io/iomgr/file.c +++ b/ntoskrnl/io/iomgr/file.c @@ -1975,142 +1975,147 @@ IopQueryNameInternal(IN PVOID ObjectBody, /* Get buffer pointer */ p = (PWCHAR)(ObjectNameInfo + 1); - /* Copy the information */ - if (QueryDosName && NoObCall) + _SEH2_TRY { - ASSERT(PreviousMode == KernelMode); + /* Copy the information */ + if (QueryDosName && NoObCall) + { + ASSERT(PreviousMode == KernelMode); - /* Copy structure first */ - RtlCopyMemory(ObjectNameInfo, - LocalInfo, - (Length >= LocalReturnLength ? sizeof(OBJECT_NAME_INFORMATION) : Length)); - /* Name then */ - RtlCopyMemory(p, LocalInfo->Name.Buffer, - (Length >= LocalReturnLength ? LocalInfo->Name.Length : Length - sizeof(OBJECT_NAME_INFORMATION))); + /* Copy structure first */ + RtlCopyMemory(ObjectNameInfo, + LocalInfo, + (Length >= LocalReturnLength ? sizeof(OBJECT_NAME_INFORMATION) : Length)); + /* Name then */ + RtlCopyMemory(p, LocalInfo->Name.Buffer, + (Length >= LocalReturnLength ? LocalInfo->Name.Length : Length - sizeof(OBJECT_NAME_INFORMATION))); - if (FileObject->DeviceObject->DeviceType != FILE_DEVICE_NETWORK_FILE_SYSTEM) + if (FileObject->DeviceObject->DeviceType != FILE_DEVICE_NETWORK_FILE_SYSTEM) + { + ExFreePool(LocalInfo->Name.Buffer); + } + } + else { - ExFreePool(LocalInfo->Name.Buffer); + RtlCopyMemory(ObjectNameInfo, + LocalInfo, + (LocalReturnLength > Length) ? + Length : LocalReturnLength); } - } - else - { - RtlCopyMemory(ObjectNameInfo, - LocalInfo, - (LocalReturnLength > Length) ? - Length : LocalReturnLength); - } - /* Set buffer pointer */ - ObjectNameInfo->Name.Buffer = p; + /* Set buffer pointer */ + ObjectNameInfo->Name.Buffer = p; - /* Advance in buffer */ - p += (LocalInfo->Name.Length / sizeof(WCHAR)); + /* Advance in buffer */ + p += (LocalInfo->Name.Length / sizeof(WCHAR)); - /* Check if this already filled our buffer */ - if (LocalReturnLength > Length) - { - /* Set the length mismatch to true, so that we can return - * the proper buffer size to the caller later - */ - LengthMismatch = TRUE; + /* Check if this already filled our buffer */ + if (LocalReturnLength > Length) + { + /* Set the length mismatch to true, so that we can return + * the proper buffer size to the caller later + */ + LengthMismatch = TRUE; - /* Save the initial buffer length value */ - *ReturnLength = LocalReturnLength; - } + /* Save the initial buffer length value */ + *ReturnLength = LocalReturnLength; + } - /* Now get the file name buffer and check the length needed */ - LocalFileInfo = (PFILE_NAME_INFORMATION)LocalInfo; - FileLength = Length - - LocalReturnLength + - FIELD_OFFSET(FILE_NAME_INFORMATION, FileName); + /* Now get the file name buffer and check the length needed */ + LocalFileInfo = (PFILE_NAME_INFORMATION)LocalInfo; + FileLength = Length - + LocalReturnLength + + FIELD_OFFSET(FILE_NAME_INFORMATION, FileName); - /* Query the File name */ - if (PreviousMode == KernelMode && - BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO)) - { - Status = IopGetFileInformation(FileObject, - LengthMismatch ? Length : FileLength, - FileNameInformation, - LocalFileInfo, - &LocalReturnLength); - } - else - { - Status = IoQueryFileInformation(FileObject, - FileNameInformation, - LengthMismatch ? Length : FileLength, - LocalFileInfo, - &LocalReturnLength); - } - if (NT_ERROR(Status)) - { - /* Allow status that would mean it's not implemented in the storage stack */ - if (Status != STATUS_INVALID_PARAMETER && Status != STATUS_INVALID_DEVICE_REQUEST && - Status != STATUS_NOT_IMPLEMENTED && Status != STATUS_INVALID_INFO_CLASS) + /* Query the File name */ + if (PreviousMode == KernelMode && + BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO)) { - ExFreePoolWithTag(LocalInfo, TAG_IO); - return Status; + Status = IopGetFileInformation(FileObject, + LengthMismatch ? Length : FileLength, + FileNameInformation, + LocalFileInfo, + &LocalReturnLength); } - - /* In such case, zero output */ - LocalReturnLength = FIELD_OFFSET(FILE_NAME_INFORMATION, FileName); - LocalFileInfo->FileNameLength = 0; - LocalFileInfo->FileName[0] = OBJ_NAME_PATH_SEPARATOR; - } - else - { - /* We'll at least return the name length */ - if (LocalReturnLength < FIELD_OFFSET(FILE_NAME_INFORMATION, FileName)) + else + { + Status = IoQueryFileInformation(FileObject, + FileNameInformation, + LengthMismatch ? Length : FileLength, + LocalFileInfo, + &LocalReturnLength); + } + if (NT_ERROR(Status)) { + /* Allow status that would mean it's not implemented in the storage stack */ + if (Status != STATUS_INVALID_PARAMETER && Status != STATUS_INVALID_DEVICE_REQUEST && + Status != STATUS_NOT_IMPLEMENTED && Status != STATUS_INVALID_INFO_CLASS) + { + _SEH2_LEAVE; + } + + /* In such case, zero output */ LocalReturnLength = FIELD_OFFSET(FILE_NAME_INFORMATION, FileName); + LocalFileInfo->FileNameLength = 0; + LocalFileInfo->FileName[0] = OBJ_NAME_PATH_SEPARATOR; + } + else + { + /* We'll at least return the name length */ + if (LocalReturnLength < FIELD_OFFSET(FILE_NAME_INFORMATION, FileName)) + { + LocalReturnLength = FIELD_OFFSET(FILE_NAME_INFORMATION, FileName); + } } - } - /* If the provided buffer is too small, return the required size */ - if (LengthMismatch) - { - /* Add the required length */ - *ReturnLength += LocalFileInfo->FileNameLength; + /* If the provided buffer is too small, return the required size */ + if (LengthMismatch) + { + /* Add the required length */ + *ReturnLength += LocalFileInfo->FileNameLength; - /* Free the allocated buffer and return failure */ - ExFreePoolWithTag(LocalInfo, TAG_IO); - return STATUS_BUFFER_OVERFLOW; - } + /* Free the allocated buffer and return failure */ + Status = STATUS_BUFFER_OVERFLOW; + _SEH2_LEAVE; + } - /* Now calculate the new lengths left */ - FileLength = LocalReturnLength - - FIELD_OFFSET(FILE_NAME_INFORMATION, FileName); - LocalReturnLength = (ULONG)((ULONG_PTR)p - - (ULONG_PTR)ObjectNameInfo + - LocalFileInfo->FileNameLength); + /* Now calculate the new lengths left */ + FileLength = LocalReturnLength - + FIELD_OFFSET(FILE_NAME_INFORMATION, FileName); + LocalReturnLength = (ULONG)((ULONG_PTR)p - + (ULONG_PTR)ObjectNameInfo + + LocalFileInfo->FileNameLength); - /* Don't copy the name if it's not valid */ - if (LocalFileInfo->FileName[0] != OBJ_NAME_PATH_SEPARATOR) - { - /* Free the allocated buffer and return failure */ - ExFreePoolWithTag(LocalInfo, TAG_IO); - return STATUS_OBJECT_PATH_INVALID; - } + /* Don't copy the name if it's not valid */ + if (LocalFileInfo->FileName[0] != OBJ_NAME_PATH_SEPARATOR) + { + /* Free the allocated buffer and return failure */ + Status = STATUS_OBJECT_PATH_INVALID; + _SEH2_LEAVE; + } - /* Write the Name and null-terminate it */ - RtlCopyMemory(p, LocalFileInfo->FileName, FileLength); - p += (FileLength / sizeof(WCHAR)); - *p = UNICODE_NULL; - LocalReturnLength += sizeof(UNICODE_NULL); + /* Write the Name and null-terminate it */ + RtlCopyMemory(p, LocalFileInfo->FileName, FileLength); + p += (FileLength / sizeof(WCHAR)); + *p = UNICODE_NULL; + LocalReturnLength += sizeof(UNICODE_NULL); - /* Return the length needed */ - *ReturnLength = LocalReturnLength; + /* Return the length needed */ + *ReturnLength = LocalReturnLength; - /* Setup the length and maximum length */ - FileLength = (ULONG)((ULONG_PTR)p - (ULONG_PTR)ObjectNameInfo); - ObjectNameInfo->Name.Length = (USHORT)FileLength - - sizeof(OBJECT_NAME_INFORMATION); - ObjectNameInfo->Name.MaximumLength = (USHORT)ObjectNameInfo->Name.Length + - sizeof(UNICODE_NULL); + /* Setup the length and maximum length */ + FileLength = (ULONG)((ULONG_PTR)p - (ULONG_PTR)ObjectNameInfo); + ObjectNameInfo->Name.Length = (USHORT)FileLength - + sizeof(OBJECT_NAME_INFORMATION); + ObjectNameInfo->Name.MaximumLength = (USHORT)ObjectNameInfo->Name.Length + + sizeof(UNICODE_NULL); + } + _SEH2_FINALLY + { + /* Free buffer and return */ + ExFreePoolWithTag(LocalInfo, TAG_IO); + } _SEH2_END; - /* Free buffer and return */ - ExFreePoolWithTag(LocalInfo, TAG_IO); return Status; }
6 years, 2 months
1
0
0
0
01/01: [NTOSKRNL] Call IoCreateFileSpecifyDeviceObjectHint with the hint if it was specified
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=15b9a6aa4c131b99ada2b…
commit 15b9a6aa4c131b99ada2bccfe79e319e0daed750 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Wed Oct 3 21:28:11 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Wed Oct 3 21:29:12 2018 +0200 [NTOSKRNL] Call IoCreateFileSpecifyDeviceObjectHint with the hint if it was specified --- ntoskrnl/io/iomgr/iofunc.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c index 2ee72479cf..58a6316751 100644 --- a/ntoskrnl/io/iomgr/iofunc.c +++ b/ntoskrnl/io/iomgr/iofunc.c @@ -905,14 +905,16 @@ IopOpenLinkOrRenameTarget(OUT PHANDLE Handle, RenameInfo->RootDirectory, NULL); - /* And open its parent directory */ + /* And open its parent directory + * Use hint if specified + */ if (FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION) { + PFILE_OBJECT_EXTENSION FileObjectExtension; + ASSERT(!(FileObject->Flags & FO_DIRECT_DEVICE_OPEN)); -#if 0 - /* Commented out - we don't support FO extension yet - * FIXME: Corrected last arg when it's supported - */ + + FileObjectExtension = FileObject->FileObjectExtension; Status = IoCreateFileSpecifyDeviceObjectHint(&TargetHandle, DesiredAccess | SYNCHRONIZE, &ObjectAttributes, @@ -927,12 +929,7 @@ IopOpenLinkOrRenameTarget(OUT PHANDLE Handle, CreateFileTypeNone, NULL, IO_FORCE_ACCESS_CHECK | IO_OPEN_TARGET_DIRECTORY | IO_NO_PARAMETER_CHECKING, - FileObject->DeviceObject); -#else - ASSERT(FALSE); - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; -#endif + FileObjectExtension->TopDeviceObjectHint); } else {
6 years, 2 months
1
0
0
0
01/01: [LDR] Include dllname in snap failure DPRINT. CORE-15135
by Mark Jansen
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1a9b50690a241dfec86ed…
commit 1a9b50690a241dfec86ed32dd7ac7a7a7c9a1644 Author: Mark Jansen <mark.jansen(a)reactos.org> AuthorDate: Wed Oct 3 19:34:14 2018 +0200 Commit: Mark Jansen <mark.jansen(a)reactos.org> CommitDate: Wed Oct 3 19:34:14 2018 +0200 [LDR] Include dllname in snap failure DPRINT. CORE-15135 --- dll/ntdll/ldr/ldrpe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dll/ntdll/ldr/ldrpe.c b/dll/ntdll/ldr/ldrpe.c index 598e3e5477..d0bf128a63 100644 --- a/dll/ntdll/ldr/ldrpe.c +++ b/dll/ntdll/ldr/ldrpe.c @@ -1028,14 +1028,14 @@ FailurePath: /* Is this a static snap? */ if (Static) { + RtlInitAnsiString(&TempString, DllName ? DllName : "Unknown"); /* Inform the debug log */ if (IsOrdinal) - DPRINT1("Failed to snap ordinal 0x%x\n", OriginalOrdinal); + DPRINT1("Failed to snap ordinal %Z!0x%x\n", &TempString, OriginalOrdinal); else - DPRINT1("Failed to snap %s\n", ImportName); + DPRINT1("Failed to snap %Z!%s\n", &TempString, ImportName); /* These are critical errors. Setup a string for the DLL name */ - RtlInitAnsiString(&TempString, DllName ? DllName : "Unknown"); RtlAnsiStringToUnicodeString(&HardErrorDllName, &TempString, TRUE); /* Set it as the parameter */
6 years, 2 months
1
0
0
0
01/01: [NTOSKRNL] In IoQueryFileDosDeviceName(), in case of an error, return appropriate status
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=520f404e9c9d31fa2a36c…
commit 520f404e9c9d31fa2a36c1d1e0cebfe9fe581ed7 Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Wed Oct 3 17:08:42 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Wed Oct 3 17:08:42 2018 +0200 [NTOSKRNL] In IoQueryFileDosDeviceName(), in case of an error, return appropriate status --- ntoskrnl/io/iomgr/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c index df4e37638e..f8afc889fd 100644 --- a/ntoskrnl/io/iomgr/file.c +++ b/ntoskrnl/io/iomgr/file.c @@ -3619,7 +3619,7 @@ IoQueryFileDosDeviceName(IN PFILE_OBJECT FileObject, */ if (Status != STATUS_BUFFER_OVERFLOW) { - return STATUS_BUFFER_OVERFLOW; + return Status; } }
6 years, 2 months
1
0
0
0
07/07: [NTOSKRNL] Implement DOS name query in IopQueryNameInternal()
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8c6c5a92e86ecd69d0fd5…
commit 8c6c5a92e86ecd69d0fd5662645a1696706eb56a Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Wed Oct 3 13:56:18 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Wed Oct 3 13:56:18 2018 +0200 [NTOSKRNL] Implement DOS name query in IopQueryNameInternal() --- ntoskrnl/io/iomgr/file.c | 88 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 76 insertions(+), 12 deletions(-) diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c index 1112686225..df4e37638e 100644 --- a/ntoskrnl/io/iomgr/file.c +++ b/ntoskrnl/io/iomgr/file.c @@ -1902,6 +1902,9 @@ IopQueryNameInternal(IN PVOID ObjectBody, BOOLEAN LengthMismatch = FALSE; NTSTATUS Status; PWCHAR p; + PDEVICE_OBJECT DeviceObject; + BOOLEAN NoObCall; + IOTRACE(IO_FILE_DEBUG, "ObjectBody: %p\n", ObjectBody); /* Validate length */ @@ -1912,17 +1915,56 @@ IopQueryNameInternal(IN PVOID ObjectBody, return STATUS_INFO_LENGTH_MISMATCH; } - if (QueryDosName) return STATUS_NOT_IMPLEMENTED; - /* Allocate Buffer */ LocalInfo = ExAllocatePoolWithTag(PagedPool, Length, TAG_IO); if (!LocalInfo) return STATUS_INSUFFICIENT_RESOURCES; - /* Query the name */ - Status = ObQueryNameString(FileObject->DeviceObject, - LocalInfo, - Length, - &LocalReturnLength); + /* Query DOS name if the caller asked to */ + NoObCall = FALSE; + if (QueryDosName) + { + DeviceObject = FileObject->DeviceObject; + + /* In case of a network file system, don't call mountmgr */ + if (DeviceObject->DeviceType == FILE_DEVICE_NETWORK_FILE_SYSTEM) + { + /* We'll store separator and terminator */ + LocalReturnLength = sizeof(OBJECT_NAME_INFORMATION) + 2 * sizeof(WCHAR); + if (Length < LocalReturnLength) + { + Status = STATUS_BUFFER_OVERFLOW; + } + else + { + LocalInfo->Name.Length = sizeof(WCHAR); + LocalInfo->Name.MaximumLength = sizeof(WCHAR); + LocalInfo->Name.Buffer = (PVOID)((ULONG_PTR)LocalInfo + sizeof(OBJECT_NAME_INFORMATION)); + LocalInfo->Name.Buffer[0] = OBJ_NAME_PATH_SEPARATOR; + Status = STATUS_SUCCESS; + } + } + /* Otherwise, call mountmgr to get DOS name */ + else + { + Status = IoVolumeDeviceToDosName(DeviceObject, &LocalInfo->Name); + LocalReturnLength = LocalInfo->Name.Length + sizeof(OBJECT_NAME_INFORMATION) + sizeof(WCHAR); + } + } + + /* Fall back if querying DOS name failed or if caller never wanted it ;-) */ + if (!QueryDosName || !NT_SUCCESS(Status)) + { + /* Query the name */ + Status = ObQueryNameString(FileObject->DeviceObject, + LocalInfo, + Length, + &LocalReturnLength); + } + else + { + NoObCall = TRUE; + } + if (!NT_SUCCESS(Status) && (Status != STATUS_INFO_LENGTH_MISMATCH)) { /* Free the buffer and fail */ @@ -1930,14 +1972,36 @@ IopQueryNameInternal(IN PVOID ObjectBody, return Status; } + /* Get buffer pointer */ + p = (PWCHAR)(ObjectNameInfo + 1); + /* Copy the information */ - RtlCopyMemory(ObjectNameInfo, - LocalInfo, - (LocalReturnLength > Length) ? - Length : LocalReturnLength); + if (QueryDosName && NoObCall) + { + ASSERT(PreviousMode == KernelMode); + + /* Copy structure first */ + RtlCopyMemory(ObjectNameInfo, + LocalInfo, + (Length >= LocalReturnLength ? sizeof(OBJECT_NAME_INFORMATION) : Length)); + /* Name then */ + RtlCopyMemory(p, LocalInfo->Name.Buffer, + (Length >= LocalReturnLength ? LocalInfo->Name.Length : Length - sizeof(OBJECT_NAME_INFORMATION))); + + if (FileObject->DeviceObject->DeviceType != FILE_DEVICE_NETWORK_FILE_SYSTEM) + { + ExFreePool(LocalInfo->Name.Buffer); + } + } + else + { + RtlCopyMemory(ObjectNameInfo, + LocalInfo, + (LocalReturnLength > Length) ? + Length : LocalReturnLength); + } /* Set buffer pointer */ - p = (PWCHAR)(ObjectNameInfo + 1); ObjectNameInfo->Name.Buffer = p; /* Advance in buffer */
6 years, 2 months
1
0
0
0
06/07: [NTOSKRNL] Allow FileNameInformation not to be implemented in storage stack
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=769157f6ff016be3ea0e3…
commit 769157f6ff016be3ea0e3086a61d946262be8f7d Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Wed Oct 3 13:52:05 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Wed Oct 3 13:52:05 2018 +0200 [NTOSKRNL] Allow FileNameInformation not to be implemented in storage stack --- ntoskrnl/io/iomgr/file.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c index 0fbac2cc91..1112686225 100644 --- a/ntoskrnl/io/iomgr/file.c +++ b/ntoskrnl/io/iomgr/file.c @@ -1981,9 +1981,26 @@ IopQueryNameInternal(IN PVOID ObjectBody, } if (NT_ERROR(Status)) { - /* Fail on errors only, allow warnings */ - ExFreePoolWithTag(LocalInfo, TAG_IO); - return Status; + /* Allow status that would mean it's not implemented in the storage stack */ + if (Status != STATUS_INVALID_PARAMETER && Status != STATUS_INVALID_DEVICE_REQUEST && + Status != STATUS_NOT_IMPLEMENTED && Status != STATUS_INVALID_INFO_CLASS) + { + ExFreePoolWithTag(LocalInfo, TAG_IO); + return Status; + } + + /* In such case, zero output */ + LocalReturnLength = FIELD_OFFSET(FILE_NAME_INFORMATION, FileName); + LocalFileInfo->FileNameLength = 0; + LocalFileInfo->FileName[0] = OBJ_NAME_PATH_SEPARATOR; + } + else + { + /* We'll at least return the name length */ + if (LocalReturnLength < FIELD_OFFSET(FILE_NAME_INFORMATION, FileName)) + { + LocalReturnLength = FIELD_OFFSET(FILE_NAME_INFORMATION, FileName); + } } /* If the provided buffer is too small, return the required size */
6 years, 2 months
1
0
0
0
05/07: [NTOSKRNL] In IopQueryNameInternal() don't copy name if it's not valid
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=46bda8a4c67c411aa4359…
commit 46bda8a4c67c411aa4359411ad9f6c980d0c3eef Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Wed Oct 3 13:50:16 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Wed Oct 3 13:50:16 2018 +0200 [NTOSKRNL] In IopQueryNameInternal() don't copy name if it's not valid --- ntoskrnl/io/iomgr/file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c index 1fb691809c..0fbac2cc91 100644 --- a/ntoskrnl/io/iomgr/file.c +++ b/ntoskrnl/io/iomgr/file.c @@ -2004,6 +2004,14 @@ IopQueryNameInternal(IN PVOID ObjectBody, (ULONG_PTR)ObjectNameInfo + LocalFileInfo->FileNameLength); + /* Don't copy the name if it's not valid */ + if (LocalFileInfo->FileName[0] != OBJ_NAME_PATH_SEPARATOR) + { + /* Free the allocated buffer and return failure */ + ExFreePoolWithTag(LocalInfo, TAG_IO); + return STATUS_OBJECT_PATH_INVALID; + } + /* Write the Name and null-terminate it */ RtlCopyMemory(p, LocalFileInfo->FileName, FileLength); p += (FileLength / sizeof(WCHAR));
6 years, 2 months
1
0
0
0
04/07: [NTOSKRNL] Implement IoQueryFileDosDeviceName()
by Pierre Schweitzer
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4a7e89770eaefdd54b9f2…
commit 4a7e89770eaefdd54b9f2f3c20047c29cd52a19a Author: Pierre Schweitzer <pierre(a)reactos.org> AuthorDate: Wed Oct 3 11:56:21 2018 +0200 Commit: Pierre Schweitzer <pierre(a)reactos.org> CommitDate: Wed Oct 3 11:56:21 2018 +0200 [NTOSKRNL] Implement IoQueryFileDosDeviceName() --- ntoskrnl/io/iomgr/file.c | 54 +++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/ntoskrnl/io/iomgr/file.c b/ntoskrnl/io/iomgr/file.c index 792376ca82..1fb691809c 100644 --- a/ntoskrnl/io/iomgr/file.c +++ b/ntoskrnl/io/iomgr/file.c @@ -3480,15 +3480,63 @@ IoCancelFileOpen(IN PDEVICE_OBJECT DeviceObject, } /* - * @unimplemented + * @implemented */ NTSTATUS NTAPI IoQueryFileDosDeviceName(IN PFILE_OBJECT FileObject, OUT POBJECT_NAME_INFORMATION *ObjectNameInformation) { - UNIMPLEMENTED; - return STATUS_NOT_IMPLEMENTED; + NTSTATUS Status; + ULONG Length, ReturnLength; + POBJECT_NAME_INFORMATION LocalInfo; + + /* Start with a buffer length of 200 */ + ReturnLength = 200; + /* + * We'll loop until query works. + * We will use returned length for next loop + * iteration, trying to have a big enough buffer. + */ + for (Length = 200; ; Length = ReturnLength) + { + /* Allocate our work buffer */ + LocalInfo = ExAllocatePoolWithTag(PagedPool, Length, 'nDoI'); + if (LocalInfo == NULL) + { + return STATUS_INSUFFICIENT_RESOURCES; + } + + /* Query the DOS name */ + Status = IopQueryNameInternal(FileObject, + TRUE, + TRUE, + LocalInfo, + Length, + &ReturnLength, + KernelMode); + /* If it succeed, nothing more to do */ + if (Status == STATUS_SUCCESS) + { + break; + } + + /* Otherwise, prepare for re-allocation */ + ExFreePoolWithTag(LocalInfo, 'nDoI'); + + /* + * If we failed because of something else + * than memory, simply stop and fail here + */ + if (Status != STATUS_BUFFER_OVERFLOW) + { + return STATUS_BUFFER_OVERFLOW; + } + } + + /* Success case here: return our buffer */ + *ObjectNameInformation = LocalInfo; + return STATUS_SUCCESS; } /*
6 years, 2 months
1
0
0
0
← Newer
1
...
29
30
31
32
33
34
35
36
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Results per page:
10
25
50
100
200