https://git.reactos.org/?p=reactos.git;a=commitdiff;h=650cca217ad8ad0bab16a…
commit 650cca217ad8ad0bab16a61a96251463ebc9aaa1
Author: Ged Murphy <gedmurphy(a)gmail.com>
AuthorDate: Thu Oct 12 21:06:41 2017 +0100
[FLTMGR]
- Implement FltGetVolumeProperties
- Internal structs taken from public pdbs
---
drivers/filters/fltmgr/CMakeLists.txt | 1 +
drivers/filters/fltmgr/Volume.c | 110 ++++++++++++++++++++++++++++++++++
drivers/filters/fltmgr/fltmgr.spec | 1 +
drivers/filters/fltmgr/fltmgrint.h | 108 +++++++++++++++++++++++++++++++++
4 files changed, 220 insertions(+)
diff --git a/drivers/filters/fltmgr/CMakeLists.txt
b/drivers/filters/fltmgr/CMakeLists.txt
index f3d52e2200..5a02cab116 100644
--- a/drivers/filters/fltmgr/CMakeLists.txt
+++ b/drivers/filters/fltmgr/CMakeLists.txt
@@ -7,6 +7,7 @@ list(APPEND SOURCE
Messaging.c
Misc.c
Object.c
+ Volume.c
${CMAKE_CURRENT_BINARY_DIR}/fltmgr.def
fltmgr.h)
diff --git a/drivers/filters/fltmgr/Volume.c b/drivers/filters/fltmgr/Volume.c
new file mode 100644
index 0000000000..6a854f76a6
--- /dev/null
+++ b/drivers/filters/fltmgr/Volume.c
@@ -0,0 +1,110 @@
+/*
+* PROJECT: Filesystem Filter Manager
+* LICENSE: GPL - See COPYING in the top level directory
+* FILE: drivers/filters/fltmgr/Context.c
+* PURPOSE: Contains routines for the volume
+* PROGRAMMERS: Ged Murphy (gedmurphy(a)reactos.org)
+*/
+
+/* INCLUDES ******************************************************************/
+
+#include "fltmgr.h"
+#include "fltmgrint.h"
+
+#define NDEBUG
+#include <debug.h>
+
+
+/* DATA *********************************************************************/
+
+
+
+/* EXPORTED FUNCTIONS ******************************************************/
+
+NTSTATUS
+FLTAPI
+FltGetVolumeProperties(
+ _In_ PFLT_VOLUME Volume,
+ _Out_writes_bytes_to_opt_(VolumePropertiesLength, *LengthReturned)
PFLT_VOLUME_PROPERTIES VolumeProperties,
+ _In_ ULONG VolumePropertiesLength,
+ _Out_ PULONG LengthReturned
+)
+{
+ ULONG BufferRequired;
+ ULONG BytesWritten;
+ PCHAR Ptr;
+ NTSTATUS Status;
+
+ /* Calculate the required buffer size */
+ BufferRequired = sizeof(FLT_VOLUME_PROPERTIES) +
+ Volume->CDODriverName.Length +
+ Volume->DeviceName.Length +
+ Volume->CDODeviceName.Length;
+
+ /* If we don't have enough buffer to fill in the fixed struct, return with the
required size */
+ if (VolumePropertiesLength < sizeof(FLT_VOLUME_PROPERTIES))
+ {
+ *LengthReturned = BufferRequired;
+ return STATUS_BUFFER_TOO_SMALL;
+ }
+
+ /* Clear out the buffer */
+ RtlZeroMemory(VolumeProperties, sizeof(FLT_VOLUME_PROPERTIES));
+
+ /* Fill in the fixed data */
+ VolumeProperties->DeviceType = Volume->DeviceObject->DeviceType;
+ VolumeProperties->DeviceObjectFlags = Volume->DeviceObject->Flags;
+ VolumeProperties->AlignmentRequirement =
Volume->DeviceObject->AlignmentRequirement;
+ VolumeProperties->SectorSize = Volume->DeviceObject->SectorSize;
+ if (Volume->DiskDeviceObject)
+ {
+ VolumeProperties->DeviceCharacteristics =
Volume->DiskDeviceObject->Characteristics;
+ }
+ else
+ {
+ VolumeProperties->DeviceCharacteristics =
Volume->DeviceObject->Characteristics;
+ }
+
+ /* So far we've written the fixed struct data */
+ BytesWritten = sizeof(FLT_VOLUME_PROPERTIES);
+ Ptr = (PCHAR)(VolumeProperties + 1);
+
+ /* Make sure we have enough room to add the dynamic data */
+ if (VolumePropertiesLength >= BufferRequired)
+ {
+ /* Add the FS device name */
+ VolumeProperties->FileSystemDeviceName.Length = 0;
+ VolumeProperties->FileSystemDeviceName.MaximumLength =
Volume->CDODeviceName.Length;
+ VolumeProperties->FileSystemDeviceName.Buffer = (PWCH)Ptr;
+ RtlCopyUnicodeString(&VolumeProperties->FileSystemDeviceName,
&Volume->CDODeviceName);
+ Ptr += VolumeProperties->FileSystemDeviceName.Length;
+
+ /* Add the driver name */
+ VolumeProperties->FileSystemDriverName.Length = 0;
+ VolumeProperties->FileSystemDriverName.MaximumLength =
Volume->CDODriverName.Length;
+ VolumeProperties->FileSystemDriverName.Buffer = (PWCH)Ptr;
+ RtlCopyUnicodeString(&VolumeProperties->FileSystemDriverName,
&Volume->CDODriverName);
+ Ptr += VolumeProperties->FileSystemDriverName.Length;
+
+ /* Add the volume name */
+ VolumeProperties->RealDeviceName.Length = 0;
+ VolumeProperties->RealDeviceName.MaximumLength =
Volume->DeviceName.Length;
+ VolumeProperties->RealDeviceName.Buffer = (PWCH)Ptr;
+ RtlCopyUnicodeString(&VolumeProperties->RealDeviceName,
&Volume->DeviceName);
+
+ BytesWritten = BufferRequired;
+
+ Status = STATUS_SUCCESS;
+ }
+ else
+ {
+ Status = STATUS_BUFFER_OVERFLOW;
+ }
+
+ /* Set the number of bytes we wrote and return */
+ *LengthReturned = BytesWritten;
+ return Status;
+}
+
+
+/* INTERNAL FUNCTIONS ******************************************************/
\ No newline at end of file
diff --git a/drivers/filters/fltmgr/fltmgr.spec b/drivers/filters/fltmgr/fltmgr.spec
index 9e18cd5997..c7094eb9cf 100644
--- a/drivers/filters/fltmgr/fltmgr.spec
+++ b/drivers/filters/fltmgr/fltmgr.spec
@@ -7,4 +7,5 @@
@ stdcall FltBuildDefaultSecurityDescriptor(ptr long)
@ stdcall FltFreeSecurityDescriptor(ptr)
@ stdcall FltGetDiskDeviceObject(ptr ptr)
+ @ stdcall FltGetVolumeProperties(ptr ptr long ptr)
diff --git a/drivers/filters/fltmgr/fltmgrint.h b/drivers/filters/fltmgr/fltmgrint.h
index e5280879b0..a060b70eec 100644
--- a/drivers/filters/fltmgr/fltmgrint.h
+++ b/drivers/filters/fltmgr/fltmgrint.h
@@ -201,6 +201,114 @@ typedef struct _FLT_PORT_OBJECT
} FLT_PORT_OBJECT, *PFLT_PORT_OBJECT;
+typedef enum _FLT_VOLUME_FLAGS
+{
+ VOLFL_NETWORK_FILESYSTEM = 0x1,
+ VOLFL_PENDING_MOUNT_SETUP_NOTIFIES = 0x2,
+ VOLFL_MOUNT_SETUP_NOTIFIES_CALLED = 0x4,
+ VOLFL_MOUNTING = 0x8,
+ VOLFL_SENT_SHUTDOWN_IRP = 0x10,
+ VOLFL_ENABLE_NAME_CACHING = 0x20,
+ VOLFL_FILTER_EVER_ATTACHED = 0x40,
+ VOLFL_STANDARD_LINK_NOT_SUPPORTED = 0x80
+
+} FLT_VOLUME_FLAGS, *PFLT_VOLUME_FLAGS;
+
+
+typedef enum _CALLBACK_NODE_FLAGS
+{
+ CBNFL_SKIP_PAGING_IO = 0x1,
+ CBNFL_SKIP_CACHED_IO = 0x2,
+ CBNFL_USE_NAME_CALLBACK_EX = 0x4,
+ CBNFL_SKIP_NON_DASD_IO = 0x8
+
+} CALLBACK_NODE_FLAGS, *PCALLBACK_NODE_FLAGS;
+
+
+typedef struct _CALLBACK_CTRL
+{
+ LIST_ENTRY OperationLists[50];
+ CALLBACK_NODE_FLAGS OperationFlags[50];
+
+} CALLBACK_CTRL, *PCALLBACK_CTRL;
+
+typedef struct _TREE_ROOT
+{
+ RTL_SPLAY_LINKS *Tree;
+
+} TREE_ROOT, *PTREE_ROOT;
+
+
+typedef struct _CONTEXT_LIST_CTRL
+{
+ TREE_ROOT List;
+
+} CONTEXT_LIST_CTRL, *PCONTEXT_LIST_CTRL;
+
+typedef struct _NAME_CACHE_LIST_CTRL_STATS
+{
+ ULONG Searches;
+ ULONG Hits;
+ ULONG Created;
+ ULONG Temporary;
+ ULONG Duplicate;
+ ULONG Removed;
+ ULONG RemovedDueToCase;
+
+} NAME_CACHE_LIST_CTRL_STATS, *PNAME_CACHE_LIST_CTRL_STATS;
+
+
+typedef struct _NAME_CACHE_VOLUME_CTRL_STATS
+{
+ ULONG AllContextsTemporary;
+ ULONG PurgeNameCache;
+ NAME_CACHE_LIST_CTRL_STATS NormalizedNames;
+ NAME_CACHE_LIST_CTRL_STATS OpenedNames;
+ NAME_CACHE_LIST_CTRL_STATS ShortNames;
+ ULONG AncestorLookup;
+ ULONG ParentHit;
+ ULONG NonParentHit;
+
+} NAME_CACHE_VOLUME_CTRL_STATS, *PNAME_CACHE_VOLUME_CTRL_STATS;
+
+
+typedef struct _NAME_CACHE_VOLUME_CTRL
+{
+ FAST_MUTEX Lock;
+ ULONG AllContextsTemporary;
+ LARGE_INTEGER LastRenameCompleted;
+ NAME_CACHE_VOLUME_CTRL_STATS Stats;
+
+} NAME_CACHE_VOLUME_CTRL, *PNAME_CACHE_VOLUME_CTRL;
+
+
+typedef struct _FLT_VOLUME
+{
+ FLT_OBJECT Base;
+ FLT_VOLUME_FLAGS Flags;
+ FLT_FILESYSTEM_TYPE FileSystemType;
+ PDEVICE_OBJECT DeviceObject;
+ PDEVICE_OBJECT DiskDeviceObject;
+ PFLT_VOLUME FrameZeroVolume;
+ PFLT_VOLUME VolumeInNextFrame;
+ PFLTP_FRAME Frame;
+ UNICODE_STRING DeviceName;
+ UNICODE_STRING GuidName;
+ UNICODE_STRING CDODeviceName;
+ UNICODE_STRING CDODriverName;
+ FLT_RESOURCE_LIST_HEAD InstanceList;
+ CALLBACK_CTRL Callbacks;
+ EX_PUSH_LOCK ContextLock;
+ CONTEXT_LIST_CTRL VolumeContexts;
+ FLT_RESOURCE_LIST_HEAD StreamListCtrls;
+ FLT_RESOURCE_LIST_HEAD FileListCtrls;
+ NAME_CACHE_VOLUME_CTRL NameCacheCtrl;
+ ERESOURCE MountNotifyLock;
+ ULONG TargetedOpenActiveCount;
+ EX_PUSH_LOCK TxVolContextListLock;
+ TREE_ROOT TxVolContexts;
+
+} FLT_VOLUME, *PFLT_VOLUME;