Export (0) Print
Expand All

WdfDriverCreate method

[Applies to KMDF and UMDF]

The WdfDriverCreate method creates a framework driver object for the calling driver.

Syntax


NTSTATUS WdfDriverCreate(
  [in]             PDRIVER_OBJECT DriverObject,
  [in]             PCUNICODE_STRING RegistryPath,
  [in, optional]   PWDF_OBJECT_ATTRIBUTES DriverAttributes,
  [in]             PWDF_DRIVER_CONFIG DriverConfig,
  [out, optional]  WDFDRIVER *Driver
);

Parameters

DriverObject [in]

A pointer to a DRIVER_OBJECT structure that represents a Windows Driver Model (WDM) driver object. The driver receives this pointer as input to its DriverEntry routine.

RegistryPath [in]

A pointer to a UNICODE_STRING structure that contains the registry path string that the driver received as input to its DriverEntry routine.

DriverAttributes [in, optional]

A pointer to a caller-allocated WDF_OBJECT_ATTRIBUTES structure. (The structure's ParentObject member must be NULL.) This parameter is optional and can be WDF_NO_OBJECT_ATTRIBUTES.

DriverConfig [in]

A pointer to a caller-allocated WDF_DRIVER_CONFIG structure.

Driver [out, optional]

A pointer to a location that receives a handle to the new framework driver object. This parameter is optional and can be WDF_NO_HANDLE.

Return value

WdfDriverCreate returns STATUS_SUCCESS if the operation succeeds. Otherwise, this method might return one of the following values:

Return codeDescription
STATUS_DRIVER_INTERNAL_ERROR

The driver called WdfDriverCreate more than once.

STATUS_INVALID_PARAMETER

A non-Plug and Play (PnP) driver specified an EvtDriverDeviceAdd callback function.

 

For more information about return values, see Framework Object Creation Errors.

This method might also return other NTSTATUS values.

A system bug check occurs if the DriverObject, RegistryPath, or DriverConfig parameter is NULL.

Remarks

A driver that uses Kernel-Mode Driver Framework must call WdfDriverCreate from within its DriverEntry routine, before calling any other framework routines. For more information about DriverEntry, see DriverEntry for Framework-based Drivers.

Before your driver calls WdfDriverCreate, the driver must call WDF_DRIVER_CONFIG_INIT to initialize its WDF_DRIVER_CONFIG structure.

The framework driver object is the top of your driver's tree of framework objects and therefore does not have a parent object.

If your driver provides EvtCleanupCallback or EvtDestroyCallback callback functions for the driver object, note that the framework calls these callback functions at IRQL = PASSIVE_LEVEL.

Examples

The following code example is a DriverEntry routine that initializes a WDF_DRIVER_CONFIG structure and then creates a framework driver object.


NTSTATUS
DriverEntry(
    IN PDRIVER_OBJECT  DriverObject,
    IN PUNICODE_STRING  RegistryPath
    )
{
    WDF_DRIVER_CONFIG  config;
    NTSTATUS  status = STATUS_SUCCESS;

    WDF_DRIVER_CONFIG_INIT(
                           &config,
                           MyEvtDeviceAdd
                           );
    config.EvtDriverUnload = MyEvtDriverUnload;
    status = WdfDriverCreate(
                             DriverObject,
                             RegistryPath,
                             WDF_NO_OBJECT_ATTRIBUTES,
                              &config,
                             WDF_NO_HANDLE
                             );
    if (!NT_SUCCESS(status)) {
        TraceEvents(
                    TRACE_LEVEL_ERROR,
                    DBG_PNP,
                    "WdfDriverCreate failed with status %!STATUS!",
                    status
                    );
    }
    return status;
}

Requirements

Minimum KMDF version

1.0

Minimum UMDF version

2.0

Header

Wdfdriver.h (include Wdf.h)

Library

Wdf01000.sys (KMDF);
WUDFx02000.dll (UMDF)

IRQL

PASSIVE_LEVEL

DDI compliance rules

ChangeQueueState, DriverAttributeChanged, DriverCreate, KmdfIrql, KmdfIrql2, MiniportOnlyWdmDevice

See also

DRIVER_OBJECT
DriverEntry
EvtDriverDeviceAdd
UNICODE_STRING
WDF_DRIVER_CONFIG
WDF_DRIVER_CONFIG_INIT
WDF_OBJECT_ATTRIBUTES

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft