【原创】DOS下TSR程序的汇编演示代码2--黑屏保护程序

王朝other·作者佚名  2006-01-09
宽屏版  字体: |||超大  

windows提供了屏幕保护程序,当我们在规定的时间内没有对电脑进行操作时,系统会自动运行我们事先指定的屏幕保护程序。

下面我们在DOS实现一个简单的黑屏保护程序。

注意:

1。如果你运行了明伦五笔高手速成,那么本程序将不起作用,可能的原因是明伦五笔高手速成修改了有关的DOS中断,而没有回调。

2。如果想在window 95/98的MS-DOS方式下使用,应将MS-DOS方式窗口设为全屏。

3。win 2000/xp未作测试。

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; 文件名: SafeScr.asm

; 功 能: 在指定时间内未使用键盘则关闭屏幕显示(黑屏)

;

; 作 者: 黄志斌 2003年3月 广西河池

;

;参考: 电脑报 1996年合订本上册243页代码, 软件报 1993年合订本114页代码

; 申 明: 可以自由转载,应保存完整性.且不能用于商业用途

;

; 说 明:

; 1. 第一次运行时常驻内存,再次运行则撤出内存

; 2.如果你运行了明伦五笔高手速成,那么本程序将不起作用,

; 可能的原因是明伦五笔高手速成修改了;有关的DOS中断,而没有回调。

2。如果想在window 95/98的MS-DOS方式下使用,应将MS-DOS方式窗口设为全屏。

3。win 2000/xp未作测试。; Log

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

;Name :

;Function : ;Author : Purple Endurer

;Reference: Computer paper 1996U243, Software 1993 P114

;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

cseg segment

assume cs: cseg, ds: cseg

org 100h

start: jmp @Init

;====================

Old1cAddr label dword

Old1cOff dw ?

Old1cSeg dw ?

Old09Addr label dword

Old09Off dw ?

Old09Seg dw ?

mcb_evb dw ? ; mcb: Memmory Control Block

mcb_psp dw ?

show dw 1

count dw 0

VarLen equ $ - Old1cAddr

time equ 1000

;///////////////////////////

new1ch proc far

;///////////////////////////

;sti

push ax

push bx

inc cs:[count]

;mov ax, cs: [time]

cmp cs:[count], time

jne @New1chEnd

mov bl, 36h

mov ax, 1201h

int 10h

mov cs:[count], 0

mov cs:[show], 0

@New1chEnd:

pop bx

pop ax

jmp cs:Old1cAddr

new1ch endp

;///////////////////////////

new09h proc far

;sti

push ax

push bx

cmp cs:[show], 1h

je @New09hEnd

mov cs:[show], 0h

mov bl, 36h

mov ax, 1200h

int 10h

@New09hEnd:

mov cs:[count], 0

pop bx

pop ax

jmp cs:Old09Addr

new09h endp

;///////////////////////////

@Init:

mov ax, 3509h ; Get current 1ch interrupt vector

int 21h

cmp bx, offset new09h ; Has been Intalled?

jnz @install ; No install

mov dx, offset strMsgUninstall

mov ah, 09h

int 21h

mov bx, 1ch * 04h ; Restore old 1ch interrupt vector

xor ax, ax ; to System interrupt vector talbe

mov ds, ax

mov ax, es:[Old1cOff]

mov ds:[bx], ax

mov ax, es:[Old1cSeg]

mov ds:[bx+2], ax

mov bx, 09h * 04h ; Restore old 09h interrupt vector

mov ax, es:[Old09Off] ; to System interrupt vector talbe

;xor ax, ax

;mov ds, ax ; ds must equal 0

mov ds:[bx], ax

mov ax, es:[Old09Seg]

mov ds:[bx+2], ax

mov bx, 1 ; Release evirenment parameter block

mov ax, es:[mcb_evb]

mov ds, ax

mov word ptr ds:[bx], 0

mov ax, es:[mcb_psp] ; Release TSR

mov ds, ax

mov word ptr ds:[bx], 0

mov ax, 4c00h

int 21h

@install:

;mov ax, 3509h ; Get current 1ch interrupt vector

;int 21h

mov Old09Seg, es ; Store current 09h interrupt vector

mov Old09Off, bx

mov dx, offset new09h ; Set new 09h interrupt vector

mov ax, 2509h

int 21h

mov ax, 351ch ; Get current 1ch interrupt vector

int 21h

mov Old1cSeg, es ; Store current 1ch interrupt vector

mov Old1cOff, bx

mov dx, offset new1ch ; Set new 1ch interrupt vector

mov ax, 251ch

int 21h

mov dx, offset strMsgInstall

mov ah, 09h

int 21h

; Store the address of evirenment parameter block

mov ax, cs

dec ax

mov [mcb_psp], ax ;mov cs:[mcb_psp], ax

mov bx, 2ch

mov ax, [bx] ;mov ax, cs:[bx]

dec ax

mov cs:[mcb_evb], ax

mov dx, offset @Init

add dx, VarLen + 2

mov cl, 04h

shr dx, cl

mov ax, 3100h

int 21h

;====================

strMsgInstall db 07h, "Screensafer installed!$"

strMsgUninstall db 07h, "Screensafer uninstalled!$"

cseg ends

end start

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有