Prevent device from loading

Hi,
I’m trying to develop minifilter that will prevent device from loading. I’ve registered a call back for PRE on IRP_MJ_PNP and tried to stop loading through there, but have not succeeded. The device still loading
This is my code:

if (Data->Iopb->MinorFunction == IRP_MN_START_DEVICE)
{
.
.
.

finalStatus = FLT_PREOP_COMPLETE;
Data->IoStatus.Status = STATUS_DEVICE_NOT_READY;
Data->IoStatus.Information = 0;
.
.
.
}
return finalStatus;

Do you have any ideas?

It appears you are implementing a ‘file system’ mini-filter driver. An
FS mini-filter can’t prevent a device from loading, you can prevent
access to a storage device but by the time your mini-filter loads the
device is already present in the system. To accomplish this you would
need to be a lower device class or other type of filter driver.

Pete

On 9/21/2014 3:23 AM, xxxxx@gmail.com wrote:

Hi,
I’m trying to develop minifilter that will prevent device from loading. I’ve registered a call back for PRE on IRP_MJ_PNP and tried to stop loading through there, but have not succeeded. The device still loading
This is my code:

if (Data->Iopb->MinorFunction == IRP_MN_START_DEVICE)
{
.
.
.

finalStatus = FLT_PREOP_COMPLETE;
Data->IoStatus.Status = STATUS_DEVICE_NOT_READY;
Data->IoStatus.Information = 0;
.
.
.
}
return finalStatus;

Do you have any ideas?


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Kernel Drivers
Windows File System and Device Driver Consulting
www.KernelDrivers.com
866.263.9295

Are you trying this because when an instance is removed, the remaining one bugchecks the system ?

If this is the reason, you should work on the driver-wide resources. A specific device instance should not release a resource that may be used by another instance. Each device instance should use it’s own device extension for the particular case of allocating system resources. This way, device instances are isolated.

If you think a second instance results in system resources being wasted, you can fail it’s creation. But it’s removal should not make your driver fail.