Jeko wrote:
INT 3 is the breakpoint exception, but I can use it how I want.
You can, however then you become limited with your debugging options. Int 3 (as a single opcode) is useful because a debugger can replace any instruction with it to create a breakpoint. You can replace a two byte instruction with a two byte opcode easily enough and so on, but it becomes more difficult when the instruction you want to break on is only one byte. For example, say you have:
Code:
func1:
add eax, 2;
ret;
func2:
mov eax, 5;
call func1;
ret;
Now you can easily break on the first line of func1 by replacing it with int3, or int 4,5,6 etc. Then your handler will trigger the 'break_point_hit' code, and restore the actual opcodes before iret to continue. To be short, it doesn't matter how much of the 'add eax, 2' opcodes you overwrite, because you will restore them before they are executed. The problem is if you want to break on the ret in func1. Replacing it with anything longer than a single opcode will overwrite the start of func2, and you cannot guarantee that that code will not be executed before the breakpoint (in func1) is hit (and the code restored), therefore a single byte interrupt instruction is very useful to have around. IMHO its best to preserve the special encoding of int 3 for this purpose.
Regards,
John.