我想在每次windbg启动时运行一个初始命令,然后我不得不一直使用windbg -c blabla
。
是否有要写入的配置文件/注册表项?这样windbg会在启动时自动运行它们,无论是作为调试器还是由用户手动启动
我想在每次windbg启动时运行一个初始命令,然后我不得不一直使用windbg -c blabla
。
是否有要写入的配置文件/注册表项?这样windbg会在启动时自动运行它们,无论是作为调试器还是由用户手动启动
每次测试一些假设时,我都会加载一堆第三方扩展和补丁系统 DLL 。为了重复它,我在某处创建了一些文本文件c:\initwind.txt
,并将所有初始化内容放入该文本文件中。示例文件内容如下:
C:\>type initwind.txt
.echo windbg is starting
.echo loading extra extension sdbgext
.load sdbgext
.echo loading extra extension domdbg
.load domdbg
.echo patching ntdll for leet stuff
u 7c94b8a1 l1
eb 7c94b8a1+3 00
u 7c94b8a1 l1
为了利用这个文本文件,我创建了一个 bat 文件,PATH
其内容粘贴在下面。
注意-cfr
for cdb/kd 和-c $$>a<
for windbg 使用相同文件的用法。
此外,正如 Ed Chum 评论的那样,您可以将以下内容添加到 AeDebug:
C:\>reg query "hklm\software\microsoft\windows nt\currentversion\aedebug" /v Debugger
! REG.EXE VERSION 3.0
HKEY_LOCAL_MACHINE\software\microsoft\windows nt\currentversion\aedebug
Debugger REG_SZ "windbg.exe" -p %ld -e %ld -g -c "$$>a< c:\initwind.txt"
bat文件内容
C:\>type c:\WINDOWS\rundbg.bat
@ECHO OFF
IF "%1" == "windbg" goto windbg
IF "%1" == "cdb" goto cdb
IF "%1" == "lkd" goto lkd
IF "%1" == "" goto usage
:windbg
IF NOT "%2" == "" goto startwindapp
@call windbg.exe -c "$$>a< c:\initwind.txt"
goto exit
:startwindapp
@call windbg.exe -c "$$>a< c:\initwind.txt" %2
goto EXIT
:cdb
IF NOT "%2" == "" goto startcdbapp
@call cdb.exe -cfr "c:\initwind.txt"
goto exit
:startcdbapp
@call cdb.exe -cfr "c:\initwind.txt" %2
goto EXIT
:lkd
IF NOT "%2" == "" goto startkdapp
@call kd.exe -kl -cfr "c:\initwind.txt"
goto exit
:startkdapp
@call kd.exe -kl -cfr "c:\initwind.txt" %2
goto EXIT
:usage
echo runwind.bat ^<debugger viz windbg/cdb/kd^> ^<executable / other commands^>
goto exit
:exit
C:\>
我现在可以从任何命令提示符甚至从 Start -> Run 启动 windbg / cdb / kd -kl 等,我可以重新启动目标 n 次,而不必担心一次又一次地执行 init 操作。
示例输出如下所示calc.exe
,使用命令cdb.exe
重新启动。calc
.restart
要更改 init 命令,您只需编辑c:\initwind.txt
.
C:\>rundbg cdb calc
CommandLine: calc
ntdll!DbgBreakPoint:
7c90120e cc int 3
0:000> .echo windbg is starting
windbg is starting
0:000> .echo loading extra extension sdbgext
loading extra extension sdbgext
0:000> .load sdbgext
0:000> .echo loading extra extension domdbg
loading extra extension domdbg
0:000> .load domdbg
dom WinDBG extension v0.3 loaded
0:000> .echo patching ntdll for leet stuff
patching ntdll for leet stuff
0:000> u 7c94b8a1 l1
ntdll!RtlAllocateHeapSlowly+0xde6:
7c94b8a1 81e3ff0fffff and ebx,0FFFF0FFFh
0:000> eb 7c94b8a1+3 00
0:000> u 7c94b8a1 l1
ntdll!RtlAllocateHeapSlowly+0xde6:
7c94b8a1 81e3ff00ffff and ebx,0FFFF00FFh
0:000> .echo checking the extension chain
checking the extension chain
0:000> .extcmds
.load ntsdexts
.load uext
.load exts
.load ext
.load dbghelp
.load sdbgext
.load domdbg
0:000> .restart
CommandLine: calc
ntdll!DbgBreakPoint:
7c90120e cc int 3
0:000> .echo windbg is starting
windbg is starting
0:000> .echo loading extra extension sdbgext
loading extra extension sdbgext
0:000> .load sdbgext
0:000> .echo loading extra extension domdbg
loading extra extension domdbg
0:000> .load domdbg
dom WinDBG extension v0.3 loaded
0:000> .echo patching ntdll for leet stuff
patching ntdll for leet stuff
0:000> u 7c94b8a1 l1
ntdll!RtlAllocateHeapSlowly+0xde6:
7c94b8a1 81e3ff0fffff and ebx,0FFFF0FFFh
0:000> eb 7c94b8a1+3 00
0:000> u 7c94b8a1 l1
ntdll!RtlAllocateHeapSlowly+0xde6:
7c94b8a1 81e3ff00ffff and ebx,0FFFF00FFh
0:000> .echo checking the extension chain
checking the extension chain
0:000> .extcmds
.load ntsdexts
.load uext
.load exts
.load ext
.load dbghelp
.load sdbgext
.load domdbg
0:000>