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

最新文章

  1. javascript 手势缩放 旋转 拖动支持:hammer.js
  2. (Python )格式化输出、文件操作、json
  3. VIM替换、截取及追加操作
  4. oracle入门-%的用法
  5. 关于跨域的ajax
  6. Safari浏览器的调试
  7. 积累的VC编程小技巧之属性页
  8. 快速构建Windows 8风格应用37-常见发布注意事项
  9. MySQL · 引擎特性 · 临时表那些事儿
  10. Nginx的配置文件nginx.conf解析
  11. Docker 删除容器日志
  12. python基础(字典)
  13. python3读取MySQL-Front的MYSQL密码
  14. Mysql相关存储函数,函数,游标
  15. HTML表单 CSS样式
  16. usermod - linux修改用户帐户信息
  17. JAVA记录-SpringMVC集成redis
  18. 使用UWA GOT优化Unity性能和内存
  19. python学习之老男孩python全栈第九期_day005作业
  20. java 多线程 33: 多线程组件之 Callable、Future和FutureTask

热门文章

  1. IO流分类
  2. input select 值得绑定与获取
  3. Linux下安装PHP的curl扩展
  4. 搭建本地 8.8 W 乌云漏洞库
  5. (转)websocket
  6. 其它课程中的python---6、python读取数据
  7. Http协议中get和post的区别 转载https://www.cnblogs.com/lexiaofei/p/http.html
  8. 使用Netfilter进行数据包分析
  9. 使用uc进行手机页面调试
  10. leetcode.哈希表.594最长和谐子序列-Java