WinDbg: using commands for the condition in .if

前端 未结 1 664
傲寒
傲寒 2021-01-06 08:43

WinDbg has the .if statement for conditional execution of commands:

   .if (Condition) { Commands } .else { Commands } 

For Condition, it\'

1条回答
  •  北海茫月
    2021-01-06 09:18

    I tested this and it loads the correct sos.dll if it finds clr in the list of modules: .foreach (module {lm1m} ) { .if ($sicmp("${module}","clr") == 0) {.echo FOUND ${module}; .loadby sos.dll clr} }

    You can easily extend it using .elsif and comparing module with "mscorwks".

    As for checking for your process, I attached to calc.exe and ran | which gives me: . 0 id: 6bc attach name: C:\Windows\system32\calc.exe

    I only want the last token so I can skip the first six by specifying /pS 6 to .foreach. The following uses a wildcard comparison for *calc.exe and if found, tells the debugger to debug child processes:

    .foreach /pS 6 (token {|}) {.echo ${token}; .if($spat("${token}","*calc.exe") == 1) {.echo FOUND MY APP;.childdbg 1} .else {.echo FAILED TO FIND MY APP} }

    Also tested and worked.

    ps. my debugger version is 6.2.8400.0

    0 讨论(0)
提交回复
热议问题