Funzione WdfRequestWdmFormatUsingStackLocation (wdfrequest.h)

[Si applica solo a KMDF]

Il metodo WdfRequestWdmFormatUsingStackLocation formatta una richiesta di I/O copiando il contenuto di una struttura dello stack WDM I/O specificata nel percorso dello stack successivo nella richiesta.

Sintassi

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

Parametri

[in] Request

Handle per un oggetto richiesta framework.

[in] Stack

Puntatore a una struttura IO_STACK_LOCATION contenente informazioni fornite dal driver.

Valore restituito

nessuno

Osservazioni

Un controllo di bug si verifica se il driver fornisce un handle di oggetti non valido.

Il metodo WdfRequestWdmFormatUsingStackLocation copia le informazioni fornite dal parametro Stack nel percorso dello stack IRP successivo nella richiesta.

WdfRequestWdmFormatUsingStackLocation formatta la richiesta indipendentemente dal fatto che l'oggetto di destinazione I/O della richiesta sia locale o remoto.

Se si vuole impostare una routine di completamento per la richiesta, il driver deve chiamare WdfRequestSetCompletionRoutine dopo aver chiamato WdfRequestWdmFormatUsingStackLocation.

Per altre informazioni su WdfRequestWdmFormatUsingStackLocation, vedere Inoltro delle richieste di I/O.

Esempio

Nell'esempio di codice seguente viene fornita una struttura IO_STACK_LOCATION per una richiesta di I/O, imposta una funzione di callback di CompletamentoRoutine e quindi invia la richiesta a una destinazione di 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
                            );

Nell'esempio di codice seguente viene illustrato come inviare un IRP_MN_QUERY_CAPABILITIES PnP a una destinazione I/O.

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);
}

Requisiti

Requisito Valore
Piattaforma di destinazione Universale
Versione KMDF minima 1.0
Intestazione wdfrequest.h (include Wdf.h)
Libreria Wdf01000.sys (vedere Framework Library Versioning).
IRQL <=DISPATCH_LEVEL
Regole di conformità DDI DriverCreate(kmdf), InvalidReqAccess(kmdf), InvalidReqAccessLocal(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf), RequestFormattedValid(kmdf)

Vedi anche

WdfRequestSetCompletionRoutine