patching icon indicating copy to clipboard operation
patching copied to clipboard

Add the ability to revert one patched instruction rather than entire patch

Open CaledoniaProject opened this issue 3 years ago • 1 comments

The Revert action reverts everything I've edited, can you change this behavior? It would be better to revert only the selected address range.

CaledoniaProject avatar Feb 15 '22 05:02 CaledoniaProject

It is actually possible to do partial reverts by selecting a range of the patch, and then right click -> revert.

Specifically, within the patch / preview UI, you can select a few characters on a single line of the instruction you want to revert, and right click revert that single instruction.

But reverting individual instructions is not always easy or intuitive, especially on architectures with mixed length instructions. Imagine you patch over a 5 byte instruction (say, a call instruction in x86) with a 3 byte instruction and a 2 byte instruction:

xor eax, eax
inc eax

If you revert inc eax .. what is the expected behavior? Restore the last two bytes of the call instruction that are now just garbage? If you chose to only show "revert instruction" in some cases but not others, it may become confusing/frustrating to users instead.

This is why I opted to make the default behavior to simply revert the entire contiguous patch. The fallback (range selection / partial reverts) was supposed to be the solution to this, but it's intentionally 'hidden' from users that might not know better.

PS: I noticed the single line range selection / revert is not working in the main IDA disass listing, but it does work within the patch preview window. I vaguely remember this being one of the bugs I found after release and wanted to fix but never got around to it.

gaasedelen avatar Aug 17 '24 04:08 gaasedelen