Hardware Dev Center

MiniportHaltEx routine

NDIS calls a miniport driver's MiniportHaltEx function to free resources when a miniport adapter is removed, and to stop the hardware. This function puts the miniport into the Halted state, where no other callback can occur (including MiniportShutdownEx). For more information about miniport driver states, see Miniport Adapter States and Operations.

Note  You must declare the function by using the MINIPORT_HALT type. For more information, see the following Examples section.



VOID MiniportHaltEx(
  _In_ NDIS_HANDLE      MiniportAdapterContext,
  _In_ NDIS_HALT_ACTION HaltAction
{ ... }


MiniportAdapterContext [in]

A handle to a context area that the miniport driver allocated in its MiniportInitializeEx function. The miniport driver uses this context area to maintain state information for a miniport adapter.

HaltAction [in]

The reason for halting the miniport adapter. It can be one of the following values:


NDIS is halting the miniport adapter in response to a Plug and Play (PnP) remove message.


NDIS is halting the miniport adapter in response to an intermediate driver calling the NdisIMDeInitializeDeviceInstance function.


NDIS is halting the miniport adapter because the system is going to a sleeping state.


The miniport adapter has been surprise removed and the hardware is not present.


The miniport adapter is being removed because of a hardware failure. Either the miniport driver called the NdisMRemoveMiniport function or a bus driver did not power up the NIC on resume.


NDIS could not initialize the miniport adapter for an unknown reason after the MiniportInitializeEx function completed successfully.


NDIS is halting the miniport adapter in response to a PnP stop device message.

Return value



A driver specifies the MiniportHaltEx entry point when it calls the NdisMRegisterMiniportDriver function.

NDIS can call MiniportHaltEx at any time after a driver's MiniportInitializeEx function returns successfully. If the driver controls a physical NIC, MiniportHaltEx should stop the NIC. If an NDIS intermediate driver calls the NdisIMDeInitializeDeviceInstance function, NDIS calls the MiniportHaltEx function for the driver's virtual device.

MiniportHaltEx must free all resources that were allocated in MiniportInitializeEx for a device. MiniportHaltEx also frees any other resources that the driver allocated in subsequent operations for that device. The driver must call the reciprocals of the NdisXxx functions with which it originally allocated the resources. As a general rule, a MiniportHaltEx function should call the reciprocal NdisXxx functions in reverse order to the calls the driver made from MiniportInitializeEx.

If a NIC generates interrupts, a miniport driver's MiniportHaltEx function can be preempted by the driver's MiniportInterrupt function until the MiniportHaltEx call to the NdisMDeregisterInterruptEx function returns. Such a driver's MiniportHaltEx function should disable interrupts, and call NdisMDeregisterInterruptEx as soon as possible. Note that a driver can keep getting interrupts until NdisMDeregisterInterruptEx returns. NdisMDeregisterInterruptEx does not return until the driver finishes all the scheduled DPCs (see the MiniportInterruptDPC function for more information).

If the driver has a NetTimerCallback function that is associated with a timer object that could be in the system timer queue, MiniportHaltEx should call the NdisCancelTimerObject function. If NdisCancelTimerObject fails, the timer could have already fired. In this case, the driver should wait for the timer function to complete before the driver returns from MiniportHaltEx.

NDIS does not call MiniportHaltEx if there are outstanding OID requests or send requests. NDIS submits no further requests for the affected device after NDIS calls MiniportHaltEx.

If the driver must wait for any operation to complete, MiniportHaltEx can use the NdisWaitEvent function or the NdisMSleep function.

NDIS calls MiniportHaltEx at IRQL = PASSIVE_LEVEL.


To define a MiniportHaltEx function, you must first provide a function declaration that identifies the type of function you're defining. Windows provides a set of function types for drivers. Declaring a function using the function types helps Code Analysis for Drivers, Static Driver Verifier (SDV), and other verification tools find errors, and it's a requirement for writing drivers for the Windows operating system.

For example, to define a MiniportHaltEx function that is named "MyHaltEx", use the MINIPORT_HALT type as shown in this code example:


Then, implement your function as follows:

    NDIS_HANDLE  MiniportAdapterContext,
    NDIS_HALT_ACTION  HaltAction

The MINIPORT_HALT function type is defined in the Ndis.h header file. To more accurately identify errors when you run the code analysis tools, be sure to add the _Use_decl_annotations_ annotation to your function definition. The _Use_decl_annotations_ annotation ensures that the annotations that are applied to the MINIPORT_HALT function type in the header file are used. For more information about the requirements for function declarations, see Declaring Functions by Using Function Role Types for NDIS Drivers. For information about _Use_decl_annotations_, see Annotating Function Behavior.


Target platform



Supported in NDIS 6.0 and later.


Ndis.h (include Ndis.h)



DDI compliance rules

WlanAssociation, WlanConnectionRoaming, WlanDisassociation, WlanTimedAssociation, WlanTimedConnectionRoaming, WlanTimedConnectRequest, WlanTimedLinkQuality, WlanTimedScan

See also

Adapter States of a Miniport Driver
Halting a Miniport Adapter
Miniport Adapter States and Operations
Miniport Driver Reset and Halt Functions



Send comments about this topic to Microsoft

© 2015 Microsoft