Issue with Querying Serial Number of USB device

Following code block used for querying the serial number

                                   try
				{
					if(Descriptor->SerialNumberOffset!=0)
					{
						memset(pszStart,0,255);
						RtlStringCopyWorkerA(pszStart,255,((char*)(UINT_PTR)Descriptor+(DWORD32)Descriptor->SerialNumberOffset),255);
						if(pszStart != ANSI_NULL)
						{
							DbgPrint("Serial Number %s ",pszStart );
						}
					}	
				}
				except (EXCEPTION_EXECUTE_HANDLER) 
				{
					/* Error handling code */
				}

But for some of device its not work correctly.
example
while checking with the device having pnp id=USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_1.00\60A44C413BF2F0718628B8E0&0
we are getting the serial no ‘0’
but checking with other tool (USBDeview) it showing serial as 60A44C413BF2F0718628B8E0
why its happen?

Nikhil_V_S wrote:

But for some of device its not work correctly.

example
while checking with the device having pnp id=USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_1.00\60A44C413BF2F0718628B8E0&0
we are getting the serial no ‘0’
but checking with other tool (USBDeview) it showing serial as 60A44C413BF2F0718628B8E0
why its happen?

You haven’t provided nearly enough information.  Is this code in an
application or in a driver, and if a driver, what kind?  Where is the
code you used to fetch the structure?  Have you dumped the whole
structure to see if the other parts look reasonable?  Are you using the
normal include files, or have you copied the struct definition into your
own code?

And, by the way, this code is wrong:

    if(pszStart != ANSI_NULL)

You’re trying to find out of the string is empty.  That means you need
to check the first character, not the ADDRESS of the first character:

    if(pszStart[0] != ANSI_NULL )

Mr. Nikhil_V_S,

You started this discussion in the A&A (administration) section.

In the future, please make some additional effort to start your discussions in the correct section.

Thanks,

Peter

@“Peter_Viscarola_(OSR)” thank you and sorry for the mistake

@Tim_Roberts said:
Nikhil_V_S wrote:

But for some of device its not work correctly.

example
while checking with the device having pnp id=USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_1.00\60A44C413BF2F0718628B8E0&0
we are getting the serial no ‘0’
but checking with other tool (USBDeview) it showing serial as 60A44C413BF2F0718628B8E0
why its happen?

You haven’t provided nearly enough information. Is this code in an
application or in a driver, and if a driver, what kind? Where is the
code you used to fetch the structure? Have you dumped the whole
structure to see if the other parts look reasonable? Are you using the
normal include files, or have you copied the struct definition into your
own code?

And, by the way, this code is wrong:

 if(pszStart != ANSI_NULL)

You’re trying to find out of the string is empty. That means you need
to check the first character, not the ADDRESS of the first character:

 if(pszStart[0] != ANSI_NULL )

@Tim_Roberts said:
Nikhil_V_S wrote:

But for some of device its not work correctly.

example
while checking with the device having pnp id=USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_1.00\60A44C413BF2F0718628B8E0&0
we are getting the serial no ‘0’
but checking with other tool (USBDeview) it showing serial as 60A44C413BF2F0718628B8E0
why its happen?

You haven’t provided nearly enough information. Is this code in an
application or in a driver, and if a driver, what kind? Where is the
code you used to fetch the structure? Have you dumped the whole
structure to see if the other parts look reasonable? Are you using the
normal include files, or have you copied the struct definition into your
own code?

And, by the way, this code is wrong:

 if(pszStart != ANSI_NULL)

You’re trying to find out of the string is empty. That means you need
to check the first character, not the ADDRESS of the first character:

 if(pszStart[0] != ANSI_NULL )

@Tim_Roberts said:
Nikhil_V_S wrote:

But for some of device its not work correctly.

example
while checking with the device having pnp id=USBSTOR\DISK&VEN_KINGSTON&PROD_DATATRAVELER_2.0&REV_1.00\60A44C413BF2F0718628B8E0&0
we are getting the serial no ‘0’
but checking with other tool (USBDeview) it showing serial as 60A44C413BF2F0718628B8E0
why its happen?

You haven’t provided nearly enough information. Is this code in an
application or in a driver, and if a driver, what kind? Where is the
code you used to fetch the structure? Have you dumped the whole
structure to see if the other parts look reasonable? Are you using the
normal include files, or have you copied the struct definition into your
own code?

And, by the way, this code is wrong:

 if(pszStart != ANSI_NULL)

You’re trying to find out of the string is empty. That means you need
to check the first character, not the ADDRESS of the first character:

 if(pszStart[0] != ANSI_NULL )

Is there any way to find the PUSBDEVICEINFO in file system driver

Nikhil_V_S wrote:

Is there any way to find the PUSBDEVICEINFO in file system driver

USBDEVICEINFO is a structure that is internal to the USBView
application.  It’s not a system-defined structure at all.

A file system driver is not supposed to know anything about nor make any
assumptions about the underlying hardware.