> 文章列表 > windbg脚本编写和调试

windbg脚本编写和调试

windbg脚本编写和调试

1.如何直接运行

写一个脚本,例如写一个脚本1.txt,放在c:\\tmp下。

直接在windbg命令行里运行
$$><c:\\tmp\\1.txt

2.如何下断点的时候执行脚本

bp kernel32!CreateFileW "$<c:\\\\tools\\\\filescript.txt"

3.CreateFileW时如何查找a.txt并停下,同时未命中时输出全部文件名的脚本,64位

r $t1=rcx
as /mu $FileName $t1 
.echo
.printf  "File:%mu",$t1
.echo
.if($spat("${$FileName}","*a.txt"))    { .echo 'find '; ad ${/v:$FileName} } .else    { .echo no find; ad ${/v:$FileName}; gc    }

4.如何遍历指针->指针->指针

假设第一个指针是0x0a4db828。

r $t0 = 0x0a4db828
.for (r $t1 = poi(@$t0);
      (@$t1 != 0) & (@$t1 != @$t0);
      r $t1 = poi(@$t1))
{
    .printf  "data:%x\\n",$t1
}