Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model tiny
- .386
- locals
- .code
- org 100h
- include macro.asm
- Start:
- mov dl, 0
- jmp Main
- table1 db 32 dup (13), 0, 12 dup (13), 1, 26 dup (13), 2, 3, 13, 4, 7 dup (13), 5, 13, 6, 6 dup (13), 7, 11 dup (13), 8, 9, 13, 10, 7 dup (13), 11, 13, 12, 138 dup (13)
- table2 db 1, 14 dup (8), 2, 5 dup (8), 2, 8 dup (8), 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 1, 13 dup (8), 1, 13 dup (8), 1, 13 dup (8), 1, 13 dup (8), 1, 13 dup (8)
- usageMess db 'r1 [\h] [\i] [\k] [\s] [\u]', 24h
- helpMess db 'This program is for interrupt handler installation for int 2Fh', 24h
- installed db 'Installed', 24h
- notInstall db 'Not installed', 24h
- intHandled db 'Interrupt handled', 24h
- notAuthorized db 'Not authorized', 24h
- authorCode db 'SM', 24h
- oldHandler dd ?
- HandleInterrupt proc
- ; +-------------------------------------------
- ; | The main interruption handler procedure
- ; |
- ; | On entry:
- ; | dx - shold contain auth-code
- ; |
- ; | Returns:
- ; | bx - a place where is the resident
- ; +-------------------------------------------
- pushf
- push ds
- push cs
- pop ds
- cmp dx, offset authorCode
- jne @@1
- mov bx, cs
- @@1:
- pop ds
- jmp oldHandler
- iret
- HandleInterrupt endp
- Main:
- mov si, 80h
- lodsb
- mov cl, al
- Automata:
- lodsb
- dec cl
- cmp cl, 0
- jl Usage
- lea bx, table1
- xlat
- mov ch, al
- mov al, dl
- mov bl, 14
- mul bl
- mov bl, ch
- add al, bl
- lea bx, table2
- xlat
- cmp al, 8
- je Usage
- cmp al, 3
- je PrintHelp
- cmp al, 4
- je InstallRes
- cmp al, 5
- je KillRes
- cmp al, 6
- je Stat
- cmp al, 7
- je UninstallRes
- mov dl, al
- jmp Automata
- ret
- Usage:
- printf usageMess
- ret
- PrintHelp:
- printf helpMess
- ret
- InMemory:
- printf installed
- ret
- NotInMemory:
- printf notInstall
- ret
- InstallRes:
- xor bx, bx
- mov ax, bx
- lea dx, authorCode
- int 2Fh
- cmp ax, bx
- jne InMemory
- mov ah, 35h
- mov al, 2Fh
- int 21h
- mov word ptr oldHandler, bx
- mov word ptr oldHandler+2, es
- mov ah, 25h
- mov al, 2Fh
- mov dx, offset HandleInterrupt
- int 21h
- mov ah, 31h
- mov al, 0
- mov dx, 17
- int 21h
- ret
- KillRes:
- xor bx, bx
- mov ax, bx
- lea dx, authorCode
- int 2Fh
- mov ah, 25h
- mov al, 2Fh
- mov dx, word ptr oldHandler
- mov ds, [word ptr oldHandler+2]
- int 21h
- cmp ax, bx
- jne CleanMemory
- ret
- CleanMemory:
- ; +------------------------------------------------
- ; | Releases 17 paragraphs from a set segment
- ; |
- ; | On entry:
- ; | bx - segment address of memory to be released
- ; +------------------------------------------------
- mov ds, bx
- mov ah, 49h
- mov ds, ds:110h
- int 21h
- ret
- Stat:
- xor bx, bx
- mov ax, bx
- lea dx, authorCode
- int 2Fh
- cmp ax, bx
- jne InMemory
- je NotInMemory
- ret
- UninstallRes:
- xor bx, bx
- mov ax, bx
- lea dx, authorCode
- int 2Fh
- cmp ax, bx
- je NotInMemory
- mov ah, 25h
- mov al, 2Fh
- mov dx, word ptr oldHandler
- mov ds, [word ptr oldHandler+2]
- int 21h
- jmp CleanMemory
- ret
- end Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement