博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
KdPrint/DbgPrint and UNICODE_STRING/ANSI_STRING
阅读量:6364 次
发布时间:2019-06-23

本文共 1524 字,大约阅读时间需要 5 分钟。

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_vsnprintfKdPrint/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));

转载于:https://www.cnblogs.com/vcerror/p/4289061.html

你可能感兴趣的文章
go语言中在变量后加上接口是什么意思?
查看>>
day5-iptables
查看>>
版本配置
查看>>
python之进程
查看>>
wpf中嵌入winform控件的坑
查看>>
VMware Workstation and Hyper-V are not compatible. 解决方案
查看>>
POJ-3304Segments[计算几何]
查看>>
杭电2120--Ice_cream's world I(并查集)
查看>>
雅虎前段优化35条
查看>>
(转)接口100
查看>>
UIScrollView 大概是如何实现的,它是如何捕捉、响应手势的?
查看>>
asp.net MVC中实现调取web api
查看>>
keepalived实现服务高可用
查看>>
iOS模型以及使用
查看>>
NSString 去除空格
查看>>
swift - 网络请求数据处理 - 协议处理
查看>>
[BZOJ1588]营业额统计(Splay)
查看>>
[BZOJ 4869][SHOI&SXOI2017]相逢是问候(扩展欧拉定理+线段树)
查看>>
2017-08-13
查看>>
条件语句优化面面观
查看>>