I'm writing a debugger on Windows. And I have this little useless assembly code I debug with it:
global _start
section .text
_start:
mov eax, 1
mov ebx, 2
mov ecx, 3
mov edx, [myVar]
push 0
hlt
section .data
myVar dw 1234h
Of course it will crash at hlt.
I write debugging events on the console, after running and continuing twice I have these:
Process created.
DLL loaded: ntdll.dll
DLL loaded: C:\WINDOWS\system32\kernel32.dll
Exception happened.
First chance exception.
>>> 0x7c90120e EXCEPTION_BREAKPOINT
Exception happened.
First chance exception.
>>> 0x00401017 EXCEPTION_PRIV_INSTRUCTION
Exception happened.
First chance exception.
>>> 0x00401017 EXCEPTION_PRIV_INSTRUCTION
Now the question is, why I get that breakpoint exception? I expect to get exceptions only for the privileged instruction.