First post, by llm
FYI: this is my very first DOS TSR after >30Years
its a reduced example of my NoUniVBE project that just contains my TSR install/uninstall
the program installs a TSR that hooks Interrupt 10h (doing nothing currently) and
uses some Interrupt 10h relative Data to finde itself for uninstalling (UniVBE does is alike and the detection Data will be much larger in the end)
i detect if the TSR is installed, recover the original int 10h vector entry and
free the memory with int 21h/49h
the problem is that after calling int 21h/49h dosbox waits for a kexpress (i think there is something very wrong in my code that produces this effect)
and the original int 10h seems to be not recovered after the uninstall because my install detection matches again
any idea?
; USAM or MASM
; uasm.exe tsrint10.asm
; ulink.exe -T16 -Tdc tsrint10.obj, tsrint10.com,tsrint10.map
; or 16bit link.exe from microsoft
.MODEL TINY
PSP_BYTES = 100h
Far_pointer struc
offs dw 0
segm dw 0
Far_pointer ends
TSR_ID_STR EQU <"MyID">
TSR_info_t struc
signature db TSR_ID_STR
load_segment dw 0
old_int10h Far_pointer<>
TSR_info_t ends
.CODE
org PSP_BYTES
start:
jmp configure
;====================================================
; resident part
;====================================================
tsr_info TSR_info_t<>
; resident code
detoured_int10h:
pushf
call cs:tsr_info.old_int10h
iret
end_of_resident:
;====================================================
; configure part (not resident)
;====================================================
PARAGRAPH_BYTES = 16
RESIDENT_BYTES = end_of_resident - start
RESIDENT_PARAGRAPHS = (PSP_BYTES + RESIDENT_BYTES + (PARAGRAPH_BYTES-1))/PARAGRAPH_BYTES
TSR_INFO_DISTANCE = detoured_int10h - tsr_info
VIDEO_BIOS_INT = 10h ; 5h for testing
; configure data
installed_msg db 'installed!',10,13,'$'
uninstalled_msg db 'uninstalled!',10,13,'$'
; configure code
configure:
; is TSR installed
mov ah,35h
mov al,VIDEO_BIOS_INT
cli
int 21h
sti
mov di,bx
sub di,TSR_INFO_DISTANCE
; es:di = tsr_info
; exists TSR info signature?
cld
mov cx, sizeof(TSR_info_t.signature)
mov si, offset(tsr_info.signature)
repe cmpsb
jne install
jmp uninstall
install:
; safe old VIDEO BIOS interrupt handler ptr
mov ah,35h
mov al,VIDEO_BIOS_INT
cli
int 21h
sti
mov [tsr_info.old_int10h.segm],es
mov [tsr_info.old_int10h.offs],bx
; install new handler
mov ah,25h
mov al,VIDEO_BIOS_INT
push ds
push cs
pop ds
mov dx,offset(detoured_int10h)
cli
int 21h
sti
pop ds
; safe load segment of TSR
mov [tsr_info.load_segment],cs
mov dx,offset(installed_msg)
mov ah,9h
int 21h
; stay resident
mov dx,RESIDENT_PARAGRAPHS
mov ah,31h
mov al,0
int 21h
uninstall:
mov ah,35h
mov al,VIDEO_BIOS_INT
cli
int 21h
sti
; es:di = tsr_info
mov di,bx
sub di,TSR_INFO_DISTANCE
; install old handler
mov ah,25h
mov al,VIDEO_BIOS_INT
push ds
mov ax,es:[di+TSR_info_t.old_int10h.segm]
mov ds,ax
mov dx,es:[di+TSR_info_t.old_int10h.offs]
cli
int 21h
sti
pop ds
mov ah,49h
mov ax,es:[di+TSR_info_t.load_segment]
mov es,ax
int 21h
; <<<<<<<<<<<<<<<<<< Dosbox waits here for a keypress?
;<<<<<<<<<<<<<<<<<< and the recover of the old int 10h seems to not happen
mov dx,offset(uninstalled_msg)
mov ah,9h
int 21h
mov ax,4c00h
int 21h
end start