📄 cwhelp.asm
字号:
mov ecx,4
@@0hb: cmp HBRK_Flags[esi],1+2
jnz @@1hb
mov bx,HBRK_Handle[esi]
mov ax,0b02h
int 31h
jc @@1hb
test ax,1
jnz @@8hb
@@1hb: add esi,size HBRK
dec ecx
jnz @@0hb
or eax,-1
jmp @@10hb
;
@@8hb: xor eax,eax
;
@@10hb: pop ds
popad
ret
IsHardBreak endp
;*******************************************************************************
;Catch single instruction trace and debug register traps.
;*******************************************************************************
Int01Handler proc near public
pushs eax,ebp,ds,es
mov ax,DGROUP ;make our data addresable.
mov ds,ax
cmp Executing,0
jz @@Oldi01
mov Executing,0
call IsHardBreak
jnz @@0i01
mov ExceptionFlag,1
@@0i01: or TraceFlag,-1
mov ebp,esp ;make stack addresable.
;
;Need a stack alias for DPMI.
;
mov ax,ss
mov es,ax
;
;Retrieve general registers.
;
mov eax,es:[ebp+4+4+4]
mov DebugEAX,eax
mov DebugEBX,ebx
mov DebugECX,ecx
mov DebugEDX,edx
mov DebugESI,esi
mov DebugEDI,edi
mov eax,es:[ebp+4+4]
mov DebugEBP,eax
mov ax,es:[ebp+4]
mov DebugDS,ax
mov ax,es:[ebp+0]
mov DebugES,ax
mov DebugFS,fs
mov DebugGS,gs
;
;Fetch origional Flags:CS:EIP
;
mov eax,es:[ebp+(4+4+4+4)+(4+4)]
and eax,not 256
mov DebugEFL,eax
mov eax,es:[ebp+(4+4+4+4)+(4)]
mov DebugCS,ax
mov eax,es:[ebp+(4+4+4+4)+(0)]
mov DebugEIP,eax
;
;Now modify origional CS:EIP,SS:ESP values and return control
;to this code via interupt structure to restore stacks.
;
mov eax,offset @@returni01
mov es:[ebp+(4+4+4+4)+(0)],eax
mov es:w[ebp+(4+4+4+4)+(4)],cs
and es:w[ebp+(4+4+4+4)+(4+4)],65535-256
pops eax,ebp,ds,es
iretd
;
@@returni01: ;Now return control to exec caller.
;
mov ax,DGROUP
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov DebugSS,ss
mov DebugESP,esp
lss esp,f[DebuggerESP]
ret
;
@@Oldi01:
pops eax,ebp,ds,es
assume ds:nothing
jmp cs:f[OldInt01]
assume ds:DGROUP
OldInt01 df 0
Int01Handler endp
public OldInt01
;*******************************************************************************
;Catch single step or debug register traps.
;*******************************************************************************
EInt01Handler proc near public
pushs eax,ebp,ds,es
mov ax,DGROUP ;make our data addresable.
mov ds,ax
cmp Executing,0
jz @@Olde01
mov Executing,0
call IsHardBreak
jnz @@0e01
mov ExceptionFlag,1
@@0e01: or TraceFlag,-1
mov ebp,esp ;make stack addresable.
mov ax,ss
mov es,ax
;
;Retrieve general registers.
;
mov eax,es:[ebp+4+4+4]
mov DebugEAX,eax
mov DebugEBX,ebx
mov DebugECX,ecx
mov DebugEDX,edx
mov DebugESI,esi
mov DebugEDI,edi
mov eax,es:[ebp+4+4]
mov DebugEBP,eax
mov ax,es:[ebp+4]
mov DebugDS,ax
mov ax,es:[ebp+0]
mov DebugES,ax
mov DebugFS,fs
mov DebugGS,gs
;
;Fetch origional Flags:CS:EIP
;
mov eax,es:[ebp+(4+4+4)+(4+4+4)+(4+4)+4]
and eax,not 256
mov DebugEFL,eax
mov ax,es:[ebp+(4+4+4)+(4+4+4)+(4)+4]
mov DebugCS,ax
mov eax,es:[ebp+(4+4+4)+(4+4+4)+(0)+4]
mov DebugEIP,eax
;
;Now modify origional CS:EIP,SS:ESP values and return control
;to this code via interupt structure to restore stacks.
;
mov eax,offset @@returne01
mov es:d[ebp+(4+4+4)+(4+4+4)+(0)+4],eax
mov es:w[ebp+(4+4+4)+(4+4+4)+(4)+4],cs
and es:w[ebp+(4+4+4)+(4+4+4)+(4+4)+4],65535-256
pops eax,ebp,ds,es
retf
;
@@returne01: ;Now return control to exec caller.
;
mov ax,DGROUP
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov DebugSS,ss
mov DebugESP,esp
lss esp,f[DebuggerESP]
ret
;
@@Olde01:
pops eax,ebp,ds,es
assume ds:nothing
jmp cs:f[OldEInt01]
assume ds:DGROUP
OldEInt01 df 0
EInt01Handler endp
public OldEInt01
;*******************************************************************************
;Catch INT 3's.
;*******************************************************************************
Int03Handler proc near public
pushs eax,ebp,ds,es
mov ax,DGROUP ;make our data addresable.
mov ds,ax
cmp Executing,0
jz @@Oldi03
mov Executing,0
or BreakFlag,-1
mov ebp,esp ;make stack addresable.
;
;Need a stack alias for DPMI.
;
mov ax,ss
mov es,ax
;
;Retrieve general registers.
;
mov eax,es:[ebp+4+4+4]
mov DebugEAX,eax
mov DebugEBX,ebx
mov DebugECX,ecx
mov DebugEDX,edx
mov DebugESI,esi
mov DebugEDI,edi
mov eax,es:[ebp+4+4]
mov DebugEBP,eax
mov ax,es:[ebp+4]
mov DebugDS,ax
mov ax,es:[ebp+0]
mov DebugES,ax
mov DebugFS,fs
mov DebugGS,gs
;
;Fetch origional Flags:CS:EIP
; MED 08/15/96
; attempt to allow debugging of hardware interrupt handler
; which has extra values placed on stack
KernalSS equ 68h+3 ;Kernal SS
mov ax,ss
cmp ax,KernalSS
jne med2a
mov eax,es:[ebp+(4+4+4+4)+(4+4)+(4+4+4)]
and eax,not 256
mov DebugEFL,eax
mov eax,es:[ebp+(4+4+4+4)+(4)+(4+4+4)]
mov DebugCS,ax
mov eax,es:[ebp+(4+4+4+4)+(0)+(4+4+4)]
mov DebugEIP,eax
jmp med2b
med2a:
mov eax,es:[ebp+(4+4+4+4)+(4+4)]
and eax,not 256
mov DebugEFL,eax
mov eax,es:[ebp+(4+4+4+4)+(4)]
mov DebugCS,ax
mov eax,es:[ebp+(4+4+4+4)+(0)]
mov DebugEIP,eax
med2b:
cmp ExceptionFlag,-1
jnz @@NoEIPDec
dec DebugEIP ;account for int 3 instruction length.
cmp TerminationFlag,-1
jnz @@NoEIPDec
dec DebugEIP
@@NoEIPDec:
;Now modify origional CS:EIP,SS:ESP values and return control
;to this code via interupt structure to restore stacks.
;
mov eax,offset @@returni03
mov es:[ebp+(4+4+4+4)+(0)],eax
mov es:w[ebp+(4+4+4+4)+(4)],cs
and es:w[ebp+(4+4+4+4)+(4+4)],65535-256
pops eax,ebp,ds,es
iretd
;
@@returni03: ;Now return control to exec caller.
;
mov ax,DGROUP
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov DebugSS,ss
mov DebugESP,esp
lss esp,f[DebuggerESP]
ret
;
@@Oldi03:
pops eax,ebp,ds,es
assume ds:nothing
jmp cs:f[OldInt03]
assume ds:DGROUP
OldInt03 df 0
Int03Handler endp
public OldInt03
;*******************************************************************************
;Catch break exceptions.
;*******************************************************************************
EInt03Handler proc near public
pushs eax,ebp,ds,es
mov ax,DGROUP ;make our data addresable.
mov ds,ax
cmp Executing,0
jz @@Olde03
mov Executing,0
or BreakFlag,-1
mov ebp,esp ;make stack addresable.
mov ax,ss
mov es,ax
;
;Retrieve general registers.
;
mov eax,es:[ebp+4+4+4]
mov DebugEAX,eax
mov DebugEBX,ebx
mov DebugECX,ecx
mov DebugEDX,edx
mov DebugESI,esi
mov DebugEDI,edi
mov eax,es:[ebp+4+4]
mov DebugEBP,eax
mov ax,es:[ebp+4]
mov DebugDS,ax
mov ax,es:[ebp+0]
mov DebugES,ax
mov DebugFS,fs
mov DebugGS,gs
;
;Fetch origional Flags:CS:EIP
;
mov eax,es:[ebp+(4+4+4)+(4+4+4)+(4+4)+4]
and eax,not 256
mov DebugEFL,eax
mov ax,es:[ebp+(4+4+4)+(4+4+4)+(4)+4]
mov DebugCS,ax
mov eax,es:[ebp+(4+4+4)+(4+4+4)+(0)+4]
mov DebugEIP,eax
;
cmp ExceptionFlag,-1
jnz @@NoEIPDece03
dec DebugEIP ;account for int 3 instruction length.
cmp TerminationFlag,-1
jnz @@NoEIPDece03
dec DebugEIP
@@NoEIPDece03: ;
;Now modify origional CS:EIP,SS:ESP values and return control
;to this code via interupt structure to restore stacks.
;
mov eax,offset @@returne03
mov es:d[ebp+(4+4+4)+(4+4+4)+(0)+4],eax
mov es:w[ebp+(4+4+4)+(4+4+4)+(4)+4],cs
and es:w[ebp+(4+4+4)+(4+4+4)+(4+4)+4],65535-256
pops eax,ebp,ds,es
retf
;
@@returne03: ;Now return control to exec caller.
;
mov ax,DGROUP
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov DebugSS,ss
mov DebugESP,esp
lss esp,f[DebuggerESP]
ret
;
@@Olde03:
pops eax,ebp,ds,es
assume ds:nothing
jmp cs:f[OldEInt03]
assume ds:DGROUP
OldEInt03 df 0
EInt03Handler endp
public OldEInt03
;*******************************************************************************
;Catch divide by zero faults.
;*******************************************************************************
Exc00Handler proc near public
pushs eax,ebp,ds,es
mov ax,DGROUP ;make our data addresable.
mov ds,ax
cmp Executing,0
jz @@Olde00
mov Executing,0
mov ExceptionFlag,0
mov ebp,esp ;make stack addresable.
mov ax,ss
mov es,ax
;
;Retrieve general registers.
;
mov eax,es:[ebp+4+4+4]
mov DebugEAX,eax
mov DebugEBX,ebx
mov DebugECX,ecx
mov DebugEDX,edx
mov DebugESI,esi
mov DebugEDI,edi
mov eax,es:[ebp+4+4]
mov DebugEBP,eax
mov ax,es:[ebp+4]
mov DebugDS,ax
mov ax,es:[ebp+0]
mov DebugES,ax
mov DebugFS,fs
mov DebugGS,gs
;
;Fetch origional Flags:CS:EIP
;
mov eax,es:[ebp+(4+4+4)+(4+4+4)+(4+4)+4]
and eax,not 256
mov DebugEFL,eax
mov ax,es:[ebp+(4+4+4)+(4+4+4)+(4)+4]
mov DebugCS,ax
mov eax,es:[ebp+(4+4+4)+(4+4+4)+(0)+4]
mov DebugEIP,eax
;
;Now modify origional CS:EIP,SS:ESP values and return control
;to this code via interupt structure to restore stacks.
;
mov eax,offset @@returne00
mov es:d[ebp+(4+4+4)+(4+4+4)+(0)+4],eax
mov es:w[ebp+(4+4+4)+(4+4+4)+(4)+4],cs
and es:w[ebp+(4+4+4)+(4+4+4)+(4+4)+4],65535-256
pops eax,ebp,ds,es
retf
;
@@returne00: ;Now return control to exec caller.
;
mov ax,DGROUP
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov DebugSS,ss
mov DebugESP,esp
lss esp,f[DebuggerESP]
ret
;
@@Olde00:
pops eax,ebp,ds,es
assume ds:nothing
jmp cs:f[OldExc00]
assume ds:DGROUP
OldExc00 df 0
Exc00Handler endp
public OldExc00
;*******************************************************************************
;Catch stack exceptions.
;*******************************************************************************
Exc12Handler proc near public
pushs eax,ebp,ds,es
mov ax,DGROUP ;make our data addresable.
mov ds,ax
cmp Executing,0
jz @@Olde12
mov Executing,0
mov ExceptionFlag,12
mov ebp,esp ;make stack addresable.
mov ax,ss
mov es,ax
;
;Retrieve general registers.
;
mov eax,es:[ebp+4+4+4]
mov DebugEAX,eax
mov DebugEBX,ebx
mov DebugECX,ecx
mov DebugEDX,edx
mov DebugESI,esi
mov DebugEDI,edi
mov eax,es:[ebp+4+4]
mov DebugEBP,eax
mov ax,es:[ebp+4]
mov DebugDS,ax
mov ax,es:[ebp+0]
mov DebugES,ax
mov DebugFS,fs
mov DebugGS,gs
;
;Fetch origional Flags:CS:EIP
;
mov eax,es:[ebp+(4+4+4)+(4+4+4)+(4+4)+4]
and eax,not 256
mov DebugEFL,eax
mov ax,es:[ebp+(4+4+4)+(4+4+4)+(4)+4]
mov DebugCS,ax
mov eax,es:[ebp+(4+4+4)+(4+4+4)+(0)+4]
mov DebugEIP,eax
;
;Now modify origional CS:EIP,SS:ESP values and return control
;to this code via interupt structure to restore stacks.
;
mov eax,offset @@returne12
mov es:d[ebp+(4+4+4)+(4+4+4)+(0)+4],eax
mov es:w[ebp+(4+4+4)+(4+4+4)+(4)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -