Hi All,
I am getting this exception in my USB-SERIAL KMDF driver, when I tried to read from certain "Vendor commands" and when VERIFIER is on.
Strange, this issue is not coming if verifier is disabled.
WARNING: This break is not a step/trace completion.
The last command has been cleared to prevent
accidental continuation of this unrelated event.
Check the event, location and thread before resuming.
Break instruction exception - code 80000003 (first chance)
nt!DbgBreakPoint:
It is occurring @ WdfUsbTargetDeviceSendControlTransferSynchronously
Initially I thought, it because of "pData" being passed directly to "WDF_MEMORY_DESCRIPTOR_INIT_BUFFER".
I am now using memoryHandle instead. Still this keeps occurring.
Any additional processing required to overcome this?
Below is code part which is causing the exception:
STSTATUS
Usb_GetVendor(
IN PDEVICE_EXTENSION deviceExtension,
IN UCHAR request,
IN USHORT value,
OUT PULONG length,
OUT PVOID pData
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
PURB urb;
ULONG siz = 0;
UCHAR ChannelNumber;
WDFMEMORY wdfUrbHandle;
ULONG nbytes;
WDF_USB_CONTROL_SETUP_PACKET controlSetupPacket;
WDF_MEMORY_DESCRIPTOR memoryDesc;
WDF_OBJECT_ATTRIBUTES objectAttribs;
WDF_REQUEST_SEND_OPTIONS sendOptions;
WDFMEMORY memoryHandle = NULL;
WDF_OBJECT_ATTRIBUTES_INIT(&objectAttribs);
objectAttribs.ParentObject = deviceExtension->UsbDevice;
WDF_REQUEST_SEND_OPTIONS_INIT(&sendOptions,
WDF_REQUEST_SEND_OPTION_TIMEOUT
);
WDF_REQUEST_SEND_OPTIONS_SET_TIMEOUT(&sendOptions,
(5 * -1 * WDF_TIMEOUT_TO_SEC)
);
switch(request) {
case IOCTL_SER_GET_BAUDRATE: siz = sizeof(SERIAL_BAUD_RATE);
break;
case IOCTL_SER_GET_MDMSTS: siz = 1; //sizeof(ULONG);
break;
case IOCTL_SER_GET_LINE_CTL: siz = 2; //sizeof(SERIAL_LINE_CONTROL);
break;
case IOCTL_SER_GET_CHARS: siz = sizeof(SERIAL_CHARS);
break;
case IOCTL_SER_GET_FLOW: siz = sizeof(SERIAL_HANDFLOW); //0x10
break;
default:
ntStatus = STATUS_INVALID_PARAMETER;
return ntStatus;
}
ntStatus = WdfMemoryCreate(NULL,
NonPagedPool,
POOL_TAG,
siz,
&memoryHandle,
NULL);
if (!NT_SUCCESS(ntStatus)) {
return ntStatus;
}
WDF_USB_CONTROL_SETUP_PACKET_INIT_VENDOR(
&controlSetupPacket,
BmRequestDeviceToHost,
BmRequestToDevice,
request,
value,
0
);
//WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(
WDF_MEMORY_DESCRIPTOR_INIT_HANDLE(
&memoryDesc,
memoryHandle,
NULL
);
ntStatus = WdfUsbTargetDeviceSendControlTransferSynchronously(deviceExtension->UsbDevice,
WDF_NO_HANDLE,//NULL,
&sendOptions,
&controlSetupPacket,
&memoryDesc,
&nbytes
);
if (!NT_SUCCESS(ntStatus)) {
DbgPrint("WdfIoTargetSendInternalIoctlSynchronously Request=0x%x Value=0x%x Status=0x%x \n", request, value, ntStatus);
WdfObjectDelete(memoryHandle);
return ntStatus;
}
if(siz && nbytes)
RtlCopyMemory(pData, memoryHandle, siz);
WdfObjectDelete(memoryHandle);
DbgPrint("exit Usb_GetVendor Request=0x%x Value=0x%x Status=0x%x \n", request, value, ntStatus);
return ntStatus;
}