Can someone help to print a UNICODE_STRING to the debig window?
The string is in POBJECT_ATTRIBUTES ObjectAttributes
ObjectAttributes->ObjectName

I believe this is correct so far?

But how can I print it, can I use DbgPrint ?

DbgPrint(("message %s \n", buffer ));

but buffer is normally ansi

Thanks

Re: How can I DbgPrint a UNICODE_STRING ? by Don

Don
Thu Oct 13 19:40:11 CDT 2005

Use %wZ this is the format specifier for a UNICODE_STRING.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply



<Essie> wrote in message news:OcCWCPF0FHA.3660@TK2MSFTNGP15.phx.gbl...
> Can someone help to print a UNICODE_STRING to the debig window?
> The string is in POBJECT_ATTRIBUTES ObjectAttributes
> ObjectAttributes->ObjectName
>
> I believe this is correct so far?
>
> But how can I print it, can I use DbgPrint ?
>
> DbgPrint(("message %s \n", buffer ));
>
> but buffer is normally ansi
>
> Thanks
>
>



Re: How can I DbgPrint a UNICODE_STRING ? by Thomas

Thomas
Thu Oct 13 19:51:36 CDT 2005


"Don Burn" <burn@stopspam.acm.org> wrote in message
news:uR70hfF0FHA.1256@TK2MSFTNGP09.phx.gbl...
> Use %wZ this is the format specifier for a UNICODE_STRING.
>

Don,

Did you mean %ws, or have I overlooked one more new thing?

Thos

>
> --
> Don Burn (MVP, Windows DDK)
> Windows 2k/XP/2k3 Filesystem and Driver Consulting
> Remove StopSpam from the email to reply
>
>
>
> <Essie> wrote in message news:OcCWCPF0FHA.3660@TK2MSFTNGP15.phx.gbl...
>> Can someone help to print a UNICODE_STRING to the debig window?
>> The string is in POBJECT_ATTRIBUTES ObjectAttributes
>> ObjectAttributes->ObjectName
>>
>> I believe this is correct so far?
>>
>> But how can I print it, can I use DbgPrint ?
>>
>> DbgPrint(("message %s \n", buffer ));
>>
>> but buffer is normally ansi
>>
>> Thanks
>>
>>
>
>


Re: How can I DbgPrint a UNICODE_STRING ? by Bill

Bill
Thu Oct 13 20:12:05 CDT 2005

He meant %wZ and it isn't new, but it didn't used to be documented. Several
of the DDK samples use it.

Now it is documented with KdPrint(Ex) and DbgPrint(Ex) and the following
quote is interesting:

"The Format string supports all the printf-style formatting codes. However,
the Unicode format codes (%C, %S, %lc, %ls, %wc, %ws, and %wZ) can only be
used with IRQL = PASSIVE_LEVEL."

Bill M.


"Thomas F. Divine [DDK MVP]" <tdivine@NOpcausaSPAM.com> wrote in message
news:OmRSylF0FHA.1028@TK2MSFTNGP12.phx.gbl...
>
> "Don Burn" <burn@stopspam.acm.org> wrote in message
> news:uR70hfF0FHA.1256@TK2MSFTNGP09.phx.gbl...
>> Use %wZ this is the format specifier for a UNICODE_STRING.
>>
>
> Don,
>
> Did you mean %ws, or have I overlooked one more new thing?
>
> Thos
>
>>
>> --
>> Don Burn (MVP, Windows DDK)
>> Windows 2k/XP/2k3 Filesystem and Driver Consulting
>> Remove StopSpam from the email to reply
>>
>>
>>
>> <Essie> wrote in message news:OcCWCPF0FHA.3660@TK2MSFTNGP15.phx.gbl...
>>> Can someone help to print a UNICODE_STRING to the debig window?
>>> The string is in POBJECT_ATTRIBUTES ObjectAttributes
>>> ObjectAttributes->ObjectName
>>>
>>> I believe this is correct so far?
>>>
>>> But how can I print it, can I use DbgPrint ?
>>>
>>> DbgPrint(("message %s \n", buffer ));
>>>
>>> but buffer is normally ansi
>>>
>>> Thanks
>>>
>>>
>>
>>
>



