[comp.os.msdos.programmer] Answer to how to make TSR name show on MAPMEM display.

sonny@charybdis.harris-atd.com (Bob Davis) (12/03/90)

I seem to have stumbled upon the answer to my own question of a while
back in this newsgroup:

     Q: How do you make your TSR's name show under the "owner"
	column in Kim Kokkonen's TSR Mark/Release package "mapmem"
	display?

     A: Don't deallocate the TSR's environment when you install the
        TSR.

The mapmem command must look at the environment to determine the
command name to place under the "owner" column. Might be nice to
figure out a way to deallocate the DOS environment and then re-install
a tiny "pseudo-environment" containing nothing but the command name so
mapmem could see it. Any idea how I might do that?

	Thanks,
_____________________________________________________________________________
Bob Davis, UofALA'66   \\ INTERNET: sonny@trantor.harris-atd.com  |  _   _  |
Harris Corporation, ESS \\    UUCP: ...!uunet!x102a!trantor!sonny |_| |_| | |
Advanced Technology Dept.\\ AETHER: K4VNO          |==============|_/\/\/\|_|
PO Box 37, MS 3A/1912     \\ VOICE: (407) 727-5886 | I SPEAK ONLY | |_| |_| |
Melbourne, FL 32902        \\  FAX: (407) 729-2537 | FOR MYSELF.  |_________|

valley@uchicago (Doug Dougherty) (12/03/90)

I never thought deallocating the environment was such a hot idea anyway.
What are we trying to do here, save a few hundred bytes?  What's the point?

My testing with this sometime ago indicated that the name field
in a MAPMEM display is the only thing you lose.  My advice is "Don't do it."

mlord@bwdls58.bnr.ca (Mark Lord) (12/03/90)

In article <valley.660166653@gsbsun> valley@uchicago (Doug Dougherty) writes:
<I never thought deallocating the environment was such a hot idea anyway.
<What are we trying to do here, save a few hundred bytes?  What's the point?
<
<My testing with this sometime ago indicated that the name field
<in a MAPMEM display is the only thing you lose.  My advice is "Don't do it."

I disagree.  DO it.  Or make it an option for folks who like 
wasting 3-4K of memory on duplicated environments for their 5-15 TSRs,
none of which actually want the environment for anything.

My TSRs typically deallocate everything AFTER the name field, so that
MAPMEM and the like can still identify them.

Actually, another useful trick is to not define anything in autoexec.bat
until AFTER all TSRs have been loaded.  This includes setting COMSPEC and
PATH to null beforehand.  This reduces the size of the environment snapshot
for each TSR.
-- 
 ___Mark S. Lord__________________________________________
| ..uunet!bnrgate!mlord%bmerh724 | Climb Free Or Die (NH) |
| MLORD@BNR.CA   Ottawa, Ontario | Personal views only.   |
|________________________________|________________________|

valley@uchicago (Doug Dougherty) (12/03/90)

mlord@bwdls58.bnr.ca (Mark Lord) writes:

>I disagree.  DO it.  Or make it an option for folks who like 
>wasting 3-4K of memory on duplicated environments for their 5-15 TSRs,
>none of which actually want the environment for anything.

3-4K???  Your environment is 3-4K in size?  If so, then you're right.
Deallocate it.  Mine tend to be more like 3-4 C (C = hundred)

mlord@bwdls58.bnr.ca (Mark Lord) (12/06/90)

In article <valley.660238337@gsbsun> valley@uchicago (Doug Dougherty) writes:
<mlord@bwdls58.bnr.ca (Mark Lord) writes:
<
<>I disagree.  DO it.  Or make it an option for folks who like 
<>wasting 3-4K of memory on duplicated environments for their 5-15 TSRs,
<>none of which actually want the environment for anything.
<
<3-4K???  Your environment is 3-4K in size?  If so, then you're right.
<Deallocate it.  Mine tend to be more like 3-4 C (C = hundred)

No, silly!

My environment is about 400 bytes.  But a copy is made for EACH
of the 17 TSRs I have, giving a total space of 17 * 400 = about 6K or so.
-- 
 ___Mark S. Lord__________________________________________
| ..uunet!bnrgate!mlord%bmerh724 | Climb Free Or Die (NH) |
| MLORD@BNR.CA   Ottawa, Ontario | Personal views only.   |
|________________________________|________________________|

rspangle@jarthur.Claremont.EDU (Froot Loop) (12/06/90)

In article <5044@bwdls58.UUCP> mlord@bwdls58.bnr.ca (Mark Lord) writes:
>My environment is about 400 bytes.  But a copy is made for EACH
>of the 17 TSRs I have, giving a total space of 17 * 400 = about 6K or so.

My AUTOEXEC.BAT starts like this:

path c:\;

