DbgPrint and Unicode strings?Message 1 in thread
      Subject: DbgPrint and Unicode strings?
      From: xxx@omnishift.com
      Date: Wed, 20 Sep 2000 14:55:52 -0700


Hi all:

Is there any format flag I can send to DbgPrint() to have it interpret a
PUNICODE_STRING?  Right now, I'm using something like:

        PUNICODE_STRING string;

        DbgPrint("name is %S\n", string->Buffer);

But of course, this buffer isn't likely to be NULL-terminated, so I get lots
of garbage in my debug output.

The DebugPrint() stuff in Chris Cant's "Writing Windows WDM Device Driver"
has a "%T" flag that seems to work, but if I'm just using the standard
DbgPrint() API, I'm stuck.

Thanks in advance for any help you can provide.

Curt
Message 2 in thread
      Subject: RE: DbgPrint and Unicode strings?
      From: "Vodicka, Michal" <xxx@rkk.cz>
      Date: Thu, 21 Sep 2000 00:02:28 +0200


%wZ is for PUNICODE_STRINGs.

Best regards,

Michal Vodicka
Veridicom
(RKK - Skytale)
[WWW: http://www.veridicom.com , http://www.skytale.com]



> ----------
> From:
> xxx@omnishift.com[SMTP:xxx@omnishift.com]
> Reply To:     File Systems Developers
> Sent:         Wednesday, September 20, 2000 23:55
> To:   File Systems Developers
> Subject:      [ntfsd] DbgPrint and Unicode strings?
> 
> Hi all: 
> 
> Is there any format flag I can send to DbgPrint() to have it interpret a
> PUNICODE_STRING?  Right now, I'm using something like:
> 
>         PUNICODE_STRING string; 
> 
>         DbgPrint("name is %S\n", string->Buffer); 
> 
> But of course, this buffer isn't likely to be NULL-terminated, so I get
> lots of garbage in my debug output. 
> 
> The DebugPrint() stuff in Chris Cant's "Writing Windows WDM Device Driver"
> has a "%T" flag that seems to work, but if I'm just using the standard
> DbgPrint() API, I'm stuck.
> 
> Thanks in advance for any help you can provide. 
> 
> Curt 
> 
> 

Message 3 in thread
      Subject: RE: DbgPrint and Unicode strings?
      From: Hrdina Pavel <xxx@COMPELSON.COM>
      Date: Thu, 21 Sep 2000 11:58:09 +0200


I'm providing this explanation also for all NTFSD developers:
 
There are four types of string:
1. NULL-terminated string (ANSI, OEM)
    type PCHAR
2. NULL-terminated UNICODE string
    type PWCHAR
3. Counted string (ANSI, OEM)
    type STRING (also ANSI_STRING, OEM_STRING)
4. Counted UNICODE string
    type UNICODE_STRING
 
For DbgPrint (or macro KdPrint) - which is like printf - the following
formats should be used (expected type of argument):
 
1. %s (PCHAR)
2. %ws (PWCHAR)
3. %Z (PSTRING, PANSI_STRING, POEM_STRING)
4. %wZ (PUNICODE_STRING)
 
In fact %Z and %wZ are not documented in the official documentation,
but you can find them in CRT source file for _output().
Microsoft uses them for eg. in NTOSKRNL for both debug prints and
buffer prints ([v]s[n]printf) when some of the argument is counted
string.
 
NOTE: In the documentation of "Format Specification Fields:
           printf and wprintf Functions" some fields are missing.
 
type should contain Z (uppercase only) which is for counted strings.
        The precision is not applied to this type.
 
[{h | l | I64 | L}] should also contain w (lowecase only) which sets
        the FL_WIDECHAR flag in _output(). So if the corresponding type
        is some char/string type (c, s, Z), this means the UNICODE
version
        is expected as an argument.
 
Paul
 
PS: If you want to know more about this look into OUTPUT.C is
reccomened.


-----Original Message-----
From: xxx@lists.osr.com
[mailto:xxx@lists.osr.com]On Behalf Of
xxx@omnishift.com
Sent: Wednesday, September 20, 2000 10:56 PM
To: File Systems Developers
Subject: [ntfsd] DbgPrint and Unicode strings?



Hi all: 

Is there any format flag I can send to DbgPrint() to have it interpret a
PUNICODE_STRING?  Right now, I'm using something like:

        PUNICODE_STRING string; 

        DbgPrint("name is %S\n", string->Buffer); 

But of course, this buffer isn't likely to be NULL-terminated, so I get
lots of garbage in my debug output. 

The DebugPrint() stuff in Chris Cant's "Writing Windows WDM Device
Driver" has a "%T" flag that seems to work, but if I'm just using the
standard DbgPrint() API, I'm stuck.

Thanks in advance for any help you can provide. 

Curt 

Message 4 in thread
      Subject: Re: DbgPrint and Unicode strings?
      From: "Maxim S. Shatskih" <xxx@storagecraft.com>
      Date: Sun, 24 Sep 2000 03:29:43 +0400


DbgPrint and Unicode strings?> there any format flag I can send to
DbgPrint() to have it interpret a
>PUNICODE_STRING?

%wZ

>        DbgPrint("name is %S\n", string->Buffer);
>But of course, this buffer isn't likely to be NULL-terminated, so I get
lots of
>garbage in my debug output.

Use ("%.*S", string->Length / sizeof(WCHAR), string->Buffer).

    Max



