[comp.sys.ibm.pc.programmer] memory control blocks?

TOMIII@MTUS5.BITNET (Thomas Dwyer III) (07/19/90)

How does one "follow the chain of memory control blocks" to determine
what program is using what memory?  I would like to write my own program
which determines where all my memory is going.  If I use INT 21, AH=52
to get the first block, how do I get to the next block, etc?

Thanks,
Thomas Dwyer III                            TOMIII   @ MTUS5.BITNET
Network Programmer                          DWYERIII @ MTUS5.BITNET
Computing Technology Services
Michigan Technological University

dixon@sagittarius.crd.ge.com (walt dixon) (07/20/90)

In <90199.195855TOMIII@MTUS5.BITNET> Thomas Dwyer III asks:

>How does one "follow the chain of memory control blocks" to determine
>what program is using what memory?  I would like to write my own program
>which determines where all my memory is going.  If I use INT 21, AH=52
>to get the first block, how do I get to the next block, etc?

For DOS 3.x,  int 21h AH=52 returns a pointer to a list of DOS data structures
in es:bx.  es:[bx-2] contains the paragraph of the first memory control
block.  Each memory control block has the following structure:

Field		Size	Use
Signature	BYTE	A value of 'M' indicates a normal Memory control block
			A value of 'Z' indicates the last Memory control block
Owner		WORD	PSP of block owner
			0 if not allocated
Size		WORD	size in paragraphs of MCB (not including header)
Unused		BYTE[11]

To get from one MCB to the next add the size+1 to the paragraph of the
current header.  You must check the signature field to find the end of
the chain.  A value of zero in the owner field indicates a free block.
NB that there are some strange values for MCBs allocated to device drivers
(8, from memory) that don't correspond to a PSP but still indicate
the block is owned.

I hope this helps

Walt Dixon	{internet:	dixon@crd.ge.com	}
		{us mail:	ge crd			}
		{		po box 8		}
		{		schenectady, ny 12301	}
		{phone:		518-387-5798 (W)	}
		{		518-875-6203 (H)	}
Walt Dixon dixon@crd.ge.com