1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
.model small
.data
int09h dw 2 dup (0)
msg db "To exit press ESC! $"
tsr_end equ $
; B_UP equ 1Ch ; вверх
.stack 100h
.486
.code
; pNewInterrupt PROC far
; PUSHF
; PUSH ax
; in al, 60h ; Читаем сканкод
; cmp al, B_UP
; JE hotkey
; ; ; Наш код
; ; mov dx, offset mesg
; ; MOV ah,09h
; ; INT 21h
; POP ax
; POPF
; PUSHF
; CALL cs:[int09h]
; jmp exit
; hotkey:
; ; Обработка аппаратного прерывания
; in al,61h
; mov ah,al
; or al,80h
; out 61h,al
; xchg ah,al
; out 61h,al
; mov al,20h
; out 20h,al
; ; Наш код
; mov dx, offset mesg
; MOV ah,09h
; INT 21h
; exit:
; POPF
; IRET
; pNewInterrupt ENDP
start:
JMP program
pNewInterrupt PROC far
PUSHF
CALL dword ptr cs:int09h
IRET
pNewInterrupt ENDP
program:
MOV ax, @DATA
MOV ds, ax
; MOV ax,3509h ;Hook interrupt 09H
; INT 21h
; MOV word ptr int09h,bx
; MOV word ptr int09h[2],es
; ; MOV ax, 2509h
; ; MOV dx, offset pNewInterrupt
; ; INT 21h
; ; Восстанавливаем прерывание
; MOV ax, 2509h
; MOV ds, word ptr int09h[2]
; MOV dx, offset int09h
; INT 21h
; INT 09h
MOV ax, 3509h
INT 21h
MOV word ptr int09h, bx
MOV word ptr int09h[2], es
MOV ax, 2509h
MOV dx, offset pNewInterrupt
INT 21h
MOV ah,09h
MOV dx, offset msg
INT 21h
MOV dx, offset tsr_end
INT 27h
; ; Выходим из программы
; MOV ax, 4c00h
; INT 21h
END start
|