gpt4 book ai didi

c++ - 无法设置 4 字节硬件断点 Windbg

转载 作者:太空狗 更新时间:2023-10-29 19:52:13 24 4
gpt4 key购买 nike

我无法使用 windbg 设置 4 字节读/写访问硬件断点。

0:000> dd 02e80dcf
02e80dcf 13121110 17161514 1a191800 1e1d1c1b
02e80ddf 011c171f c7be7df1 00000066 4e454900

实际上,我必须检查值 0x13121110(位于地址 0x02e80dcf)何时被程序更改/覆盖。

所以当我尝试设置一个 4 字节写访问硬件断点@0x02e80dcf时,我得到了数据断点必须对齐错误。

0:000> ba w 4 02e80dcf
Data breakpoint must be aligned
^ Syntax error in 'ba w 4 02e80dcf'
0:000> ba r 4 02e80dcf
Data breakpoint must be aligned
^ Syntax error in 'ba r 4 02e80dcf'
0:000> ba w 1 02e80dcf
breakpoint 0 redefined

我可以在该地址设置 1 字节写访问断点,但是当指针@地址 0x02e80dcf 被覆盖时它不会被触发。

而且,如果有人可以建议任何其他方法来检测地址被覆盖的事情,那将非常有帮助。

注意:我在特定程序中遇到的问题。我能够在相同的调试环境中设置 4 字节硬件断点。

最佳答案

附带说明一下,这种特殊行为来自 CPU 架构本身(而不是来自系统或调试器)。

x86 和 x86-64(英特尔术语中的 IA32 和 IA32-e)架构使用 Drx(调试寄存器)来处理硬件断点。

Dr7 LENn 字段将设置断点的长度,Dr0 到 Dr3 将保存断点地址。

来自 Intel 手册 3B - 第 18.2.5 章。 “断点字段识别”:

The LENn fields permit specification of a 1-, 2-, 4-, or 8-byte range, beginning at the linear address specified in the corresponding debug register (DRn).

在同一章节中明确指出:

Two-byte ranges must be aligned on word boundaries; 4-byte ranges must be aligned on doubleword boundaries.

如果你用足够长的数据断点覆盖所需的地址,那么它将陷入陷阱(断点将被命中):

A data breakpoint for reading or writing data is triggered if any of the bytes participating in an access is within the range defined by a breakpoint address register and its LENn field.

然后手册继续给出陷阱未对齐地址的提示,并给出了一个示例表:

A data breakpoint for an unaligned operand can be constructed using two breakpoints, where each breakpoint is byte-aligned and the two breakpoints together cover the operand.

Hardware brakpoints help table

关于c++ - 无法设置 4 字节硬件断点 Windbg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29438224/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com