Re: How can I DbgPrint a UNICODE_STRING ? by Essie>

Essie>
Thu Oct 13 20:20:49 CDT 2005


> He meant %wZ and it isn't new, but it didn't used to be documented.
Several
> of the DDK samples use it.

> Now it is documented with KdPrint(Ex) and DbgPrint(Ex) and the following
> quote is interesting:

It is still undocumented as far as I can see. They say we are allowed to use
%wZ but they don't say what it does.



Re: How can I DbgPrint a UNICODE_STRING ? by Bill

Bill
Thu Oct 13 20:30:24 CDT 2005

Well, okay partially documented. The DDK docs do say: "Unicode format
codes". Again, there are sample drivers in the DDK that use it.

Bill M.


<Essie> wrote in message news:ey9Qq2F0FHA.3896@TK2MSFTNGP10.phx.gbl...
>
>> He meant %wZ and it isn't new, but it didn't used to be documented.
> Several
>> of the DDK samples use it.
>
>> Now it is documented with KdPrint(Ex) and DbgPrint(Ex) and the following
>> quote is interesting:
>
> It is still undocumented as far as I can see. They say we are allowed to
> use
> %wZ but they don't say what it does.
>
>



Re: How can I DbgPrint a UNICODE_STRING ? by Thomas

Thomas
Thu Oct 13 20:28:32 CDT 2005

Thanks, Bill.

At least I learn something new every day.

Thos

"Bill McKenzie" <bm01_REMOVE_@csr.com> wrote in message
news:%23nKbAwF0FHA.3756@tk2msftngp13.phx.gbl...
> He meant %wZ and it isn't new, but it didn't used to be documented.
> Several of the DDK samples use it.
>
> Now it is documented with KdPrint(Ex) and DbgPrint(Ex) and the following
> quote is interesting:
>
> "The Format string supports all the printf-style formatting codes.
> However, the Unicode format codes (%C, %S, %lc, %ls, %wc, %ws, and %wZ)
> can only be used with IRQL = PASSIVE_LEVEL."
>
> Bill M.
>
>
> "Thomas F. Divine [DDK MVP]" <tdivine@NOpcausaSPAM.com> wrote in message
> news:OmRSylF0FHA.1028@TK2MSFTNGP12.phx.gbl...
>>
>> "Don Burn" <burn@stopspam.acm.org> wrote in message
>> news:uR70hfF0FHA.1256@TK2MSFTNGP09.phx.gbl...
>>> Use %wZ this is the format specifier for a UNICODE_STRING.
>>>
>>
>> Don,
>>
>> Did you mean %ws, or have I overlooked one more new thing?
>>
>> Thos
>>
>>>
>>> --
>>> Don Burn (MVP, Windows DDK)
>>> Windows 2k/XP/2k3 Filesystem and Driver Consulting
>>> Remove StopSpam from the email to reply
>>>
>>>
>>>
>>> <Essie> wrote in message news:OcCWCPF0FHA.3660@TK2MSFTNGP15.phx.gbl...
>>>> Can someone help to print a UNICODE_STRING to the debig window?
>>>> The string is in POBJECT_ATTRIBUTES ObjectAttributes
>>>> ObjectAttributes->ObjectName
>>>>
>>>> I believe this is correct so far?
>>>>
>>>> But how can I print it, can I use DbgPrint ?
>>>>
>>>> DbgPrint(("message %s \n", buffer ));
>>>>
>>>> but buffer is normally ansi
>>>>
>>>> Thanks
>>>>
>>>>
>>>
>>>
>>
>
>


Re: How can I DbgPrint a UNICODE_STRING ? by Essie>

Essie>
Thu Oct 13 20:36:35 CDT 2005



> At least I learn something new every day.

So you are assuming Don did not make a typo ?



Re: How can I DbgPrint a UNICODE_STRING ? by Thomas

