KdPrint/DbgPrint and UNICODE_STRING/ANSI_STRING
2014-04-11 16:54
921 查看
typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; PWSTR Buffer; } UNICODE_STRING; typedef UNICODE_STRING *PUNICODE_STRING;
typedef struct _STRING { USHORT Length; USHORT MaximumLength; PCHAR Buffer;} STRING;typedef STRING *PSTRING;typedef STRING ANSI_STRING;typedef PSTRING PANSI_STRING;
To make life easier MS have extended kernel CRTL output() function with Z format specifier. This works for all kernel functions those understand formatted strings (e.g. sprintf, _vsnprintf, KdPrint/DbgPrint). For example:PUNICODE_STRING pUStr;PANSI_STRING pAStr;...KdPrint(("Unicode string: %wZ\n", pUStr));KdPrint(("ANSI string: %Z\n", pAStr));Though, you can use a little more complicated documented way. Btw, this form is suitable for printing byte array of strictly defined length.
KdPrint(("Unicode string: %*.*ws\n",pUStr->Length/sizeof(WCHAR), pUStr->Length/sizeof(WCHAR), pUStr));KdPrint(("Unicode string: %*.*S\n",pUStr->Length/sizeof(WCHAR), pUStr->Length/sizeof(WCHAR), pUStr));KdPrint(("ANSI string: %*.*s\n", pAStr->Length/sizeof(CHAR), pAStr->Length/sizeof(CHAR), pAStr));Or, if you want to take into account NULL-terminator, but limit output length to specified number of characters:
KdPrint(("Unicode string: %.*ws\n", pUStr->Length/sizeof(WCHAR), pUStr));KdPrint(("Unicode string: %.*S\n", pUStr->Length/sizeof(WCHAR), pUStr));KdPrint(("ANSI string: %.*s\n", pAStr->Length/sizeof(CHAR), pAStr));
相关文章推荐
- KdPrint/DbgPrint and UNICODE_STRING/ANSI_STRING
- KdPrint/DbgPrint and UNICODE_STRING/ANSI_STRING
- ANSI and UnicodeCharacter and String Data Types
- 从Java String实例来理解ANSI、Unicode、BMP、UTF等编码概念
- print in UNICODE and MBCS
- CStdioFile的Writestring写入中文的总结(unicode-ucs2/utf8-无Bom/ansi-gb2312)
- ANSI_STRING和UNICODE_STRING的成员变量Length很重要
- string 和 wstring 互相转换的方法(即 Ansi & Unicode 在标准库下的互转)
- 将unicode下的wstring转化成ansi下的string
- 在Python中使用protobuf2.6.1 string format utf-8 and unicode error
- Convert CString to ANSI string in UNICODE projects
- windows KdPrint打印中文文件夹的问题,应该是DbgPrint的BUG
- ANSI(字符集) and Unicode(字符集) and UTF-8(编码Unicode字符集)
- Generic Macro for UNICODE and ANSI
- UnicodeToAnsi and AnsiToUnicode
- DbgPrint和KdPrint的输出格式
- Getting DbgPrint Output To Appear In Vista and Later
- Unicode and ANSI
- python print 打印unicode string的时候 去掉u' remove u'
- STL String and Unicode