Condividi tramite


IOCTL_WRITE_REGISTERS IOCTL (usbscan.h)

Scrive nei registri dei dispositivi USB, usando la pipe di controllo.

Codice principale

IRP_MJ_DEVICE_CONTROL

Buffer di input

Puntatore a una struttura IO_BLOCK .

Lunghezza del buffer di input

Dimensioni del buffer di input.

Buffer di output

NULL

Lunghezza del buffer di output

Zero

Blocco dello stato

Irp->IoStatus.Status è impostato su STATUS_SUCCESS se la richiesta ha esito positivo. In caso contrario, stato alla condizione di errore appropriata come codice NTSTATUS .

Commenti

Parametri DeviceIoControl

Quando la funzione DeviceloControl viene chiamata con il codice di controllo I/O IOCTL_WRITE_REGISTERS, il chiamante deve specificare l'indirizzo di una struttura IO_BLOCK come parametro lpInBuffer della funzione.

Usando il contenuto del IO_BLOCK, il driver in modalità kernel crea un oggetto ODBC che contiene una struttura _URB_CONTROL_VENDOR_OR_CLASS_REQUEST .

La tabella seguente indica i valori assegnati ai membri della struttura _URB_CONTROL_VENDOR_OR_CLASS_REQUEST.

Membro struttura Valore sssigned
TransferFlags 0
TransferBufferLength pIoBlock-uLength>
TransferBuffer pIoBlock-pbyData>
TransferBufferMDL NULL
RequestTypeReservedBits 0x40
Richiesta (pIoBlock->uLength> 1) ? 0x04 : 0x0C
Valore (SHORT) pIoBlock-uOffset>
Index pIoBlock-uIndex>

Per altre informazioni, vedere Accesso ai driver Kernel-Mode per i dispositivi ancora immagine.

DWORD             cbRet;
BOOL              bRet;
IO_BLOCK          IoBlock;
OVERLAPPED        overlapped;

IoBlock.uOffset = (BYTE)byOffset;
IoBlock.uLength = (BYTE)byNbOfReg;
IoBlock.pbyData = pbyData;

memset(&overlapped, 0, sizeof(OVERLAPPED));
overlapped.hEvent =
    CreateEvent(NULL,    // pointer to security attributes
                         // WIN95 ignores this parameter
                FALSE,   // automatic reset
                FALSE,   // initialize to not signaled
                NULL);   // pointer to the event-object name

bRet = DeviceIoControl( DeviceHandle,
                        (DWORD) IOCTL_WRITE_REGISTERS,
                        &IoBlock,
                        sizeof(IO_BLOCK),
                        NULL,
                        0,
                        &cbRet,
                        &overlapped);

if( bRet == TRUE )
{
    WaitForSingleObject(overlapped.hEvent, INFINITE);
    // we do not the test, the result is zero
}

CloseHandle(overlapped.hEvent);

Requisiti

Requisito Valore
Intestazione usbscan.h (include Usbscan.h)