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

%wZ is for PUNICODE_STRINGs.

Best regards,

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


From:
xxxxx@omnishift.com[SMTP:xxxxx@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

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):
    ?
  5. %s (PCHAR)
  6. %ws (PWCHAR)
  7. %Z (PSTRING, PANSI_STRING, POEM_STRING)
  8. %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: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com]On Behalf Of
xxxxx@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