https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bd0445dbf21ec930d235d…
commit bd0445dbf21ec930d235d30b4d8397b5348e37c7
Author: Jérôme Gardou <jerome.gardou(a)reactos.org>
AuthorDate: Mon Nov 16 09:24:58 2020 +0100
Commit: Jérôme Gardou <jerome.gardou(a)reactos.org>
CommitDate: Tue Dec 22 11:37:53 2020 +0100
[NTOS/FSRTL] Implement FsRtlAcquireToCreateMappedSection using filter callbacks
---
ntoskrnl/fsrtl/fastio.c | 54 ++++++++++++++++++++++++++++++++++++++-
ntoskrnl/include/internal/fsrtl.h | 8 ++++++
2 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/ntoskrnl/fsrtl/fastio.c b/ntoskrnl/fsrtl/fastio.c
index c9ff2f03752..a056b67e109 100644
--- a/ntoskrnl/fsrtl/fastio.c
+++ b/ntoskrnl/fsrtl/fastio.c
@@ -1561,15 +1561,55 @@ FsRtlAcquireFileExclusiveCommon(IN PFILE_OBJECT FileObject,
PFSRTL_COMMON_FCB_HEADER FcbHeader;
PDEVICE_OBJECT DeviceObject;
PFAST_IO_DISPATCH FastDispatch;
+ PEXTENDED_DRIVER_EXTENSION DriverExtension;
+ PFS_FILTER_CALLBACKS FilterCallbacks;
/* Get Device Object and Fast Calls */
FcbHeader = (PFSRTL_COMMON_FCB_HEADER)FileObject->FsContext;
DeviceObject = IoGetRelatedDeviceObject(FileObject);
- FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
/* Get master FsRtl lock */
FsRtlEnterFileSystem();
+ DriverExtension =
(PEXTENDED_DRIVER_EXTENSION)DeviceObject->DriverObject->DriverExtension;
+ FilterCallbacks = DriverExtension->FsFilterCallbacks;
+
+ /* Check if Filter Cllbacks are supported */
+ if (FilterCallbacks &&
FilterCallbacks->PreAcquireForSectionSynchronization)
+ {
+ NTSTATUS Status;
+ PVOID CompletionContext;
+
+ FS_FILTER_CALLBACK_DATA CbData;
+
+ RtlZeroMemory(&CbData, sizeof(CbData));
+
+ CbData.SizeOfFsFilterCallbackData = sizeof(CbData);
+ CbData.Operation = FS_FILTER_ACQUIRE_FOR_SECTION_SYNCHRONIZATION;
+ CbData.DeviceObject = DeviceObject;
+ CbData.FileObject = FileObject;
+ CbData.Parameters.AcquireForSectionSynchronization.PageProtection = Reserved;
+ CbData.Parameters.AcquireForSectionSynchronization.SyncType = SyncType;
+
+ Status = FilterCallbacks->PreAcquireForSectionSynchronization(&CbData,
&CompletionContext);
+ if (!NT_SUCCESS(Status))
+ {
+ FsRtlExitFileSystem();
+ return Status;
+ }
+
+ /* Should we do something in-between ? */
+
+ if (FilterCallbacks->PostAcquireForSectionSynchronization)
+ {
+ FilterCallbacks->PostAcquireForSectionSynchronization(&CbData, Status,
CompletionContext);
+ }
+
+ return Status;
+ }
+
+ FastDispatch = DeviceObject->DriverObject->FastIoDispatch;
+
/* Check if Fast Calls are supported, and check AcquireFileForNtCreateSection */
if (FastDispatch &&
FastDispatch->AcquireFileForNtCreateSection)
@@ -1599,6 +1639,18 @@ FsRtlAcquireFileExclusive(IN PFILE_OBJECT FileObject)
(VOID)FsRtlAcquireFileExclusiveCommon(FileObject, SyncTypeOther, 0);
}
+/*
+ * @implemented
+ */
+NTSTATUS
+NTAPI
+FsRtlAcquireToCreateMappedSection(_In_ PFILE_OBJECT FileObject,
+ _In_ ULONG SectionPageProtection)
+{
+ PAGED_CODE();
+
+ return FsRtlAcquireFileExclusiveCommon(FileObject, SyncTypeCreateSection,
SectionPageProtection);
+}
/*
* @implemented
*/
diff --git a/ntoskrnl/include/internal/fsrtl.h b/ntoskrnl/include/internal/fsrtl.h
index 6e65bd78886..79cc3b6cfbc 100644
--- a/ntoskrnl/include/internal/fsrtl.h
+++ b/ntoskrnl/include/internal/fsrtl.h
@@ -140,3 +140,11 @@ FsRtlInitSystem(
//
extern PERESOURCE FsRtlPagingIoResources;
extern PAGED_LOOKASIDE_LIST FsRtlFileLockLookasideList;
+
+//
+// File locking routine
+//
+NTSTATUS
+NTAPI
+FsRtlAcquireToCreateMappedSection(_In_ PFILE_OBJECT FileObject,
+ _In_ ULONG SectionPageProtection);