Thomas
Thu Oct 13 20:57:27 CDT 2005


<Essie> wrote in message news:%23blKd$F0FHA.2884@TK2MSFTNGP09.phx.gbl...
>
>
>> At least I learn something new every day.
>
> So you are assuming Don did not make a typo ?
>
>
I'll look into it a little more.

However, since I don't know what the advantage of %wZ is over %ws, I will
probably stick with %ws myself.

Thos


Re: How can I DbgPrint a UNICODE_STRING ? by Pavel

Pavel
Thu Oct 13 21:13:29 CDT 2005

For %ws the argument is WCHAR*; for %wZ - PUNICODE_STRING
so instead of %wZ you can print the buffer of UNICODE_STRING with %ws
if it were always zero terminated.

--PA

"Thomas F. Divine [DDK MVP]" <tdivine@NOpcausaSPAM.com> wrote in message news:%23VuWlKG0FHA.2932@TK2MSFTNGP10.phx.gbl...
>
> <Essie> wrote in message news:%23blKd$F0FHA.2884@TK2MSFTNGP09.phx.gbl...
>>
>>
>>> At least I learn something new every day.
>>
>> So you are assuming Don did not make a typo ?
>>
>>
> I'll look into it a little more.
>
> However, since I don't know what the advantage of %wZ is over %ws, I will probably stick with %ws myself.
>
> Thos
>



Re: How can I DbgPrint a UNICODE_STRING ? by Skywing

Skywing
Thu Oct 13 21:38:56 CDT 2005

You can use %*ws to replicate that behavior (with an additional argument).

As an additional piece of useful information, the Microsoft user mode CRTs
also support those format types in the user mode printf family of functions
(%wZ for PUNICODE_STRING and %Z for PANSI_STRING). You can see how it works
by checking out the VC CRT source code distributed with Visual Studio.

"Pavel A." <pavel_a@NOwritemeNO.com> wrote in message
news:u6galTG0FHA.720@TK2MSFTNGP15.phx.gbl...
> For %ws the argument is WCHAR*; for %wZ - PUNICODE_STRING
> so instead of %wZ you can print the buffer of UNICODE_STRING with %ws
> if it were always zero terminated.
>
> --PA
>
> "Thomas F. Divine [DDK MVP]" <tdivine@NOpcausaSPAM.com> wrote in message
> news:%23VuWlKG0FHA.2932@TK2MSFTNGP10.phx.gbl...
>>
>> <Essie> wrote in message news:%23blKd$F0FHA.2884@TK2MSFTNGP09.phx.gbl...
>>>
>>>
>>>> At least I learn something new every day.
>>>
>>> So you are assuming Don did not make a typo ?
>>>
>>>
>> I'll look into it a little more.
>>
>> However, since I don't know what the advantage of %wZ is over %ws, I will
>> probably stick with %ws myself.
>>
>> Thos
>>
>
>



Re: How can I DbgPrint a UNICODE_STRING ? by Mark

Mark
Thu Oct 13 21:43:23 CDT 2005

Essie wrote:
>>At least I learn something new every day.
>
>
> So you are assuming Don did not make a typo ?
>
>
Don did not make a typo. %wZ is one of the ddk arcania. It is superior
to %ws in that it does not require null termination of the wide char
string. Do be careful about the STUPIDLY paged unicode character set
translation buffers that sit behind the wchar debug print processing.
They will kill you dead at the worst time if you aren't careful about
your irql.

--

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032
www.hollistech.com

Re: How can I DbgPrint a UNICODE_STRING ? by Thomas

Thomas
Thu Oct 13 22:50:45 CDT 2005


"Mark Roddy" <markr@hollistech.com> wrote in message
news:emeoQkG0FHA.916@TK2MSFTNGP10.phx.gbl...
> Essie wrote:
>>>At least I learn something new every day.
>>
>>
>> So you are assuming Don did not make a typo ?
>>
>>
> Don did not make a typo. %wZ is one of the ddk arcania. It is superior to
> %ws in that it does not require null termination of the wide char string.
> Do be careful about the STUPIDLY paged unicode character set translation
> buffers that sit behind the wchar debug print processing. They will kill
> you dead at the worst time if you aren't careful about your irql.
>
I have already been bitten by the paged unicode bug.

