Share via


Register Your Miniport Driver with NDIS 6.0 (Compact 2013)

3/26/2014

Your miniport driver provides a DriverEntry routine that the OS calls to load your driver. Like NDIS 5.x, NDIS 6.0 miniport drivers register with NDIS in the DriverEntry routine. Unlike NDIS 5.x, NDIS 6.0 miniport drivers do not use the NdisMInitializeWrapper, NdisMRegisterUnloadHandler, and NdisMRegisterMiniport functions. These legacy functions are not available in NDIS 6.0. Instead, you register your NDIS 6.0 miniport driver by calling the NdisMRegisterMiniportDriver function. If the call to NdisMRegisterMiniportDriver succeeds, your miniport driver must call the NdisMDeregisterMiniportDriver function when your driver unregisters from NDIS.

The following table shows which API elements have been renamed and/or changed for NDIS 6.0.

NDIS 5.x

NDIS 6.0

NdisMInitializeWrapper
NdisMRegisterUnloadHandler
NdisMRegisterMiniport

NdisMRegisterMiniportDriver

NdisTerminateWrapper

NdisMDeregisterMiniportDriver

To register your miniport driver with NDIS 6.0, make the following changes:

  1. Remove calls to the NDIS 5.xNdisMInitializeWrapper, NdisMRegisterUnloadHandler, and NdisMRegisterMiniport functions.

  2. Call the NdisMRegisterMiniportDriver function to register your driver with NDIS 6.0.

    Like NdisMRegisterMiniport, the input parameters to NdisMRegisterMiniportDriver include the driver object, registry path, and the driver characteristics structure. The driver characteristics structure must be initialized as described in Initialize the Miniport Driver Characteristics Structure. In addition, NdisMRegisterMiniportDriver requires a pointer to an NDIS_HANDLE variable that NDIS uses to return a handle back to you. You use this handle to identify your driver in subsequent NDIS function calls.

    The following example illustrates a call to NdisMRegisterMiniportDriver to register a miniport driver. For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment:

    NDIS_HANDLE MiniportDriverContext = NULL;
    NDIS_HANDLE NdisMiniportDriverHandle = NULL;
    NDIS_STATUS DriverEntry 
    (
       IN PDRIVER_OBJECT DriverObject,
       IN PUNICODE_STRING RegistryPath
    )
    {
    // Initialize MyMDC
        . . .
    // Register driver
    Status = NdisMRegisterMiniportDriver (
               DriverObject, RegistryPath, (PNDIS_HANDLE)MiniportDriverContext,
               &MyMDC, &NdisMiniportDriverHandle);
    }
    

    In the preceding example, MiniportDriverContext and NdisMiniportDriverHandle are global variables that are declared in the driver. This example code calls NdisMRegisterMiniportDriver after it initializes the miniport driver characteristics structure, MyMDC. DriverObject is the pointer to the driver object that the OS passes to DriverEntry, and RegistryPath is the pointer to the driver registry path that the OS passes to DriverEntry. NdisMiniportDriverHandle is the variable that stores the handle returned from NdisMRegisterMiniportDriver.

    Call NdisMDeregisterMiniportDriver to unregister your driver from NDIS. Call NdisMDeregisterMiniportDriver in the context of your driver unload entry point function. If an error occurs after a successful call to NdisMRegisterMiniportDriver, you must call the NdisMDeregisterMiniportDriver function before returning from your DriverEntry function. NDIS 6.0 miniport drivers do not call the NdisTerminateWrapper function.

See Also

Concepts

Convert Miniport Driver Initialization for NDIS 6.0