printf 和 wprintf

Eric Kohl
转载请征得作者同意.
2000.1.11


此次连续2天更新WEB.弥补前次10天没有更新. :)大家还是要多多捧场啊. :)
本文描述了NTDLL.DLL和NTOSKRNL.EXE里的printf() and wprintf()非标准支持.乃MS自己在SMSS.EXE里所用.这里描述了这些UNDOCUMENTED用法.

Hello!

At present I'm working on the printf() and wprintf() functions in ntoskrnl
and ntdll. I only want to notify you about some incompatibilities between
the current implementation and the implementation in WinNT.

M$ added some non-standard format types to the printf() and wprintf()
functions:
    type prefixes:
        I64 : 64 bit integer (long long, unsigned long long, __int64)
        w : unicode charater (only used in "%wc", "%ws" and "%wZ")

    types:
        C : unicode character (in printf()) or single byte character (in
wprintf())
        S : unicode string (in printf()) or single byte string (in
wprintf())
        Z : PANSI_STRING ("%Z") or PUNICODE_STRING ("%wZ")

The format types 'c', 'C', 's' and 'S' also allow the prefixes 'h' and 'l':
    printf():
        %c : single byte character
        %hc : single byte character
        %lc : unicode character
        %wc : unicode character
        %C : unicode character
        %hC : single byte character
        %lC : unicode character
        %s : single byte string
        %hs : single byte string
        %ls : unicode string
        %wc : unicode string
        %S : unicode string
        %hS : single byte string
        %lS : unicode string

    wprintf():
        %c : unicode character
        %hc : single byte character
        %lc : unicode character
        %wc : unicode character
        %C : single byte character
        %hC : single byte character
        %lC : unicode character
        %s : unicode string
        %hs : single byte string
        %ls : unicode string
        %ws : unicode string
        %S : single byte string
        %hS : single byte string
        %lS : unicode string

AFAIK, printf() and wprintf() functions in crtdll don't support the '%Z' and
'%wZ' formats.

Hint: Have a look at WinNT ntoskrnl.exe or smss.exe and search for '%Z' or
'%wZ'. It's used there.

Bye,
Eric Kohl