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:
デバッグヒープなし
cdb -hd -c "!gflag;q" procdump.exe -x procdump.exe | grep -i -A 5 ntglob
Current NtGlobalFlag contents: 0x00000000
quit:
debugheap 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 -hd -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'
[23:12:29] Dump 1 initiated: foo.dmp\NETSTAT.EXE_161108_231229.dmp
Active Connections
Proto Local Address Foreign Address State
TCP 192.168.43.171:49464 stackoverflow:https ESTABLISHED
[23:12:29] Dump count not reached.
0:000> q
quit:
procdump は dbgeng 関数を使用せず、win32apis CreateProcessW (CreateFlags 0x7) を使用します
depends または dumpbin /imports を実行して、モジュールを確認できます
dumpbin /imports procdump.exe | grep -i process
4 EnumProcessModules
C6 DebugActiveProcessStop
A8 CreateProcessW
1C0 GetCurrentProcess
380 OpenProcess
1DF GetExitCodeProcess
4C0 TerminateProcess
396 Process32FirstW
398 Process32NextW
C5 DebugActiveProcess
119 ExitProcess
24C GetProcessId
1C1 GetCurrentProcessId
3C3 ReadProcessMemory
304 IsProcessorFeaturePresent
24A GetProcessHeap
1A4 GetWindowThreadProcessId
212 OpenProcessToken
休憩時にスタック
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:
UPDATE は、procdump 上の procdump で windbg を使用して子プロセスをチェックします
cdb -hd -g -o -c "!handle 0 f Process;.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