sys: call IoRegisterFileSystem from DriverEntry

This commit is contained in:
Bill Zissimopoulos 2015-12-10 16:31:01 -08:00
parent 138a10d232
commit 140e567fdc
2 changed files with 22 additions and 0 deletions

View File

@ -289,9 +289,13 @@ VOID FspFsctlDeviceVolumeCreated(PDEVICE_OBJECT DeviceObject)
ASSERT(FspFsctlDeviceExtensionKind == FspDeviceExtension(DeviceObject)->Kind);
ASSERT(ExIsResourceAcquiredExclusiveLite(&FspDeviceExtension(DeviceObject)->Resource));
#if 1
FspFsctlDeviceExtension(DeviceObject)->FsvrtDeviceObjectCount++;
#else
ULONG FsvrtDeviceObjectCount = FspFsctlDeviceExtension(DeviceObject)->FsvrtDeviceObjectCount++;
if (0 == FsvrtDeviceObjectCount)
IoRegisterFileSystem(DeviceObject);
#endif
}
VOID FspFsctlDeviceVolumeDeleted(PDEVICE_OBJECT DeviceObject)
@ -301,9 +305,13 @@ VOID FspFsctlDeviceVolumeDeleted(PDEVICE_OBJECT DeviceObject)
ASSERT(FspFsctlDeviceExtensionKind == FspDeviceExtension(DeviceObject)->Kind);
ASSERT(ExIsResourceAcquiredExclusiveLite(&FspDeviceExtension(DeviceObject)->Resource));
#if 1
--FspFsctlDeviceExtension(DeviceObject)->FsvrtDeviceObjectCount;
#else
ULONG FsvrtDeviceObjectCount = --FspFsctlDeviceExtension(DeviceObject)->FsvrtDeviceObjectCount;
if (0 == FsvrtDeviceObjectCount)
IoUnregisterFileSystem(DeviceObject);
#endif
}
PVOID FspFsvolDeviceLookupContext(PDEVICE_OBJECT DeviceObject, UINT64 Identifier)

View File

@ -121,6 +121,20 @@ NTSTATUS DriverEntry(
#pragma prefast(suppress:28175, "We are a filesystem: ok to access FastIoDispatch")
DriverObject->FastIoDispatch = &FspFastIoDispatch;
/*
* Register our devices as file systems. We do this here to simplify file system
* registration/unregistration, although this makes our driver unloadable from the
* get go.
*
* Unfortunately a call to IoRegisterFileSystem(), even if followed by a call to
* IoUnregistreFileSystem(), makes the driver unloadable. We attempted to move
* the register/unregister calls to FspFsctlDeviceVolume{Created,Deleted}, but it
* did not make any difference with regards to making the driver unloadable. Hence
* we stick to the simpler scheme of doing registration here.
*/
IoRegisterFileSystem(FspFsctlDiskDeviceObject);
IoRegisterFileSystem(FspFsctlNetDeviceObject);
#pragma prefast(suppress:28175, "We are in DriverEntry: ok to access DriverName")
FSP_LEAVE("DriverName=\"%wZ\", RegistryPath=\"%wZ\"",
&DriverObject->DriverName, RegistryPath);