共用方式為


WdfRequestWdmFormatUsingStackLocation 函式 (wdfrequest.h)

[僅適用於 KMDF]

WdfRequestWdmFormatUsingStackLocation 方法會將指定的 WDM I/O 堆棧位置的內容複製到要求中的下一個堆疊 位置,以格式化 I/O 要求。

語法

void WdfRequestWdmFormatUsingStackLocation(
  [in] WDFREQUEST         Request,
  [in] PIO_STACK_LOCATION Stack
);

參數

[in] Request

架構要求物件的句柄。

[in] Stack

包含驅動程式所提供資訊之 IO_STACK_LOCATION 結構的指標。

傳回值

沒有

言論

如果驅動程式提供無效的物件句柄,就會發生錯誤檢查。

WdfRequestWdmFormatUsingStackLocation 方法會將 Stack 參數所提供的資訊複製到要求的下一個 IRP 堆棧位置。

WdfRequestWdmFormatUsingStackLocation 將要求格式化,而不論要求的 I/O 目標對像是本機還是遠端。

如果您想要設定要求的完成例程,驅動程式必須在呼叫 WdfRequestWdmFormatUsingStackLocation之後呼叫 WdfRequestSetCompletionRoutine

如需 WdfRequestWdmFormatUsingStackLocation的詳細資訊,請參閱 轉送 I/O 要求

例子

下列程式代碼範例提供 I/O 要求的 IO_STACK_LOCATION 結構、設定 CompletionRoutine 回呼函式,然後將要求傳送至 I/O 目標。

IO_STACK_LOCATION  ioStackLocation;
BOOLEAN sendStatus;
...
//
// Initialize the IO_STACK_LOCATION structure here.
//
...
//
// Assign the IO_STACK_LOCATION structure to the request.
//
WdfRequestWdmFormatUsingStackLocation(
                                      request,
                                      &ioStackLocation
                                      );
//
// Assign a CompletionRoutine callback function.
//
WdfRequestSetCompletionRoutine(
                               Request,
                               RequestTimeoutComplete,
                               NULL
                               );
//
// Send the request.
//
sendStatus = WdfRequestSend(
                            Request,
                            target,
                            NULL
                            );

下列程式代碼範例說明如何將 PnP IRP_MN_QUERY_CAPABILITIES IRP 傳送至 IO 目標。

target = WdfDeviceGetIoTarget(Device);
status = WdfRequestCreate(WDF_NO_OBJECT_ATTRIBUTES,
                          target,
                          &request);

if (!NT_SUCCESS(status)) {
    // Log failure and leave
}

//
// PnP IRPs must be initialized with STATUS_NOT_SUPPORTED
//
WDF_REQUEST_REUSE_PARAMS_INIT(&reuse,
                              WDF_REQUEST_REUSE_NO_FLAGS,
                              STATUS_NOT_SUPPORTED);

WdfRequestReuse(request, &reuse);


//
// Initialize device capabilities
//
RtlZeroMemory(Capabilities, sizeof(DEVICE_CAPABILITIES));
Capabilities->Size = sizeof(DEVICE_CAPABILITIES);
Capabilities->Version  =  1;
Capabilities->Address  = (ULONG) -1;
Capabilities->UINumber = (ULONG) -1;
RtlZeroMemory(&stack, sizeof(stack));
stack.MajorFunction = IRP_MJ_PNP;
stack.MinorFunction = IRP_MN_QUERY_CAPABILITIES;
stack.Parameters.DeviceCapabilities.Capabilities = Capabilities;

WdfRequestWdmFormatUsingStackLocation(request, &stack);

WDF_REQUEST_SEND_OPTIONS_INIT(&options,
                              WDF_REQUEST_SEND_OPTION_SYNCHRONOUS);

if (WdfRequestSend(request, target, &options) == FALSE) {
    // Log failure
}

status = WdfRequestGetStatus(request);

if (!NT_SUCCESS(status)) {
    // Log failure
}

// Remember to delete the WDFREQUEST after creating it
if (request != NULL) {
    WdfObjectDelete(request);
}

要求

要求 價值
目標平臺 普遍
最低 KMDF 版本 1.0
標頭 wdfrequest.h (包括 Wdf.h)
連結庫 Wdf01000.sys (請參閱架構連結庫版本控制。)
IRQL <=DISPATCH_LEVEL
DDI 合規性規則 DriverCreate(kmdf)InvalidReqAccess(kmdf)InvalidReqAccessLocal(kmdf)KmdfIrql(kmdf)KmdfIrql2(kmdf),KmdfIrqlExplicit(kmdf),RequestFormattedValid(kmdf)

另請參閱

WdfRequestSetCompletionRoutine