Removing a NIC

The following steps describe how NDIS participates in the removal of a NIC:

  1. The PnP manager issues an IRP_MN_QUERY_REMOVE_DEVICE request to query whether the NIC can be removed without disrupting the computer.

  2. When NDIS receives this IRP, it calls the FilterNetPnPEvent function of the lowest filter driver that is attached to the NIC in the driver stack. In this call, NDIS specifies an event code of NetEventQueryRemoveDevice.

    Note  NDIS performs this step only for filter drivers that advertise an entry point for the FilterNetPnPEvent function. A filter driver advertises this entry point when it calls the NdisFRegisterFilterDriver function.

  3. Within the context of the call to its FilterNetPnPEvent function, the filter driver must call NdisFNetPnPEvent to forward the NetEventQueryRemoveDevice event up to the next filter driver in the driver stack. This causes NDIS to call that filter driver's FilterNetPnPEvent function with an event code of NetEventQueryRemoveDevice.

    Note  NDIS performs this step only for the next filter driver in the driver stack that advertises an entry point for the FilterNetPnPEvent function.

  4. Each filter driver in the driver stack repeats the previous step until the highest filter driver in the stack has forwarded the NetEventQueryRemoveDevice event.

    When this happens, NDIS calls the ProtocolNetPnPEvent function of all protocol drivers that are bound to the NIC. In this call, NDIS specifies an event code of NetEventQueryRemoveDevice.

  5. If a protocol driver fails the NetEventQueryRemoveDevice event by returning a failure code NDIS_STATUS_FAILURE from ProtocolNetPnPEvent, NDIS or the PnP manager might ignore the failure and subsequently succeed the IRP_MN_QUERY_REMOVE_DEVICE request. A protocol driver must, therefore, be prepared to handle the removal of the NIC even though the protocol driver failed the NetEventQueryRemoveDevice event.

  6. The PnP manager issues an IRP_MN_REMOVE_DEVICE request to remove the software representation (device objects, and so on) for the NIC or an IRP_MN_CANCEL_REMOVE_DEVICE request to cancel the pending removal. Note that an IRP_MN_REMOVE_DEVICE request is not always preceded by an IRP_MN_QUERY_REMOVE_DEVICE request.

  7. If the PnP manager issues an IRP_MN_CANCEL_REMOVE_DEVICE request, NDIS calls the FilterNetPnPEvent function of the lowest filter driver that is attached to the NIC in the driver stack. In this call, NDIS specifies an event code of NetEventCancelRemoveDevice.

    Note  NDIS performs this step only for filter drivers that advertise an entry point for the FilterNetPnPEvent function.

  8. Within the context of the call to its FilterNetPnPEvent function, the filter driver must call NdisFNetPnPEvent to forward the NetEventCancelRemoveDevice event up to the next filter driver in the driver stack. This causes NDIS to call that filter driver's FilterNetPnPEvent function with an event code of NetEventCancelRemoveDevice.

    Note  NDIS performs this step only for the next filter driver in the driver stack that advertises an entry point for the FilterNetPnPEvent function.

  9. Each filter driver in the driver stack repeats the previous step until the highest filter driver in the stack has forwarded the NetEventCancelRemoveDevice event.

    When this happens, NDIS calls the ProtocolNetPnPEvent function of all protocol drivers that are bound to the NIC. In this call, NDIS specifies an event code of NetEventCancelRemoveDevice. This event code ends the removal sequence.

  10. If the PnP manager issues an IRP_MN_REMOVE_DEVICE request, NDIS performs these steps:

    1. It pauses all protocol drivers that are bound to the NIC.

    2. It pauses all filter drivers that are attached to the NIC.

    3. It pauses the miniport driver for the NIC.

    4. It calls the ProtocolUnbindAdapterEx function of all protocol drivers that are bound to the NIC.

    5. It calls the FilterDetach function of all filter modules that are attached to the NIC.

  11. If the miniport driver was successfully initialized, NDIS calls the miniport driver's MiniportHaltEx function. NDIS sets the HaltAction parameter of MiniportHaltEx to NdisHaltDeviceDisabled.

  12. NDIS sends the IRP_MN_REMOVE_DEVICE request to the next lower device object in the stack.

  13. When NDIS receives the completed IRP_MN_REMOVE_DEVICE request from the next lower device object in the stack, NDIS destroys the functional device object (FDO) that it created for the NIC.