I have taken this from : Programming microsoft windows driver 2nd edition by woney I hope this helps.
Removability of devices in a Plug and Play environment is the ultimate source of the early-unload problem mentioned in the text. it’s your responsibility to avoid sending an IRP to a driver that might no longer be in memory and to prevent the PnP manager from unloading a driver that’s still processing an IRP you’ve sent to that driver. One aspect of how you fulfill that responsibility is shown in the text: take an extra reference to the file object returned by IoGetDeviceObjectPointer around the call to IoCallDriver. In most drivers, you’ll probably need the extra reference only when you’re sending an asynchronous IRP. In that case, the code that ordinarily dereferences the file object is likely to be in some other part of your driver that runs asynchronously with the call to IoCallDriver—say, in the completion routine you’re obliged to install for an asynchronous IRP. If you send a synchronous IRP, you’re much more likely to code your driver in such a way that you don’t dereference the file object until the IRP completes.