;;\r
;; For reference, the context structure looks like this:\r
;; struct {\r
-;; UINT32 ExceptionData;\r
-;; FX_SAVE_STATE FxSaveState; // 512 bytes, must be 16 byte aligned\r
-;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;\r
-;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;\r
-;; UINT32 Ldtr, Tr;\r
-;; UINT64 Gdtr, Idtr;\r
-;; UINT32 EFlags;\r
-;; UINT32 Eip;\r
-;; UINT32 SegGs, SegFs, SegEs, SegDs, SegCs, SegSs;\r
-;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;\r
+;; UINT32 ExceptionData;\r
+;; FX_SAVE_STATE_IA32 FxSaveState; // 512 bytes, must be 16 byte aligned\r
+;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;\r
+;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;\r
+;; UINT32 EFlags;\r
+;; UINT32 Ldtr, Tr;\r
+;; UINT32 Gdtr[2], Idtr[2];\r
+;; UINT32 Eip;\r
+;; UINT32 Gs, Fs, Es, Ds, Cs, Ss;\r
+;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;\r
;; } SYSTEM_CONTEXT_IA32; // 32 bit system context record\r
\r
\r
mov eax, Vector\r
mov ecx, DestPtr\r
mov word ptr [ecx], ax ; write bits 15..0 of offset\r
- mov word ptr [ecx+2], 20h ; SYS_CODE_SEL from GDT\r
+ mov dx, cs\r
+ mov word ptr [ecx+2], dx ; SYS_CODE_SEL from GDT\r
mov word ptr [ecx+4], 0e00h OR 8000h ; type = 386 interrupt gate, present\r
shr eax, 16\r
mov word ptr [ecx+6], ax ; write bits 31..16 of offset\r
; copied and fixed up once for each IDT entry that is hooked.\r
;\r
InterruptEntryStub::\r
- mov AppEsp, esp ; save stack top\r
+ mov AppEsp, esp ; save stack top\r
mov esp, offset DebugStackBegin ; switch to debugger stack\r
- push 0 ; push vector number - will be modified before installed\r
- db 0e9h ; jump rel32\r
- dd 0 ; fixed up to relative address of CommonIdtEntry\r
+ push 0 ; push vector number - will be modified before installed\r
+ db 0e9h ; jump rel32\r
+ dd 0 ; fixed up to relative address of CommonIdtEntry\r
InterruptEntryStubEnd:\r
\r
\r
;;\r
;; typedef\r
;; struct {\r
-;; UINT32 ExceptionData;\r
-;; FX_SAVE_STATE FxSaveState;\r
-;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;\r
-;; UINT32 Cr0, Cr2, Cr3, Cr4;\r
-;; UINT32 Ldtr, Tr;\r
-;; UINT64 Gdtr, Idtr;\r
-;; UINT32 EFlags;\r
-;; UINT32 Eip;\r
-;; UINT32 SegGs, SegFs, SegEs, SegDs, SegCs, SegSs;\r
-;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;\r
+;; UINT32 ExceptionData;\r
+;; FX_SAVE_STATE_IA32 FxSaveState;\r
+;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;\r
+;; UINT32 Cr0, Cr2, Cr3, Cr4;\r
+;; UINT32 EFlags;\r
+;; UINT32 Ldtr, Tr;\r
+;; UINT32 Gdtr[2], Idtr[2];\r
+;; UINT32 Eip;\r
+;; UINT32 Gs, Fs, Es, Ds, Cs, Ss;\r
+;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;\r
;; } SYSTEM_CONTEXT_IA32; // 32 bit system context record\r
\r
;; UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;\r
mov eax, AppEsp\r
push dword ptr [eax]\r
\r
-;; UINT64 Gdtr, Idtr;\r
+;; UINT32 Gdtr[2], Idtr[2];\r
push 0\r
push 0\r
sidt fword ptr [esp]\r
mov eax, dr0\r
push eax\r
\r
-;; FX_SAVE_STATE FxSaveState;\r
+;; FX_SAVE_STATE_IA32 FxSaveState;\r
sub esp, 512\r
mov edi, esp\r
; IMPORTANT!! The debug stack has been carefully constructed to\r
;; UINT32 ExceptionData;\r
add esp, 4\r
\r
-;; FX_SAVE_STATE FxSaveState;\r
+;; FX_SAVE_STATE_IA32 FxSaveState;\r
mov esi, esp\r
FXRSTOR_ESI\r
add esp, 512\r
mov eax, AppEsp\r
pop dword ptr [eax + 8]\r
\r
-;; UINT16 Ldtr, Tr;\r
-;; UINT64 Gdtr, Idtr;\r
+;; UINT32 Ldtr, Tr;\r
+;; UINT32 Gdtr[2], Idtr[2];\r
;; Best not let anyone mess with these particular registers...\r
add esp, 24\r
\r
pop ss\r
\r
;; The next stuff to restore is the general purpose registers that were pushed\r
-;; using the pushad instruction.\r
+;; using the "pushad" instruction.\r
;;\r
;; The value of ESP as stored in the context record is the application ESP\r
;; including the 3 entries on the application stack caused by the exception\r
mov AppEsp, eax\r
NoAppStackMove:\r
mov eax, DebugEsp ; restore the DebugEsp on the debug stack\r
- ; so our popad will not cause a stack switch\r
+ ; so our "popad" will not cause a stack switch\r
mov [esp + 12], eax\r
\r
cmp ExceptionNumber, 068h\r