-
-
WDF如何发送URB请求
-
发表于:
2012-12-12 16:32
4455
-
原来基于WDM的驱动大量使用URB, 现在有一个逻辑,需要在prepareHarware(原来是startDevice)的时候,主动给设备发送发送一点东西,发送的是URB请求。
现在我的做法如下,但是在执行WdfUsbTargetPipeSendUrbSynchronously时发生了崩溃, dump文件经分析后,也没看到啥价值.就是wdfFunctions[**]();崩溃.
求wdf可替代方案
URB urb;
NTSTATUS ntStatus = STATUS_SUCCESS;
PURB pUrb = &urb;
PDEVICE_CONTEXT pDevContext;
WDFUSBPIPE stUSBPipe;
RtlZeroMemory(pUrb,sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST));
pUrb->UrbHeader.Length = sizeof(struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST);
pUrb->UrbHeader.Function = URB_FUNCTION_VENDOR_DEVICE;
pUrb->UrbControlVendorClassRequest.TransferBufferLength = ptr->Length;
pUrb->UrbControlVendorClassRequest.TransferBuffer = ptr->Data;
pUrb->UrbControlVendorClassRequest.Request = 0xA3;
pUrb->UrbControlVendorClassRequest.Value = ptr->Address;
pUrb->UrbControlVendorClassRequest.Index = 0;
pDevContext = CyGetDeviceContext(device);
stUSBPipe = WdfUsbInterfaceGetConfiguredPipe(WdfUsbTargetDeviceGetInterface(pDevContext->CyUsbDevice, 0), 0, NULL);
return WdfUsbTargetPipeSendUrbSynchronously(stUSBPipe, NULL, WDF_NO_SEND_OPTIONS, pUrb);
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!