在windbg中打开calc.exe
windbg calc
跳过所有 ldrint 系统调用
bp calc!WinMain ; g
仅从 eip 跟踪 calc 模块到某个特定地址并打印返回值(请注意使用任意值作为 EndAddress 可能会通过在指令中间插入 0xcc 来破坏代码)
0:000> wt -l 2 -oR -m calc =@eip @eip+5fa
带有返回值的跟踪结果(已修剪)
30 0 [ 0] calc!WinMain
5 0 [ 1] kernel32!GetModuleHandleWStub
1 0 [ 1] kernel32!GetModuleHandleW
11 0 [ 1] KERNELBASE!GetModuleHandleW eax = b40000
32 17 [ 0] calc!WinMain
11 0 [ 1] USER32!LoadStringW eax = a
36 28 [ 0] calc!WinMain
3 0 [ 1] calc!CCalculatorSQM::onAppEntry
5 0 [ 2] msvcrt!time
24 0 [ 2] msvcrt!_time32 eax = 574fd43e
5 29 [ 1] calc!CCalculatorSQM::onAppEntry eax = 574fd43e
41 62 [ 0] calc!WinMain
12 0 [ 1] calc!McGenEventRegister
38 0 [ 2] ntdll!EtwEventRegister eax = 0
14 38 [ 1] calc!McGenEventRegister eax = 0
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
364 12901 [ 0] calc!WinMain
24 0 [ 1] USER32!GetMessageW eax = 1
372 12925 [ 0] calc!WinMain
21 0 [ 1] USER32!TranslateAcceleratorW eax = 0
378 12946 [ 0] calc!WinMain
19 0 [ 1] calc!CContainer::HandleGlobalTabbing eax = 0
382 12965 [ 0] calc!WinMain
13347 instructions were executed in 13346 events (0 from other threads)
总结和 wt 在指示的地方打破了
ole32!CoInitialize 1 8 8 8
oleacc!ATL::CComObject<CPropMgr>::Release 1 16 16 16
oleacc!CPropMgr::SetHwndPropStr 5 66 66 66
0 system calls were executed
eax=000cf030 ebx=00000000 ecx=00b94210 edx=76f070b4 esi=00b94210 edi=766e667e
eip=00b41c2f esp=000cef5c ebp=000cfcc4 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
calc!WinMain+0x7d5:
00b41c2f e8e2010000 call calc!CEditBoxInput::HandleWinMainMessage (00b41e16)
0:000> ? calc!WinMain+5fa
note eip expression and EndAddress in wt command
Evaluate expression: 11803695 = 00b41c2f