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