Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

How to keep resident only a part of the program (Developers)

posted by ecm Homepage E-mail, Düsseldorf, Germany, 15.08.2021, 13:47

> > Is possible solution to allocate a additional memory block via
> > INT21h/AH=48h, copy the code of KeyClick into this block and the program
> > end not with Keep but hith Halt?
>
> That will likely not work --- DOS will free up all memory blocks
> allocated by your program, including those from int 0x21, ah = 0x48.

You can make it work by hacking the MCB to be owned by someone other than your process. Tom mentions a way to do that but I think it is cleaner to just access the MCB directly instead of setting the current PSP to another, possibly invalid value.

In my tsr example I first relocate the process (to avoid memory fragmentation) then allocate a new block for the resident portion using service 48h, then I hack the MCB's owner and name fields to make the resident block survive the final process termination (using service 4Ch). I described this in some detail in https://retrocomputing.stackexchange.com/questions/20001/how-much-of-the-program-segment-prefix-area-can-be-reused-by-programs-with-impun/20006#20006

By the way, if you do use service 31h you should close all file handles manually, unless you intend to use them while resident.

---
l

 

Complete thread:

Back to the forum
Board view  Mix view
22049 Postings in 2034 Threads, 396 registered users, 59 users online (0 registered, 59 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum