Expand Minimize

WdfDeviceAssignMofResourceName method

[Applies to KMDF only]

The WdfDeviceAssignMofResourceName method registers a MOF resource name for a specified device.

Syntax


NTSTATUS WdfDeviceAssignMofResourceName(
  [in]  WDFDEVICE Device,
  [in]  PCUNICODE_STRING MofResourceName
);

Parameters

Device [in]

A handle to a framework device object.

MofResourceName [in]

A pointer to a UNICODE_STRING structure that specifies the name of a MOF resource.

Return value

If the operation succeeds, WdfDeviceAssignMofResourceName returns STATUS_SUCCESS. Additional return values include:

Return codeDescription
STATUS_INVALID_DEVICE_REQUEST

The driver has already called WdfDeviceAssignMofResourceName.

STATUS_INSUFFICIENT_RESOURCES

Insufficient memory is available.

 

The method might return other NTSTATUS values.

A bug check occurs if the driver supplies an invalid object handle.

Remarks

A driver that provides a MOF file to support WMI must call WdfDeviceAssignMofResourceName, typically from within its EvtDriverDeviceAdd or EvtDevicePrepareHardware callback function. The MOF resource name is the file name that the driver specifies in a MofResource statement in its resource script (RC) file. For more information about specifying a MOF resource name, see Compiling a Driver's MOF File.

A driver that enumerates the devices on a bus can call WdfDeviceAssignMofResourceName for the parent device, and the framework will use the parent's MOF resource name for child devices.

For more information about WMI, see Supporting WMI in Framework-Based Drivers.

Examples

The following code example declares a Unicode string that represents a MOF resource name and then registers the name.


NTSTATUS  status;
DECLARE_CONST_UNICODE_STRING(mofRsrcName, MOFRESOURCENAME);

status = WdfDeviceAssignMofResourceName(
                                        Device,
                                        &mofRsrcName
                                        );
if (!NT_SUCCESS(status)) {
    return status;
}

Requirements

Minimum KMDF version

1.0

Header

Wdfdevice.h (include Wdf.h)

Library

Wdf01000.sys (see Framework Library Versioning.)

IRQL

PASSIVE_LEVEL

DDI compliance rules

DriverCreate, KmdfIrql, KmdfIrql2

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft