I have the following code:
UNICODE_STRING str;
// initialization of str, in WinDbg I see that it has correct value, like: FILE1
KdPrint(“String: %S\n”, str.Buffer);
In DebugView I see:
String: FILE1456767
After string value I see garbage. Maybe because UNICODE_STRING is not NULL-terminated? What is correct way to print it?
KdPrint(“string: %wZ\n”, &str);
And yes, the garbage is because a counted string doesn’t need to a
nul terminator to be manipulated.
At 13:50 28/05/2008, xxxxx@yahoo.com wrote:
I have the following code:
UNICODE_STRING str;
// initialization of str, in WinDbg I see that it has correct value,
like: FILE1
KdPrint(“String: %S\n”, str.Buffer);
In DebugView I see:
String: FILE1456767
After string value I see garbage. Maybe because UNICODE_STRING is
not NULL-terminated? What is correct way to print it?
xxxxx@yahoo.com wrote:
Use %wZ instead. Unicode_strings are counted and not terminated usually.
Matt
I have the following code:
UNICODE_STRING str;
// initialization of str, in WinDbg I see that it has correct value, like: FILE1
KdPrint(“String: %S\n”, str.Buffer);
In DebugView I see:
String: FILE1456767
After string value I see garbage. Maybe because UNICODE_STRING is not NULL-terminated? What is correct way to print it?
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
KdPrint(“string: %wZ\n”, &str);
From some reason, this line prints:
string:
Without string value.
Maybe the string is empty. Use “string: <%wZ>\n” or “string: "%wZ>"\n”
format to see it exactly.
If the string buffer contains something doesn’t necessarily means that
string isn’t empty. UNICODE_STRINGs are counted and the valid data size
determined by Length field (hint: print it out). That’s why printing
only buffer is wrong even if the string in the buffer is zero
terminated.
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.com
Sent: Wednesday, May 28, 2008 8:08 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KdPrint and UNICODE_STRING
KdPrint(“string: %wZ\n”, &str);
From some reason, this line prints:
string:
Without string value.
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online
at http://www.osronline.com/page.cfm?name=ListServer
xxxxx@yahoo.com wrote:
KdPrint(“string: %wZ\n”, &str);
>From some reason, this line prints:
string:
Without string value.
Is that EXACTLY how you have it? Or do you really have the correct syntax:
KdPrint(( “string: %wZ\n”, &str ));
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.
> After string value I see garbage. Maybe because UNICODE_STRING is not
NULL-terminated?
Yes
What is correct way to print it?
KdPrint(“String: %wZ\n”, &str);
–
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com
Yes, in my code this is:
KdPrint((“String: %wZ\n”, &str));
I found that in WinDbg it works correctly, but in DbgView shows empty value. So, code is OK. Does anybody know about this DbgView problem, or this is one of strange things, that happens only with beginners?
Hmmmmmm. How wide is the Debug Print collumn in the DebugView? Does it
help if you make it wider?
Best regards,
Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@yahoo.com
Sent: Thursday, May 29, 2008 7:53 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] KdPrint and UNICODE_STRING
Yes, in my code this is:
KdPrint((“String: %wZ\n”, &str));
I found that in WinDbg it works correctly, but in DbgView
shows empty value. So, code is OK. Does anybody know about
this DbgView problem, or this is one of strange things, that
happens only with beginners?
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online
at http://www.osronline.com/page.cfm?name=ListServer
Good guess, but this is not a case 
I think that this is surprise especially for beginners, one month later I will not be able to reproduce this.