下面是我写的安装9号中断的程序,当输入a并松开的时候,显示满屏幕的'A',按其它键默认处理
; p62.asm
assume cs:code
stack segment
db 128 dup(0)
stack ends
code segment
start:
mov ax, stack
mov ss, ax
mov sp, 128
push cs
pop ds
mov ax, 0
mov es, ax
mov si, offset int9
mov di, 204h
mov cx, offset int9end - offset int9
cld
rep movsb
push es:[9*4]
pop es:[200h]
push es:[9*4+2]
pop es:[202h]
cli
mov word ptr es:[9*4], 204h
mov word ptr es:[9*4+2], 0
sti
mov ax, 4c00h
int 21h
int9:
push ax
push cx
push si
push es
in al, 60h
pushf
call dword ptr cs:[200h]
cmp al, 9eh
jne int9ret
mov ax, 0b800h
mov es, ax
xor si, si
mov cx, 2000
s: mov byte ptr es:[si], 'A'
add si, 2
loop s
int9ret:
pop es
pop si
pop cx
pop ax
iret
int9end:nop
code ends
end start
当安装了该中断之后,只要按'a'键,就会满屏幕的‘A’,如果你是在windows的dos窗口下运行该程序,那么你必须重新启动该窗口,否则你要是干其它的活,比如,你要继续用masm编译程序的话,是根本不可能的,所以,能安装,就能卸载,根据上面一个程序,我写了一个卸载程序,恢复原有的9号中断,不过,有一点要求,就是该程序的可执行文件不能含有字母'a',这样,你就可以随时安装,随时卸载了,下面是卸载程序:
assume cs:code
; p63.asm
; 清除p62.asm 安装的9号中断,恢复原有的9号中断
code segment
start:
mov ax, 0
mov ds, ax
cli
mov ax, ds:[200h]
mov ds:[9*4], ax
mov ax, ds:[202h]
mov ds:[9*4+2], ax
sti
mov ax, 4c00h
int 21h
code ends
end start |