https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1d777ffab5458495c04f2…
commit 1d777ffab5458495c04f250cf7ced379f306a7af
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Nov 12 22:33:58 2017 +0100
[NTOSKNRL] In NtWriteFile, remove the check that is now redundant with ObReferenceFileObjectForWrite().
CORE-14003
---
ntoskrnl/io/iomgr/iofunc.c | 15 ---------------
1 file changed, 15 deletions(-)
diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c
index 9ab983ac21..46fcce201d 100644
--- a/ntoskrnl/io/iomgr/iofunc.c
+++ b/ntoskrnl/io/iomgr/iofunc.c
@@ -3511,21 +3511,6 @@ NtWriteFile(IN HANDLE FileHandle,
{
_SEH2_TRY
{
- /*
- * Check if the handle has either FILE_WRITE_DATA or
- * FILE_APPEND_DATA granted. However, if this is a named pipe,
- * make sure we don't ask for FILE_APPEND_DATA as it interferes
- * with the FILE_CREATE_PIPE_INSTANCE access right!
- */
- if (!(ObjectHandleInfo.GrantedAccess &
- ((!(FileObject->Flags & FO_NAMED_PIPE) ?
- FILE_APPEND_DATA : 0) | FILE_WRITE_DATA)))
- {
- /* We failed */
- ObDereferenceObject(FileObject);
- _SEH2_YIELD(return STATUS_ACCESS_DENIED);
- }
-
/* Probe the status block */
ProbeForWriteIoStatusBlock(IoStatusBlock);
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 */
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=5f255827d3282b2dea1bc…
commit 5f255827d3282b2dea1bc6d5ba77607550742ced
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Nov 12 21:16:31 2017 +0100
[CDFS_NEW] Following 1bef487, add a hack and stub FastIO write routine to avoid bugchecks on write attempts.
This allows booting the ReactOS LiveCD as HDD image in Qemu without issues :-)
---
drivers/filesystems/cdfs_new/cdinit.c | 36 +++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/drivers/filesystems/cdfs_new/cdinit.c b/drivers/filesystems/cdfs_new/cdinit.c
index b6bec14c45..1f086fe61d 100755
--- a/drivers/filesystems/cdfs_new/cdinit.c
+++ b/drivers/filesystems/cdfs_new/cdinit.c
@@ -58,6 +58,29 @@ CdShutdown (
#pragma alloc_text(INIT, CdInitializeGlobalData)
#endif
+#ifdef __REACTOS__
+
+//
+// Stub for CcWrite, this is a hack
+//
+BOOLEAN
+NTAPI
+CdFastIoWrite (
+ IN PFILE_OBJECT FileObject,
+ IN PLARGE_INTEGER FileOffset,
+ IN ULONG Length,
+ IN BOOLEAN Wait,
+ IN ULONG LockKey,
+ IN PVOID Buffer,
+ OUT PIO_STATUS_BLOCK IoStatus,
+ IN PDEVICE_OBJECT DeviceObject)
+{
+ ASSERT(FALSE);
+ return FALSE;
+}
+
+#endif
+
//
// Local support routine
@@ -342,6 +365,19 @@ Return Value:
CdFastIoDispatch.SizeOfFastIoDispatch = sizeof(FAST_IO_DISPATCH);
CdFastIoDispatch.FastIoCheckIfPossible = CdFastIoCheckIfPossible; // CheckForFastIo
CdFastIoDispatch.FastIoRead = FsRtlCopyRead; // Read
+#ifdef __REACTOS__
+
+ //
+ // Add a stub for CdFastIoWrite. This is a hack required because
+ // our current implementation of NtWriteFile won't validate
+ // access granted to files opened. And some applications may attempt
+ // to write to a file. In case it is cached, the kernel will null-dereference
+ // the fastIO routine, trying to call it.
+ // FIXME: remove once NtWriteFile got fixed!
+ //
+
+ CdFastIoDispatch.FastIoWrite = CdFastIoWrite; // Write
+#endif
CdFastIoDispatch.FastIoQueryBasicInfo = CdFastQueryBasicInfo; // QueryBasicInfo
CdFastIoDispatch.FastIoQueryStandardInfo = CdFastQueryStdInfo; // QueryStandardInfo
CdFastIoDispatch.FastIoLock = CdFastLock; // Lock
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1bef48796e4df655c71dd…
commit 1bef48796e4df655c71ddd92a00417dbe9e530ca
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Nov 12 21:11:22 2017 +0100
[NTOSKRNL] Add a FIXME in NtWriteFile() that explains how broken is our current implementation regarding read-only FSDs
---
ntoskrnl/io/iomgr/iofunc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/ntoskrnl/io/iomgr/iofunc.c b/ntoskrnl/io/iomgr/iofunc.c
index 5aa67ee3e1..93f1fe4e5f 100644
--- a/ntoskrnl/io/iomgr/iofunc.c
+++ b/ntoskrnl/io/iomgr/iofunc.c
@@ -3499,7 +3499,13 @@ NtWriteFile(IN HANDLE FileHandle,
CapturedByteOffset.QuadPart = 0;
IOTRACE(IO_API_DEBUG, "FileHandle: %p\n", FileHandle);
- /* Get File Object */
+ /* 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,