WdfDeviceAddQueryInterface method
EvtDeviceReportedMissing
EvtDeviceUsageNotificationEx
EvtDeviceWdmIrpDispatch
EvtDeviceWdmPostPoFxRegisterDevice
EvtDeviceWdmPrePoFxUnregisterDevice
WDF_DEVICE_INTERFACE_PROPERTY_DATA
WDF_DEVICE_INTERFACE_PROPERTY_DATA_INIT
WDF_DEVICE_PROPERTY_DATA
WDF_DEVICE_PROPERTY_DATA_INIT
WDF_DISPATCH_IRP_TO_IO_QUEUE_FLAGS
WDF_EVENT_TYPE
WDF_IO_TYPE_CONFIG
WDF_IO_TYPE_CONFIG_INIT
WDF_POWER_FRAMEWORK_SETTINGS
WDF_POWER_FRAMEWORK_SETTINGS_INIT
WDF_POWER_POLICY_IDLE_TIMEOUT_TYPE
WDF_RELEASE_HARDWARE_ORDER_ON_FAILURE
WDF_REMOVE_LOCK_OPTIONS
WDF_REMOVE_LOCK_OPTIONS_FLAGS
WDF_REMOVE_LOCK_OPTIONS_INIT
WdfDeviceAllocAndQueryInterfaceProperty method
WdfDeviceAllocAndQueryPropertyEx method
WdfDeviceAssignInterfaceProperty method
WdfDeviceAssignProperty method
WdfDeviceConfigureWdmIrpDispatchCallback method
WdfDeviceGetDeviceStackIoType method
WdfDeviceGetHardwareRegisterMappedAddress
WdfDeviceInitSetIoTypeEx method
WdfDeviceInitSetReleaseHardwareOrderOnFailure method
WdfDeviceInitSetRemoveLockOptions method
WdfDeviceMapIoSpace
WdfDeviceOpenDevicemapKey method
WdfDevicePostEvent
WdfDeviceQueryInterfaceProperty method
WdfDeviceQueryPropertyEx method
WdfDeviceReadFromHardware
WdfDeviceResumeIdleWithTag method
WdfDeviceStopIdleWithTag method
WdfDeviceUnmapIoSpace
WdfDeviceWdmAssignPowerFrameworkSettings method
WdfDeviceWdmDispatchIrp method
WdfDeviceWdmDispatchIrpToIoQueue method
WdfDeviceWriteToHardware
WdfFdoInitAllocAndQueryPropertyEx method
WdfFdoInitQueryPropertyEx method
TOC
目次を折りたたむ
目次を展開する

WdfDeviceAddQueryInterface メソッド

The WdfDeviceAddQueryInterface method creates a driver-defined interface that other drivers can query and use.

構文

NTSTATUS WdfDeviceAddQueryInterface(
  [in]  WDFDEVICE Device,
  [in]  PWDF_QUERY_INTERFACE_CONFIG InterfaceConfig
);

パラメーター

Device [in]

A handle to a framework device object.

InterfaceConfig [in]

A pointer to a driver-allocated WDF_QUERY_INTERFACE_CONFIG structure that describes the interface.

戻り値

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

リターン コード説明
STATUS_INVALID_DEVICE_REQUEST

The method was called at the wrong IRQL.

STATUS_INVALID_PARAMETER

An input parameter (possibly including members of the WDF_QUERY_INTERFACE_CONFIG structure) was invalid.

STATUS_INFO_LENGTH_MISMATCH

The size of the WDF_QUERY_INTERFACE_CONFIG structure was incorrect.

STATUS_INSUFFICIENT_RESOURCES

There was insufficient memory.

 

For a list of additional return values, see Framework Object Creation Errors.

This method might also return other NTSTATUS values.

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

解説

Drivers that create driver-defined interfaces typically call WdfDeviceAddQueryInterface from within an EvtDriverDeviceAdd or EvtDevicePrepareHardware callback function.

After a driver calls WdfDeviceAddQueryInterface to create a driver-defined interface, another framework-based driver can access the interface by calling WdfFdoQueryForInterface.

For more information about driver-defined interfaces, see Using Driver-Defined Interfaces.

The following code example is from the Toaster sample bus driver. This example creates a driver-defined interface that uses the toaster sample's TOASTER_INTERFACE_STANDARD structure.

typedef struct _TOASTER_INTERFACE_STANDARD {
 INTERFACE  InterfaceHeader;
  PTOASTER_GET_CRISPINESS_LEVEL  GetCrispinessLevel;
  PTOASTER_SET_CRISPINESS_LEVEL  SetCrispinessLevel;
  PTOASTER_IS_CHILD_PROTECTED  IsSafetyLockEnabled;
} TOASTER_INTERFACE_STANDARD, *PTOASTER_INTERFACE_STANDARD;

TOASTER_INTERFACE_STANDARD  ToasterInterface;
WDF_QUERY_INTERFACE_CONFIG  qiConfig;

//
// Initialize the ToasterInterface structure.
//
RtlZeroMemory(
              &ToasterInterface,
              sizeof(ToasterInterface)
              );

ToasterInterface.InterfaceHeader.Size = sizeof(ToasterInterface);
ToasterInterface.InterfaceHeader.Version = 1;
ToasterInterface.InterfaceHeader.Context = (PVOID)hChild;

ToasterInterface.InterfaceHeader.InterfaceReference =
        WdfDeviceInterfaceReferenceNoOp;
ToasterInterface.InterfaceHeader.InterfaceDereference =
        WdfDeviceInterfaceDereferenceNoOp;

ToasterInterface.GetCrispinessLevel = Bus_GetCrispinessLevel;
ToasterInterface.SetCrispinessLevel = Bus_SetCrispinessLevel;
ToasterInterface.IsSafetyLockEnabled = Bus_IsSafetyLockEnabled;

//
// Initialize the qiConfig structure.
//
WDF_QUERY_INTERFACE_CONFIG_INIT(
                                &qiConfig,
                                (PINTERFACE)&ToasterInterface,
                                &GUID_TOASTER_INTERFACE_STANDARD,
                                NULL
                                );

//
// Create the interface.
//
status = WdfDeviceAddQueryInterface(
                                    hChild,
                                    &qiConfig
                                    );
if (!NT_SUCCESS(status)) {
    return status;
}

要件

バージョン

Available in version 1.0 and later versions of KMDF.

ヘッダー

Wdfqueryinterface.h (includeWdf.h)

ライブラリ

Wdf<MajorVersionNumber>000.sys (see Framework Library Versions.)

IRQL

PASSIVE_LEVEL

参照

WDF_QUERY_INTERFACE_CONFIG_INIT
WdfDeviceInterfaceReferenceNoOp
WdfDeviceInterfaceDereferenceNoOp
EvtDevicePrepareHardware
EvtDriverDeviceAdd
WDF_QUERY_INTERFACE_CONFIG
WdfFdoQueryForInterface

 

 

コミュニティの追加

追加
表示:
© 2016 Microsoft