调试kext时读取user-space地址address
Reading user-space address address when debugging kext
我想在通过 kdp
调试远程机器驱动程序 (kext) 时从 lldb
读取用户 space 地址。我知道在代码中我可以使用 copyin
以便将代码移动到内核 space 并轻松阅读它,所以正如预期的那样,当我尝试直接读取用户内存时它失败了:
(lldb) memory read 0x000070000d15a024
error: kdp read memory failed (error 4)
在运行时调试会话期间是否有替代 copyin
的方法将我的数据转换到我可以从调试器读取的位置?
谢谢
假设您为您使用的特定内核加载调试脚本(应该在适当的 KDK 中),您有 printuserdata
命令。
这是它的描述:
printuserdata:
Read userspace data for given task and print based on format provided.
Syntax: (lldb) printuserdata <task_t> <uspace_address> <format_specifier>
params:
<task_t> : pointer to task
<uspace_address> : address to user space memory
<format_specifier> : String representation for processing the data and printing it.
e.g Q -> unsigned long long, q -> long long, I -> unsigned int, i -> int
10i -> 10 ints, 20s -> 20 character string, s -> null terminated string
See: https://docs.python.org/2/library/struct.html#format-characters
options:
-X : print all values in hex.
-O <file path>: Save data to file
调用示例:
(lldb) printuserdata 0xffffff8013257d80 0x00007fff941f5000 10c
我想在通过 kdp
调试远程机器驱动程序 (kext) 时从 lldb
读取用户 space 地址。我知道在代码中我可以使用 copyin
以便将代码移动到内核 space 并轻松阅读它,所以正如预期的那样,当我尝试直接读取用户内存时它失败了:
(lldb) memory read 0x000070000d15a024
error: kdp read memory failed (error 4)
在运行时调试会话期间是否有替代 copyin
的方法将我的数据转换到我可以从调试器读取的位置?
谢谢
假设您为您使用的特定内核加载调试脚本(应该在适当的 KDK 中),您有 printuserdata
命令。
这是它的描述:
printuserdata:
Read userspace data for given task and print based on format provided.
Syntax: (lldb) printuserdata <task_t> <uspace_address> <format_specifier>
params:
<task_t> : pointer to task
<uspace_address> : address to user space memory
<format_specifier> : String representation for processing the data and printing it.
e.g Q -> unsigned long long, q -> long long, I -> unsigned int, i -> int
10i -> 10 ints, 20s -> 20 character string, s -> null terminated string
See: https://docs.python.org/2/library/struct.html#format-characters
options:
-X : print all values in hex.
-O <file path>: Save data to file
调用示例:
(lldb) printuserdata 0xffffff8013257d80 0x00007fff941f5000 10c