Debugging ProcDump是否使用调试堆?
当我们在Visual Studio 2013或WinDbg等调试器下启动应用程序时,Windows将使用调试堆。但是,似乎可以关闭该行为,就像在Visual Studio 2015或WinDbg中使用Debugging ProcDump是否使用调试堆?,debugging,windbg,procdump,Debugging,Windbg,Procdump,当我们在Visual Studio 2013或WinDbg等调试器下启动应用程序时,Windows将使用调试堆。但是,似乎可以关闭该行为,就像在Visual Studio 2015或WinDbg中使用-hd命令行开关启动时所做的那样 现在有了一个调试器,它的行为就像一个调试器;事实上,它可以通过-i开关安装为AE事后调试器 如何确定使用ProcDump的-x开关运行应用程序是否会使用调试堆?似乎没有命令行选项来更改行为,我也不确定它是否会遵守_NO_DEBUG_HEAP环境变量 我认为调试器将使
-hd
命令行开关启动时所做的那样
现在有了一个调试器,它的行为就像一个调试器;事实上,它可以通过-i
开关安装为AE事后调试器
如何确定使用ProcDump的-x
开关运行应用程序是否会使用调试堆?似乎没有命令行选项来更改行为,我也不确定它是否会遵守_NO_DEBUG_HEAP环境变量
我认为调试器将使用或启动进程。它将传递哪个CreateFlags
可以设置DEBUG\u CREATE\u PROCESS\u NO\u DEBUG\u HEAP
标志
所以我使用了WinDbg并在WinDbg下启动了ProcDump。然后,我等待调试器引擎模块被加载(sxe ld dbgeng
),这样我就可以设置一个断点并观察它了——但该模块从未被加载
cdb -c "!gflag;q" procdump.exe -x procdump.exe | grep -i -A 5 ntglob
Current NtGlobalFlag contents: 0x00000070
htc - Enable heap tail checking
hfc - Enable heap free checking
hpc - Enable heap parameter checking
quit:
不带debugheap
cdb -hd -c "!gflag;q" procdump.exe -x procdump.exe | grep -i -A 5 ntglob
Current NtGlobalFlag contents: 0x00000000
quit:
如果是调试堆ntdll!RtlDebugAllocateHeap在其他情况下不使用
脚本内容
cat testdbgheap.txt
bp ntdll!RtlDebugAllocateHeap "kb4;q"
g
用dbgheap
cdb -c "$$>a< testdbgheap.txt" -o -g procdump.exe -x foo.dmp "c:\Windows\System32\NETSTAT.EXE" -a
Microsoft (R) Windows Debugger Version 10.0.10586.567 X86
CommandLine: procdump.exe -x foo.dmp "c:\Windows\System32\NETSTAT.EXE" -a
ProcDump v7.1 - Writes process dump files
0:000> cdb: Reading initial command '$$>a< testdbgheap.txt'
ChildEBP RetAddr Args to Child
0022f788 76eda376 00320000 40000062 0000000c ntdll!RtlDebugAllocateHeap
0022f86c 76ea5ae0 0000000c 00000000 00000000 ntdll!RtlpAllocateHeap+0xc4
0022f8f0 0096f5f1 00320000 40000060 0000000c ntdll!RtlAllocateHeap+0x23a
WARNING: Stack unwind information not available. Following frames may be wrong.
0022f910 0096fca0 0000000c 00000000 00000000 procdump+0xf5f1
quit:
断开时堆叠
cdb -c "bp kernel32!CreateProcessW \"ddu /c 1 @esp lc;q\";g" procdump.exe -x . netstat -a
| grep -i quit -B 11
0178e340 00000000
0178e344 012acc30 ""netstat" -a"
0178e348 00000000
0178e34c 00000000
0178e350 00000000
0178e354 00000007 CreateSuspended | debug process | debug only this
0178e358 00000000
0178e35c 00000000
0178e360 0178e3a0 "D" = 0x44 = sizeof(startupinfo)
0178e364 0178e390 ""
0178e368 00000000
quit:
在procdump上通过procdump更新windbg检查子进程
cdb-hd-g-o-c“!处理进程0;.tlist;q”procdump-x。计算
Microsoft (R) Windows Debugger Version 10.0.10586.567 X86
CommandLine: procdump -x . calc
ProcDump v7.1 - Writes process dump files
0:000> cdb: Reading initial command '!handle 0 f Process;.tlist;q'
Handle e8
Type Process
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Object Specific Information
Process Id 2836
Parent Process 2900
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1 handles of type Process
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
0n2860 cdb.exe
0n2900 procdump.exe
0n2836 calc.exe
直接问这个标记:这些是cdb使用的标志,而不是ProcDump使用的标志——或者我遗漏了什么?但是我可能会使用ProcDump创建一个转储,然后检查转储中的标志,如果调试堆与那些运行
的标志完全相同!gflag
在由procdump-x创建的转储文件上。procdump
返回当前NtGlobalFlag内容:0x00000000@ThomasWeller-hd应用于被调试对象,因此第一个procdump没有debugheap,通常子进程继承父进程特征,但如果您希望确认,只需请求windbg打开。子进程并检查,您会注意到它没有使用debug heap
cdb -c "bp kernel32!CreateProcessW \"ddu /c 1 @esp lc;q\";g" procdump.exe -x . netstat -a
| grep -i quit -B 11
0178e340 00000000
0178e344 012acc30 ""netstat" -a"
0178e348 00000000
0178e34c 00000000
0178e350 00000000
0178e354 00000007 CreateSuspended | debug process | debug only this
0178e358 00000000
0178e35c 00000000
0178e360 0178e3a0 "D" = 0x44 = sizeof(startupinfo)
0178e364 0178e390 ""
0178e368 00000000
quit:
Microsoft (R) Windows Debugger Version 10.0.10586.567 X86
CommandLine: procdump -x . calc
ProcDump v7.1 - Writes process dump files
0:000> cdb: Reading initial command '!handle 0 f Process;.tlist;q'
Handle e8
Type Process
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Object Specific Information
Process Id 2836
Parent Process 2900
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
1 handles of type Process
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
0n2860 cdb.exe
0n2900 procdump.exe
0n2836 calc.exe