Partager via


UsbDbgPdd_Ioctl (Compact 2013)

10/16/2014

Implement this function to deliver buffer information to the model device driver (MDD).

Syntax

extern "C" BOOL UsbDbgPdd_Ioctl(
    DWORD ioControlCode,
    LPVOID lpInBuffer,
    DWORD  cbInBufferSize,
    LPVOID lpOutBuffer,
    DWORD  cbOutBufferSize,
    LPDWORD lpBytesReturned
    )

Parameters

  • lpInBuffer
    [in] Incoming buffer.
  • cbInBufferSize
    [in] Incoming buffer size in bytes.
  • lpOutBuffer
    [out] Outgoing buffer in bytes.
  • cbOutBufferSize
    [out] Outgoing buffer size in bytes.
  • lpBytesReturned
    [out] The size of the returned data in bytes.

Return Value

Implement this function to return TRUE if the IOCTL is supported; otherwise, return FALSE.

Remarks

The MDD uses the default implementation of an IOCTL if the platform-dependent device driver (PDD) returns FALSE.

Example

The following example shows a typical implementation of the UsbDbgPdd_Ioctl function.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

extern "C" BOOL UsbDbgPdd_Ioctl(
    DWORD ioControlCode,        /* USBDBG_PDD_IOCTL */
    LPVOID lpInBuffer,          /* incoming buffer */
    DWORD  cbInBufferSize,      /* incoming buffer size */
    LPVOID lpOutBuffer,         /* outgoing buffer */
    DWORD  cbOutBufferSize,     /* outgoing buffer size */
    LPDWORD lpBytesReturned     /* outgoing buffer filled */
    )
{
    USBDBGMSG(USBDBG_ZONE_FUNC, (L"usbdbgpdd: +UsbDbgPdd_Ioctl\r\n"));

    switch (ioControlCode)
    {
        // return maxpacket size for an endpoint
        case USBDBG_PDD_IOCTL_ENDPT_MAXPACKETSIZE:
            if (lpInBuffer && lpOutBuffer)
            {
                DWORD endPtNum = *((DWORD*)lpInBuffer);
                if (endPtNum == 0)
                {
                    *((UINT32*)lpOutBuffer) = USB_FULL_HIGH_SPEED_CONTROL_MAX_PACKET_SIZE;
                }
                else
                {
                    *((UINT32*)lpOutBuffer) = USB_HIGH_SPEED_BULK_MAX_PACKET_SIZE;
                }
                return  TRUE;
            }
            break;

        case USBDBG_PDD_IOCTL_MANUFACTURER_STRING:
            if (lpOutBuffer)
            {
                *((USB_STRING**)(lpOutBuffer)) = (USB_STRING*) &m_Manufacturer;
                return  TRUE;
             }
            break;

        case USBDBG_PDD_IOCTL_PRODUCT_STRING:
            if (lpOutBuffer)
            {
                *((USB_STRING**)(lpOutBuffer)) = (USB_STRING*) &m_Product;
                return  TRUE;
             }
            break;
    }

    USBDBGMSG(USBDBG_ZONE_FUNC, (L"usbdbgpdd: -UsbDbgPdd_Ioctl\r\n"));
    return FALSE;
}

Requirements

Header

UsbDbgDdsi.h

See Also

Reference

USBDBG PDD Functions