https://git.reactos.org/?p=reactos.git;a=commitdiff;h=92dca372783529d8361f7…
commit 92dca372783529d8361f7a3c035d2dfd6a7e5bae
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Sun Oct 28 09:26:12 2018 +0100
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Mon Oct 29 23:56:39 2018 +0100
[FLTMGR] Implement FltEnumerateVolumes()
---
drivers/filters/fltmgr/Volume.c | 75 +++++++++++++++++++++++++++++++++++++-
drivers/filters/fltmgr/fltmgr.spec | 1 +
2 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/drivers/filters/fltmgr/Volume.c b/drivers/filters/fltmgr/Volume.c
index 6a854f76a6..d4c21bb999 100644
--- a/drivers/filters/fltmgr/Volume.c
+++ b/drivers/filters/fltmgr/Volume.c
@@ -107,4 +107,77 @@ FltGetVolumeProperties(
}
-/* INTERNAL FUNCTIONS ******************************************************/
\ No newline at end of file
+NTSTATUS
+FLTAPI
+FltEnumerateVolumes(
+ _In_ PFLT_FILTER Filter,
+ _Out_writes_to_opt_(VolumeListSize,*NumberVolumesReturned) PFLT_VOLUME *VolumeList,
+ _In_ ULONG VolumeListSize,
+ _Out_ PULONG NumberVolumesReturned)
+{
+ ULONG i;
+ PFLTP_FRAME Frame;
+ PFLT_VOLUME Volume;
+ PLIST_ENTRY ListEntry;
+ ULONG NumberOfVolumes = 0;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ PAGED_CODE();
+
+ Frame = Filter->Frame;
+
+ /* Lock the attached volumes list */
+ KeEnterCriticalRegion();
+ ExAcquireResourceSharedLite(&Frame->AttachedVolumes.rLock, TRUE);
+
+ /* If it's not empty */
+ if (!IsListEmpty(&Frame->AttachedVolumes.rList))
+ {
+ /* Browse every entry */
+ for (ListEntry = Frame->AttachedVolumes.rList.Flink;
+ ListEntry != &Frame->AttachedVolumes.rList;
+ ListEntry = ListEntry->Flink)
+ {
+ /* Get the volume */
+ Volume = CONTAINING_RECORD(ListEntry, FLT_VOLUME, Base.PrimaryLink);
+
+ /* If there's still room in the output buffer */
+ if (NumberOfVolumes < VolumeListSize)
+ {
+ /* Reference the volume and return it */
+ FltObjectReference(Volume);
+ VolumeList[NumberOfVolumes] = Volume;
+ }
+
+ /* We returned one more volume */
+ ++NumberOfVolumes;
+ }
+ }
+
+ /* Release the list */
+ ExReleaseResourceLite(&Frame->AttachedVolumes.rLock);
+ KeLeaveCriticalRegion();
+
+ /* If we want to return more volumes than we can */
+ if (NumberOfVolumes > VolumeListSize)
+ {
+ /* We will clear output */
+ for (i = 0; i < VolumeListSize; ++i)
+ {
+ FltObjectDereference(VolumeList[i]);
+ VolumeList[i] = NULL;
+ }
+
+ /* And set failure status */
+ Status = STATUS_BUFFER_TOO_SMALL;
+ }
+
+ /* Always return the max amount of volumes we want to return */
+ *NumberVolumesReturned = NumberOfVolumes;
+
+ /* Done */
+ return Status;
+}
+
+
+/* INTERNAL FUNCTIONS ******************************************************/
diff --git a/drivers/filters/fltmgr/fltmgr.spec b/drivers/filters/fltmgr/fltmgr.spec
index e3c88de91d..916d742ac6 100644
--- a/drivers/filters/fltmgr/fltmgr.spec
+++ b/drivers/filters/fltmgr/fltmgr.spec
@@ -10,4 +10,5 @@
@ stdcall FltGetVolumeProperties(ptr ptr long ptr)
@ stdcall FltObjectDereference(ptr)
@ stdcall FltSendMessage(ptr ptr ptr long ptr ptr ptr)
+ @ stdcall FltEnumerateVolumes(ptr ptr long ptr)