Ok let's resume
My handler :
Code: Select all
void _cdecl IDTManager::DefaultHandler(){
__asm{
add esp, 12
pushad
}
IDTManager::cs->Write("Exception fired !"); // cs : static pointer to static object console
__asm{
popad
iretd
}
}
I try this test :
Call handler directly :
Code: Select all
IDT::IDTManager::DefaultHandler();
It works fine :
- write message "Exception fired !"
- hang on iretd // not an error for a classic call
call with int n or /0
hang directly , no message
I have put a breakpoint on my handler in bochs to trace and surprise ...
On the direct call i have this
Code: Select all
00100c90: ( ): push ebp ; 55
00100c91: ( ): mov ebp, esp ; 8bec
00100c93: ( ): push ebx ; 53
00100c94: ( ): push esi ; 56
00100c95: ( ): push edi ; 57
00100c96: ( ): add esp, 0x0000000c ; 83c40c
00100c99: ( ): pushad ; 60
00100c9a: ( ): push 0x0010163c ; 683c161000
00100c9f: ( ): mov ecx, dword ptr ds:0x102248 ; 8b0d48221000
00100ca5: ( ): call .+0xfffff806 ; e806f8ffff <--- the call to cs->Write(...
00100caa: ( ): popad ; 61
00100cab: ( ): iretd ; cf
On int or /0 i have this :
Code: Select all
00100c90: ( ): push bp ; 55
00100c91: ( ): mov bp, sp ; 8bec
00100c93: ( ): push bx ; 53
00100c94: ( ): push si ; 56
00100c95: ( ): push di ; 57
00100c96: ( ): add sp, 0x000c ; 83c40c
00100c99: ( ): pusha ; 60
00100c9a: ( ): push 0x163c ; 683c16
00100c9d: ( ): adc byte ptr ds:[bx+si], al ; 1000
00100c9f: ( ): mov cx, word ptr ds:[di] ; 8b0d
00100ca1: ( ): dec ax ; 48
00100ca2: ( ): and dl, byte ptr ds:[bx+si] ; 2210
00100ca4: ( ): add al, ch ; 00e8
00100ca6: ( ): push es ; 06
00100ca7: ( ): clc ; f8
00100ca8: ( ): (invalid) ; ffff ??? where is the call to cs->Write(... ???
00100caa: ( ): popa ; 61
00100cab: ( ): iret ; cf
It's the same code , the only change is the way of call.
It seems like 16 bits code interpretation on int
My descriptors are
0x0008 : 0x0c90 selector : offset low
0x0010 : 0x8E00 offset hight : flag - reserved
I clearly think that there is a switch to 16bits mode , but why an how ?
Any idea ?