A quick way of disabling instructions you don't want to execute during a WinDbg session is to
nop (no-op) the code in memory. WinDbg takes care of changing the protection over the code segment pages and hopefully it also flushes the instruction cache. In any case, it seems to work fine. Let's look at an example.
In the session below, I want to disable the "
return BAD" statement under the breakpoint (the breakpoint is highlighted in red).
The first thing to do is to see which instructions have to be disabled. In the assembly window ensure that "Highlight instructions from current source line" is selected. This allows us to see which instructions correspond to the source line we want disabled.
Next, in the disassembly view, move to the line of interest (here I am using
"Source Line Syntax" (
`recfile.cpp:116`) but any addressing mode will work).
Finally, fill the range with the
NOP(=0x90) instruction (
"f <start> <end> 90" will work).
Done! Now, in my example, the "
return BAD;" will be ignored and the loop will continue.
Easy enough. Of course you can also do this with a
jmp instructions if you like but this is simpler and cleaner.