https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c3d5a3f2bdff97f03b802…
commit c3d5a3f2bdff97f03b802fe95dce9d0c9375e53e
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Nov 12 22:32:16 2017 +0100
[NTOSKRNL] In NtWriteFile, quit using ObReferenceObjectByHandle in favor of
ObReferenceFileObjectForWrite().
This avoids RO FSDs being called for write operations.
CORE-14003
---
ntoskrnl/io/iomgr/iofunc.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c
index 93f1fe4e5f..9ab983ac21 100644
--- a/ntoskrnl/io/iomgr/iofunc.c
+++ b/ntoskrnl/io/iomgr/iofunc.c
@@ -3499,19 +3499,11 @@ NtWriteFile(IN HANDLE FileHandle,
CapturedByteOffset.QuadPart = 0;
IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
- /* Get File Object
- * FIXME: We should call ObReferenceFileObjectForWrite() instead to
- * check whether write access was actually granted. If not it will
- * fail and we will return.
- * That would allow avoiding ASSERT on FastIO later on if the FSD
- * is read-only
- */
- Status = ObReferenceObjectByHandle(FileHandle,
- 0,
- IoFileObjectType,
- PreviousMode,
- (PVOID*)&FileObject,
- &ObjectHandleInfo);
+ /* Get File Object for write */
+ Status = ObReferenceFileObjectForWrite(FileHandle,
+ PreviousMode,
+ &FileObject,
+ &ObjectHandleInfo);
if (!NT_SUCCESS(Status)) return Status;
/* Validate User-Mode Buffers */