Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LOAD_OFFSET equ 0x100 ; COM program origin point
- RELOC_OFFSET equ 0x5c ; Offset in PSP we can overwrite
- PARA_SIZE equ 16 ; Paragraph size is 16 bytes
- ; This code will remain resident and will be moved
- ; so it occupies the unused portion of the PSP
- section .resident vstart=RELOC_OFFSET start=0
- resident_start:
- jmp init_start
- MyInt28:
- push ax
- push es
- push di
- push cx
- push ds
- push dx
- mov ax, 0013h ; BIOS.SetVideoMode
- int 10h
- mov ax, 0A000h
- mov es, ax
- xor di, di
- mov cx, 64000/2
- mov ax, 0909h
- cld
- rep stosw
- PatchA:
- mov ax, 0
- mov ds, ax
- PatchB:
- mov dx, 0
- mov ax, 2528h ; DOS.SetInterruptVector
- int 21h
- pop dx
- pop ds
- pop cx
- pop di
- pop es
- pop ax
- iret
- RESIDENT_LEN equ $ - $$
- init_start:
- section .init vstart=LOAD_OFFSET+RESIDENT_LEN follows=.resident align=1
- ; Relocate the resident part of this code
- ; so it starts in the free area of the PSP
- mov di, resident_start
- mov si, LOAD_OFFSET
- mov cx, RESIDENT_LEN
- rep movsb
- mov ax, 3528h ; DOS.GetInterruptVector
- int 21h ; -> ES:BX
- mov [PatchA + 1], es
- mov [PatchB + 1], bx
- mov dx, MyInt28
- mov ah, 25h ; DOS.SetInterruptVector
- int 21h
- ; Compute the number of paragraphs needed to stay resident
- mov dx, (RELOC_OFFSET+RESIDENT_LEN+(PARA_SIZE-1))/PARA_SIZE
- mov ax, 3100h ; DOS.TerminateAndStayResident
- int 21h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement