Condividi tramite


Funzione WdfRequestWdmFormatUsingStackLocation (wdfrequest.h)

[Si applica solo a KMDF]

Il metodo WdfRequestWdmFormatUsingStackLocation formatta una richiesta di I/O copiando il contenuto di un percorso dello stack I/O specificato struttura nello 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 che contiene informazioni fornite dal driver.

Valore restituito

Nessuno

Osservazioni

Se il driver fornisce un handle di oggetto non valido, si verifica un controllo di bug.

Il metodo WdfRequestWdmFormatUsingStackLocation copia le informazioni fornite dal parametro Stack nella posizione successiva dello stack IRP nella richiesta.

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

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

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

Esempi

L'esempio di codice seguente fornisce una struttura IO_STACK_LOCATION per una richiesta di I/O, imposta un CompletionRoutine funzione di callback 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 protocollo PnP IRP_MN_QUERY_CAPABILITIES IRP 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);
}

Fabbisogno

Requisito Valore
piattaforma di destinazione Universale
versione minima di KMDF 1.0
intestazione wdfrequest.h (include Wdf.h)
libreria Wdf01000.sys (vedere Controllo delle versioni della libreria framework).
IRQL <=DISPATCH_LEVEL
regole di conformità DDI DriverCreate(kmdf), InvalidReqAccess(kmdf), InvalidReqAccessLocal(kmdf), KmdfIrql(kmdf), KmdfIrql2(kmdf), KmdfIrqlExplicit(kmdf), RequestFormattedValid(kmdf)

Vedere anche

WdfRequestSetCompletionRoutine