Thx, I’ll take a look at the 2 paths and see what is going on.
d
– I can spell, I just can’t type.
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Larry Bovie
Sent: Monday, June 05, 2006 10:43 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] WdfUsbTargetDeviceQueryString returns
STATUS_UNSUCCESSFUL for iSerialNumber
‘0’, not ‘\0’.
My workaround (be gentle, it’s Friday afternoon work following
significant thrashing about in the morning):
//inside EvtDevicePrepareHardware I read up the serial number // after
having retrieved the device descriptor:
status = usbStringDescRead( devExt, devExt->UsbDevDesc->iSerialNumber,
&userial);
NTSTATUS usbStringDescRead(PMCCUSB_DEVICE devExt, UCHAR istring,
PUNICODE_STRING ustring)
{
NTSTATUS status = STATUS_UNSUCCESSFUL;
USHORT nChars=0;
PUSHORT strBuffer=NULL;
URB urb;
USHORT data[65]; //a little overkill, expect string lengths < 16
LANGID langid=0x0409; //english
RtlZeroMemory(data, sizeof(data));
UsbBuildGetDescriptorRequest( &urb,
sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
USB_STRING_DESCRIPTOR_TYPE,
istring,
langid,
data,
NULL,
sizeof(data),
NULL);
status = WdfUsbTargetDeviceSendUrbSynchronously( devExt->UsbDevice,
NULL,
NULL,
&urb);
//…
return status;
}
(I know, don’t allocate buffers off the stack and avoid magic numbers. I
only intended to check that I could read back the descriptor strings. )
The offending code (which still demonstrates the problem) includes:
WDFMEMORY huserial;
USHORT userialLen;
status = WdfUsbTargetDeviceAllocAndQueryString(
devExt->UsbDevice,
WDF_NO_OBJECT_ATTRIBUTES,
&huserial,
&userialLen,
devExt->UsbDevDesc->iSerialNumber,
0x0409);
-Larry
Doron Holan wrote:
Is that a ‘0’ or a ‘\0’ ? It doesn’t really matter, KMDF doesn’t
validate the contents of the string anyways.
KMDF does not return STATUS_UNSUCCESSFUL from any error path in the
this DDI. The only way this could be returned is if the USB core
returned this value.
Can you send the code that you use to successfully retrieve the serial
number using WDM?
Thx
d
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Larry Bovie
Sent: Monday, June 05, 2006 8:18 AM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] WdfUsbTargetDeviceQueryString returns
STATUS_UNSUCCESSFUL for iSerialNumber
Hi Doron,
My goof. I should have reread your post this morning and checked my
own code before posting. I had it stuck in my head that your code
snippet used ‘WdfUsbTargetDeviceFormatRequestForString’. Anyways, I
had built an
URB as you described in your post and sent it down using the
‘WdfUsbTargetDeviceSendUrbSynchronously’. Nothing special to report on
the workaround.
On #3, the original Wdf function appeared to work for
iManufacturer(which was used in the help code snippet), but not for
the value I was interested in: iSerialNumber. (I hadn’t tried any
other device descriptor indices. ) Incidentally, the serial number for
the device happened to be ‘12345670’–might the trailing ‘0’ be
significant?
Thanks,
Larry
Doron Holan wrote:
> 1) you are using them as intended
> 2) there is no limitation as far as I can tell. These functions work
as
> soon as the WDFUSBDEVICE has been created for you.
> 3) maybe.
>
> Quick question for you: is your workaround WDM code doing what KMDF
is
> doing? Are you building the same type of URB and sending it down the
> stack? Or are you sending another type of URB in your workaround?
>
> d
>
> -----Original Message-----
> From: xxxxx@lists.osr.com
> [mailto:xxxxx@lists.osr.com] On Behalf Of Larry Bovie
> Sent: Monday, June 05, 2006 4:07 AM
> To: Windows System Software Devs Interest List
> Subject: Re:[ntdev] WdfUsbTargetDeviceQueryString returns
> STATUS_UNSUCCESSFUL for iSerialNumber
>
> Thanks Doron,
>
> But that’s not quite the question I was asking. Yes, pulling the
string
> values out of the device descriptor is fairly routine stuff. I had
done
> it with the WDM version of the driver, and converted that routine
> over
> for use with the WDF driver (essentially, the second option you
> mentioned below). I should have been more clear in my question.
> Actually, there were probably several implied questions that I should
> have asked:
> 1. Am I misusing WdfUsbTargetDeviceQueryString or
> WdfUsbTargetDeviceAllocateAndQueryString?
>
> 2. Is there some limitation on the 2 functions that I’ve neglected?
> Is
> there some step I need to perform to prep the target for these
> functions?
>
> 3. Is there a bug that I need to log or report against these
functions?
> As you said, this is fairly standard stuff. So, if this is what these
> functions are intended for, then why don’t they work? I have a
> “work-around”, but I still would like to know why I couldn’t use
> these
> functions.
>
> Thanks,
> Larry
>
> Doron Holan wrote:
>> This is the basice code that we use to query a string descriptor, it
> is
>> pretty standard stuff. This is assuming you pass a string buffer
>> (String) and *NumCharacters is the number of elements in String.
>>
>> PUSB_STRING_DESCRIPTOR pDescriptor;
>> PVOID buffer;
>> _URB_CONTROL_DESCRIPTOR_REQUEST urb;
>>
>> length = sizeof(USB_STRING_DESCRIPTOR) + (*NumCharacters - 1) *
>> sizeof(WCHAR);
>>
>> buffer = AllocatePool(NonPagedPool, length);
>>
>> RtlZeroMemory(buffer, length);
>> pDescriptor = (PUSB_STRING_DESCRIPTOR) buffer;
>>
>> UsbBuildGetDescriptorRequest((PURB) &urb,
>> sizeof(urb),
>> USB_STRING_DESCRIPTOR_TYPE,
>> StringIndex,
>> LangID,
>> pDescriptor,
>> NULL,
>> length,
>> NULL);
>>
>> And then we send the URB down the stack. That’s all. If you want
>> to send your own URB, you can format it and then call
>> WdfUsbTargetDeviceSendUrbSynchronously to send it for you.
>>
>> D
>>
>> – I can spell, I just can’t type.
>>
>> -----Original Message-----
>> From: xxxxx@lists.osr.com
>> [mailto:xxxxx@lists.osr.com] On Behalf Of Larry Bovie
>> Sent: Friday, June 02, 2006 7:01 AM
>> To: Windows System Software Devs Interest List
>> Subject: [ntdev] WdfUsbTargetDeviceQueryString returns
>> STATUS_UNSUCCESSFUL for iSerialNumber
>>
>> I’m trying to convert a working WDM USB driver to WDF, but am
>> running into a few hitches. One problem involves reading up the
>> serial number from the device. When calling
>> WdfUsbTargetDeviceQueryString or
>> WdfUsbTargetDeviceAllocAndQueryString, I receive STATUS_UNSUCCESSFUL
>> when supplying the iSerialNumber(=0x03) from the
> USB_DEVICE_DESCRIPTOR.
>> On the other hand, if I supply iManufacturer, both functions return
> the
>> correct strings.
>>
>> Note that my WDM driver is able read up the iSerialNumber, and
USBVIEW
>> from the DDK is able to read it, as well.
>>
>> Next, I’ll translate my WDM code over to the WDF driver…
>>
>> Meanwhile, has anyone been able to get these wdf functions to work
for
>> all the descriptor strings? Is there some undocumented magic?
>>
>> Thanks,
>> Larry
>>
>> —
>> Questions? First check the Kernel Driver FAQ at
>> http://www.osronline.com/article.cfm?id=256
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer