1、KdPrint_DbgPrint and UNICODE_STRING_ANSI_STRING - swanabin的专栏 - 博客频道 - CSDN.NET.html

http://blog.csdn.net/swanabin/article/details/23457793

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

2、DbgPrint_KdPrint输出格式控制 - whatday的专栏 - 博客频道 - CSDN.NET.html

http://blog.csdn.net/whatday/article/details/9530723

在驱动编程学习中,往往需要通过DbgPrint或者KdPrint来输出调试信息,对于Check版本,KdPrint只是DbgPrint的一个宏定义,而对于Free版本,KdPrint将被优化掉。这些输出信息可以通过DebugView对内核的监控来看到。

KdPrint is identical to the DbgPrint routine in code that is compiled in achecked build environment. This routine has no effect if compiled in a free build environment. Only kernel-mode drivers can call theKdPrint routine.

下面还是说一下他们的输出格式控制吧:

符号 格式说明符 类型
%c, %lc ANSI字符 char
%C, %wc 宽字符 wchar_t
%d, %i 十进制有符号整数 int
%D 十进制__int64 __int64
%L 十六进制的LARGE_INTEGER LARGE_INTEGER
%s, %ls NULL终止的ANSI字符串 char*
%S, %ws NULL终止的宽字符串 wchar_t*
%Z ANSI_STRING字符串 ANSI_STRING
%wZ UNICODE_STRING字符串 UNICODE_STRING
%u 十进制的ULONG ULONG
%x 小写字符十六进制的ULONG ULONG
%X 大写字符十六进制的ULONG ULONG
%p 指针Pointer 32/64位  

就那么多。根据DDK上说明,Unicode格式(%C, %S, %lc, %ls, %wc, %ws, and %wZ)只能在 IRQL = PASSIVE_LEVEL时才能使用。

需要注意 中文的 WCHAR 和 UNICODE_STRING可能会被截断打印不出来 需要转化为 CHAR 和 ANSI_STRING来打印

具体实例:

ANSI_STRING ansiString;
//省去对ansiString初始化
KdPrint(("%Z\n", &ansiString));    //注意是%Z

UNICODE_STRING uniString;
//省去对uniString初始化
KdPrint(("%wZ\n", &uniString));    //注意是%wZ

3、

4、

5、

转载于:https://www.cnblogs.com/DriverSkill/p/6187104.html

UNICODE_STRING__ZC相关推荐

最新文章

  1. 时间序列竞赛炸榜技巧。
  2. 身体容易缺少的微量元素
  3. Codeforces Round #632 (Div. 2) F. Kate and imperfection 数论 + 贪心
  4. leetcode-回文链表
  5. API信息全掌控,方便你的日志管理——阿里云推出API网关打通日志服务
  6. java 显示透明背景png图片
  7. ubuntu: root用户
  8. 统计学硕士做了3年表格,多次跳槽失败,只因学不会数据工具
  9. Win2008 R2 VDI动手实验系列之二:远程桌面虚拟化主机配置
  10. 将Python和R整合进一个数据分析流程
  11. 基于MATLAB语音信号的处理与滤波
  12. ubuntu下载BT种子安装qBittorrent
  13. 语音助手——评测指标
  14. 英语语法总结_02 名词词组与代名词
  15. 用php语言说句情话,说给女朋友的感动情话50句
  16. [zz] 基于sinc的音频重采样(一):原理
  17. 移动硬盘安装centos8
  18. Power BI(十三)Power pivot之工作日计算
  19. (附源码)小程序springboot口腔诊所预约系统 毕业设计 201738
  20. 手写字体设计课程笔记

热门文章

  1. .Net中的加密解密
  2. 【SSH网上商城项目实战01】整合Struts2、Hibernate4.3和Spring4.2
  3. 随心所欲学Java,起步-心理安慰
  4. 从智慧信号灯看智能城市管理
  5. 【微信小程序开发•系列文章七】websocket
  6. S5pv210裸机实验——SDRAM重定位
  7. FTP用户无法登陆排错详解
  8. NoticeBoard 一个仿原生UI的消息通知控件
  9. IIS Express 启用目录浏览
  10. NioEventLoopGroup 源码分析