Sigh...

If any newbies aren't paying attention, if you have a debug print that
includes a unicode print format, they really should be used ONLY if you KNOW
you will ALWAYS be at IRQL == PASSIVE_LEVEL.

Thos


Re: How can I DbgPrint a UNICODE_STRING ? by David

David
Thu Oct 13 23:08:07 CDT 2005

There are two possible responses to this problem, IMHO (or not so humble):
1. Just do it and hope you don't get a blue screen. Lots of memory on a
test system will help, but don't try memory stressing your driver with this
in it.
2. Write a routine that takes a UNICODE_STRING and passes it to a worker
thread if the current IRQL is not PASSIVE_LEVEL.

WDF could provide such a routine easily and solve one of the stickier
problems that beginners seem to encounter.

"Thomas F. Divine [DDK MVP]" <tdivine@NOpcausaSPAM.com> wrote in message
news:%23qAH5JH0FHA.664@tk2msftngp13.phx.gbl...
>
> "Mark Roddy" <markr@hollistech.com> wrote in message
> news:emeoQkG0FHA.916@TK2MSFTNGP10.phx.gbl...
>> Essie wrote:
>>>>At least I learn something new every day.
>>>
>>>
>>> So you are assuming Don did not make a typo ?
>>>
>>>
>> Don did not make a typo. %wZ is one of the ddk arcania. It is superior to
>> %ws in that it does not require null termination of the wide char string.
>> Do be careful about the STUPIDLY paged unicode character set translation
>> buffers that sit behind the wchar debug print processing. They will kill
>> you dead at the worst time if you aren't careful about your irql.
>>
> I have already been bitten by the paged unicode bug.
>
> Sigh...
>
> If any newbies aren't paying attention, if you have a debug print that
> includes a unicode print format, they really should be used ONLY if you
> KNOW you will ALWAYS be at IRQL == PASSIVE_LEVEL.
>
> Thos
>



Re: How can I DbgPrint a UNICODE_STRING ? by Don

Don
Fri Oct 14 07:46:27 CDT 2005

It was not a typo, it is documented in my paper "Get Started with the
Windows Driver Development Environment"
http://www.microsoft.com/whdc/driver/foundation/DrvDev_Intro.mspx. I've
suggested to the DDK documentation folks that they fix this in their docs.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply



<Essie> wrote in message news:%23blKd$F0FHA.2884@TK2MSFTNGP09.phx.gbl...
>
>
>> At least I learn something new every day.
>
> So you are assuming Don did not make a typo ?
>
>



Re: How can I DbgPrint a UNICODE_STRING ? by Bill

Bill
Mon Oct 17 01:04:53 CDT 2005

It wasn't an assumption, perhaps you missed my posts.

Bill M.


<Essie> wrote in message news:%23blKd$F0FHA.2884@TK2MSFTNGP09.phx.gbl...
>
>
>> At least I learn something new every day.
>
> So you are assuming Don did not make a typo ?
>
>



Re: How can I DbgPrint a UNICODE_STRING ? by Maxim

Maxim
Tue Oct 18 18:19:32 CDT 2005

KdPrint(("%wZ", UnicodeStringPtr));

Not on >= DISPATCH_LEVEL, surely.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com

<Essie> wrote in message news:OcCWCPF0FHA.3660@TK2MSFTNGP15.phx.gbl...
> Can someone help to print a UNICODE_STRING to the debig window?
> The string is in POBJECT_ATTRIBUTES ObjectAttributes
> ObjectAttributes->ObjectName
>
> I believe this is correct so far?
>
> But how can I print it, can I use DbgPrint ?
>
> DbgPrint(("message %s \n", buffer ));
>
> but buffer is normally ansi
>
> Thanks
>
>