##############IoGetDeviceInterface

Hi all,
I am using IoGetDeviceInterfaces to enumerate all the
USB devices in the system with the flag set as
DEVICE_INTERFACE_INCLUDE_NONACTIVE and the GUID as
GUID_DEVCLASS_USB.
But I am getting an empty string in return always.
I am using this function call from the
IRP_MJ_PNP/IRP_MN_START_DEVICE of my upper disk filter
driver.
Here’s my source code:

ntStatus = IoGetDeviceInterfaces(
&GUID_DEVCLASS_USB,
NULL,
DEVICE_INTERFACE_INCLUDE_NONACTIVE,
&symList
);

if(NT_SUCCESS(ntStatus))
{
if( *symList != UNICODE_NULL )
{
RtlInitUnicodeString( &symName, symList );
DbgPrint(“symName is %wZ\n”,symName.Buffer);
}
}

**Please, could anybody point out what’s wrong here?

regards
V.S.


Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com

I may be wrong here as i have never used %wZ but my guess is that %wZ
expects a unicode string itself and not Buffer. Instead of %wZ try %ws and
see what happens.
Also symList contains a list of NULL terminated strings but i guess you are
printing only the first one for experiment sake only?


Pankaj Garg
This posting is provided “AS IS” with no warranties and confers no rights.

“vartika Singh” wrote in message
news:xxxxx@windbg…
> Hi all,
> I am using IoGetDeviceInterfaces to enumerate all the
> USB devices in the system with the flag set as
> DEVICE_INTERFACE_INCLUDE_NONACTIVE and the GUID as
> GUID_DEVCLASS_USB.
> But I am getting an empty string in return always.
> I am using this function call from the
> IRP_MJ_PNP/IRP_MN_START_DEVICE of my upper disk filter
> driver.
> Here’s my source code:
>
>
> ntStatus = IoGetDeviceInterfaces(
> &GUID_DEVCLASS_USB,
> NULL,
> DEVICE_INTERFACE_INCLUDE_NONACTIVE,
> &symList
> );
>
> if(NT_SUCCESS(ntStatus))
> {
> if( *symList != UNICODE_NULL )
> {
> RtlInitUnicodeString( &symName, symList );
> DbgPrint(“symName is %wZ\n”,symName.Buffer);
> }
> }
>
> **Please, could anybody point out what’s wrong here?
>
> regards
> V.S.
>
>
>
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.com
>
>

“%wZ” is a format qualifier for PUNICODE_STRING, “%ws” is format qualifier
for LPWSTR. E.g. DbgPrint(“symName is %wZ\n”, &symName).
Note that DbgPrint(“WRONG. WILL TRIGG BSOD: symName is %ws\n”,
symName.Buffer) will sooner or latter trigger BSOD on your system, because
there is no guarantee that UNICODE_STRING is zero terminated.
The same is true for all DDK structs that have name length as their member
(e.g. FILE_NAME_INFORMATION).
WBR Primoz

-----Original Message-----
From: Pankaj Garg [mailto:xxxxx@hotmail.com]
Sent: Tuesday, October 05, 2004 9:32 PM
To: Kernel Debugging Interest List
Subject: Re:[windbg] ##############IoGetDeviceInterface

I may be wrong here as i have never used %wZ but my guess is that %wZ
expects a unicode string itself and not Buffer. Instead of %wZ try %ws and
see what happens.
Also symList contains a list of NULL terminated strings but i guess you are
printing only the first one for experiment sake only?


Pankaj Garg
This posting is provided “AS IS” with no warranties and confers no rights.

