IODelete Deice Causing Error When Delete FILE_DEVICE_DISK_FILE_SYSTEM

Why don’t you post the output from WinDBG in this case (“!analyze -v”). That might be more insightful into why it’s blowing up.

I also didn’t see you call IoRegisterFileSystem (it isn’t in the code you provided), which would be necessary if you wanted mounting. I suspect (but can’t say I’ve done it) that deleting a device object while it’s registered as a file system would cause horrible things to happen (like a BSOD or FFOD).

Finally, if this were a real file system, you’d probably want to unmounts and dismantle your file system device object FIRST - before the volume on which it’s mounted.

Oh, and for what it’s worth, file systems don’t use FILE_DEVICE_SECURE_OPEN (because file systems support naming structure, they want to be called and do the security checks. That’s not causing your BSOD, but it did jump out at me.

Go look at FAT. It creates device objects in three places and none of them use FILE_DEVICE_SECURE_OPEN. Here’s the most common case (the unnamed device object it creates to attach to a volume):

//
// Create a new volume device object. This will have the Vcb
// hanging off of its end, and set its alignment requirement
// from the device we talk to.
//
if (!NT_SUCCESS(Status = IoCreateDevice( FatData.DriverObject,
sizeof(VOLUME_DEVICE_OBJECT) - sizeof(DEVICE_OBJECT),
NULL,
FILE_DEVICE_DISK_FILE_SYSTEM,
0,
FALSE,
(PDEVICE_OBJECT *)&VolDo))) {

Tony
OSR