mouse.com
ansi.com
prtscr y
(other TSR's)

path f:\;c:\;{etc. - 100 chars or so}
set temp=f:
set pktmp=f:
set lib=d:\qc25\lib
(other environment stuff)

(copying files to ramdrive, etc.)

That way, at the time each of the TSR's is loaded, the environment is only
64 bytes long.  After adding the full path and environment variables, the
environment is several hundred bytes long.  But the TSR's don't need copies
of most of it, so I don't give it to them.  This way, your memory wastage
would be

(17*64) = 1088 bytes

instead of (17*400) = 6800 bytes.

Actually, I have a 386, so I use QEMM and LOADHI to get 602 KB free with 
a ramdisk, disk cache, mouse driver, ANSI driver, files=40, buffers=10.
If you have a 386, QEMM is DEFINITELY the way to go.  And it works with 
Windows 3.0 in all modes now.

-- 
 --------------------------------------------------------------------------
|   Randy Spangler                   |   Get your mind out of the gutter   |
|   rspangle@jarthur.claremont.edu   |   you're blocking my periscope      |
 --------------------------------------------------------------------------

pipkinsj@cpqhou.uucp (Jeff Pipkins @Adv Dev@SE hou ) (01/03/91)

In article <5001@trantor.harris-atd.com> sonny@trantor.harris-atd.com (Bob Davis) writes:
>I seem to have stumbled upon the answer to my own question of a while
>back in this newsgroup:
>
>     Q: How do you make your TSR's name show under the "owner"
>	column in Kim Kokkonen's TSR Mark/Release package "mapmem"
>	display?
>
>     A: Don't deallocate the TSR's environment when you install the
>        TSR.
>
>The mapmem command must look at the environment to determine the
>command name to place under the "owner" column. Might be nice to
>figure out a way to deallocate the DOS environment and then re-install
>a tiny "pseudo-environment" containing nothing but the command name so
>mapmem could see it. Any idea how I might do that?

MS-DOS 4.x has a "mem" command that lists programs and TSRs in a similar
way.  TSRs that come with DOS 4.x put an 8-byte name in the last 8 bytes
of the memory control block that their PSP is in.  In other words, the
8 bytes immediately preceeding the PSP.  These bytes are unused in previous
versions of DOS, so it's probably a good idea to do this if you're a TSR.

In fact, this would also provide a good way for a TSR to check to see if
a copy of it is already resident.  Traverse the MCB chain looking for
a resident program with the same name.  You can find the start of the chain
by using a well-known undocumented function (Int 21h, AH=52h; on return
subtract 2 from BX, and ES:BX will point to the first MCB).

The first byte of the MCB is 'Z' if it is at the end of the chain.  The word
in bytes 3 & 4 give the block size in paragraphs.  Each MCB is located on
a paragraph boundary, so if you have the segment address of an MCB, you can
find the next one by adding the block size plus 1.  That should be everything
you need to know to find your TSR.

If your TSR has an uninstall feature, be sure to erase your name from the MCB
when you uninstall!


-- 
Jeff D. Pipkins (uunet!cpqhou!pipkinsj)

My disclaimer: My opinions do not necessarily reflect those of my employer.
Papaw's disclaimer: I've already told you more than I know.

sonny@charybdis.harris-atd.com (Bob Davis) (01/03/91)

In article <1991Jan02.160147.2030@cpqhou.uucp> pipkinsj@cpqhou.UUCP (Jeff Pipkins @Adv Dev@SE hou ) writes:
>In article <5001@trantor.harris-atd.com> sonny@trantor.harris-atd.com (Bob Davis) writes:
>>I seem to have stumbled upon the answer to my own question of a while
>>back in this newsgroup:
>>
>>     Q: How do you make your TSR's name show under the "owner"
>>	column in Kim Kokkonen's TSR Mark/Release package "mapmem"
>>	display?
>>
>>     A: Don't deallocate the TSR's environment when you install the
>>        TSR.
>>
>>The mapmem command must look at the environment to determine the
>>command name to place under the "owner" column. Might be nice to
>>figure out a way to deallocate the DOS environment and then re-install
>>a tiny "pseudo-environment" containing nothing but the command name so
>>mapmem could see it. Any idea how I might do that?
>
>MS-DOS 4.x has a "mem" command that lists programs and TSRs in a similar
>way.  TSRs that come with DOS 4.x put an 8-byte name in the last 8 bytes
>of the memory control block that their PSP is in.  In other words, the
>8 bytes immediately preceeding the PSP.  These bytes are unused in previous
>versions of DOS, so it's probably a good idea to do this if you're a TSR.
>
	[DELETIONS]
>-- 
>Jeff D. Pipkins (uunet!cpqhou!pipkinsj)
>
	That's interesting how MSDOS 4.x includes the feature. I will
have to look into that.
	Extraordinarily-useful E-mail exchanges with
Anto Prijosoesilo and Richard Brittain as a result of my original posting
about the "Pseudo-environment" idea resulted in its implementation in
my evolving TBONES06.ZIP package of skeletal ASM programs to help develop
your own TSRs.
	This "Pseudo-environment" idea basically involves the de-allocation
of the original DOS environment (which can be quite large for some users),
followed by the re-allocation of a single paragraph (16-byte) fake
environment containing only the program name plus a few bytes to satisfy
DOS's requirements on the structure of the environment.
	I certainly am more than willing to donate 16 bytes of RAM to have
the TSR name show on the MAPMEM display. And I use only these 16 bytes
more than the TSRs which totally de-allocate the environment leaving it
to the user to figure out which of the several "N/A" ID's under the "owner"
column of the MAPMEM command is the TSR for which information is sought.

	If anyone is interested in Assembly language details of how the 
"Pseudo-environment" idea has been implemented, send E-mail to me
requesting TBONES06.ZIP.
_____________________________________________________________________________
Bob Davis, UofALA alum \\ INTERNET: sonny@trantor.harris-atd.com  |  _   _  |
Harris Corporation, ESS \\    UUCP: ...!uunet!x102a!trantor!sonny |_| |_| | |
Advanced Technology Dept.\\ AETHER: K4VNO          |==============|_/\/\/\|_|
PO Box 37, MS 3A/1912     \\ VOICE: (407) 727-5886 | I SPEAK ONLY | |_| |_| |
Melbourne, FL 32902        \\  FAX: (407) 729-2537 | FOR MYSELF.  |_________|