【发布时间】:2015-09-11 02:17:51
【问题描述】:
我正在使用以下windbg脚本在读取文件时在缓冲区中遇到某个值时中断
bp ReadFile
.while(1)
{
g
$$ Get parameters of ReadFile()
r $t0 = dwo(esp+4)
r $t1 = dwo(esp+8)
r $t2 = dwo(esp+0x0c)
$$ Execute until return is reached
pt
$$ Read magic value in the buffer
$$ CHANGE position in buffer here
r $t5 = dwo(@$t1+0x00)
$$ Check if magic value matches
$$ CHANGE constant here
.if(@$t5 == 0x70170000)
{
$$db @$t1
$$ break
.break
}
}
$$ Clear BP for ReadFile (assume it is the 0th one)
bc 0
我在运行此脚本时遇到以下内存访问冲突。
Memory access error at ');; $$ Check if magic value matches; $$ CHANGE constant here; .if(@$t5 == 0x70170000); {; $$db @$t1;; $$ break; .break; };'
为什么会这样?
【问题讨论】:
-
@$t5取消引用$t5变量指向的内存,在您的情况下,内存地址错误/不可访问。检查应分配给该变量的地址的逻辑。你到底想用这个脚本做什么? -
@MaximilianGerhardt 当文件读取期间的输出缓冲区以 0x70170000 开始时,我试图中断。 $t1 包含输出缓冲区的内存地址。 $t5 应该包含地址 $t1 的内存内容。
-
假设 esp 是有效的,唯一突出的是 @$t1 不是一个有效的地址,它是报告访问错误的
dwo(@$t1+0x00)。 -
@ThomasWeller 是的。这怎么可能?
$t1应该有指向输出缓冲区的指针。相反,它包含一个空指针00000000 -
k 在顶部说
002c6b78 76fe9d12 KERNELBASE!ReadFile,所以脚本应该在ReadFile()。我也通过查看反汇编验证了这一点。
标签: windbg