PROTOCOL_UNINSTALL callback function

NDIS calls a protocol driver's ProtocolUninstall function to perform cleanup operations before a protocol driver is uninstalled.

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



void ProtocolUninstall(



This callback function has no parameters.

Return Value



The ProtocolUninstall function is optional. The protocol driver registered an entry point, if any, for this function in the NDIS_PROTOCOL_DRIVER_CHARACTERISTICS structure that it passed to the NdisRegisterProtocolDriver function.

In response to a user request to uninstall a protocol driver, NDIS calls a protocol driver's ProtocolUninstall function. NDIS calls ProtocolUninstall after calling the protocol driver's ProtocolUnbindAdapterEx function once for each bound adapter.

ProtocolUninstall performs driver-determined cleanup operations. For example, ProtocolUninstall could request clients to close open handles to device objects that the protocol driver exported. Until all such handles are closed, the I/O manager will not call the Unload routine that the protocol driver registered in the driver object passed to its DriverEntry routine. After all the handles are closed, ProtocolUninstall can call NdisDeregisterDeviceEx to delete any device objects created by the protocol driver.

The protocol lower edge of an intermediate driver might require a ProtocolUninstall function. The intermediate driver can release its protocol edge resources in ProtocolUninstall before NDIS calls its MiniportDriverUnload function.

NDIS calls ProtocolUninstall at IRQL = PASSIVE_LEVEL.


To define a ProtocolUninstall 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 ProtocolUninstall function that is named "MyUninstall", use the PROTOCOL_UNINSTALL type as shown in this code example:

Then, implement your function as follows:
The PROTOCOL_UNINSTALL 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 PROTOCOL_UNINSTALL 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.


Minimum supported client Supported in NDIS 6.0 and later.
Target Platform Windows
Header ndis.h (include Ndis.h)

See Also