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