开发者

windbg scripting if else if output matches

I'd like to set a breakpoint at a certain function, and each time it breaks, I'd like to search a memory range for a certain string. If that string exists, I'd like to not conti开发者_JS百科nue. If it does, then continue. Any suggestions? I'm thinking it'd look something like this:

.foreach /s line (s -a 0 L?0xfffffff "UNIQUE_STRING") { .if (line =~ "UNIQUE_STRING") { .break } .else { gc } }

I'm not too familiar with the .foreach commmand, so I might have gotten it a little wrong. My other idea was something like this:

.if ((.shell -ci "s -a 0 L?0xfffffff \"UNIQUE_STRING\"" findstr "UNIQUE_STRING") != "") {} .else { gc }

Has anybody done something like this? (sorry, some of that is extreme pseudo code)


Have you thought about doing this as an extension instead? IDebugDataSpaces::SearchVirtual returns an error if the pattern isn't found, which would make this easier on you.

-scott


I think your command syntax is a little wrong. Try:

bu module!Class::Function ".if (condition) { .echo hit_breakpoint } .else { gc }"

Everytime the debugger hits Function() it will execute the echo statement if the condition is true.

Look up 'conditional breakpoints' in .hh (windbg help) for great information as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