mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
[FLTMGR] Implement FltEnumerateVolumes()
This commit is contained in:
parent
5bdd806fb9
commit
92dca37278
2 changed files with 75 additions and 1 deletions
|
@ -107,4 +107,77 @@ FltGetVolumeProperties(
|
|||
}
|
||||
|
||||
|
||||
/* INTERNAL FUNCTIONS ******************************************************/
|
||||
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 ******************************************************/
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue