Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site mcnc.mcnc.UUCP Path: utzoo!watmath!clyde!cbosgd!ihnp4!mhuxn!mhuxr!ulysses!gamma!epsilon!zeta!sabre!bellcore!decvax!mcnc!jnw From: jnw@mcnc.UUCP (John White) Newsgroups: net.micro.pc Subject: Re: Weirdness in PC??? Message-ID: <599@mcnc.mcnc.UUCP> Date: Fri, 21-Jun-85 20:40:07 EDT Article-I.D.: mcnc.599 Posted: Fri Jun 21 20:40:07 1985 Date-Received: Mon, 24-Jun-85 02:33:08 EDT References: <256@timeinc.UUCP> <173@galbp.UUCP> Organization: Microelectronics Center of NC; RTP, NC Lines: 26 When a program is executed in ms-dos 2.x it is given two blocks of memory. One is the main block that starts at the begining of the 100h header and contains the program, the other is the environment block whose starting segment is given at offset 2Ch of the header. When the program terminates these two blocks are freed. If the program terminates-and-stays-resident, the environment block is not freed and the main block is shortened to the length specified by the terminate call. I have written terminate-and- stay-resident goodies that are removable. If the program is given the "remove" switch then, instead of installing itself, it looks at the interupt vector changed by a previous installation to find the address of the installed versions main block. Then the old vector is loaded from the appropriate offset in this block and the interupt vector is restored. When the program installed itself it freed up its environment pointer (using the dealloc dos call), so deallocing the main block of the installed program now removes it completely. Memory segmentation can still be a problem, so I usually remove my installed goodies in the reverse order that I installed them. This isn't important unless there is something installed that takes up a lot of memory (such as an installable ramdisk). By the way, the extra code for doing the removal is at the end of the program and is cut off by the terminate-and-stay- resident dos call so it doesn't use up memory when installed. Also, before removing the installed version, various offsets in the suposed installed version are checked to make sure the interupt vector is really pointing to an installed version. - John N. White {duke, mcnc}!jnw