wdebug.asm
来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 1,810 行 · 第 1/5 页
ASM
1,810 行
mov [edx.I_SaveSS],ax
jmp short was_special
not_special:
mov eax,[ebp.Client_ESP]
mov [edx.I_SaveESP],eax
mov eax,[ebp.Client_EIP]
mov [edx.I_SaveEIP],eax
mov eax,[ebp.Client_EFlags]
mov [edx.I_SaveEFLAGS],eax
mov ax,[ebp.Client_CS]
mov [edx.I_SaveCS],ax
mov ax,[ebp.Client_SS]
mov [edx.I_SaveSS],ax
was_special:
mov eax,[ebp.Client_EAX]
mov [edx.I_SaveEAX],eax
mov eax,[ebp.Client_EBX]
mov [edx.I_SaveEBX],eax
mov eax,[ebp.Client_ECX]
mov [edx.I_SaveECX],eax
mov eax,[ebp.Client_EDX]
mov [edx.I_SaveEDX],eax
mov eax,[ebp.Client_ESI]
mov [edx.I_SaveESI],eax
mov eax,[ebp.Client_EDI]
mov [edx.I_SaveEDI],eax
mov eax,[ebp.Client_EBP]
mov [edx.I_SaveEBP],eax
mov ax,[ebp.Client_DS]
mov [edx.I_SaveDS],ax
mov ax,[ebp.Client_ES]
mov [edx.I_SaveES],ax
mov ax,[ebp.Client_FS]
mov [edx.I_SaveFS],ax
mov ax,[ebp.Client_GS]
mov [edx.I_SaveGS],ax
mov ax,FaultType
mov [edx.I_InterruptNumber],ax
;*
;*** point application at special code segment to handle the fault
;*
and word ptr [ebp.Client_EFlags],not 100h ; turn off trace trap bit
mov ax,ICCodeSeg
mov [ebp.Client_CS],ax
movzx eax,ICCodeOff
mov [ebp.Client_EIP],eax
mov ax,ICDataSeg
mov [ebp.Client_DS],ax
mov [ebp.Client_ES],ax
mov [ebp.Client_FS],ax
mov [ebp.Client_GS],ax
mov ax,ICStackSeg
mov [ebp.Client_SS],ax
movzx eax,ICStackOff
mov [ebp.Client_ESP],eax
ret
ReflectTo16Bit ENDP
Is32BitSel PROC NEAR
VxDcall3 _GetDescriptor, eax, ebx, 0
mov dword ptr Descriptor+4,edx
test Desc4,040h
ret
Is32BitSel ENDP
;*
;*** various fault handlers
;*
BeginProc Fault00Handler
mov FaultType,0h
cmp ICVM,ebx
jne short ret00
movzx eax,[ebp.Client_SS]
call Is32BitSel
je short ret00
jmp ReflectTo16Bit
ret00:
jmp [Old00Handler]
EndProc Fault00Handler
BeginProc Fault06Handler
mov FaultType,6h
cmp ICVM,ebx
jne short ret06
cmp RealFault,0
jne ReflectTo16Bit
movzx eax,[ebp.Client_SS]
call Is32BitSel
je short ret06
jmp ReflectTo16Bit
ret06:
jmp [Old06Handler]
EndProc Fault06Handler
BeginProc Fault07Handler
pushad
movzx edx,[ebp.Client_CS]
mov ecx,0
mov edi,OFFSET EMUList
again102:
cmp word ptr [edi.E_CS],dx
je short fnd102
add edi,EMU_SIZE
inc ecx
cmp ecx,MAX_EMU_REG
jne short again102
mov eax,edx
call Is32BitSel
je short fault07_16bit
popad
jmp [Old07Handler]
fnd102:
VxDcall3 _SelectorMapFlat, ebx, edx, 0 ; returns linear addr in eax
mov ecx,ebx ; VM Handle
mov ebx,dword ptr [edi.E_8087] ; 8087 ptr
add ebx,eax ; add linear offset
call __Win387_emulator
popad
ret
fault07_16bit:
;
; We are in a 16-bit segment. Decode the instruction to find the
; start of the next instruction, and just return.
;
push es ; save es
movzx edx,[ebp.Client_CS]
mov es,dx ; point to code segment
mov esi,[ebp.Client_EIP] ; get instruction pointer
luup: mov al,es:[esi] ; get possible prefix in al
sub al,26H ; if its es:
js short endlup ; if signed, then not a prefix byte
je short is_es ; - continue with next byte
cmp al,09BH-26H ; check for "fwait" opcode
je short inc_si ; - yes, just skip over it
sub al,08H ; if its cs:
je short is_cs ; - record cs in cx and continue
sub al,08H ; if its ss:
je short is_ss ; - record ss in cx and continue
sub al,08H ; if its ds:
je short is_ds ; - record ds in cx and continue
sub al,26H ; if its fs:
je short is_fs ; - record fs in cx and continue
dec al ; if its gs:
je short is_gs ; - record gs in cx and continue
dec al ; if its operand length
je short inc_si ; - continue with next byte
dec al ; if its address length
jne short endlup ; - its not handled!!!!
is_cs:
is_ds:
is_es:
is_fs:
is_gs:
is_ss:
inc_si: inc esi ; just bump past prefix byte
jmp short luup ;
endlup:
mov al,es:[esi] ; load up opcode
and al,0F8h ; isolate top bits of opcode
cmp al,0D8h ; if it is not an 8087 opcode
jne short skip0 ; then get out
inc esi ; skip over opcode byte
mov al,es:[esi] ; get modrm byte MMxxxRRR
inc esi ; skip over modrm byte
cmp al,0C0H ; if its a 8087 STACK operation
jae short skip0 ; then end of instruction
test al,80H ; if 16-bit displacement follows
jne short skip2 ; then skip 2 bytes
test al,40H ; if 8-bit displacement follows
jne short skip1 ; then skip one byte
and al,7 ; isolate r/m bits
cmp al,6 ; if not mode 6
jne short skip0 ; then end of instruction
skip2: inc esi ; skip first byte
skip1: inc esi ; skip one byte
skip0:
mov [ebp.Client_EIP],esi ; update instruction pointer
pop es ; restore es
popad
ret
EndProc Fault07Handler
BeginProc Fault0DHandler
mov FaultType,0dh
cmp ICVM,ebx
jne short ret0d
movzx eax,[ebp.Client_SS]
call Is32BitSel
je short ret0d
jmp ReflectTo16Bit
ret0d:
jmp [Old0DHandler]
EndProc Fault0DHandler
JustReturn: ret
VxD_LOCKED_CODE_ENDS
VxD_CODE_SEG
Int01IDT:
cmp ss:[WasHotKey],1
jne short not_hot
mov ss:[WasHotKey],0
mov ss:[RealFault],257
jmp short GenericIDT
not_hot:
mov ss:[RealFault],1
GenericIDT:
push eax
mov eax,ss:[esp+014h] ; ss
mov ss:[RealSS],ax
mov eax,ss:[esp+010h] ; esp
cmp eax,8000000h ; did we have a 16-bit fault?
jb short no_zero ; yes!
movzx eax,ax
no_zero:
mov ss:[RealESP],eax
mov eax,ss:[esp+04h] ; eip
mov ss:[RealEIP],eax
mov eax,ss:[esp+08h] ; cs
mov ss:[RealCS],ax
mov eax,ss:[esp+0ch] ; eflags
mov ss:[RealEFlags],eax
and eax, not 0100h ; turn off T bit
mov ss:[esp+0ch],eax ; new flags
mov eax,ss:[ReflectToEIP]
mov ss:[esp+04h],eax ; new cs
movzx eax,ss:[ReflectToCS]
mov ss:[esp+08h],eax ; new eip
pop eax
iretd
Int03IDT:
mov ss:[RealFault],3
dec dword ptr ss:[esp] ; eip
jmp short GenericIDT
;************************************************
;*** ***
;*** WGod_Device_Init - do V86 initialization ***
;*** ***
;************************************************
BeginProc WGod_Device_Init
;*
;*** hook into V86 int 2f chain
;*
mov eax,02fh
mov esi,OFFSET WDebugV86_Int2F
VxDcall Hook_V86_Int_Chain
;*
;*** hook div by 0 fault
;*
mov eax,0
mov esi,OFFSET Fault00Handler
VxDcall Hook_PM_Fault
cmp esi,0
jne short aret0
mov esi,OFFSET JustReturn
aret0:
mov Old00Handler,esi
;*
;*** hook illegal instruction fault
;*
mov eax,6
mov esi,OFFSET Fault06Handler
VxDcall Hook_PM_Fault
cmp esi,0
jne short aret6
mov esi,OFFSET JustReturn
aret6:
mov Old06Handler,esi
;*
;*** hook Invalid Page Faults (08-feb-94)
;*
; mov eax,0eh
; mov esi,OFFSET Fault0EHandler
; VxDcall Hook_PM_Fault
; cmp esi,0
; jne short arete
; mov esi,OFFSET JustReturn
;arete:
; mov Old0EHandler,esi
;*
;*** hot key for debugging (NYI)
;*
mov ax,33 ; 'F' key
ShiftState <SS_Either_Ctrl + SS_Either_Alt + SS_Toggle_mask>, <SS_Ctrl + SS_Alt>
mov cl,CallOnPress
mov esi,OFFSET HotKeyPressed
mov edi,0
VxDcall VKD_Define_Hot_Key
clc
ret
EndProc WGod_Device_Init
;*********************************************
;*** ***
;*** HotStop - stop the system VM ***
;*** ***
;*********************************************
BeginProc HotStop
or [ebp.Client_EFlags],0100h
mov WasHotKey,1
ret
EndProc HotStop
;****************************************************;
;*** ***;
;*** HotKeyPressed - someone tried an asynch stop ***;
;*** ***;
;****************************************************;
BeginProc HotKeyPressed
cmp UseHotKey,0
jne short useit
ret
useit:
VxDcall Get_Sys_VM_Handle
mov esi,OFFSET HotStop
VxDcall Schedule_VM_Event
mov HotEventHandle,esi
ret
EndProc HotKeyPressed
;***********************************
;*** ***
;*** IDTFini - finished with IDT ***
;*** ***
;***********************************
IDTFini PROC near
push edi
push esi
push ecx
mov edi,IDTAddr
lea esi,[edi+1*8]
mov ecx,dword ptr [Idt01]
mov dword ptr [esi],ecx
mov ecx,dword ptr [Idt01+4]
mov dword ptr [esi+4],ecx
lea esi,[edi+3*8]
mov ecx,dword ptr [Idt03]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?