home *** CD-ROM | disk | FTP | other *** search
/ Black Box 4 / BlackBox.cdr / progc / dmldoc.arj / DMALOC09.DOC next >
Encoding:
Text File  |  1992-04-12  |  114.8 KB  |  2,564 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.             ********************************************************
  9.  
  10.             DDDDD   MM    MM                                    (TM)
  11.              DD DD  MMM  MMM
  12.              DD  DD MMMMMMMM
  13.              DD  DD MMMMMMMM   AA    LLLL    LLLL      OOO     CCCC
  14.              DD  DD MM MM MM  AAAA    LL      LL      OO OO   CC  CC
  15.              DD  DD MM    MM AA  AA   LL      LL     OO   OO CC
  16.              DD  DD MM    MM AA  AA   LL      LL     OO   OO CC
  17.              DD  DD MM    MM AAAAAA   LL   L  LL   L OO   OO CC
  18.              DD DD  MM    MM AA  AA   LL  LL  LL  LL  OO OO   CC  CC
  19.             DDDDD   MM    MM AA  AA  LLLLLLL LLLLLLL   OOO     CCCC
  20.  
  21.             ********************************************************
  22.  
  23.  
  24.  
  25.                                     v 0.9
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.                    A malloc memory debugger for MS-C 5.1 and 6.+
  36.  
  37.                                         by
  38.  
  39.                                Ernest E. Vogelsinger
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.               ***************** WARRANTY DISCLAIMER ****************
  56.  
  57.  
  58.                                    DMalloc  v0.9
  59.  
  60.  
  61.                       PLEASE READ THIS INFORMATION CAREFULLY
  62.                       ______________________________________
  63.  
  64.  
  65.  
  66.            Users of DMalloc must accept the following disclaimer of war-
  67.                                       ranty:
  68.  
  69.  
  70.            TRIAL USE (SHAREWARE EVALUATION VERSION) WARRANTY DISCLAIMER
  71.  
  72.  
  73.           THIS COPYRIGHTED SOFTWARE AND ITS DOCUMENTATION IS PROVIDED ON
  74.            AN "AS IS" BASIS.  THE AUTHOR MAKES NO WARRANTY OF ANY KIND,
  75.           EXPRESSED OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRAN-
  76.            TIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PUR-
  77.                                        POSE.
  78.  
  79.             THE USER ASSUMES ALL RISKS OF THE USE OF THIS SOFTWARE. THE
  80.            AUTHOR ASSUMES NO LIABILITY FOR DAMAGES, DIRECT OR CONSEQUEN-
  81.              TIAL, WHICH MAY RESULT FROM THE USE OR MISUSE OF DMALLOC.
  82.  
  83.  
  84.            As it cannot be guaranteed that loss of data will not occur,
  85.            DMalloc should be tested with non-critical data.  As always,
  86.                judicious backups are a wise and necessary continuing
  87.                                     precaution.
  88.  
  89.  
  90.  
  91.               ***************** WARRANTY DISCLAIMER ****************
  92.  
  93.  
  94.  
  95.  
  96.                    DMalloc is a trademark of Ernest Vogelsinger.
  97.            Soft-ICE and Bounds-Checker are registered trademarks of Nu-
  98.                               Mega Technologies, Inc.
  99.            Microsoft, MS-DOS, and CodeView are registered trademarks of
  100.                                   Microsoft Corp.
  101.  
  102.             Any other product names used herein are for identification
  103.           purposes only and may be trademarks or registered trademarks of
  104.                             their respective companies.
  105.  
  106.  
  107.                     1991-1992 Ernest Vogelsinger, Vienna, Austria
  108.  
  109.  Table of Contents                                               DMalloc
  110. ------------------------------------------------------------------------
  111.  
  112.           1. Introduction
  113.                1.1. What is DMalloc?
  114.                1.2. Requirements
  115.                1.3. Why DMalloc Instead of a BRAND X Heap Checker
  116.                1.4. Summary of Features
  117.                1.5. What is Shareware
  118.                1.6. DMalloc Unregistered Evaluation Version
  119.                1.7. Registration
  120.                1.8. Distribution Policies
  121.  
  122.           2. Installation
  123.                2.1. Documentation
  124.                2.2. A Quick Start
  125.                2.3. Where to from here?
  126.                2.4. Support & Thanks
  127.  
  128.           3. Demonstration Program
  129.                3.1. DMalloc Startup
  130.                3.2. Heap Overview
  131.                3.3. Total Heap Status
  132.                3.4. Detecting Heap Problems
  133.                3.5. Invalid Pointer Warning
  134.                3.6. Determining Action, Setting Breakpoints
  135.                3.7. Null Pointer Assignments
  136.                3.8. Fatal Heap Errors
  137.  
  138.           4. Dynamic Memory and DMalloc
  139.                4.1. Dynamic Memory Layout
  140.                4.2. DMalloc and Dynamic Memory
  141.                4.3. Tracking the Functions
  142.                4.4. Checking the Heap
  143.                4.5. Types of Heap Corruption
  144.                     4.5.1. Lead Corruption
  145.                     4.5.2. Trail Corruption
  146.                     4.5.3. Odd/Even Problem
  147.                     4.5.4. Mavericks
  148.                4.6. Null Pointer Assignments
  149.                4.7. Far Null Pointer Assignments
  150.                4.8. Watchpoints
  151.                4.9. Savepoints
  152.  
  153.           5. DMalloc In Detail
  154.                5.1. About DMalloc Windows
  155.                5.2. Function Keys
  156.                5.3. Information Window
  157.                     5.3.1. "You can" - Select the Next Action
  158.                     5.3.2. "Breakpoint:"
  159.                5.4. Setup Window
  160.                     5.4.1. Alert on problem
  161.                     5.4.2. Popup on saved
  162.                     5.4.3. Cycles for popup
  163.                     5.4.4. Heap check cycles
  164.  
  165.  Table of Contents                                               DMalloc
  166. ------------------------------------------------------------------------
  167.  
  168.  
  169.                     5.4.5. Popup for file/line
  170.                     5.4.6. Startup screen
  171.                     5.4.7. Shutdown screen
  172.                     5.4.8. Alternate monitor
  173.                     5.4.9. Number of handles
  174.                5.5. Colors Window
  175.                5.6. Heap Entries Window
  176.                     5.6.1. Detecting Corrupted Entries
  177.                     5.6.2. "Repairing" Corrupted Entries
  178.                     5.6.3. Watchpoints ("Tags")
  179.                     5.6.4. Savepoints
  180.                5.7. Selection Window
  181.                5.8. Dump Window
  182.                     5.8.1. Editing Data
  183.                5.9. Heap Status Window
  184.                5.10. The Configuration File
  185.  
  186.           6. How to use DMalloc for Debugging
  187.                6.1. Linking DMalloc to the Program
  188.                6.2. Recompiling
  189.                6.3. Calling the DMalloc API
  190.                6.4. DMalloc and Spawn
  191.                6.5. DMalloc and Video
  192.                     6.5.1. Calling RLSI
  193.                6.6. DMalloc and Debuggers
  194.                     6.6.1. Soft-ICE
  195.                     6.6.2. CodeView
  196.                     6.6.3. Other Debuggers
  197.                6.7. DMalloc and Bounds-Checker
  198.  
  199.           7. Programming API
  200.                7.1. Removing DMalloc API Calls
  201.  
  202.           8. Problem Solving
  203.  
  204.           Appendix A - The Legal Department (License Agreement)
  205.  
  206.           Appendix B - How to Send Email to Compuserve
  207.                B.1 How to obtain a CompuServe Account
  208.                B.2 MCI
  209.                B.3 Internet
  210.                B.4 Telex, Twx
  211.                B.5 X.400
  212.                B.6 MHS
  213.  
  214.  
  215.  Page 1                                                           DMalloc
  216. ------------------------------------------------------------------------
  217.  
  218.  
  219.    1. Introduction
  220.  
  221.       1.1. What is DMalloc?
  222.          DMalloc  is a  full-featured, convenient,  windowed pop-up
  223.          dynamic memory  debugger for  C language  applications. It
  224.          monitors  heap  integrity  and  the  dynamic  memory   re-
  225.          quirements of  an application.  From a technical  point of
  226.          view  DMalloc  is  a  library  that  is  linked  with  the
  227.          program's object files.
  228.  
  229.       1.2. Requirements
  230.          DMalloc  can  be  used   with  C  programs  compiled  with
  231.          MicroSoft C versions 5.1 and 6.x.
  232.          DMalloc is  currently available  for use with  the "large"
  233.          memory model (far code, far data).
  234.          DOS version should be 3.30 or above(1).
  235.          DMalloc will add  about 49kB to the code,  and - depending
  236.          on the setup - 28 to 168 kB of data.
  237.  
  238.       1.3. Why DMalloc Instead of a BRAND X Heap Checker
  239.          DMalloc  checks the  integrity of  dynamic memory.  Unlike
  240.          other packages,  it monitors  the  allocated memory  units
  241.          themselves,  instead  of  tracking  out-of-bounds  segment
  242.          accesses. Thus it is an ideal companion to 386-based bound
  243.          checking  utilities such as  Bounds-Checker.  For more in-
  244.          formation on  segments and allocation units  refer to sec-
  245.          tion 4.
  246.          No need  to recompile a source module.  DMalloc tracks all
  247.          calls   to   memory   allocation/deallocation,   even   in
  248.          third-party code.
  249.  
  250.          Null pointer assignments are detected much earlier than by
  251.          the runtime library (which detects  them at the end of the
  252.          program). And, as a special  feature for the large  memory
  253.          model, even assignments to  far null pointers are detected
  254.          and  repaired (if  possible) to  keep the  interrupt table
  255.          intact.
  256.          DMalloc can  cooperate with other debuggers.  Special sup-
  257.          port has been built in  for CodeView  and Soft-ICE  debug-
  258.          gers.
  259.          DMalloc can be used as a background watchdog as well as to
  260.          interactively  review the  requirements and  fragmentation
  261.          status of the dynamic heap.
  262.          DMalloc supports  an alternate monitor to  allow debugging
  263.          of graphical applications.
  264.  
  265.  
  266.  
  267.    --------------------
  268.    1  DMalloc  was tested with DOS versions 3.30, 4.01, and
  269.       5.00. However, nothing special is needed from DOS, so
  270.       other versions should do as well.
  271.  
  272.  
  273.  
  274.  Page 2                                                          DMalloc
  275. ------------------------------------------------------------------------
  276.  
  277.  
  278.          DMalloc even  remembers allocation  units  that have  been
  279.          tampered with from one session to the next.
  280.          DMalloc provides a rich API to allow fine-tuning of debug-
  281.          ging setups from within the source code.
  282.          DMalloc is shareware,  allowing you to  fully evaluate  it
  283.          for 30 days.  If you don't like it, you  don't pay for it.
  284.  
  285.          However, DMalloc is a very professional debug utility, and
  286.          not playware.
  287.                        
  288.  
  289.       1.4. Summary of Features
  290.          -  Tracking  of allocation  and deallocation  of dynamic
  291.             memory
  292.          -  Integrity check on every allocated unit
  293.          -  Integrity check on the data segment null region (null
  294.             pointer assignment error)
  295.          -  Integrity check and repair on the far-null region
  296.          -  Automatic pop-up when a heap problem is encountered
  297.          -  Automatic pop-up when allocating memory that has been
  298.             corrupted in the last debug session, or that has been
  299.             selected to be saved
  300.          -  Graceful  program  termination   when  the  heap   is
  301.             destroyed and the program would be likely to hang
  302.          -  Interactive pop-up by pressing [PrtSc]
  303.          -  Sorted display  of  data segments  and all  allocated
  304.             units
  305.          -  Assignment  of allocation  units  to source  file and
  306.             line (when recompiling)
  307.          -  Optional  selective display  selection by  specifying
  308.             source file and line number
  309.          -  Viewing and editing of allocation unit contents
  310.          -  Pop-up   when  freeing/reallocating   selected  units
  311.             (Watchpoint feature)
  312.          -  Possibility to set breakpoints to debuggers at return
  313.             from a malloc call
  314.          -  Extensive setup options to tailor DMalloc's behaviour
  315.             to  the  current debug  context,  and  changing setup
  316.             options at runtime
  317.          -  Alternate  monitor  support  to  allow  debugging  of
  318.             graphical applications
  319.          -  User-defined screen colors on both monitors
  320.          -  Automatic save  of setup  options, and  corrupted and
  321.             selected allocation units on an per-application basis
  322.          -  Rich API for program/debugger interaction
  323.  
  324.  Page 3                                                          DMalloc
  325. ------------------------------------------------------------------------
  326.  
  327.  
  328.       1.5. What is Shareware
  329.          Shareware  distribution  gives  users   a  chance  to  try
  330.          software before buying it.  If you try a Shareware program
  331.          and continue to use it, you are expected to register.
  332.          Copyright  laws  apply to  both  Shareware  and commercial
  333.          software,  and the  copyright holder  retains  all rights.
  334.          Shareware authors are accomplished programmers,  just like
  335.          commercial  authors, and  the programs  are of  comparable
  336.          quality - in  both cases, there are good  programs and bad
  337.          ones! The main difference between the two is in the method
  338.          of distribution.
  339.  
  340.          So  Shareware is  a  distribution method,  not  a type  of
  341.          software. You should find  software that suits your  needs
  342.          and pocketbook, whether it's commercial or Shareware.  The
  343.          Shareware system makes fitting your needs easier,  because
  344.          you can try before  you buy.  And because the  overhead is
  345.          low, prices are low also.
  346.  
  347.          Shareware has  the ultimate money-back guarantee  - if you
  348.          don't use the product, you don't pay for it.
  349.  
  350.       1.6. DMalloc Unregistered Evaluation Version
  351.          The unregistered  version of DMalloc is  fully functional.
  352.          When  a program  linked with  the unregistered  version is
  353.          starting and terminating, a  window will pop up  to remind
  354.          you that you are using  an unregistered copy. To pass this
  355.          reminder screen,  hit any key.  The reminder screen at the
  356.          start will automatically disappear after 5 seconds.
  357.  
  358.       1.7. Registration
  359.          DMalloc is copyrighted Shareware, it is NOT PUBLIC DOMAIN,
  360.          it is NOT FREE.  If you find DMalloc of value and continue
  361.          to use  it after a  thirty day evaluation period  you MUST
  362.          register your copy of DMalloc.
  363.          When you register you receive:
  364.          -  a serial number and license for one copy of DMalloc
  365.          -  a diskette with a registered copy of DMalloc
  366.          -  any technical  updates of DMalloc v  0.9 available at
  367.             that time
  368.          -  DMalloc v 1.0 when it becomes available
  369.          -  a printed and bound manual
  370.          -  free bonus standalone utilities (as available)
  371.          -  a greater voice in suggesting future enhancements
  372.          -  the satisfaction of supporting the shareware concept
  373.  
  374.  Page 4                                                          DMalloc
  375. ------------------------------------------------------------------------
  376.  
  377.  
  378.          If you  have  not  previously  registered,  and  after  an
  379.          evaluation  of DMalloc  you wish  to  register, or  if you
  380.          would just  like a  registered copy to  be shipped  out to
  381.          you, the cost is:
  382.  
  383.                      35.00 US$
  384.                    s/h6.00 US$
  385.                    -----------
  386.                      41.00 US$
  387.  
  388.          To have an additional manual to be shipped, the cost is
  389.  
  390.                      10.00 US$
  391.                    s/h6.00 US$
  392.                    -----------
  393.                      16.00 US$
  394.  
  395.          You have  three options  for  registering, or  ordering  a
  396.          printed manual:
  397.          1) By  regular  mail:   forward  your  name,  CompuServe
  398.             UserID if available, (and serial number if upgrading)
  399.             and  check  or money  order  made  payable to  Ernest
  400.             Vogelsinger to:
  401.  
  402.                Ernest Vogelsinger
  403.                Hietzinger Hauptstrasse 40 c
  404.                A-1130 Vienna, Austria
  405.  
  406.             If you  have the  evaluation package of  DMalloc, you
  407.             can   use   the   included   fold   up   registration
  408.             form/envelope. Then all  you need  is a  stamp and  a
  409.             check. See section 2.1 for more information.
  410.  
  411.  
  412.          2) By telephone or fax(2): if this is by VISA card, call
  413.             or fax your order to
  414.  
  415.                (+43) 1 828 46 09
  416.                ORDERS ONLY!
  417.                SUPPORT IS NOT AVAILABLE AT THAT NUMBER.
  418.  
  419.          3) By electronic mail: if this  is by VISA card, you can
  420.             forward the information directly to me by:
  421.  
  422.                Compuserve Mail at  100015,551
  423.                Internet            100015.551@compuserve.com
  424.                MHS                 MAIL@CSERVE {100015,551}
  425.  
  426.  
  427.    --------------------
  428.    2  There  is a  voice/fax switch  attached. If
  429.       your fax doesn't  get through, please  tell
  430.       the  person answering to permanently switch
  431.       to the fax.
  432.  
  433.  Page 5                                                          DMalloc
  434. ------------------------------------------------------------------------
  435.  
  436.  
  437.             Check appendix  B for detailed information  on how to
  438.             send email  to Compuserve,  and on  how  to obtain  a
  439.             Compuserve account.
  440.  
  441.          Your credit  card will be  charged in Austrian  funds. You
  442.          will  receive a confirmation by electronic mail or fax (if
  443.          available) when your order is processed.
  444.          Currency exchange will vary, but  at the time of this ver-
  445.          sion's release 41.00 US$ was approximately:
  446.  
  447.             41.00 US$ (35+6s/h)   AS 492.00   DM 68,80
  448.  
  449.          The registration fee licenses one copy of  DMalloc for use
  450.          on any one computer at any one time.  You  must treat this
  451.          software  just like  a  book.   An  example  is that  this
  452.          software may be  used by any number  of people and may  be
  453.          freely  moved from  one computer  location to  another, as
  454.          long as there is  no possibility of  it being used at  one
  455.          location  while it's  being used  at another.  Consider it
  456.          like a book, a book cannot be read by two different people
  457.          at the same time.
  458.          For  commercial users of DMalloc, site-license or multiple
  459.          license discount arrangements  may be  made by  contacting
  460.          the author at the above address.
  461.  
  462.          If there is an unavoidable delay in registering, note that
  463.          DMalloc  will   continue  to  work   unchanged  after  the
  464.          evaluation period. Under no  circumstances will DMalloc do
  465.          any mischief  to those  who  dishonestly continue  to  use
  466.          DMalloc without registering.
  467.  
  468.       1.8. Distribution Policies
  469.          DMalloc  and  its documentation  are COPYRIGHTED,  and are
  470.          NOT PUBLIC DOMAIN.
  471.          Anyone  distributing DMalloc  for any  kind of  direct fee
  472.          must   first  contact   me  at   the  address   above  for
  473.          authorization.  Although authorization  will generally  be
  474.          automatically granted to distributors recognized by ASP as
  475.          adhering  to  its guidelines  for  shareware distributors,
  476.          notification is still required.
  477.          The above restriction does not apply to the case of normal
  478.          & usual connect charges on  a BBS, where no other specific
  479.          charge is made for obtaining a copy of DMalloc.
  480.  
  481.          Individual  users  are  encouraged  to  pass  unregistered
  482.          evaluation copies  of DMalloc  along to their  friends for
  483.          evaluation.
  484.          When  secondarily  distributed,  DMalloc must  be  in  its
  485.          original  compressed  form  and  accompanied  by  its full
  486.          on-disk documentation  and other  information files.   The
  487.          distributed software and  documentation may not  have been
  488.          modified in any way.
  489.  
  490.  Page 6                                                          DMalloc
  491. ------------------------------------------------------------------------
  492.  
  493.  
  494.          No secondary  distributor  is authorized  to "register"  a
  495.          copy  of  DMalloc.  Registration  fees may  only  be  sent
  496.          directly  to the author as  outlined above in section 1.7.
  497.          Note that the  registration fee is exclusive  of, and over
  498.          and  above any  fees that  may be  charged by  a secondary
  499.          distributor.
  500.  
  501.  
  502.  Page 7                                                          DMalloc
  503. ------------------------------------------------------------------------
  504.  
  505.  
  506. 2. Installation
  507.  
  508.    DMalloc consists of at least:
  509.  
  510.       PACKING.LST    a list of all files in package
  511.  
  512.       WARRANTY.DOC   IMPORTANT WARRANTY INFORMATION
  513.       !README!.      PLEASE READ THIS!
  514.  
  515.       DMALLOC.OBJ    | 
  516.       DMALLOC.LIB    |  the actual software
  517.       DMALLOC.H      | 
  518.       DMCNONE.LIB    |
  519.       DMALLOC.BC     |
  520.       DMALOC09.DOC   this document
  521.  
  522.       MAILER.DOC     an optional  fold up registration
  523.                      form
  524.  
  525.       2.1. Documentation
  526.          MAILER.DOC is an optional  quick and handy all-in-one fold
  527.          up registration form and envelope, print it by typing:
  528.  
  529.             COPY MAILER.DOC PRN 
  530.  
  531.          To register, or to order a printed manual just fill it in,
  532.          staple your check INSIDE it,  TAPE it closed as shown, (DO
  533.          NOT USE STAPLES ON THE EXTERIOR) and stamp and mail it.
  534.          DMALOC09.DOC  is   the  installation,  demo   program  and
  535.          reference documentation.   It contains no  special format-
  536.          ting commands, can be viewed with any DOS text file viewer
  537.          or editor, and it should be printable on most any printer.
  538.          To print, type at the DOS command line:
  539.  
  540.             COPY DMALOC09.DOC PRN 
  541.  
  542.          You  should have  at least  50 pages  of paper  ready when
  543.          printing the manual. The documentation  file includes "box
  544.          drawings", these  use certain characters which  may not be
  545.          available   on  some  printers.  Generally  such  printers
  546.          replace these special  characters with italicised letters.
  547.          If you  are  able to,  choose  the "IBM  mode"  on such  a
  548.          printer.
  549.          However,  don't  let the  thickness  of  the documentation
  550.          scare you. DMalloc  is extremely easy to use.  This manual
  551.          will do its best to teach you how to use  DMalloc to debug
  552.          your program.
  553.  
  554.  Page 8                                                          DMalloc
  555. ------------------------------------------------------------------------
  556.  
  557.  
  558.       2.2. A Quick Start
  559.          To quickly  get an existing program  running with DMalloc,
  560.          relink the application together with the DMALLOC.OBJ file.
  561.          The  DMALLOC.LIB library  must  be either  in the  current
  562.          directory or  in one of  the directories specified  in the
  563.          LIB environment variable.
  564.          After linking, start the  program as usually. DMalloc will
  565.          pop up before  the main() function is called  to allow you
  566.          to set the different options.
  567.          Note: if  an application  is  not  compiled using  the
  568.                large memory model (compiler directive -AL), the
  569.                linker  will  issue  an  error message  and  the
  570.                program  will  not  work. You  must  compile the
  571.                application using the large memory model(3).
  572.  
  573.       2.3. Where to from here?
  574.          If  you have  never used DMalloc  before, I  would suggest
  575.          that you either run the demo program together with reading
  576.          section 3,  or if  do not like  a walkthrough  approach to
  577.          learning a program, then study the reference sections.
  578.  
  579.          Section 3 is the walkthrough demonstration.
  580.          Section 4 describes dynamic memory, what may go wrong with
  581.                   it and what DMalloc does to catch those bugs.
  582.          Section 5 describes the  windows that appear  in DMalloc,
  583.                   and the use of the function keys.
  584.          Section 6 describes how to use DMalloc for debugging.
  585.          Section 7 is the reference section for the DMalloc API.
  586.  
  587.       2.4. Support & Thanks
  588.          Questions, comments, suggestions, and  even thanks are all
  589.          welcome. I am supporting this software via regular mail or
  590.          fax, or alternatively  (this is preferred)  on CompuServe/
  591.          ZiffNet, either via electronic mail, or on the Programming
  592.          Forum, Toolkits(7) section.
  593.  
  594.          Via CompuServe:
  595.             Address  messages to my UserID 100015,551 through
  596.             CompuServe  MAIL, or  leave a  message for  me in
  597.             ZNT:PROGRAM forum in the Toolkits(7) section.
  598.          Via regular mail:
  599.             Forward all support questions to
  600.                Ernest Vogelsinger
  601.                Hietzinger Hauptstrasse 40 c
  602.                A-1130 Vienna, Austria
  603.          Via fax:
  604.             Call (+43)1 828 46 09
  605.             There is an automatic voice/fax switch installed. However,
  606.             support can only be granted to faxed requests.
  607.  
  608.  
  609.    --------------------
  610.    3  Future versions may support different memory models.
  611.  
  612.  Page 9                                                          DMalloc
  613. ------------------------------------------------------------------------
  614.  
  615.  
  616.          For registered users, support is free for 6 (six) months 
  617.          from date of registration. Email support continues to be
  618.          free,  whereas support  via fax  or regular mail will be 
  619.          charged US$ 10.-- per case. If the support case question
  620.          is of interest to all registered users,  it will be held
  621.          free, too.
  622.  
  623.          Improved  or  new  versions  will  be  announced  on  Com-
  624.          puServe/ZiffNet  on  the  Programming  Forum,  Toolkits(7)
  625.          section.  Registered users will  be automatically notified
  626.          either via electronic mail, fax, or regular mail.
  627.          My  sincere thanks go out to all  of those who have helped
  628.          me  to improve DMalloc  by offering  up their  wish lists,
  629.          suggestions and criticisms.
  630.  
  631.          A big  "Thank you" also  to Orest Skrypuch, the  author of
  632.          Recon , and to  M.E. Stanley, the author  of TappeT ,  for
  633.          their outstanding manuals. I couldn't resist  taking these
  634.          two as a skeleton for this documentation.
  635.  
  636.          Also a very  special thanks to all the  brave and tireless
  637.          BETA/GAMMA  testers  (they  are  all writing  much  better
  638.          programs now)!
  639.  
  640.          Enjoy!
  641.          Ernest Vogelsinger
  642.                              
  643.  
  644.  Page 10                                                         DMalloc
  645. ------------------------------------------------------------------------
  646.  
  647.  
  648. 3. Demonstration Program
  649.  
  650.       The demonstration program consists of 3 files:
  651.          DEMO.BAT       batch file to start the demo
  652.          DEMO.TXT       text echoed by the batch file
  653.          DMLDEMO.EXE    the actual demonstration program
  654.  
  655.       The demonstration program is a very simple C  program that
  656.       prints  text to  the  screen, allocates  some memory,  and
  657.       contains  some "bugs"  to  demonstrate  the  miscellaneous
  658.       features of DMalloc.
  659.       The demo  program is  not intended  to cover  the complete
  660.       functionality of DMalloc. It will give  you an overview on
  661.       the basic features, the windows, and the integrity checks.
  662.  
  663.       Note: your  monitor should  be in  text mode,  and the
  664.             display width  should  be 80x25  or greater.  If
  665.             your primary display  is smaller (e.g.40x25), or
  666.             a graphics  mode is active,  DMalloc will either
  667.             use an  alternate monitor, if available,  or im-
  668.             mediately quit  with an appropriate  runtime er-
  669.             ror.
  670.  
  671.       To start the demo, type
  672.          DEMO [Enter]
  673.  
  674.       Since  DMalloc pops up just  before the main() function is
  675.       called (and before the demo can give you any explanation),
  676.       there is  a batch file to  help you at the  very start. If
  677.       you typed  DMLDEMO instead  of  DEMO, you  are not  really
  678.       missing something, except  the batch file  telling you  to
  679.       press [F5] to start the demo.
  680.  
  681.       3.1. DMalloc Startup
  682.          Have a look  at the screen now. On top  you should see the
  683.          Information  Window. This  window will  always be  visible
  684.          whenever DMalloc pops up. Its title  shows the version and
  685.          license  number  of  DMalloc.  The  contents  will  always
  686.          reflect why  DMalloc popped  up - now  it tells  that it's
  687.          about to initialize.
  688.          The Setup Window  in the center of the screen  can be used
  689.          to  modify the configuration  options. For  now we'll keep
  690.          them as they are.
  691.  
  692.  Page 11                                                         DMalloc
  693. ------------------------------------------------------------------------
  694.  
  695.  
  696.          On the bottom line, the  function keys are displayed. This
  697.          line  always reflects  the actual  status of  the function
  698.          keys - if there is no action  for a key, it will be empty.
  699.          The keys available now are
  700.          [F2]  Colors   modify the window colors
  701.          [F4]  View     temporarily  hide the  DMalloc windows  and
  702.                         view the program screen
  703.          [F5]  Go!      close all  open  windows and  continue  the
  704.                         running program
  705.          [F6]  Select   select   the  heap  entries  that  will  be
  706.                         displayed when the Heap Entries Window pops
  707.                         up
  708.          [F10] Back     close the topmost window and  continue with
  709.                         the window below
  710.  
  711.          The [LEFT] and [RIGHT] keys are always available.
  712.  
  713.  
  714.          Remember, you  are still  before the  execution of  main()
  715.          begins. To actually start the demo program press [F5] now.
  716.          Now the demo program  is allocating a bunch of  memory. As
  717.          in a real-world C program, different source modules  issue
  718.          calls to malloc().  Two of  them have  been compiled  with
  719.          DMalloc info  enabled, and  the  third without  (as  third
  720.          party code would generally  be). While allocating you will
  721.          notice DMalloc  popping up regularly to  check the consis-
  722.          tency of the heap.
  723.          At any  time you may use  DMalloc to look at  the heap. To
  724.          interactively popup DMalloc, press [PrtSc].
  725.  
  726.       3.2. Heap Overview
  727.          As there is  no heap problem the  Information Window shows
  728.          that you  pressed [PrtSc].  Below you see the Heap Entries
  729.          Window, the main window of DMalloc.
  730.  
  731.          The Heap  Entries Window lists  all memory units  that are
  732.          used by the program(4),  sorted by address.  Use the [Up],
  733.          [Down],  [PgUp],  [PgDn], [Home]  and [End]  keys  to move
  734.          through  the list.
  735.          Press [Enter] to view the contents of a  unit, or  use the
  736.          [F7] key to see the total heap status (see  next section).
  737.          If you are done, press [F5] to continue with the demo.
  738.  
  739.       3.3. Total Heap Status
  740.          Available at any time by pressing [F7], this  window tells
  741.          you the  total amount of used and free memory, the size of
  742.          the biggest available unit  (very much like the  _memmax()
  743.          function), and the biggest  unit available from DOS  (i.e.
  744.          memory  that  has not  yet  been  claimed  by the  runtime
  745.          library).
  746.  
  747.    --------------------
  748.    4  except units allocated with halloc().
  749.  
  750.  Page 12                                                         DMalloc
  751. ------------------------------------------------------------------------
  752.  
  753.  
  754.       3.4. Detecting Heap Problems
  755.          Now the  demo program will do some  out-of-bound writes to
  756.          the  allocated units. What  in a  real-world program would
  757.          happen cannot exactly  be told since it  depends very much
  758.          on  the  actual  memory  available  at  runtime, what  the
  759.          program would do next (regarding the heap), and much more.
  760.          It could never cause any harm, it could destroy some data,
  761.          it could hang the machine, or crash the operating system.
  762.          With  DMalloc  checking the  heap, these  errors  will im-
  763.          mediately  be found.  When DMalloc  pops up  you'll notice
  764.          that the Information Window tells you  that there are cor-
  765.          rupted units  found. The bar  in the  Heap Entries  Window
  766.          will be positioned at the first corrupted unit. To quickly
  767.          switch between corrupted units, use the [Left] and [Right]
  768.          keys.
  769.  
  770.          Three types of problems are shown here:
  771.          Trailing Corruption (the  first unit):  This is  the most
  772.               common problem. It occurs whenever you write more to
  773.               a  unit than  you have  allocated. Under non-DMalloc
  774.               conditions this  would overwrite the allocation info
  775.               of the following unit.
  776.  
  777.          Odd/Even Corruption  (the second unit): Although  similar
  778.               to the first case  it would never  cause any problem
  779.               in a real-world program.  When an odd-sized  unit is
  780.               allocated, the runtime library automatically expands
  781.               the size by one byte to evenly align units. However,
  782.               the  unit  size may  have been calculated,  and this
  783.               one-byte overwrite would cause a Trailing Corruption
  784.               if the size was even!
  785.  
  786.          Leading  Corruption (the third  unit): This would destroy
  787.               the allocation info  of  the  unit itself. It may be
  788.               caused by an overwrite of the preceding unit,  or by
  789.               a faulty negative-index  calculation  into the  unit
  790.               itself.
  791.  
  792.          Press [F5] to continue the demo when you're ready.
  793.  
  794.       3.5. Invalid Pointer Warning
  795.          Whenever the program passes  invalid values to free()  and
  796.          realloc(), or a far pointer is passed to _nfree(), DMalloc
  797.          will inform you. The reason for that kind of  error may be
  798.          either uninitialized  variables, duplicate freeing  of the
  799.          same pointer, freeing pointers to  not-allocated data, and
  800.          much  more.   Since  the  free()  function  doesn't  check
  801.          anything (except  NULL  pointers), and  simply writes  the
  802.          allocation info, this could harm data needed elsewhere.
  803.  
  804.  Page 13                                                        DMalloc
  805. ------------------------------------------------------------------------
  806.  
  807.  
  808.       3.6. Determining Action, Setting Breakpoints
  809.          Now  press [F10] to  step back to  the Information  Window.
  810.          You'll notice two selection  fields:
  811.          "You can:"  and  "Breakpoint:".  These selection fields are
  812.          always present  in the  Information Window, unless you have
  813.          pressed [PrtSc].
  814.          Press [Space]  to scroll  the options,  and  press [Tab] or
  815.          [Enter] to switch between the fields.
  816.  
  817.          The "You can:" field offers the following possibilities:
  818.  
  819.          Discard:       since the pointer to be freed is invalid you
  820.                         may discard the call to free().
  821.          Exit program:  this will immediately exit the debugged
  822.                         program  by  a  call  to  exit().  Any  function
  823.                         specified  for atexit()  or onexit()  processing
  824.                         will be called.
  825.          Continue:      normally continue  the program.  (Note: if
  826.                         you choose this option now,  freeing the invalid
  827.                         pointer may hang your machine!)
  828.  
  829.          The "Breakpoints:" field offers the following possibilities:
  830.  
  831.          None:          no breakpoint will be set.
  832.          SoftIce:       DMalloc will  generate a SoftIce  breakpoint
  833.                         (see section 6.5.1). If you have SoftIce loaded,
  834.                         try this option now.
  835.          CodeView:      set a CodeView breakpoint.
  836.          Int3:          set  an  unspecified  interrupt-3  breakpoint.
  837.                         Interrupt 3 can be  generally used to set break-
  838.                         points for debuggers.
  839.  
  840.          The breakpoints  will activate  the debugger at the state-
  841.          ment  after  calling malloc.  In  assembler,  you'll see a 
  842.          statement like  "ADD  SP, +2".  In source mode, you'll see
  843.          the line containing the call to malloc().
  844.  
  845.          After taking your selections, press [F5] or [F10] to continue.
  846.  
  847.       3.7. Null Pointer Assignments
  848.          DMalloc can check for  null pointer assignments. The  demo
  849.          will now  overwrite the first  few bytes of the  data seg-
  850.          ment.  In a  real-world program this  will be  detected at
  851.          runtime end.  DMalloc will  detect it  when  it walks  the
  852.          heap.
  853.          The same check  is also available  for far null  pointers.
  854.          Usually,  far  null  assignments overwrite  the  interrupt
  855.          table.  When a  far null  assignment is  detected, DMalloc
  856.          will not only tell, but also undo the changes!
  857.  
  858.  Page 14                                                        DMalloc
  859. ------------------------------------------------------------------------
  860.  
  861.  
  862.       3.8. Fatal Heap Errors
  863.          Although   DMalloc  detects  heap  overwrites,  it  cannot
  864.          guarantee that the allocation  info needed by the  runtime
  865.          library is not tampered with. Whenever  the heap structure
  866.          is completely destroyed (and  a non-DMalloc program  would
  867.          hang),  it  will  tell  you  so  and  gracefully exit  the
  868.          program.
  869.  
  870. 4. Dynamic Memory and DMalloc
  871.       4.1. Dynamic Memory Layout
  872.          The MSC  Runtime Library allocates dynamic  memory by par-
  873.          titioning  the heap  into allocation  units. Each  unit is
  874.          preceded  by an  info block  containing the  size and  the
  875.          allocation status (used/free):
  876.  
  877.          ───┐ ┌───────────┐ ┌───────────
  878.           ╦═╧═╧╤════════╦═╧═╧╤════════╦
  879.           ║Info│Contents║Info│Contents║
  880.           ╩════╧╤═══════╩════╧════════╩
  881.                 └ malloc() pointer
  882.  
  883.          Since  the  allocation information  is  used  to link  the
  884.          single units it  is very critical to the  integrity of the
  885.          dynamic  heap. Any tampering with the  contents of the in-
  886.          formation  field will produce  unpredictable results. Even
  887.          though most  heap corruptions are only  off-by-one errors,
  888.          they can be nevertheless dangerous.
  889.  
  890.       4.2. DMalloc and Dynamic Memory
  891.  
  892.          ───┐ ┌───────────────────┐ ┌─
  893.           ╦═╧═╧╤═══╤════════╤═══╦═╧═╧╤
  894.           ║Info│Dml│Contents│Dml║Info│
  895.           ╩════╧═══╧╤═══════╧═══╩════╧
  896.                     └ malloc() pointer
  897.  
  898.          Here's  where DMalloc  comes  in  -  it  copes  with  heap
  899.          problems is two ways:
  900.          -  it  surrounds any allocated  unit with  small buffers
  901.             containing  initialized data  to track  those off-by-
  902.             some  errors, and  to provide that they  don't really
  903.             corrupt the heap (allocation overhead = 2x4 bytes)
  904.          -  it tracks all allocated units  in a tag table to hold
  905.             additional information on that unit
  906.             (tag table entry = 10 bytes):
  907.             -  it provides the source file name and the line num-
  908.                ber where this unit has been allocated
  909.             -  it allows to "mark" any  unit so freeing and real-
  910.                locating will let DMalloc pop up
  911.             -  it  can  check  the  parameters  for  free()   and
  912.                realloc() calls
  913.  Page 15                                                         DMalloc
  914. ------------------------------------------------------------------------
  915.  
  916.  
  917.       4.3. Tracking the Functions
  918.          One of the most convenient  features of DMalloc is that it
  919.          automatically tracks  calls to the  malloc functions, even
  920.          without recompiling the code. How does this work?
  921.  
  922.          On startup,  before main() is called,  DMalloc patches the
  923.          entry points to the malloc functions. When they are called
  924.          later, control will automatically be passed to the DMalloc
  925.          code. The following functions will be tracked:
  926.             _fmalloc (this is  where the malloc() label points
  927.                       to in the large memory model)
  928.             calloc
  929.             realloc
  930.             _ffree   (this  is where the  free() label points to
  931.                       in the large memory model
  932.             _nmalloc
  933.             _nfree
  934.          These functions  are referenced throughout  the manual  as
  935.          "malloc functions". Calling one of them will automatically
  936.          activate DMalloc.
  937.  
  938.       4.4. Checking the Heap
  939.          DMalloc  checks  the  heap  by  calling  the  _nheapwalk()
  940.          function for  the near  and the _fheapwalk()  function for
  941.          the  far heap  and  testing the  results  against its  tag
  942.          table. Whenever a corrupted unit  is detected it will  pop
  943.          up.  This heap  walk can  only be  done when  DMalloc gets
  944.          control:
  945.          -  one of the above functions is called
  946.          -  each time DMalloc pops up
  947.          -  using the DMalloc programming API
  948.  
  949.          Usually it  is not  necessary to check  the heap  on every
  950.          call to a malloc function.  The frequency of the automatic
  951.          check can be  changed at runtime in the  Setup Window (see
  952.          section 5.4).
  953.  
  954.       4.5. Types of Heap Corruption
  955.          A program can overwrite the allocation information  fields
  956.          in both directions: upwards,  destroying the info field of
  957.          successive  ("trailing") units,  or downwards,  destroying
  958.          its  own  ("leading") information  field.  DMalloc detects
  959.          both  kinds of  errors. Refer  also to  section 5.6,  Heap
  960.          Entries Window.
  961.  
  962.          4.5.1. Lead Corruption
  963.             Lead Corruption  occurs  when the  allocation  information
  964.             field preceding the unit is destroyed.  This may be caused
  965.             by either  faulty downward indexing at  the corrupted unit
  966.             itself, or by out-of-bounds writes to the preceding unit.
  967.  
  968.  Page 16                                                         DMalloc
  969. ------------------------------------------------------------------------
  970.  
  971.  
  972.          4.5.2. Trail Corruption
  973.             Trail  corruption occurs  when the  allocation information
  974.             field following the unit is destroyed. This is most likely
  975.             caused by out-of-bounds writes to the unit.
  976.  
  977.          4.5.3. Odd/Even Problem
  978.             Odd/Even corruption is a special case of Trail corruption.
  979.             Regardless if the allocated size  is even or odd, the mal-
  980.             loc  functions always  pad the  unit  size to  be even(5).
  981.             Thus, writing one  byte  more than  allocated would  never
  982.             cause  a problem,  and would  never be  detected.  DMalloc
  983.             catches this kind of problem as well, since the size could
  984.             be a  calculated value,  and the  off-by-one  access would
  985.             cause a Trail Corruption if it was even.
  986.  
  987.          4.5.4. Mavericks
  988.             Mavericks are  allocated units  that DMalloc  doesn't know
  989.             about, but  detects when walking the heap.  Since there is
  990.             no "legal" way of allocation bypassing DMalloc, the occur-
  991.             rence of  Mavericks is  a clear  sign that  stray pointers
  992.             corrupted the  heap. Mostly  Mavericks will be  found when
  993.             DMalloc detects  an unrecoverable  heap failure, and  thus
  994.             would terminate the program.
  995.  
  996.  
  997.       4.6. Null Pointer Assignments
  998.          The MSC  runime  library provides  a  way to  detect  Null
  999.          pointer assignments at the end of the program. Since  this
  1000.          is a bit late to tell where it could have happened,  DMal-
  1001.          loc can check the NULL  region whenever it checks the heap
  1002.          (see section 5.6.3 how to activate  this feature). It will
  1003.          pop up whenever it detects a change in the contents of the
  1004.          NULL region.
  1005.          Note: the runtime library provides 40h bytes at the be-
  1006.                ginning of the data segment to allow for checking
  1007.                against Null pointer assignments. You may disable
  1008.                this feature to save data and code space  by pro-
  1009.                viding a "int _nullcheck(void);"  function retur-
  1010.                ning 0(6). In this case, the linker will not pull
  1011.                the constant NULL  segment in,  and  DS:0 assign-
  1012.                ments  are perfectly  valid since  it's  the pro-
  1013.                gram's data.
  1014.                DMalloc is aware of this and disables the (near)
  1015.                Nullcheck feature.
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.    --------------------
  1022.    5  This grants all allocated  units to be aligned at  an
  1023.       even address.
  1024.    6  The _nullcheck() function must reside in the _TEXT segment
  1025.  
  1026.  Page 17                                                         DMalloc
  1027. ------------------------------------------------------------------------
  1028.  
  1029.  
  1030.       4.7. Far Null Pointer Assignments
  1031.          Compiling  for far data,  NULL pointers will  not point to
  1032.          the data  segment NULL region but to  the interrupt table.
  1033.          Assignments  to  FAR  NULL  pointers  normally  hang   the
  1034.          machine,  since interrupt pointers  are destroyed. DMalloc
  1035.          may check  the FAR NULL  region (see section 5.6.3  how to
  1036.          activate this feature). Whenever  an unknown  change(7) is
  1037.          detected, DMalloc will reset the contents of the interrupt
  1038.          table to a known state, and pop up.
  1039.          Note: This is not a "lifebelt". Since an interrupt may
  1040.                be called before DMalloc detects  the change, it
  1041.                may still crash the machine(8).
  1042.  
  1043.       4.8. Watchpoints
  1044.          DMalloc provides a  way to notify you  whenever a specific
  1045.          allocation unit is to be reallocated  or freed. Marking an
  1046.          allocated unit (see section  5.6.3) sets a Watchpoint that
  1047.          will direct DMalloc  to popup whenever that unit  is to be
  1048.          freed or reallocated.
  1049.  
  1050.       4.9. Savepoints
  1051.          DMalloc can remeber certain  allocated units from one ses-
  1052.          sion to the next,  where it may pop  up when a  remembered
  1053.          unit has  been allocated. This is  automatically done with
  1054.          corrupted  units.  You  may  set Savepoints  (see  section
  1055.          5.6.4) on allocated  units to save them for  the next ses-
  1056.          sion, similar to a corrupted unit.
  1057.          When  DMalloc pops up  because a remembered unit  has just
  1058.          been allocated, it will tell if it has been a corrupted or
  1059.          a saved entry.
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.    --------------------
  1076.    7  DMalloc  will know when  the operating system changes
  1077.       an interrupt.
  1078.    8  Interrupts called frequently are 08h and 1Ch (timer),
  1079.       09h and 16h  (keyboard), 10h (video), 21h  (DOS), and
  1080.       some  more. However, interrupts 00h to 07h (the first
  1081.       two paragraphs) are not frequently called.
  1082.  
  1083.  
  1084.  Page 18                                                         DMalloc
  1085. ------------------------------------------------------------------------
  1086.  
  1087.  
  1088. 5. DMalloc In Detail
  1089.  
  1090.       Regardless  of the  situation,  two elements  of the  user
  1091.       interface  will always be present when  DMalloc is up: the
  1092.       Function Key display, and the Information Window.
  1093.  
  1094.       5.1. About DMalloc Windows
  1095.          DMalloc uses three window types:
  1096.          -  Informational  windows containing only text. You can-
  1097.             not scroll or modify data
  1098.          -  Data entry windows.  You may enter or  modify data at
  1099.             various entry fields
  1100.          -  A List box type window
  1101.  
  1102.          Three types of data entry fields are available:
  1103.          -  Ascii data entry to enter text
  1104.          -  Numeric data  entry to enter numeric  values. You may
  1105.             use the [+], [Space]  or [-] keys  to let it count up
  1106.             or down.
  1107.          -  Selection  entry to  select  from  certain  available
  1108.             values. Press the [Space] key, or the first letter of
  1109.             the selection of your choice (e.g. [C] to select "Co-
  1110.             ntinue").
  1111.  
  1112.          After  entering or changing data  in an data entry window,
  1113.          you may confirm the changes by pressing [F5] or [F10], or
  1114.          undo them by pressing [Esc].
  1115.  
  1116.  
  1117.       5.2. Function Keys
  1118.          The function keys that  are currently available are always
  1119.          displayed at the bottom of the screen.
  1120.  
  1121.          Keys that are always available:
  1122.  
  1123.          [F4]  View  Hide the DMalloc  screen to show  the screen  of
  1124.                      the debugged  program (if  an alternate  monitor
  1125.                      is  used   (see  section  5.4.8),  this  key  is
  1126.                      unavailable).
  1127.          [F5]  Go!   Close all open  DMalloc  windows (as if pressing
  1128.                      [F10]) and  immediately continue the interrupted
  1129.                      program
  1130.          [F10] Back  Close the topmost window  and continue with  the
  1131.                      next below.  If  data has  been entered  in  the
  1132.                      active window, it is saved.
  1133.          [Esc] Undo  Close the  topmost window and continue  with the
  1134.                      next  below.  If data  has  been entered  in the
  1135.                      active window, changes are discarded.
  1136.  
  1137.  
  1138.  
  1139.  Page 19                                                         DMalloc
  1140. ------------------------------------------------------------------------
  1141.  
  1142.  
  1143.          Keys that open a window, or perform an action:
  1144.  
  1145.          [F2]        Setup Window
  1146.                         -> Colors Window
  1147.          [Sh] +[F2]  Repair unit
  1148.          [Ctl]+[F2]  Repair all
  1149.          [F3]        Heap Entries Window
  1150.                         -> Dump Window
  1151.                            -> Edit Contents
  1152.          [F6]        Selection Window
  1153.          [F7]        Heap Status Window
  1154.          [F9]        Set/Clear Watchpoint
  1155.          [Ctl]+[F9]  Set Watchpoint at all visible units
  1156.          [Alt]+[F9]  Toggle Watchpoint at all visible units
  1157.          [Sh] +[F9]  Clear Watchpoints at all visible units
  1158.  
  1159.  
  1160.       5.3. Information Window
  1161.  
  1162. ╔╡ DMalloc 1.00 (MSC 5.10, 6.00) (c) 1990-1992 E.Vogelsinger (UNREGISTERED)╞╗
  1163. ║ DMalloc was triggered by the host program (file test.c, line 68).         ║
  1164. ║ Program suspended for heap debugging.                                     ║
  1165. ║ You can: Continue      Breakpoint: None                1 new heap problem ║
  1166. ╚═══════════════════════════════════════════════════════════════════════════╝
  1167.  
  1168.          The title  bar shows  the DMalloc version  and the  serial
  1169.          number. The text  in the window describes the exact reason
  1170.          for DMalloc to pop up.
  1171.  
  1172.          If  a  new heap  corruption  is  detected (i.e.  corrupted
  1173.          entries that  have not yet been displayed), the total num-
  1174.          ber of the new detections  is displayed in the lower right
  1175.          corner.
  1176.  
  1177.          Two selection fields are present at the bottom:
  1178.  
  1179.       5.3.1. "You can" - Select the Next Action
  1180.          Continue       will continue the debugged program.
  1181.          Exit program   will exit the program as soon as you  leave
  1182.                         DMalloc.
  1183.          Discard action will discard the action that caused DMalloc
  1184.                         to pop up. This choice is only available if
  1185.                         -  an invalid pointer  was passed to 
  1186.                            realloc() or free()
  1187.                         -  a far pointer was passed to _nfree()
  1188.                         -  a Watchpoint has matured (see section 4.8)
  1189.  
  1190.  Page 20                                                         DMalloc
  1191. ------------------------------------------------------------------------
  1192.  
  1193.  
  1194.       5.3.2. "Breakpoint:"
  1195.          This field can  be used  to set  breakpoints to  debuggers
  1196.          (see section 6.5).
  1197.          None           will not set any breakpoint
  1198.          SoftIce        generates  a breakpoint for the Soft-ICE  debug-
  1199.                         ger
  1200.          CodeView       generates a breakpoint for the  CodeView  debug-
  1201.                         ger
  1202.          Int3           generates an unspecified INT 03h instruction
  1203.  
  1204.          Note: Both selection fields are only present if  DMalloc
  1205.                loc automatically popped  up. Pressing the [PrtSc]
  1206.                key to activate DMalloc is an asynchronous action.
  1207.                The state  of the  operating system  or a debugger
  1208.                cannot be predicted at this moment, so it could be
  1209.                fatal if  DMalloc would  try to break into the de-
  1210.                bugger, or to exit the running program.
  1211.  
  1212.  
  1213.       5.4. Setup Window
  1214.  
  1215.       ╔╡ Setup ╞════════════════╗    
  1216.       ║                         ║    
  1217.       ║ Alert on problem : Yes  ║    
  1218.       ║ Popup on saved   : No   ║    
  1219.       ║ Cycles for popup : 0    ║    
  1220.       ║ Heap check cycles: 100  ║    
  1221.       ║ Popup for file          ║    
  1222.       ║           line   : 0    ║    
  1223.       ║ Startup screen   : Yes  ║    
  1224.       ║ Shutdown screen  : Yes  ║    
  1225.       ║ Alternate monitor: No   ║    
  1226.       ║ Number of handles: 5000 ║    
  1227.       ║                         ║    
  1228.       ╚═════════════════════════╝    
  1229.  
  1230.          The Setup Window allows to modify the behaviour of DMalloc
  1231.          at runtime. The  Setup Window is always available by pres-
  1232.          sing [F2].
  1233.  
  1234.          All setup options  will be permanently stored in  the con-
  1235.          figuration file (see section 5.10).
  1236.  
  1237.  Page 21                                                         DMalloc
  1238. ------------------------------------------------------------------------
  1239.  
  1240.  
  1241.       5.4.1. Alert on problem (Default: Yes)
  1242.          Specifies if DMalloc should pop up  if heap  corruption is
  1243.          detected. Entering "No" lets DMalloc keep quiet even if it
  1244.          detects  newly corrupted allocation  units. However, there
  1245.          are situations when DMalloc will pop up regardless of this
  1246.          switch:
  1247.          -  DMalloc is about to initialize  (except switched off,
  1248.             see section 5.4.6)
  1249.          -  an unrecoverable heap failure has been detected
  1250.             a unit that has been found corrupted  during the last
  1251.             session has been allocated, and the  "Popup on saved"
  1252.             switch  (see section  5.4.2) is  set to  "Corrupt" or
  1253.             "Both"
  1254.          -  a unit marked for  save (see section 5.6.4)  has been
  1255.             allocated, and the "Popup on saved" switch is  set to
  1256.             "Saved" or "Both"
  1257.          -  the popup cycle count has elapsed (see section 5.4.3)
  1258.          -  the  source file/line  specified  as popup  reason is
  1259.             executed (see section 5.4.5)
  1260.          -  [PrtSc] has been pressed
  1261.          -  the  DML_Trigger() API  function  was  executed  (see
  1262.             section 7)
  1263.          -  the  program has  finished, and  DMalloc is  about to
  1264.             shutdown (except switched off, see section 5.4.7)
  1265.  
  1266.          Regardless of this switch, a small "Please wait" sign will
  1267.          always pop up whenever DMalloc checks the heap.
  1268.  
  1269.  
  1270.       5.4.2. Popup on saved (Default: No)
  1271.          DMalloc remembers units  that have  been found  corrupted,
  1272.          and those marked for save  (see section 5.6.4) during  the
  1273.          last debug  session.  You may  selectively  specify  which
  1274.          units you want to monitor:
  1275.          No          disables this feature
  1276.          Corrupt     will pop  up only for  those units that  have
  1277.                      been corrupted in the last session
  1278.          Saved       will pop up only for those units marked for
  1279.                      save
  1280.          Both        will popup for both types
  1281.  
  1282.  
  1283.       5.4.3. Cycles for popup (Default: 0)
  1284.          Regardless of heap corruption, DMalloc can be directed  to
  1285.          pop  up after  a certain  number  of calls  to the  malloc
  1286.          functions have  been made.  Specify 0 if  you do  not want
  1287.          cycled popup.
  1288.          Note: the internal  cycle  counter is  reset  whenever
  1289.                DMalloc pops up.
  1290.  
  1291.  Page 22                                                         DMalloc
  1292. ------------------------------------------------------------------------
  1293.  
  1294.  
  1295.       5.4.4. Heap check cycles (Default: 100)
  1296.          Specifies  after how  many calls  to the  malloc functions
  1297.          DMalloc will  check heap integrity. Although heap checking
  1298.          is quite fast, it  is not necessary to check on  any call.
  1299.          Specify 0 if you do not want any automatic checking.
  1300.          Note: the heap  will always be checked  before DMalloc
  1301.                pops up, regardless of this setting.
  1302.  
  1303.       5.4.5. Popup for file/line (Default: blank/0)
  1304.          Entering a source file name  will direct DMalloc to pop up
  1305.          whenever a  call to the  malloc functions is made  by this
  1306.          source file.  Entering a line  number will restrict  it to
  1307.          this  specific source  line,  line number 0  will allow to 
  1308.          popup at any call from this file.
  1309.          Note: the source  file in  question  must be  compiled
  1310.                with DMalloc information to enable this feature.
  1311.                If a wrong file name  or a line number that does
  1312.                not contain a  call to the  malloc functions  is
  1313.                entered, DMalloc will  not pop up,  even if  the
  1314.                line is executed.
  1315.  
  1316.       5.4.6. Startup screen (Default: Yes)
  1317.          Normally, DMalloc pops  up at the  beginning, just  before
  1318.          calling main().  You may  disable  the Startup  Window  by
  1319.          specifying "No".
  1320.  
  1321.       5.4.7. Shutdown screen (Default: Yes)
  1322.          Normally, DMalloc pops  up at the end,  after the atexit()
  1323.          or onexit() functions  have been called.  You may  disable
  1324.          the Shutdown Window by specifying "No".
  1325.  
  1326.       5.4.8. Alternate monitor (Default: No)
  1327.          You may use an alternate  monitor for DMalloc by selecting
  1328.          "Yes". DMalloc will use the selected monitor  when it pops
  1329.          up the next time.
  1330.          There are situations where DMalloc will use the  alternate
  1331.          monitor regardless of this selection:
  1332.  
  1333.          -  your program switched to graphics mode
  1334.          -  your program switched to a text mode with a different
  1335.             horizontal   or    vertical   resolution    than   at
  1336.             initialization time
  1337.  
  1338.          If you do not have an alternate monitor, and DMalloc would
  1339.          require it, it will not pop up until the display  is reset
  1340.          for DMalloc's needs.
  1341.  
  1342.  Page 23                                                         DMalloc
  1343. ------------------------------------------------------------------------
  1344.  
  1345.  
  1346.          Note: if,  at  initialization  time,  the  display  is
  1347.                either  in  graphics  mode,  or  the  text  mode
  1348.                resolution   is   below  80x25,   DMalloc   will
  1349.                exclusively  use the  alternate display.  If, in
  1350.                that case, you do not have an alternate display,
  1351.                DMalloc will  immediately terminate  at startup,
  1352.                issuing an appropriate runtime error.
  1353.          Note: if you do not have  an alternate monitor, or the
  1354.                the  alternate monitor  is  exlusively  used  by
  1355.                DMalloc, this field will not be accessible.
  1356.  
  1357.       5.4.9. Number of handles (Default: 5000, Maximum: 10900)
  1358.          As mentioned in section 4.2, DMalloc allocates a tag table
  1359.          to  track the  allocated units.  This entry  specifies the
  1360.          size of the tag table.
  1361.          As this value is needed at initialization time, this field
  1362.          is not accessible later.
  1363.          Note: If DMalloc  runs out  of handles, it  will abort
  1364.                the  program and  issue  an appropriate  runtime
  1365.                error.
  1366.  
  1367.  
  1368.       5.5. Colors Window
  1369.  
  1370.       ╔╡ Window Colors╞══════════════════════╗
  1371.       ║                                      ║
  1372.       ║ Notice       : 3E Frame  3F Contents ║
  1373.       ║ Heap         : 3E Frame  30 Contents ║
  1374.       ║ Dump         : 3E Frame  30 Contents ║
  1375.       ║ Selection    : 3E Frame  38 Contents ║
  1376.       ║ Status       : 3E Frame  31 Contents ║
  1377.       ║ Color        : 3E Frame  30 Contents ║
  1378.       ║ Setup        : 3E Frame  30 Contents ║
  1379.       ║ Wait message : 3E Frame  30 Contents ║
  1380.       ║ Function Keys:           70 Contents ║
  1381.       ║                                      ║
  1382.       ╚══════════════════════════════════════╝
  1383.  
  1384.          The Colors Window allows to customize the screen colors of
  1385.          DMalloc. It  is available  only from the  Setup Window  by
  1386.          pressing [F2].
  1387.          For  each window  there are  two entries:  for the  window
  1388.          frame, and for the window contents. The  fields are selec-
  1389.          tion  fields that can be  scrolled by pressing the [Space]
  1390.          key.  To switch between the fields, press the [Tab] or the
  1391.          [Enter] key.
  1392.  
  1393.          DMalloc maintains two color tables, one for color  and one
  1394.          for monochrome display. The Colors Window will display the
  1395.          table for matching the active display type.
  1396.          The color options will  be permanently stored in the  con-
  1397.          figuration file (see section 5.10). After colors have been
  1398.          changed they will be reflected whenever a window comes "on
  1399.          top" again.
  1400.  
  1401.  Page 24                                                         DMalloc
  1402. ------------------------------------------------------------------------
  1403.  
  1404.  
  1405.       5.6. Heap Entries Window
  1406.  
  1407.       ╔╡ Heap entries ╞══════════════════════════════════════════════╗
  1408.       ║▒Block▒▒▒▒▒▒▒▒▒▒▒▒▒▒Owner▒▒line▒▒▒▒Size▒▒▒▒▒▒▒Lead▒▒▒▒▒▒Trail▒║
  1409.       ║ 41CE:EAEC      module1.c   175      86         OK         OK ║
  1410.       ║ 41CE:EB4C      module2.c    24      77         OK         OK ║
  1411.       ║ 41CE:EBA4      ??unknown            43         OK         OK ║
  1412.       ║▒41CE:EBDA▒▒▒▒▒▒module1.c▒▒▒175▒▒▒▒▒▒86▒▒▒▒▒▒▒▒▒OK▒▒CORRUPTED▒║
  1413.       ║ 41CE:EC3A      module2.c    24      77         OK         OK ║
  1414.       ║ 41CE:EC92      ??unknown            43  CORRUPTED         OK ║
  1415.       ║ 41CE:ECC8      module1.c   175      86         OK         OK ║
  1416.       ║ 41CE:ED28      module2.c    24      77         OK   ODD-EVEN ║
  1417.       ║ 41CE:ED80      ??unknown            43         OK         OK ║
  1418.       ║ 41CE:EDB6      module1.c   175      86         OK         OK ║
  1419.       ╚══════════════════════════════════════════════════════════════╝
  1420.  
  1421.          The  Heap Entries Window displays a list of all allocated units.
  1422.          Usually,  the Heap Entries Window  is always visible(9). If not,
  1423.          you may activate it by pressing [F3].
  1424.          You may scroll  through the  heap list  using the  [Up], [Down],
  1425.          [PgUp], [PgDn], [Home], and [End] keys. The current position  in
  1426.          the list is marked by an inverted bar.
  1427.  
  1428.          Each line represents an  allocated unit,  or another part of the
  1429.          programs memory. As shown above, the display contains (from left
  1430.          to right)
  1431.  
  1432.          Block the (far) address of the allocated unit. This address
  1433.                was returned by the malloc functions.
  1434.          Owner the  source file  that allocated  this unit.  If the
  1435.                owning  source  has not  been  compiled with  DMalloc
  1436.                information, "??unknown" is displayed.
  1437.          line  the source line if the owner file is available.
  1438.          Size  the allocated size in bytes.
  1439.          Lead  the status of the  leading control block (see section
  1440.                4.2). Possible values are:
  1441.                OK        the leading control block is OK
  1442.                CORRUPTED the  leading   control   block   has   been
  1443.                          overwritten
  1444.          Trail the status  of the  trailing control block  (see
  1445.                section 4.2). Possible values are:
  1446.                OK        the trailing control block is OK
  1447.                CORRUPTED the trailing  control   block   has  been
  1448.                          overwritten
  1449.                ODD/EVEN  an off-by-one error on an odd-sized allocation
  1450.                          unit has  been detected (see  section 3.4)
  1451.  
  1452.                          
  1453.        
  1454.    --------------------
  1455.    9  Unless  you stepped back to the Information Window by
  1456.       pressing [F10]
  1457.  
  1458.  
  1459.  Page 25                                                         DMalloc
  1460. ------------------------------------------------------------------------
  1461.  
  1462.  
  1463.          Other entries that may be visible belong to preallocated
  1464.          data space and the Far Null region:
  1465.  
  1466.       ║ 0000:0000                          256         OK   FAR_NULL ║
  1467.       ║ 37DD:0000                         4112         OK   FAR_DATA ║
  1468.       ║ 38DE:0000                         5120         OK    FAR_BSS ║
  1469.       ║ 3A1E:0000                        16726         OK      _DATA ║
  1470.       ║ 3A1E:4156                          906         OK        BSS ║
  1471.       ║ 3A1E:742C                        13716         OK    DMALLOC ║
  1472.       ║ 41AC:0128                          132         OK    STARTUP ║
  1473.  
  1474.          FAR_NULL The first 256 bytes of the interrupt table. As a
  1475.                   special  feature for  far pointers,  DMalloc can
  1476.                   track Far Null  Pointer assignments (see section
  1477.                   4.7).  To have  Far Null checking  enabled, this
  1478.                   entry must be "tagged" (see section 5.6.3).
  1479.          FAR_DATA All pre-initialized  data that doesn't  fit into
  1480.                   the data segment. Listed for completeness.
  1481.          FAR_BSS  All non-initialized data  that doesn't fit  into
  1482.                   the data segment. Listed for completeness.
  1483.          _DATA    The  data   segment  containing  pre-initialized
  1484.                   data(10). DMalloc  can track  Null  pointer  as-
  1485.                   signments (see section 4.6). To have Null check-
  1486.                   ing enables,  this entry  must be "tagged"  (see
  1487.                   section 5.6.3).
  1488.          BSS      All non-initialized  data belonging to  the data
  1489.                   segment(11). Listed for completeness.
  1490.          DMALLOC  Memory allocated by DMalloc for its own purpose.
  1491.                   One unit (on  the near heap) is  used for screen
  1492.                   buffers, the others are used by the tag table.
  1493.          STARTUP  Present  only with  MSC 6.+.  Two units  get al-
  1494.                   located before DMalloc initializes. They contain
  1495.                   a  copy  of  the  environment, and  a  bunch  of
  1496.                   pointers. Listed for completeness.
  1497.  
  1498.          You may  freely select which  type of entries you  want to
  1499.          see. Refer to section 5.7, Selection Window.
  1500.  
  1501.  
  1502.  
  1503.  
  1504.          
  1505.          
  1506.      
  1507.  
  1508.    --------------------
  1509.    10 Actually the _DATA entry consists of four consecutive
  1510.       segments: NULL, _DATA, CONST, and MSG. Since they all
  1511.       contain  pre-initialized  data they  are  gathered in
  1512.       this  entry. They  all belong  to DGROUP and  are ad-
  1513.       dressed through the DS or SS register.
  1514.    11 Since the  BSS segment is  part of DGROUP  it has the
  1515.       same segment address as the _DATA entry.
  1516.  
  1517.  
  1518.  Page 26                                                         DMalloc
  1519. ------------------------------------------------------------------------
  1520.  
  1521.       5.6.1. Detecting Corrupted Entries
  1522.          Whenever  DMalloc  detects  a  problem  it  will  pop  up.
  1523.          Regardless  of the  popup reason  displayed in  the Infor-
  1524.          mation  Window, the  heap is  checked completely,  and the
  1525.          number  of newly  found corruptions  blinks in  the Infor-
  1526.          mation  Window (see  section 5.3).  Corrupted  Entries are
  1527.          always displayed in high-intensity color (refer to section
  1528.          4.5 for  different corruption  types). When they  are con-
  1529.          sidered new they will blink.
  1530.          You can quickly move between corrupted entries by pressing
  1531.          the [Left] or [Right] keys.
  1532.          
  1533.          An  allocation unit  that  has been  found  corrupted will
  1534.          always be  saved in the  configuration file  (see sections
  1535.          5.10 and 5.4.2).
  1536.  
  1537.       5.6.2. "Repairing" Corrupted Entries
  1538.          To clear the "corruption" marks at an entry, you can press
  1539.          [Shift]+[F2]  to repair  the  currently  active  unit,  or
  1540.          [Ctl]+[F2] to repair all.
  1541.          Repairing  units will reset the corruption flags, and also
  1542.          reset  the contents of the surrounding control blocks (see
  1543.          section 4.2).
  1544.          Repairing  NULLCHECK at the _DATA entry will not reset the
  1545.          contents of the Null region but only clear  the corruption
  1546.          flag.
  1547.          Repairing  NULLCHECK at the FAR_NULL entry will only clear
  1548.          the corruption flag.  The contents of the  Far Null region
  1549.          are automatically reset  whenever this type  of corruption
  1550.          is encountered.
  1551.          Note: when repairing  a corrupted  unit, DMalloc  will
  1552.                reset the control block contents. If the program
  1553.                relies  on these  contents (outside  of the  al-
  1554.                located unit) don't repair but exit the  program
  1555.                and correct the error.
  1556.          Note: Having  repaired a unit,  it will not  be remem-
  1557.                bered (see section 5.10).
  1558.  
  1559.       5.6.3. Watchpoints ("Tags")
  1560.          Watchpoints  are  used  to  activate  DMalloc  whenever  a
  1561.          watched unit  is to be  freed or reallocated  (see section
  1562.          4.8). Setting a Watchpoint  on the FAR_NULL or  _DATA seg-
  1563.          ment will enable checking for Null pointer assignments.
  1564.          Active  Watchpoints are  displayed as  "Tags"  () at  the
  1565.          watched entry.
  1566.          You can quickly  move between  tagged entries by  pressing
  1567.          the [Ctl]+[Left] or [Ctl]+[Right] keys.
  1568.  
  1569.          To set or clear Watchpoints, press
  1570.          [F9]         or [T]        to tag an entry
  1571.          [F9]         or [U]        to untag an entry
  1572.          [Ctl]+[F9]   or [Ctl]+[T]  to tag all visible entries
  1573.          [Alt]+[F9]                 to toggle all visible tags
  1574.          [Shift]+[F9] or [Ctl]+[U]  to untag all entries
  1575.  
  1576.  Page 27                                                         DMalloc
  1577. ------------------------------------------------------------------------
  1578.  
  1579.  
  1580.       5.6.4. Savepoints
  1581.          DMalloc allows  to remember allocation units between debug
  1582.          sessions (see section 4.9). This is done automatically for
  1583.          corrupted units. Optionally, you may specify some units to
  1584.          be saved  by simply pressing [S].  Whenever DMalloc  allo-
  1585.          cates a saved unit again it will pop up.
  1586.          Unlike remembering a corrupted unit, a Savepoint is sticky
  1587.          i.e. you have  to clear it by pressing  [S]  or it will be
  1588.          kept for that unit (as long as it gets allocated again).
  1589.          Active Savepoints are displayed with an 'S' at the entry.
  1590.  
  1591.  
  1592.  
  1593.       5.7. Selection Window
  1594.  
  1595.       ╔╡ Select ╞═══════════════╗         
  1596.       ║                         ║         
  1597.       ║  Allocated units :  Yes ║         
  1598.       ║  Tagged only     :  No  ║         
  1599.       ║  Nullptr. areas  :  Yes ║         
  1600.       ║  Data segments   :  No  ║         
  1601.       ║  System entries  :  No  ║         
  1602.       ║  Owner file      :      ║         
  1603.       ║        line      :  0   ║         
  1604.       ║                         ║         
  1605.       ╚═════════════════════════╝         
  1606.  
  1607.          The  Selection  Window  selects   which  entries  will  be
  1608.          displayed in the Heap Entries Window. It is available only
  1609.          from  the  Heap Entries Window by pressing  [F6]. Changing
  1610.          the selection will immediately be reflected  by  the  Heap
  1611.          Entries Window.
  1612.  
  1613.          Allocated Units (Default: Yes)
  1614.             Selects all  allocated units except  those marked  DMALLOC
  1615.             and STARTUP.
  1616.          Tagged only (Default: No)
  1617.             If Yes, only those entries  that are currently tagged will
  1618.             be shown.
  1619.          Nullptr. areas (Default: Yes)
  1620.             If Yes, the FAR_NULL and _DATA entries will be shown.
  1621.          Data segments (Default: No)
  1622.             If Yes,  all data  segments (FAR_NULL, FAR_DATA,  FAR_BSS,
  1623.             _DATA, BSS) will be shown.
  1624.             If No, the  FAR_NULL and _DATA segments may  be shown when
  1625.             "Nullptr areas" is "Yes".
  1626.          System entries (Default: No)
  1627.             If Yes, DMalloc and STARTUP entries will be shown.
  1628.          Owner file/line (Default: blank/0)
  1629.             If a  source  file is  entered  here, only  those  entries
  1630.             belonging to the specified source file/line will be shown.
  1631.  
  1632.  
  1633.  Page 28                                                         DMalloc
  1634. ------------------------------------------------------------------------
  1635.  
  1636.  
  1637.       5.8. Dump Window
  1638.  
  1639.   ╔╡ Dump 55DE:0000 ╞═══════════════════════════════════════════════════════╗
  1640.   ║ 55DE0: 00 00 00 00 00 00 00 00-4D 53 20 52 75 6E 2D 54 ........MS Run-t ║
  1641.   ║ 55DF0: 69 6D 65 20 4C 69 62 72-61 72 79 20 2D 20 43 6F ime Library - Co ║
  1642.   ║ 55E00: 70 79 72 69 67 68 74 20-28 63 29 20 31 39 39 30 pyright (c) 1990 ║
  1643.   ║ 55E10: 2C 20 4D 69 63 72 6F 73-6F 66 74 20 43 6F 72 70 , Microsoft Corp ║
  1644.   ║ 55E20: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ║
  1645.   ║ 55E30: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ║
  1646.   ║ 55E40: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ║
  1647.   ║ 55E50: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ║
  1648.   ║ 55E60: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ║
  1649.   ║ 55E70: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ║
  1650.   ║ 55E80: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ║
  1651.   ║ 55E90: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ║
  1652.   ║ 55EA0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ║
  1653.   ║ 55EB0: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ ║
  1654.   ╚═════════════════════════════════════════════════════════════════════════╝
  1655.  
  1656.          The Dump Window  allows you to view and  edit the contents
  1657.          of a  memory unit. It  is available from the  Heap Entries
  1658.          Window by pressing [F3] or [Enter].
  1659.          The Window  Title displays the unit  address. The contents
  1660.          are shown in hex and ASCII  format. The column to the  far
  1661.          left shows the (incrementing) 20-bit address(12).
  1662.  
  1663.          The size  of the Dump  Window may  vary, depending on  the
  1664.          actual  size of the  memory unit.  The maximum size  is 16
  1665.          paragraphs (or 256 bytes). If the size of the unit is big-
  1666.          ger you may scroll the Dump Window using the [Up], [Down],
  1667.          [PgUp], [PgDn], [Home], and [End] keys.
  1668.  
  1669.       5.8.1. Editing Data
  1670.          Press  [F3] to edit the Dump Window contents. When in Edit
  1671.          mode, a block cursor appears at the location where data is
  1672.          to be modified. Using the [Tab] key you can toggle between
  1673.          Hex Mode  and Ascii Mode.  Use the  [Left], [Right], [Up],
  1674.          [Down], [Home], and [End] keys to move the cursor.
  1675.          Modified  data will be displayed  in high intensity color.
  1676.          Pressing [F5] or [F10] will  write the modified data back,
  1677.          pressing [Esc] will ignore the changes.
  1678.          Note: Edit Mode  is not available at  the memory units
  1679.                marked  FAR_NULL and  DMalloc, since  their con-
  1680.                tents are critical to the system.
  1681.          Note: Modifying any data between offset 00h and offset
  1682.                40h will  result in a NULLCHECK  warning and the
  1683.                appropriate  runtime  error   at  program   ter-
  1684.                mination.
  1685.   
  1686.    --------------------
  1687.    12 In Real Mode, the highest memory address available is
  1688.       FFFF:FFFF, or as absolute address 10FFEF. It needs 21
  1689.       bits  to  form  this  number.  However, this  address
  1690.       should never be a malloc unit.
  1691.  
  1692.  Page 29                                                         DMalloc
  1693. ------------------------------------------------------------------------
  1694.  
  1695.  
  1696.       5.9. Heap Status Window
  1697.  
  1698.       ╔╡ Heap Status ╞════════════════╗
  1699.       ║             Units       Bytes ║
  1700.       ║─────────────────────┬─────────║
  1701.       ║                     │         ║
  1702.       ║ Allocated:       3  │   33860 ║
  1703.       ║ Free     :       1  │    4292 ║
  1704.       ║    biggest on heap  │    4292 ║
  1705.       ║    biggest in DOS   │  139728 ║
  1706.       ║                     │         ║
  1707.       ╚═══════════════════════════════╝
  1708.  
  1709.          The Heap Status  Window is available at any  time by pres-
  1710.          sing [F7]. The following information is presented:
  1711.  
  1712.          Allocated         how many units are currently allocated, and the
  1713.                            memory size that is occupied by them.
  1714.          Free              how many free units are currently available,and
  1715.                            the total size of all free units.
  1716.          biggest on heap   the size  of  the biggest  free unit  in
  1717.                            bytes(13).
  1718.          biggest in DOS    the  biggest continuous  memory block cur-
  1719.                            rently available from DOS(14).
  1720.  
  1721.  
  1722.       5.10. The Configuration File
  1723.          All options from the  Setup, Colors, and Selection  Window
  1724.          are permanently stored in  a configuration file. The  name
  1725.          of the  configuration file  will be the  same name  as the
  1726.          name  of the  debugged EXE file,  with extension .DMC(15).
  1727.          If, by chance,  there is another file  with the same name,
  1728.          DMalloc will not attempt to read its contents at initiali-
  1729.          zation time, and will not overwrite it when terminating.
  1730.          All  allocated units  that have  been found  corrupted are
  1731.          stored in  the configuration file, even if  they have been
  1732.          freed or reallocated again. Also units marked 'S' for save
  1733.          will be  stored. DMalloc tries  to be clever  when storing
  1734.          pointers:  the segment portion  of the  pointer is somehow
  1735.          normalized  to allow  for different  runtime environments,
  1736.          where the program may be located somewhere else in memory.
  1737.          However, if the size of  the data segments has changed, or
  1738.          the allocation sequence is different,  there is no way for
  1739.          DMalloc to detect when saved pointers are allocated, since
  1740.          they may be located somewhere else.
  1741.  
  1742.    --------------------
  1743.    13 The  similar _memmax()  function reports on  the near
  1744.       heap only. DMalloc reports on both near and far heap.
  1745.    14 The total size of free memory may vary from the maxi-
  1746.       mum size, depending on the respective environment.
  1747.    15 For example, for the TEST.EXE program,  DMalloc would
  1748.       create a TEST.DMC configuration file.
  1749.  
  1750.  Page 30                                                         DMalloc
  1751. ------------------------------------------------------------------------
  1752.  
  1753.  
  1754. 6. How to use DMalloc for Debugging
  1755.  
  1756.       There  are  different levels  of  integration  to the  debugged
  1757.       program. You may simply link DMalloc to the program,  recompile
  1758.       some  source, or  even call  the  DMalloc API  from within  the
  1759.       program.
  1760.  
  1761.       6.1. Linking DMalloc to the Program
  1762.          This is the  most simple way to integrate  DMalloc. Relink
  1763.          the program with an additional object, DMALLOC.OBJ. You do
  1764.          not need to specify the  DMALLOC.LIB library to the linker
  1765.          as  long as  it can  be  found in  one of  the directories
  1766.          specified in the LIB environment variable.
  1767.          This will integrate the whole DMalloc functionality except
  1768.          that DMalloc cannot know where units are allocated.
  1769.  
  1770.       6.2. Recompiling
  1771.          If you  want  to know  which source  file allocated  which
  1772.          units, you  may recompile  those  source files  where  the
  1773.          malloc functions are called.
  1774.  
  1775.          First, define the _DMALLOC switch. You may either add
  1776.  
  1777.             -D_DMALLOC
  1778.  
  1779.          to the  compiler directive  in the make  file, or  add the
  1780.          line
  1781.  
  1782.             #define _DMALLOC
  1783.  
  1784.          to the source file.
  1785.  
  1786.          Next, include  DMALLOC.H into  the  source by  adding  the
  1787.          following line to the source file:
  1788.             #include <DMALLOC.H>
  1789.  
  1790.          Third,  recompile  the source,  and  link  the program  as
  1791.          specified above.  You still need DMALLOC.OBJ  to be linked
  1792.          to the program.
  1793.  
  1794.          Note: The switch _DMALLOC  needs to be  defined before
  1795.                DMALLOC.H is included.
  1796.  
  1797.       6.3. Calling the DMalloc API
  1798.          DMalloc provides API functions that can be called from the
  1799.          program  (see section 7).  The API functions  allow to let
  1800.          DMalloc  check the  heap,  popup  DMalloc, temporarily  or
  1801.          permanently   modify  the   setup,   set  watchpoints   or
  1802.          savepoints on pointers, generate debugger breakpoints, and
  1803.          to disable or enable DMalloc for special purposes.  Please
  1804.          see the API reference for detailed discussion.
  1805.  
  1806.  Page 31                                                         DMalloc
  1807. ------------------------------------------------------------------------
  1808.  
  1809.  
  1810.       6.4. DMalloc and Spawn
  1811.          All exec.. functions and the system() function can be used
  1812.          together  with DMalloc. Dmalloc  will automatically detect
  1813.          when another process  is being executed,  and disable  it-
  1814.          self.
  1815.  
  1816.       6.5. DMalloc and Video
  1817.          DMalloc is compatible with the RLSI  (Relocated Screen In-
  1818.          terface) specification. If you have installed a DOS memory
  1819.          manager  (e.g. DesqView, or Memory Commander),  that relo-
  1820.          cates the video buffer, DMalloc will work as well.
  1821.          Note: Your program needs to rely on RLSI as well,  if it's
  1822.                accessing the video buffer, since the RLSI host will
  1823.                not trap video buffer accesses after  RLSI has  been
  1824.                initialized.
  1825.  
  1826.       6.5.1. Calling RLSI
  1827.          RLSI is called via interrupt 10h (video interrupt):
  1828.  
  1829.             union  REGS  regs;
  1830.             struct SREGS sregs;
  1831.  
  1832.             regs.x.ax  = 0xFE00;     // RLSI function code
  1833.             regs.x.di  = ofsVPage;   // video page offset, usually 0
  1834.             sregs.es   = segVBuffer; // video buffer, usually B800 or B000
  1835.             int86x(0x10, ®s, ®s, &sregs);
  1836.  
  1837.             ofsVPage   = regs.x.di;  // get the RLSI values
  1838.             segVBuffer = sregs.es;
  1839.  
  1840.       6.6. DMalloc and Debuggers
  1841.          DMalloc allows to set debugger breakpoints. Whenever DMal-
  1842.          loc  pops up (except [PrtSc] has been pressed) you may di-
  1843.          rect it to  set a debugger breakpoint (see section 5.3.2).
  1844.          The debugger will receive control at the statement immedi-
  1845.          ately following the call to the malloc function  (i.e. in
  1846.          your  code  instead of  code belonging to  the runtime li-
  1847.          brary, or DMalloc).
  1848.  
  1849.       6.6.1. Soft-ICE 
  1850.          Soft-ICE  is a  resident protected-mode debugger  from Nu-
  1851.          Mega  Technologies, Inc. It can be used to debug operating
  1852.          system code,  high frquent  interrupt code, TSR  programs,
  1853.          and much more.
  1854.          Soft-ICE  breakpoints  are  sticky.  When   Soft-ICE  gets
  1855.          control you will see a message like this:
  1856.  
  1857.             Breakpoint generated by DMalloc (remove with BC 0)
  1858.  
  1859.          If you  do not  clear that breakpoint,  Soft-ICE will
  1860.          always pop up at the very same location.
  1861.          Note: It  will do  no  harm trying  to set  a Soft-ICE
  1862.                breakpoint without having Soft-ICE loaded.
  1863.  
  1864.  Page 32                                                         DMalloc
  1865. ------------------------------------------------------------------------
  1866.  
  1867.  
  1868.       6.6.2. CodeView 
  1869.          Contrary  to a  Soft-ICE breakpoint,  CodeView breakpoints
  1870.          are not sticky. CodeView will get control at the statement
  1871.          after the  malloc function  call, but no  permanent break-
  1872.          point will be set.
  1873.  
  1874.       6.6.3. Other Debuggers
  1875.          Every  debugger will  get  control when  interrupt 03h  is
  1876.          executed.  DMalloc provides  that  unspecific  method  for
  1877.          other debuggers.
  1878.          Note: CodeView will  also get control at  this type of
  1879.                breakpoint, Soft-ICE will not by default.
  1880.  
  1881.       6.7. DMalloc and Bounds-Checker 
  1882.          Bounds-Checker is  a 386-based utility  to detect  out-of-
  1883.          bounds  memory accesses  while running  a DOS  program. It
  1884.          gives  the same type  of memory protection  as a protected
  1885.          mode  operating system.  DMalloc  and  Bounds-Checker  are
  1886.          ideal  companions. You  can use  Bounds-Checker  to verify
  1887.          segment-based integrity,  and  DMalloc to  assure the  in-
  1888.          tegrity of the heap contents.
  1889.          Bounds-Checker can  be directed to allow  access to memory
  1890.          locations that  are protected by default(16) by specifying
  1891.          exceptions  in an  exception file. Since  DMalloc accesses
  1892.          some restricted locations,  Bounds-Checker must know about
  1893.          it or  it would  complain. An exception  file for  Bounds-
  1894.          Checker  comes  with  the  DMalloc  package  (DMALLOC.BC).
  1895.          Simply copy  the contents of  this file to  your exception
  1896.          file, and Bounds-Checker will accept the liberties DMalloc
  1897.          takes.
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.    --------------------
  1916.    16 Typical candidates for exceptions are the code segment
  1917.       for  routines  written  in assembler,  the  Bios area
  1918.       beginning  at segment  40h, or  the  video buffer  at
  1919.       B000h and B800h.
  1920.  
  1921.  
  1922.  Page 33                                                         DMalloc
  1923. ------------------------------------------------------------------------
  1924.  
  1925.  
  1926. 7. Programming API
  1927.  
  1928.  
  1929.       The DMalloc  API functions  are defined  and prototyped  in the
  1930.       DMALLOC.H include file. If the  _DMALLOC switch is defined  the
  1931.       functions will be accessed. If the _DMALLOC switch is undefined
  1932.       the functions are defined  as "empty statements" so the  source
  1933.       file will compile without errors.
  1934.  
  1935.  
  1936.       7.1. Removing DMalloc API Calls
  1937.          Even without  recompiling you can  remove DMalloc  code from
  1938.          the  program  by  replacing  the  DMALLOC.LIB  library  with
  1939.          DMCNONE.LIB. This library provides  dummy  entries  for  all
  1940.          functions, and reroutes the DMalloc malloc function calls to
  1941.          the runtime library.
  1942.  
  1943.  
  1944.  
  1945.       void pascal DML_Trigger (void)
  1946.          Purpose:    Directs DMalloc to pop up.
  1947.          Parameters: none
  1948.          Return:     void
  1949.          Remarks:    Actually this is a macro calling
  1950.                            DM_Trigger$(__FILE__, __LINE__).
  1951.  
  1952.  
  1953.  
  1954.       void pascal DML_Check (void)
  1955.          Purpose:    Directs DMalloc  to check the heap. DMalloc will
  1956.                      pop up if a problem is found unless supressed in
  1957.                      the setup (see section 5.4.1).
  1958.          Parameters: none
  1959.          Return:     void
  1960.  
  1961.  Page 34                                                         DMalloc
  1962. ------------------------------------------------------------------------
  1963.  
  1964.       void  pascal DML_Setup  (fAlert, fSaved,  usPopCycles,
  1965.                                usCheckCycles, pszOwner, usLine)
  1966.          Purpose:    Modifies  switches  from the  Setup  Window (see
  1967.                      section 5.4).
  1968.          Parameters: unsigned fAlert        SET_ON         "Yes"
  1969.                                             SET_OFF        "No"
  1970.                                             SET_UNCHANGED  keep current value
  1971.                      unsigned fSaved        SET_CORRUPTED  "Corrupted"
  1972.                                             SET_SAVED      "Saved"
  1973.                                             SET_BOTH       "Both"
  1974.                                             SET_OFF        "No"
  1975.                                             SET_UNCHANGED  keep current value
  1976.                      unsigned usPopCycles   lets  DMalloc   pop  up
  1977.                                             regularly   after  this
  1978.                                             number  of  calls  have
  1979.                                             been done
  1980.                      unsigned usCheckCycles lets DMalloc check  the
  1981.                                             heap after  this number
  1982.                                             of calls have been done
  1983.                      char *pszOwner         lets DMalloc pop up whenever
  1984.                                             this  file calls  the malloc
  1985.                                             functions.
  1986.                                             Specify PSZ_UNCHANGED to
  1987.                                             keep the current value
  1988.                      unsigned usLine        narrows  popup   for  a
  1989.                                             source  file  to   this
  1990.                                             source line
  1991.                                             Specify SET_UNCHANGED to
  1992.                                             keep the current value
  1993.          Return:     void
  1994.  
  1995.  
  1996.  
  1997.       void  pascal DML_Select (fMalloc, fMarked, fNull, fData,
  1998.                                fSystem, pszOwner, usLine)
  1999.          Purpose:    modifies switches from the Selection Window (see
  2000.                      section 5.7). For the logical switches you may
  2001.                      specify either SET_ON, SET_OFF, or SET_UNCHANGED.
  2002.          Parameters: unsigned fMalloc       show allocated units
  2003.                      unsigned fMarked       show only tagged units
  2004.                      unsigned fNull         show both NULL segment entries
  2005.                      unsigned fData         show the data segment entries
  2006.                      unsigned fSystem       show the system entries
  2007.                      unsigned pszOwner      show only entries owned
  2008.                                             by that source file
  2009.                                             Specify PSZ_UNCHANGED to
  2010.                                             keep the current value
  2011.                      unsigned usLine        narrows the source file
  2012.                                             range to this source line
  2013.                                             Specify SET_UNCHANGED to
  2014.                                             keep the current value
  2015.          Return:     void
  2016.  
  2017.  
  2018.  Page 35                                                         DMalloc
  2019. ------------------------------------------------------------------------
  2020.  
  2021.  
  2022.       void pascal DML_SaveState (pSaveBuffer)
  2023.          Purpose:    Save the current DMalloc state to a save buffer.
  2024.          Parameters: void *pSaveBuffer      Pointer to the buffer
  2025.                                             where DMalloc should save
  2026.                                             its setup.
  2027.          Return:     void
  2028.          Remarks:    The setup  contains all switch settings from the
  2029.                      Setup Window, the Selection Window, and the
  2030.                      Colors Window.
  2031.                      You  may use the handy DML_SAVEAREA macro to
  2032.                      define a local (or global) variable. If you are
  2033.                      allocating a save buffer be sure to provide at
  2034.                      least DML_SAVESIZE bytes.
  2035.  
  2036.  
  2037.       void pascal DML_RestoreState (pSaveBuffer)
  2038.          Purpose:    Restore a previously saved DMalloc state.
  2039.          Parameters: void *pSaveBuffer      Pointer to the
  2040.                                             buffer where DMalloc
  2041.                                             saved its setup.
  2042.          Return:     void
  2043.          Remarks:    The setup contains all switch settings  from the
  2044.                      Setup  Window,  the  Selection Window,  and  the
  2045.                      Colors Window.
  2046.                      You  may use  the  handy  DML_SAVEAREA macro  to
  2047.                      define a local (or  global) variable. If you are
  2048.                      allocating a  save buffer be sure  to provide at
  2049.                      least DML_SAVESIZE bytes.
  2050.                      There is no error correction. You must not use a
  2051.                      buffer that  has not  been previously  filled by
  2052.                      the DML_SaveState() function.
  2053.  
  2054.  
  2055.  Page 36                                                         DMalloc
  2056. ------------------------------------------------------------------------
  2057.  
  2058.       unsigned pascal DML_Watchpoint (pUnit, fOnOff)
  2059.          Purpose:    Set or clear a Watchpoint
  2060.          Parameters: void *pUnit            Pointer to an allocated
  2061.                                             unit. You  may  specify
  2062.                                             FAR_NULLCHECK or
  2063.                                             DATA_NULLCHECK  to
  2064.                                             en- or disable Null
  2065.                                             pointer  assignment
  2066.                                             checks
  2067.                      unsigned fOnOff        SET_ON to switch
  2068.                                             Watchpoint on
  2069.                                             SET_OFF to switch
  2070.                                             Watchpoint off
  2071.                                             SET_UNCHANGED to keep it.
  2072.          Return:     A nonzero value  indicates that  the Watchpoint
  2073.                      has been set or cleared.
  2074.                      A zero  value indicates that  the pointer passed
  2075.                      to that function could not be found in DMalloc's
  2076.                      tag table. Specifying SET_UNCHANGED may  be used
  2077.                      to verify  if the pointer has  been allocated by
  2078.                      the malloc functions.
  2079.          Remarks:    without the  _DMALLOC switch  defined, this
  2080.                      function will always return nonzero.
  2081.  
  2082.  
  2083.       unsigned pascal DML_Savepoint (pUnit, fOnOff)
  2084.          Purpose:    Set or clear a Savepoint
  2085.          Parameters: void *pUnit             Pointer to an allocated unit.
  2086.                      unsigned fOnOff         SET_ON to switch
  2087.                                              Savepoint on
  2088.                                              SET_OFF to switch
  2089.                                              Savepoint off
  2090.                                              SET_UNCHANGED to keep it.
  2091.          Return:     A nonzero value indicates that the Savepoint has
  2092.                      been set or cleared.
  2093.                      A zero  value indicates that the  pointer passed
  2094.                      to that function could not be found in DMalloc's
  2095.                      tag table. Specifying  SET_UNCHANGED may be used
  2096.                      to verify  if the pointer has  been allocated by
  2097.                      the malloc functions.
  2098.          Remarks:    without the  _DMALLOC switch  defined, this
  2099.                      function will always return nonzero.
  2100.  
  2101.  
  2102.       void pascal DML_Breakpoint (fType)
  2103.          Purpose:    Trigger a debugger breakpoint
  2104.          Parameters: unsigned fType          BPT_SOFTICE to set a
  2105.                                              Soft-ICE breakpoint,
  2106.                                              BPT_CODEVIEW for a
  2107.                                              CodeView
  2108.                                              BPT_INT3 for a generic
  2109.                                              Int03 breakpoint.
  2110.          Return:     void
  2111.          Remarks:    The debugger will  get control at the  statement
  2112.                      following the call to DML_Breakpoint().
  2113.  
  2114.  Page 37                                                         DMalloc
  2115. ------------------------------------------------------------------------
  2116.  
  2117.  
  2118.       void pascal DML_Disable (void)
  2119.          Purpose:    Completely disables DMalloc
  2120.          Parameters: none
  2121.          Return:     void
  2122.          Remarks:    Normally this function needs  not to be  called.
  2123.                      It  completely disables  DMalloc, and  after re-
  2124.                      enabling it,  any memory  unit allocated  in the
  2125.                      meantime will  show up as  MAVERICK error, since
  2126.                      DMalloc   didn't   know  about   it.   Disabling
  2127.                      increments a  counter.  You  need  to  call  the
  2128.                      enable function as often  as you have called the
  2129.                      disable function.
  2130.  
  2131.  
  2132.       void pascal DML_Enable (void)
  2133.          Purpose:    Enables DMalloc after disabling
  2134.          Parameters: none
  2135.          Return:     void
  2136.          Remarks:    Enable DMalloc.  Since DMalloc is enabled at the
  2137.                      beginning, this function is only necessary after
  2138.                      calling DML_Disable.
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  Page 38                                                         DMalloc
  2144. ------------------------------------------------------------------------
  2145.  
  2146.  
  2147. 8. Problem Solving
  2148.  
  2149.       Q: When I'm pressing the [PrtSc] key, DMalloc doesn't pop
  2150.          up, but something else happens.
  2151.       A: Three reasons are possible:
  2152.          -  Your keyboard doesn't have a sole [PrtSc] key.  Try
  2153.             the [Shift]+[PrtSc] keys together.
  2154.          -  Your  program  redirected   interrupt  05h  (the
  2155.             print-screen interrupt) for its own use. If this
  2156.             is  the case,  you  cannot  interactively  popup
  2157.             DMalloc.  DMallocs  heap  checker  functionality
  2158.             will  still be kept, and it will pop up whenever
  2159.             necessary.
  2160.             You  may force  DMalloc to  pop up  regularly by
  2161.             selecting a  popup cycle count in the setup win-
  2162.             dow (see section 5.4.3).
  2163.          -  Some  resident  program is  repeatedly  changing
  2164.             interrupt 05h ([PrtSc] interrupt).Known programs
  2165.             are Pizzaz Plus, and HiJaak. Either unload these
  2166.             programs,  or  modify their  setup,  if possible
  2167.             (e.g. HiJaak can be set to "semi-active").
  2168.  
  2169.       Q: When  I start  the program,  DMalloc doesn't  come up
  2170.          with the Setup Window.
  2171.       A: In the Setup  Window, you have specified "No"  at the
  2172.          "Startup  Screen" entry. Either change this to "Yes",
  2173.          or simply delete  the configuration  file to  restore
  2174.          the default setup.
  2175.  
  2176.       Q: Whenever I  run the program, DMalloc  repeatedly pops
  2177.          up and shows an overwrite to the FARNULL region.
  2178.       A: Some resident program  is repeatedly changing  inter-
  2179.          rupts that  have been routed to  your program. Inter-
  2180.          rupts used by the C runtime library and DMalloc are:
  2181.             Int 00h - division by zero (runtime library)
  2182.             Int 05h - print screen handler (DMalloc)
  2183.             Int 16h - keyboard interrupt (DMalloc)
  2184.             Int 21h - DOS OS entry (DMalloc)
  2185.             Int 23h - Ctrl-C and Ctrl-Break handler (runtime
  2186.                       library and DMalloc)
  2187.          Some  resident programs  hook  one or  more of  these
  2188.          interrupts,  and, using  the  timer tick,  repeatedly
  2189.          reset them,  bypassing  the  operating  system. Known
  2190.          examples are Pizzaz Plus and HiJaak.
  2191.          Having  loaded  these  programs,  untag  the  topmost 
  2192.          (FARNULL) entry in the Heap Window. This will disable
  2193.          checking of the FARNULL region.
  2194.  
  2195.  Page 39                                                         DMalloc
  2196. ------------------------------------------------------------------------
  2197.  
  2198.  
  2199.       Q: After  an   unrecoverable  heap  failure,   the  con-
  2200.          figuration   file  doesn't   contain  the   corrupted
  2201.          pointers, only those I specified to "Save".
  2202.       A: This  is  perfectly  normal.  Usually,  when  an  un-
  2203.          recoverable  heap  error  is  encountered,  you  will
  2204.          notice a  lot of different problems  like overwritten
  2205.          pointers,  and Maverick  entries. To  avoid confusion
  2206.          during the next session, DMalloc  skips the corrupted
  2207.          pointers in that case, and only saves those specified
  2208.          for "Save".
  2209.  
  2210.       Q: The  manual  states that  the configuration file name
  2211.          would be the  same as  the program  name. Why is mine
  2212.          named "_DMALLOC.DMC" ?
  2213.       A: DMalloc  uses the environment information to retrieve
  2214.          the  program name.  If either  your operating  system
  2215.          doesn't provide this information (DOS <3.0), or  your
  2216.          program releases the  environment for memory's  sake,
  2217.          DMalloc uses this name as a last resort.
  2218.  
  2219.       Q: I had corrupted pointers,  but DMalloc didn't  remind
  2220.          me on the next session, even with the correct setup.
  2221.       A: To  have this  feature work  reliable, there  are two
  2222.          things that must be kept in mind:
  2223.          -  The  environment   settings,  and   the  program
  2224.             parameters,  should be the same. This is because
  2225.             the MSC startup  code allocates some memory  for
  2226.             these values,  and if  the sizes of  these units
  2227.             differ,  so may the  location of successivly al-
  2228.             located units.
  2229.          -  The size of the data segments should not change.
  2230.             If  you have  recompiled with  somewhat modified
  2231.             code, this feature is most likely to fail.
  2232.          -  It is absolutely necessary to do the same things
  2233.             you did in the last session, and in the same se-
  2234.             quence. If you're  calling the malloc  functions
  2235.             in   different   order,    or   with   different
  2236.             parameters, the layout of the dynamic heap  will
  2237.             be  different, and  the  pointers  will be  dif-
  2238.             ferent, too.
  2239.  
  2240.       Q: I  want  to  have   NULLCHECK  enabled,  but  DMalloc
  2241.          wouldn't let me tag the _DATA segment entry.
  2242.       A: It is  possible to  disable the runtime  library NULL
  2243.          check.  If   you  provide   a  module  containing   a
  2244.          "_nullcheck()" routine at link time, the  linker will
  2245.          take this module instead  of that the runtime library
  2246.          provides.  Your  _nullcheck()  function  must  return
  2247.          (int)0.
  2248.  
  2249.  Page 40                                                         DMalloc
  2250. ------------------------------------------------------------------------
  2251.  
  2252.  
  2253.          In that case  the linker will not link  the NULL seg-
  2254.          ment that normally makes up the first 4 paragraphs of
  2255.          the data segment. As the contents of these paragraphs
  2256.          are  data  of  your  program and  no  constant  value
  2257.          anymore,  Null  Pointer   assignments  are  perfectly
  2258.          valid. DMalloc is aware  of this, and will  not allow
  2259.          to do Nullcheck on a non-constant data segment.
  2260.  
  2261.       Q: I am  using Bounds-Checker , and so far my code seems
  2262.          to be clean. Now, having linked my program with DMal-
  2263.          loc,   Bounds-Checker   permanently   pops   up   and
  2264.          complains.
  2265.       A: You need to tell Bounds-Checker the exceptions needed
  2266.          for DMalloc. Copy the contents of the DMALLOC.BC file
  2267.          from the DMalloc original  diskette to your exception
  2268.          file, and Bounds-Checker should not complain any more.
  2269.  
  2270.       Q: Under DesqView,  my program used to work. Now, having
  2271.          linked with DMalloc,  I can see DMalloc's output, but
  2272.          my program's windows are gone!
  2273.       A: DMalloc uses the  RLSI (Relocatable Screen Interface)
  2274.          specification  for  direct  video access.  So if your
  2275.          program writes to the screen buffer directly, an RLSI
  2276.          host  (as DV)  would normally trap  and relocate your
  2277.          memory access -- your program is slower.  Using RLSI,
  2278.          you'll get  the actual address  of your video buffer.
  2279.          Alas,  after  RLSI  has  initialized,  the "standard"
  2280.          video  accesses  are not trapped anymore.  Thus, your
  2281.          program writes to "nowhere".
  2282.          Refer to section 6.5.1 on how to call the RLSI host.
  2283.  
  2284.  
  2285.  Page 41                                                         DMalloc
  2286. ------------------------------------------------------------------------
  2287.  
  2288. Appendix A - The Legal Department (License Agreement)
  2289.  
  2290.    Shareware  distribution gives  users a  chance to  try software
  2291.    before buying it. If you  try a shareware program  and continue
  2292.    using it, you are expected to register. Individual programs may
  2293.    differ  on details  -  some request  registration while  others
  2294.    require it,  some specify a maximum  trial period. Registration
  2295.    often entitles the user  for updates, printed documentation, or
  2296.    other "perks".
  2297.  
  2298.    Copyright laws apply to both shareware and commercial software,
  2299.    and  the  copyright  holder may  retain  all  rights.  The only
  2300.    meaningful difference between shareware and commercial software
  2301.    is in the method of distribution. Shareware authors specifical-
  2302.    ly grant the  rights to copy  and distribute the software/docu-
  2303.    mentation,  either to all and sundry, or with specific restric-
  2304.    tions.
  2305.  
  2306.    You should  find software  that suits your  needs and  bank ac-
  2307.    count, whether  it's commercial  or shareware. Both  types have
  2308.    good programs and  bad, but shareware  makes finding the  right
  2309.    program  easier, because  you  can try  before  you buy.  Also,
  2310.    because distribution overhead  is much lower, shareware  prices
  2311.    are often lower, too. Finally, shareware has the ultimate money
  2312.    back guarantee - if you don't use it, you don't pay for it.
  2313.  
  2314.    For this  agreement, the term  "DMalloc" refers to  the DMalloc
  2315.    library  and  include  file  (DMALLOC.EXE and  DMALLOC.H),  the
  2316.    demonstration  program  (DEMO.BAT, DEMO.TXT,  and  DMLDEMO.EXE)
  2317.    together with its accompanying documentation (DMALOC09.DOC).
  2318.  
  2319.                             A G R E E M E N T
  2320.                             *****************
  2321.  
  2322.    DMALLOC IS "SHAREWARE" AND IS LICENSED AT NO CHARGE TO THE USER
  2323.    FOR EVALUATION. FEEL  FREE TO SHARE IT,  BUT YOU MAY  NOT ALTER
  2324.    THE PROGRAM OR  DOCUMENTATION NOR  INCLUDE DMALLOC  AS PART  OF
  2325.    ANOTHER SYSTEM. IF YOU FIND THIS LIBRARY USEFUL AND CONTINUE TO
  2326.    USE  DMALLOC AFTER  A  30 DAY  TRIAL  PERIOD, YOU  MUST MAKE  A
  2327.    REGISTRATION  PAYMENT TO  ERNEST VOGELSINGER.  THE REGISTRATION
  2328.    FEE WILL  LICENSE ONE COPY FOR  USE ON ONE COMPUTER  AT ANY ONE
  2329.    TIME.
  2330.  
  2331.    FOR  COMMERCIAL USERS  OF DMALLOC,  AND FOR  THOSE WHO  WANT TO
  2332.    INCLUDE DMALLOC  WITHIN A BETA-VERSION  OF A PROGRAM,  VERY AT-
  2333.    TRACTIVE  SITE-LICENSE AGREEMENTS  MAY  BE OBTAINED  BY  ERNEST
  2334.    VOGELSINGER.
  2335.  
  2336.    ANYONE DISTRIBUTING  DMALLOC FOR REMUNERATION OF  ANY SORT MUST
  2337.    FIRST  OBTAIN  AUTHORIZATION   FROM  ERNEST  VOGELSINGER.  SUCH
  2338.    AUTHORIZATION WILL  AUTOMATICALLY  BE GRANTED  TO  DISTRIBUTORS
  2339.    RECOGNIZED  BY  THE (ASP)  AS  ADHERING TO  ITS  GUIDELINES FOR
  2340.    SHAREWARE  DISTRIBUTORS, AND  SUCH  DISTRIBUTORS MAY  BEGIN OF-
  2341.    FERING DMALLOC IMMEDIATELY. IN  EITHER CASE, ERNEST VOGELSINGER
  2342.    MUST BE ADVISED.
  2343.  Page 42                                                         DMalloc
  2344. ------------------------------------------------------------------------
  2345.  
  2346.  
  2347.    You are  encouraged to pass a copy of the DMalloc library, demo
  2348.    program, and documentation along to your friends and colleagues
  2349.    for  evaluation. Please  encourage  them to  register too.  All
  2350.    registered  users receive  the many  benefits decribed  in sec-
  2351.    tion 1.7.
  2352.  
  2353.  Page 43                                                         DMalloc
  2354. ------------------------------------------------------------------------
  2355.  
  2356.  
  2357. Appendix B - How to Send Email to Compuserve
  2358.  
  2359.       The following information was put together by CompuServe's
  2360.       Feedback team in a response time  of less than 12 hours to
  2361.       my inquiry. A very big thanks to all those  people doing a
  2362.       wonderful job!
  2363.  
  2364.       B.1 How to obtain a CompuServe Account
  2365.          DMalloc is also supported via CompuServe,  either  on  the
  2366.          ZNT:PROGRAMMING  forum  (ZiffNet is  part  of CompuServe),
  2367.          Toolkits(7) section, or via CompuServe MAIL(17). If you do
  2368.          not have a CompuServe,  or PC Magnet, account, and want to
  2369.          obtain one, please contact
  2370.  
  2371.             CompuServe Customer Service
  2372.                   800-848-8990
  2373.                or 614-457-8650
  2374.  
  2375.          You may use  your modem to call PC MagNet  via CompuServe.
  2376.          Dial 800-346-3247.  When the  modem connects:
  2377.  
  2378.             -  at the HOST NAME prompt, enter PHONES.
  2379.             
  2380.          Follow  the menus and note the number closest to you.
  2381.  
  2382.          Set  your communications  software to  300, 1200,  or 2400
  2383.          bits per second, 7 data bits, 1 stop bit, and full duplex.
  2384.          Dial  the  local number.  When  the  modem connects:
  2385.  
  2386.             -  type ^C.
  2387.             -  At the HOST NAME prompt, enter CIS.
  2388.             -  At the USER ID prompt, enter  177000,5000.
  2389.             -  At the PASSWORD prompt, enter PC*MAGNET.
  2390.             -  At the ENTER AGGREEMENT NUMBER prompt, type PCMAG92.
  2391.  
  2392.          Register  your name  and enter  your MasterCard,  Visa, or
  2393.          American Express number. (If you want to have your company
  2394.          billed instead, call CompuServe at 800-848-8900).
  2395.          Your  personal User  Id and a  temporary password  will be
  2396.          displayed. A new password  will arrive in the mail  within
  2397.          10 days to confirm your subscription.
  2398.  
  2399.          To send email, type GO  MAIL at any CompuServe "!" prompt.
  2400.          Follow  the instructions from  CompuServe. If  you want to
  2401.          register DMalloc, send a note to  100015,551, stating your
  2402.          will to register, your Visa number, and that you agree  to
  2403.          pay with your Visa account.
  2404.  
  2405.          If you have an account on a different network it is likely
  2406.          that you  are able to  send email to CompuServe.  For some
  2407.          systems here's how to send email to CompuServe:
  2408.  
  2409.  
  2410.    --------------------
  2411.    17 Former "Easyplex"
  2412.  
  2413.  Page 44                                                         DMalloc
  2414. ------------------------------------------------------------------------
  2415.  
  2416.  
  2417.       B.2 MCI
  2418.          At  MCI Mail's  "Command:"  prompt,  type CREATE  and
  2419.          press the [Enter] key.
  2420.  
  2421.          At the "TO:" prompt, type my name, press [Space], type EMS
  2422.          within parenthesis and press the [Enter] key.
  2423.  
  2424.          For example:
  2425.             TO:   Ernest Vogelsinger (EMS) 
  2426.  
  2427.          At the "EMS:" prompt, type COMPUSERVE and press the [Enter]
  2428.          key.
  2429.  
  2430.          For example:
  2431.             EMS:  COMPUSERVE 
  2432.  
  2433.          MCI Mail responds by displaying
  2434.             EMS   281-6320 COMPUSERVE.
  2435.  
  2436.          At the "MBX:" prompt, type my CompuServe User ID number and
  2437.          press [Enter] :
  2438.             MBX:  100015,551 
  2439.  
  2440.          At the second "MBX:" prompt, press [Enter].
  2441.  
  2442.          The information  that you  have entered is  displayed
  2443.          for your approval. You should type YES if correct  or
  2444.          type NO if there is an error and press [Enter].
  2445.  
  2446.          For example:
  2447.             TO:   Ernest Vogelsinger
  2448.             EMS:  COMPUSERVE/ MCI ID: 281-6320
  2449.             MBX:  100015,551
  2450.  
  2451.             Is this address correct (Yes or No)?   YES 
  2452.  
  2453.          At the next  two prompts, "TO:"  and "CC:",  press
  2454.          to skip them.
  2455.  
  2456.          Now  type your message  and send  it as any  MCI Mail
  2457.          message. When unsure as to  what to enter at any  MCI
  2458.          Mail  prompt,  typing  a "?" and pressing the [Enter]
  2459.          key will display an explanation of available options.
  2460.  
  2461.  
  2462.  Page 45                                                         DMalloc
  2463. ------------------------------------------------------------------------
  2464.  
  2465.       B.3 Internet
  2466.          Internet   is  an   electronic   mail  system   connecting
  2467.          governmental institutions,  military branches, educational
  2468.          institutions,  and commercial  companies. Only  ASCII text
  2469.          messages up to 50,000 characters can be sent  through this
  2470.          system.
  2471.  
  2472.          Internet is  a connection of various  systems. The message
  2473.          format will vary from one system to another. Check at your
  2474.          mail location for the correct format.
  2475.          Two things that must be known:
  2476.             My User Id is 100015.551 (note that the comma changes
  2477.                                       to a period on Internet)
  2478.             The CompuServe domain address is "compuserve.com".
  2479.  
  2480.          An  typical example  of  the format  used on  the Internet
  2481.          system is:
  2482.  
  2483.             INTERNET: 100015.551@compuserve.com
  2484.  
  2485.          The format  will vary, but  the essential elements  of the
  2486.          address will stay the same.
  2487.  
  2488.       B.4 Telex, Twx
  2489.          CompuServe Mail allows to  receive messages from any TELEX
  2490.          or TWX machine in the world.
  2491.          The information the TELEX user  needs to send a message to
  2492.          a CompuServe electronic mailbox is:
  2493.  
  2494.             The User Id (100015,551)
  2495.             The machine number to send the message to:
  2496.                3762848 (which has the answerback of CompuServe)
  2497.  
  2498.          Specify  on  the first  non-blank line  of the  message a
  2499.          "TO:" followed  by the User  ID to inform  CompuServe Mail
  2500.          where to  deliver the message.   If a subject  is desired,
  2501.          you  also can  add an  "RE:" after the  "TO:" line  in the
  2502.          message.
  2503.  
  2504.          The format would look as follows:
  2505.             TO:  100015,551            (This is required)
  2506.                  CompuServe Inc.       (This is optional)
  2507.             RE:  DMalloc Registration  (This is optional)
  2508.  
  2509.             Note: If you are using another electronic mail service
  2510.                   to generate  a TELEX  to be sent  to CompuServe,
  2511.                   you need to first verify you can place the "TO:"
  2512.                   information on  the first non-blank line  of the
  2513.                   message.    Some    electronic   mail    systems
  2514.                   automatically  insert other  information at  the
  2515.                   top  of an  outbound TELEX making  it impossible
  2516.                   for  CompuServe Mail  to  determine the  correct
  2517.                   address.
  2518.                   EasyLink is  an  electronic mail  service from  which
  2519.                   CompuServe cannot currently receive inbound TELEXes.
  2520.  Page 46                                                         DMalloc
  2521. ------------------------------------------------------------------------
  2522.  
  2523.  
  2524.       B.5 X.400
  2525.          The address that you should specify to a mail system which
  2526.          can route  messages to CompuServe via  an X.400 connection
  2527.          is:
  2528.             Country = US
  2529.             ADMD    = CompuServe
  2530.             PRMD    = CSMail
  2531.             DDA     = 100015.551 (note the period instead the comma)
  2532.  
  2533.          On AT&T Mail, for example, you could specify
  2534.             To:  mhs/c=us/ad=compuserve/pd=csmail/d.id=100015.551
  2535.  
  2536.          AT&T  has  defined a  gateway  named  mhs!csmail that  may
  2537.          replace the c=, ad=, and pd= information. On AT&T, you could
  2538.          also specify
  2539.             To:  mhs!csmail!100015.551
  2540.  
  2541.          Note: Again, the User Id must contain a period instead of a comma.
  2542.  
  2543.  
  2544.       B.6 MHS
  2545.          You  can send  MHS messages  to the  CompuServe Mail  Hub.
  2546.          Specify the message adressee as
  2547.             MAIL@CSERVE {100015,551}
  2548.  
  2549.          Note: Some  MHS applications  do  not have  a specific
  2550.                procedure  for  entering   the  foreign  address
  2551.                field. If you are unsure of the foreign  address
  2552.                field capabilities of  the MHS application, con-
  2553.                sult the  documentation or call the producers of
  2554.                the  software to see  if their  package supports
  2555.                foreign address fields.
  2556.  
  2557.          If an MHS  application does not  specifically support  the
  2558.          foreign address field, there may still be a way to address
  2559.          a message to a non-MHS address. In the space where the MHS
  2560.          address is normally entered, you  may be able to enter the
  2561.          foreign address  field. The foreign address  field must be
  2562.          enclosed in braces.
  2563.          For example, at the TO: or CC: prompt enter:
  2564.             MAIL@CSERVE {100015,551}
  2565.  
  2566.  
  2567.