“vartika Singh” wrote in message
news:xxxxx@windbg…
> Hi all,
> I am using IoGetDeviceInterfaces to enumerate all the
> USB devices in the system with the flag set as
> DEVICE_INTERFACE_INCLUDE_NONACTIVE and the GUID as
> GUID_DEVCLASS_USB.
> But I am getting an empty string in return always.
> I am using this function call from the
> IRP_MJ_PNP/IRP_MN_START_DEVICE of my upper disk filter
> driver.
> Here’s my source code:
>
>
> ntStatus = IoGetDeviceInterfaces(
> &GUID_DEVCLASS_USB,
> NULL,
> DEVICE_INTERFACE_INCLUDE_NONACTIVE,
> &symList
> );
>
> if(NT_SUCCESS(ntStatus))
> {
> if( *symList != UNICODE_NULL )
> {
> RtlInitUnicodeString( &symName, symList );
> DbgPrint(“symName is %wZ\n”,symName.Buffer);
> }
> }
>
> **Please, could anybody point out what’s wrong here?
>
> regards
> V.S.
>
>
>
> _______________________________
> Do you Yahoo!?
> Declare Yourself - Register online to vote today!
> http://vote.yahoo.com
>
>


You are currently subscribed to windbg as: xxxxx@hermes.si
To unsubscribe send a blank email to xxxxx@lists.osr.com

I understand the point. I just wanted him to use %ws to see if it works. The
original usage below of passing the actual buffer contained in the
UNICODE_STRING for %wZ is wrong because %wZ expects a pointer to the
UNICODE_STRING itself and not the buffer pointed by it.

Am i correct here or missing something?

“Primoz Beltram” wrote in message
news:xxxxx@windbg…
> “%wZ” is a format qualifier for PUNICODE_STRING, “%ws” is format qualifier
> for LPWSTR. E.g. DbgPrint(“symName is %wZ\n”, &symName).
> Note that DbgPrint(“WRONG. WILL TRIGG BSOD: symName is %ws\n”,
> symName.Buffer) will sooner or latter trigger BSOD on your system, because
> there is no guarantee that UNICODE_STRING is zero terminated.
> The same is true for all DDK structs that have name length as their member
> (e.g. FILE_NAME_INFORMATION).
> WBR Primoz
>
> -----Original Message-----
> From: Pankaj Garg [mailto:xxxxx@hotmail.com]
> Sent: Tuesday, October 05, 2004 9:32 PM
> To: Kernel Debugging Interest List
> Subject: Re:[windbg] ##############IoGetDeviceInterface
>
> I may be wrong here as i have never used %wZ but my guess is that %wZ
> expects a unicode string itself and not Buffer. Instead of %wZ try %ws and
> see what happens.
> Also symList contains a list of NULL terminated strings but i guess you
are
> printing only the first one for experiment sake only?
>
> –
> Pankaj Garg
> This posting is provided “AS IS” with no warranties and confers no rights.
>
> “vartika Singh” wrote in message
> news:xxxxx@windbg…
> > Hi all,
> > I am using IoGetDeviceInterfaces to enumerate all the
> > USB devices in the system with the flag set as
> > DEVICE_INTERFACE_INCLUDE_NONACTIVE and the GUID as
> > GUID_DEVCLASS_USB.
> > But I am getting an empty string in return always.
> > I am using this function call from the
> > IRP_MJ_PNP/IRP_MN_START_DEVICE of my upper disk filter
> > driver.
> > Here’s my source code:
> >
> >
> > ntStatus = IoGetDeviceInterfaces(
> > &GUID_DEVCLASS_USB,
> > NULL,
> > DEVICE_INTERFACE_INCLUDE_NONACTIVE,
> > &symList
> > );
> >
> > if(NT_SUCCESS(ntStatus))
> > {
> > if( *symList != UNICODE_NULL )
> > {
> > RtlInitUnicodeString( &symName, symList );
> > DbgPrint(“symName is %wZ\n”,symName.Buffer);
> > }
> > }
> >
> > **Please, could anybody point out what’s wrong here?
> >
> > regards
> > V.S.
> >
> >
> >
> > _______________________________
> > Do you Yahoo!?
> > Declare Yourself - Register online to vote today!
> > http://vote.yahoo.com
> >
> >
>
>
>
> —
> You are currently subscribed to windbg as: xxxxx@hermes.si
> To unsubscribe send a blank email to xxxxx@lists.osr.com
>
>