Advertisement
MichaelPetch

SO 56403333

Jun 2nd, 2019
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. LOAD_OFFSET equ 0x100 ; COM program origin point
  2. RELOC_OFFSET equ 0x5c ; Offset in PSP we can overwrite
  3. PARA_SIZE equ 16 ; Paragraph size is 16 bytes
  4.  
  5. ; This code will remain resident and will be moved
  6. ; so it occupies the unused portion of the PSP
  7.  
  8. section .resident vstart=RELOC_OFFSET start=0
  9. resident_start:
  10. jmp init_start
  11.  
  12. MyInt28:
  13. push ax
  14. push es
  15. push di
  16. push cx
  17. push ds
  18. push dx
  19. mov ax, 0013h ; BIOS.SetVideoMode
  20. int 10h
  21. mov ax, 0A000h
  22. mov es, ax
  23. xor di, di
  24. mov cx, 64000/2
  25. mov ax, 0909h
  26. cld
  27. rep stosw
  28. PatchA:
  29. mov ax, 0
  30. mov ds, ax
  31. PatchB:
  32. mov dx, 0
  33. mov ax, 2528h ; DOS.SetInterruptVector
  34. int 21h
  35. pop dx
  36. pop ds
  37. pop cx
  38. pop di
  39. pop es
  40. pop ax
  41. iret
  42.  
  43. RESIDENT_LEN equ $ - $$
  44.  
  45. init_start:
  46. section .init vstart=LOAD_OFFSET+RESIDENT_LEN follows=.resident align=1
  47.  
  48. ; Relocate the resident part of this code
  49. ; so it starts in the free area of the PSP
  50. mov di, resident_start
  51. mov si, LOAD_OFFSET
  52. mov cx, RESIDENT_LEN
  53. rep movsb
  54.  
  55. mov ax, 3528h ; DOS.GetInterruptVector
  56. int 21h ; -> ES:BX
  57. mov [PatchA + 1], es
  58. mov [PatchB + 1], bx
  59. mov dx, MyInt28
  60. mov ah, 25h ; DOS.SetInterruptVector
  61. int 21h
  62.  
  63. ; Compute the number of paragraphs needed to stay resident
  64. mov dx, (RELOC_OFFSET+RESIDENT_LEN+(PARA_SIZE-1))/PARA_SIZE
  65. mov ax, 3100h ; DOS.TerminateAndStayResident
  66. int 21h
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement