Bewerken

Delen via


IPnpCallbackHardware::OnPrepareHardware method (wudfddi.h)

[Warning: UMDF 2 is the latest version of UMDF and supersedes UMDF 1. All new UMDF drivers should be written using UMDF 2. No new features are being added to UMDF 1 and there is limited support for UMDF 1 on newer versions of Windows 10. Universal Windows drivers must use UMDF 2. For more info, see Getting Started with UMDF.]

The OnPrepareHardware method notifies a driver to make the specified hardware accessible.

Syntax

HRESULT OnPrepareHardware(
  [in] IWDFDevice *pWdfDevice
);

Parameters

[in] pWdfDevice

A pointer to the IWDFDevice interface for the device object of the device to make accessible.

Return value

OnPrepareHardware returns S_OK if the operation succeeds. Otherwise, this method returns one of the error codes defined in Winerror.h. Do not return HRESULT_FROM_NT(STATUS_NOT_SUPPORTED).

If OnPrepareHardware returns an error code, the framework will still call the IPnpCallbackHardware::OnReleaseHardware method. The OnReleaseHardware method can then free resources that were allocated during the call to OnPrepareHardware. Because OnReleaseHardware must free resources for both success and failure cases of OnPrepareHardware, it must be able to handle the cleanup of partial resources.

This method must use the HRESULT_FROM_NT macro to return a specific HRESULT value to return status to a kernel-mode client. For more information, see Supporting Kernel-mode Clients.

Remarks

A driver registers the IPnpCallbackHardware interface when it calls the IWDFDriver::CreateDevice method to create a device object.

Receiving a call to the OnPrepareHardware method is equivalent to a Microsoft Windows Driver Model (WDM) driver receiving an IRP_MN_START_DEVICE IRP.

For more information, see Finding and Mapping Hardware Resources in a UMDF Driver.

Requirements

Requirement Value
Target Platform Windows
Header wudfddi.h (include Wudfddi.h)

See also

IPnpCallbackHardware

IPnpCallbackHardware2::OnPrepareHardware

IPnpCallbackHardware::OnReleaseHardware

IRP_MN_START_DEVICE

IWDFDevice

IWDFDriver::CreateDevice