diff --git a/src/sys/device.c b/src/sys/device.c index 9bf23bbd..3befca07 100644 --- a/src/sys/device.c +++ b/src/sys/device.c @@ -291,7 +291,7 @@ static NTSTATUS FspFsvolDeviceInit(PDEVICE_OBJECT DeviceObject) FsvolDeviceExtension->InitDoneIoq = 1; /* initialize our generic table */ - KeInitializeGuardedMutex(&FsvolDeviceExtension->GenericTableMutex); + ExInitializeResourceLite(&FsvolDeviceExtension->GenericTableResource); RtlInitializeGenericTableAvl(&FsvolDeviceExtension->GenericTable, FspFsvolDeviceCompareElement, FspFsvolDeviceAllocateElement, FspFsvolDeviceFreeElement, 0); FsvolDeviceExtension->InitDoneGenTab = 1; @@ -326,24 +326,25 @@ static VOID FspFsvolDeviceFini(PDEVICE_OBJECT DeviceObject) if (FsvolDeviceExtension->InitDoneTimer) IoStopTimer(DeviceObject); -#if 0 - /* FspDeviceFreeElement is now a no-op, so this is no longer necessary */ - /* - * 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. - */ - if (FsvolDeviceExtension->InitDoneGenTab) - { - FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Element; - while (0 != (Element = RtlGetElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, 0))) - RtlDeleteElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Element->Identifier); - } -#endif - /* delete the Ioq */ if (FsvolDeviceExtension->InitDoneIoq) FspIoqDelete(FsvolDeviceExtension->Ioq); + if (FsvolDeviceExtension->InitDoneGenTab) + { +#if 0 + /* FspDeviceFreeElement is now a no-op, so this is no longer necessary */ + /* + * 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. + */ + FSP_DEVICE_GENERIC_TABLE_ELEMENT_DATA *Element; + while (0 != (Element = RtlGetElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, 0))) + RtlDeleteElementGenericTableAvl(&FsvolDeviceExtension->GenericTable, &Element->Identifier); +#endif + ExDeleteResourceLite(&FsvolDeviceExtension->GenericTableResource); + } + /* finalize our delete lock */ if (FsvolDeviceExtension->InitDoneDelRsc) ExDeleteResourceLite(&FsvolDeviceExtension->DeleteResource); @@ -413,7 +414,7 @@ VOID FspFsvolDeviceLockContextTable(PDEVICE_OBJECT DeviceObject) PAGED_CODE(); FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject); - KeAcquireGuardedMutex(&FsvolDeviceExtension->GenericTableMutex); + ExAcquireResourceExclusiveLite(&FsvolDeviceExtension->GenericTableResource, TRUE); } VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject) @@ -421,7 +422,7 @@ VOID FspFsvolDeviceUnlockContextTable(PDEVICE_OBJECT DeviceObject) PAGED_CODE(); FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension = FspFsvolDeviceExtension(DeviceObject); - KeReleaseGuardedMutex(&FsvolDeviceExtension->GenericTableMutex); + ExReleaseResourceLite(&FsvolDeviceExtension->GenericTableResource); } PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier) diff --git a/src/sys/driver.h b/src/sys/driver.h index 667f5d86..88e5415d 100644 --- a/src/sys/driver.h +++ b/src/sys/driver.h @@ -434,7 +434,7 @@ typedef struct KSPIN_LOCK ExpirationLock; WORK_QUEUE_ITEM ExpirationWorkItem; BOOLEAN ExpirationInProgress; - KGUARDED_MUTEX GenericTableMutex; + ERESOURCE GenericTableResource; RTL_AVL_TABLE GenericTable; PVOID GenericTableElementStorage; UNICODE_STRING VolumeName;