From: Doron Holan [MSFT] on
> In the code above
>
> WdfRequestRetrieveOutputBuffer returns value of Returns value of 0x20 . I
> am not sure if this correct
why is that not correct? I assume you mean 0x20 is assigned to
output_bufflen. that is the output buffer length passed by the caller

> Also the function
> WDF_MEMORY_DESCRIPTOR_INIT_BUFFER() :
> returns gives the following message while debugging via null modem "
> Access violation - code c0000005.*** ERROR: Module load completed but
> symbols could not be loaded for dfu.sys"

that is because you are passing a NULL pointer,
> PWDF_MEMORY_DESCRIPTOR memoryDesc = NULL;

instead, do this
WDF_MEMORY_DESCRIPTOR memoryDesc;

if this is confusing you, you need to take a step back and learn about
pointers and C in general.

d


--

This posting is provided "AS IS" with no warranties, and confers no rights.


"Sikandar" wrote in message news:2009121714810sikandar031(a)gmail.com...
> The following code snippet:
>
> VOID
> UsbDfu_EvtIoDeviceControl(
> IN WDFQUEUE Queue,
> IN WDFREQUEST Request,
> IN size_t OutputBufferLength,
> IN size_t InputBufferLength,
> IN ULONG IoControlCode
> )
> {
>
> WDFDEVICE device;
> device = WdfIoQueueGetDevice(Queue);
> pDevContext = GetDeviceContext(device);
>
> switch(IoControlCode) {
>
> case DFU_GETSTATE :
> getstate(device ,Request);
> break;
>
> default :
> ...
> }
> }
>
>
> NTSTATUS getstate(WDFDEVICE Device,WDFREQUEST hRequest)
> {
> PURB pUrb = NULL;
> WDFMEMORY urbMemory;
> WDF_OBJECT_ATTRIBUTES objectAttribs;
> PULONG nbytes =0;
> NTSTATUS status = STATUS_SUCCESS;
> size_t output_bufflen;
> PVOID pOutBuff= NULL;
> ULONG ulInpLen;
> ULONG ulOutLen=2;
> PULONG requiredSize;
> PDEVICE_CONTEXT pDeviceContext;
> ULONG usUrbSize;
> PWDF_MEMORY_DESCRIPTOR memoryDesc = NULL;
> PWDF_USB_CONTROL_SETUP_PACKET controlSetupPacket;
> WDF_REQUEST_PARAMETERS sReqParams;
>
> usUrbSize = (USHORT)sizeof(struct
> _URB_CONTROL_VENDOR_OR_CLASS_REQUEST);
> WDF_OBJECT_ATTRIBUTES_INIT(&objectAttribs);
> objectAttribs.ParentObject = Device;
>
> pDeviceContext = GetDeviceContext(Device);
> status = WdfUsbTargetDeviceRetrieveConfigDescriptor(
> pDeviceContext->WdfUsbTargetDevice,
> NULL, &requiredSize);
>
> status = WdfMemoryCreate(
> WDF_NO_OBJECT_ATTRIBUTES,
> PagedPool,
> NULL,//POOL_TAG,
> usUrbSize,
> &urbMemory,
> NULL);
>
> if (!NT_SUCCESS(status)) {
> DbgPrint(3, ("Failed to alloc mem for urb\n"));
> status = STATUS_INSUFFICIENT_RESOURCES;
> return status;
> }
>
> //pOutBuff = (PVOID)urbMemory;
>
>
> status =
> WdfRequestRetrieveOutputBuffer(hRequest,requiredSize,//sizeof(ULONG),
> &pOutBuff,&output_bufflen);
>
> /*Returns value of 0x20 */
>
> WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(memoryDesc, pOutBuff,
> 31);//sizeof(pOutBuff));
>
> /*Return Access violation - code c0000005 */
>
> WDF_USB_CONTROL_SETUP_PACKET_INIT_CLASS(&controlSetupPacket,
> BMREQUEST_DEVICE_TO_HOST,
> BMREQUEST_TO_INTERFACE,//BMREQUEST_TO_ENDPOINT,//BMREQUEST_TO_DEVICE,//
> BMREQUEST_TO_OTHER,//
> DFU_GETSTATE,// Request(DFU_DETACH,DFU_DNLOAD etc)
> 0, //value
> 0); //Index
>
> status = WdfUsbTargetDeviceSendControlTransferSynchronously(//Device,
> pDeviceContext->WdfUsbTargetDevice,
> NULL,
> NULL,
> &controlSetupPacket,
> memoryDesc,//NULL,
> NULL);// &nbytes);
>
> if (!NT_SUCCESS(status)) {
> DbgPrint(3, ("WdfIoTargetSendInternalIoctlSynchronously Failed \
> with error 0x%x\n",status));
> return status;
> }
> return status;
>
> }
>
> In the code above
>
> WdfRequestRetrieveOutputBuffer returns value of Returns value of 0x20 . I
> am not sure if this correct
>
> Also the function
> WDF_MEMORY_DESCRIPTOR_INIT_BUFFER() :
> returns gives the following message while debugging via null modem "
> Access violation - code c0000005.*** ERROR: Module load completed but
> symbols could not be loaded for dfu.sys"
>
>
>
> Please help me with your replies,
> Regards,
> Sikandar
>
>
>
>
>
>
>
>
>
>
>
> Submitted via EggHeadCafe - Software Developer Portal of Choice
> Silverlight Modal Dialog With Custom User Controls
> http://www.eggheadcafe.com/tutorials/aspnet/a01af6c8-c067-4fdd-bc01-d47cf3410feb/silverlight-modal-dialog.aspx