不是 pykd 答案,但 windbgs 内置 pc/tc(步骤/跟踪到下一个呼叫)将打印出所有呼叫
0:000> .printf "%y\n" , @eip
multithread!wmain (00411430)
0:000> $ iam at start of winmain and i have disabled all output except disassembly via .prompt_allow
0:000> $ i have set a breakpoint on winmains exit
0:000> $ code for demo is exact copy paste of msdn sample code for createthread documentation
0:000> $lets roll and log all call instructions
0:000> tc 1000000
0041147c ff1530824100 call dword ptr [multithread!_imp__GetProcessHeap (00418230)]
00411484 e8e9fcffff call multithread!ILT+365(__RTC_CheckEsp) (00411172)
0041148a ff152c824100 call dword ptr [multithread!_imp__HeapAlloc (0041822c)]
7c955264 e827ffffff call ntdll!LdrpTagAllocateHeap (7c955190)
7c9551b0 e80faffbff call ntdll!RtlAllocateHeap (7c9100c4)
7c9100ce e8f8e7ffff call ntdll!_SEH_prolog (7c90e8cb)
removed =====================
7c923b25 e80b000000 call ntdll!LdrShutdownProcess+0x1e0 (7c923b35)
7c923b3a e8a1d5fdff call ntdll!RtlLeaveCriticalSection (7c9010e0)
7c923b2a e8d7adfeff call ntdll!_SEH_epilog (7c90e906)
7c81cac3 ff153410807c call dword ptr [kernel32!_imp__CsrClientCallServer (7c801034)]
7c912de3 e8f6acffff call ntdll!NtRequestWaitReplyPort (7c90dade)
7c90dae8 ff12 call dword ptr [edx]
7c90e512 0f34 sysenter
7c81cacc ffd6 call esi
7c90de78 ff12 call dword ptr [edx]
7c90e512 0f34 sysenter
7c90e514 c3 ret
如果您遵循 msdn 示例中的代码并且想要跟踪线程调用,则可以使用断点( hack 但在大多数情况下都可以使用)
.prompt_allow
要禁用除反汇编之外的所有内容,请
设置一个conditional break-point
onCreateThread
条件,setting another break point on poi(@esp+c)
LpThreadStartRoutine
直到下一次调用和
我们在示例中的步骤,因此我们在手动执行之前将 pc 10000000 的continuing
线程数自动化
了三倍。next three pc 1000000
one quit
know we have three threads
if you don't know
enter pc 1000000 manually on each thread exit
:cdb -c ".prompt_allow -src -reg -sym -ea ;g wmain;bp kernel32!CreateThread \"ba e1 poi(@esp+c) \\"?$tid ;pc 100000 \\";gc\" ;pc 100000;pc 1000000;pc 1000000;pc 1000000;pc 10000000;pc 1000000;pc 10000000;q" multithread.exe | grep -iE "写|评估"
Evaluate expression: 2148 = 00000864
004011c6 ff1520204000 call dword ptr [multithread!_imp__WriteConsoleW (004
02020)]
Evaluate expression: 2780 = 00000adc
004011c6 ff1520204000 call dword ptr [multithread!_imp__WriteConsoleW (004
02020)]
Evaluate expression: 3440 = 00000d70
004011c6 ff1520204000 call dword ptr [multithread!_imp__WriteConsoleW (004
02020)]