mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
sys: FspFsvolDevice{Lookup,Insert,Delete}Context: now require use of FsvolDeviceExtension Resource
This commit is contained in:
parent
f0ee13b04c
commit
b5cf090144
@ -47,9 +47,15 @@ VOID FspDeviceDeleteAll(VOID);
|
|||||||
#pragma alloc_text(PAGE, FspFsvrtDeviceInit)
|
#pragma alloc_text(PAGE, FspFsvrtDeviceInit)
|
||||||
#pragma alloc_text(PAGE, FspFsvrtDeviceFini)
|
#pragma alloc_text(PAGE, FspFsvrtDeviceFini)
|
||||||
#pragma alloc_text(PAGE, FspFsvolDeviceInit)
|
#pragma alloc_text(PAGE, FspFsvolDeviceInit)
|
||||||
//! #pragma alloc_text(PAGE, FspFsvolDeviceFini)
|
#pragma alloc_text(PAGE, FspFsvolDeviceFini)
|
||||||
#pragma alloc_text(PAGE, FspFsctlDeviceVolumeCreated)
|
#pragma alloc_text(PAGE, FspFsctlDeviceVolumeCreated)
|
||||||
#pragma alloc_text(PAGE, FspFsctlDeviceVolumeDeleted)
|
#pragma alloc_text(PAGE, FspFsctlDeviceVolumeDeleted)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceLookupContext)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceInsertContext)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceDeleteContext)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceCompareElement)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceAllocateElement)
|
||||||
|
#pragma alloc_text(PAGE, FspFsvolDeviceFreeElement)
|
||||||
#pragma alloc_text(PAGE, FspDeviceCopyList)
|
#pragma alloc_text(PAGE, FspDeviceCopyList)
|
||||||
#pragma alloc_text(PAGE, FspDeviceDeleteList)
|
#pragma alloc_text(PAGE, FspDeviceDeleteList)
|
||||||
#pragma alloc_text(PAGE, FspDeviceDeleteAll)
|
#pragma alloc_text(PAGE, FspDeviceDeleteAll)
|
||||||
@ -214,26 +220,25 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject)
|
|||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
|
|
||||||
ExInitializeFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
RtlInitializeGenericTableAvl(&FsvolDeviceExtension->GenericTable,
|
||||||
RtlInitializeGenericTableAvl(&FsvolDeviceExtension->GenericTable, 0, 0, 0, 0);
|
FspFsvolDeviceCompareElement, FspFsvolDeviceAllocateElement, FspFsvolDeviceFreeElement, 0);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject)
|
static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject)
|
||||||
{
|
{
|
||||||
// !PAGED_CODE(); /* because of fast mutex use in GenericTable */
|
PAGED_CODE();
|
||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Enumerate and delete all entries in the GenericTable.
|
* Enumerate and delete all entries in the GenericTable.
|
||||||
|
* There is no need to protect accesses to the table as we are in the device destructor.
|
||||||
*/
|
*/
|
||||||
ExAcquireFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT *Element;
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT *Element;
|
||||||
while (0 != (Element = RtlGetElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, 0)))
|
while (0 != (Element = RtlGetElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, 0)))
|
||||||
RtlDeleteElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Element->Identifier);
|
RtlDeleteElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Element->Identifier);
|
||||||
ExReleaseFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dereference the virtual volume device so that it can now go away.
|
* Dereference the virtual volume device so that it can now go away.
|
||||||
@ -307,36 +312,34 @@ VOID FspFsctlDeviceVolumeDeleted(PDEVICE_OBJECT DeviceObject)
|
|||||||
|
|
||||||
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier)
|
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier)
|
||||||
{
|
{
|
||||||
// !PAGED_CODE(); /* because of fast mutex use in GenericTable */
|
PAGED_CODE();
|
||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
ASSERT(FspFsvolDeviceExtensionKind == FsvolDeviceExtension->Base.Kind);
|
ASSERT(FspFsvolDeviceExtensionKind == FsvolDeviceExtension->Base.Kind);
|
||||||
|
ASSERT(ExIsResourceAcquiredExclusiveLite(&FsvolDeviceExtension->Base.Resource));
|
||||||
|
|
||||||
PVOID Result;
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT *Result;
|
||||||
|
|
||||||
ExAcquireFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
|
||||||
Result = RtlLookupElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Identifier);
|
Result = RtlLookupElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Identifier);
|
||||||
ExReleaseFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
|
||||||
|
|
||||||
return Result;
|
return 0 != Result ? Result->Context : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier, PVOID Context,
|
||||||
PBOOLEAN PInserted)
|
PBOOLEAN PInserted)
|
||||||
{
|
{
|
||||||
// !PAGED_CODE(); /* because of fast mutex use in GenericTable */
|
PAGED_CODE();
|
||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
ASSERT(FspFsvolDeviceExtensionKind == FsvolDeviceExtension->Base.Kind);
|
ASSERT(FspFsvolDeviceExtensionKind == FsvolDeviceExtension->Base.Kind);
|
||||||
|
ASSERT(ExIsResourceAcquiredExclusiveLite(&FsvolDeviceExtension->Base.Resource));
|
||||||
|
|
||||||
FSP_DEVICE_GENERIC_TABLE_ELEMENT *Result, Element = { 0 };
|
FSP_DEVICE_GENERIC_TABLE_ELEMENT *Result, Element = { 0 };
|
||||||
Element.Identifier = Identifier;
|
Element.Identifier = Identifier;
|
||||||
Element.Context = Context;
|
Element.Context = Context;
|
||||||
|
|
||||||
ExAcquireFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
|
||||||
Result = RtlInsertElementGenericTableAvl(&FsvolDeviceExtension->GenericTable,
|
Result = RtlInsertElementGenericTableAvl(&FsvolDeviceExtension->GenericTable,
|
||||||
&Element, sizeof Element, PInserted);
|
&Element, sizeof Element, PInserted);
|
||||||
ExReleaseFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
|
||||||
|
|
||||||
return 0 != Result ? Result->Context : 0;
|
return 0 != Result ? Result->Context : 0;
|
||||||
}
|
}
|
||||||
@ -344,16 +347,15 @@ PVOID FspFsvolDeviceInsertContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier
|
|||||||
VOID FspFsvolDeviceDeleteContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier,
|
VOID FspFsvolDeviceDeleteContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier,
|
||||||
PBOOLEAN PDeleted)
|
PBOOLEAN PDeleted)
|
||||||
{
|
{
|
||||||
// !PAGED_CODE(); /* because of fast mutex use in GenericTable */
|
PAGED_CODE();
|
||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject);
|
||||||
ASSERT(FspFsvolDeviceExtensionKind == FsvolDeviceExtension->Base.Kind);
|
ASSERT(FspFsvolDeviceExtensionKind == FsvolDeviceExtension->Base.Kind);
|
||||||
|
ASSERT(ExIsResourceAcquiredExclusiveLite(&FsvolDeviceExtension->Base.Resource));
|
||||||
|
|
||||||
BOOLEAN Deleted;
|
BOOLEAN Deleted;
|
||||||
|
|
||||||
ExAcquireFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
|
||||||
Deleted = RtlDeleteElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Identifier);
|
Deleted = RtlDeleteElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Identifier);
|
||||||
ExReleaseFastMutex(&FsvolDeviceExtension->GenericTableFastMutex);
|
|
||||||
|
|
||||||
if (0 != PDeleted)
|
if (0 != PDeleted)
|
||||||
*PDeleted = Deleted;
|
*PDeleted = Deleted;
|
||||||
@ -362,7 +364,7 @@ VOID FspFsvolDeviceDeleteContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier,
|
|||||||
static RTL_GENERIC_COMPARE_RESULTS NTAPI FspFsvolDeviceCompareElement(
|
static RTL_GENERIC_COMPARE_RESULTS NTAPI FspFsvolDeviceCompareElement(
|
||||||
PRTL_AVL_TABLE Table, PVOID FirstElement, PVOID SecondElement)
|
PRTL_AVL_TABLE Table, PVOID FirstElement, PVOID SecondElement)
|
||||||
{
|
{
|
||||||
// !PAGED_CODE(); /* because of fast mutex use in GenericTable */
|
PAGED_CODE();
|
||||||
|
|
||||||
if (FirstElement < SecondElement)
|
if (FirstElement < SecondElement)
|
||||||
return GenericLessThan;
|
return GenericLessThan;
|
||||||
@ -376,16 +378,15 @@ static RTL_GENERIC_COMPARE_RESULTS NTAPI FspFsvolDeviceCompareElement(
|
|||||||
static PVOID NTAPI FspFsvolDeviceAllocateElement(
|
static PVOID NTAPI FspFsvolDeviceAllocateElement(
|
||||||
PRTL_AVL_TABLE Table, CLONG ByteSize)
|
PRTL_AVL_TABLE Table, CLONG ByteSize)
|
||||||
{
|
{
|
||||||
// !PAGED_CODE(); /* because of fast mutex use in GenericTable */
|
PAGED_CODE();
|
||||||
|
|
||||||
/* allocate from non-paged pool because of fast mutex use */
|
return ExAllocatePoolWithTag(PagedPool, ByteSize, FSP_TAG);
|
||||||
return ExAllocatePoolWithTag(NonPagedPool, ByteSize, FSP_TAG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID NTAPI FspFsvolDeviceFreeElement(
|
static VOID NTAPI FspFsvolDeviceFreeElement(
|
||||||
PRTL_AVL_TABLE Table, PVOID Buffer)
|
PRTL_AVL_TABLE Table, PVOID Buffer)
|
||||||
{
|
{
|
||||||
// !PAGED_CODE(); /* because of fast mutex use in GenericTable */
|
PAGED_CODE();
|
||||||
|
|
||||||
ExFreePoolWithTag(Buffer, FSP_TAG);
|
ExFreePoolWithTag(Buffer, FSP_TAG);
|
||||||
}
|
}
|
||||||
|
@ -304,7 +304,6 @@ typedef struct
|
|||||||
{
|
{
|
||||||
FSP_DEVICE_EXTENSION Base;
|
FSP_DEVICE_EXTENSION Base;
|
||||||
PDEVICE_OBJECT FsvrtDeviceObject;
|
PDEVICE_OBJECT FsvrtDeviceObject;
|
||||||
FAST_MUTEX GenericTableFastMutex;
|
|
||||||
RTL_AVL_TABLE GenericTable;
|
RTL_AVL_TABLE GenericTable;
|
||||||
} FSP_FSVOL_DEVICE_EXTENSION;
|
} FSP_FSVOL_DEVICE_EXTENSION;
|
||||||
static inline
|
static inline
|
||||||
|
Loading…
x
Reference in New Issue
Block a user