home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / funkybox.zip / DISKMOD.DOC < prev    next >
Text File  |  1983-05-02  |  7KB  |  133 lines

  1.  
  2.  
  3.  
  4. ***************************************************************
  5.  
  6.     WELCOME TO DISK MODIFICATION WITH DEBUG -- A TUTORIAL
  7.                -- UNERASING A SMALL FILE --
  8.  
  9. ***************************************************************
  10.  
  11.                PEOPLE SYSTEMS,LTD. (C) 1983
  12.  
  13. IF YOU'VE GOT THE TIME ---- WE'VE GOT DE-BUG --- or so the jingle goes.
  14. The whole subject of DEBUG could fill a full disk and then some. Some
  15. folks have gotten into dumping the contents of memory, (even the ROM)
  16. and probably have tried to make a fix or two on their programs. But the
  17. subject is complex and the more you do the better you get.
  18.  
  19. In SAVEDLIN.TBX we discuss running EDLIN in the DEBUG environment to
  20. keep from losing our files IF we get a DISK FULL report. There is 
  21. also another technique which is worth getting familiar with and that is
  22. recovering a small file (<512 bytes) which was just erased in error.
  23.    
  24. The disk must not have been tampered with or SAVEd over since the 
  25. erasure. In fact, this technique should be practised so that you will 
  26. be able to perform it correctly the  first time you need it.
  27.  
  28. To play it safe, any DEBUG operations should be performed on a tempo-
  29. rary disk, just in case the directory gets all screwed up. So pull out
  30. the disk with the erased file and DISKCOPY it onto another disk, first.
  31. Mark the original erased disk and put it away. We will show you how to
  32. recover the erased file and then you can copy it back onto the original
  33. disk after you are satisfied that it is correct.
  34.  
  35. When a file is erased, DOS makes one directory change -- it changes the
  36. first letter of the name to a &H E5 which is a greek symbol σ (small 
  37. sigma) but DEBUG helps by printing a small  e  in its ASCII translation
  38. or  CHR$(101) + 128 = &HE5 or 229. DOS also releases the clusters after
  39. the starting one that is shown in Directory. We will not try to unerase
  40. anything but the starting sector in this program. But if you are inter-
  41. ested in further exploration, take a formatted/s disk and SAVE an
  42. ASCII text file onto it which uses several sectors ( each 512 Bytes ).
  43. Go DEBUG and print out the FAT and the Directory sectors with DEBUG.
  44.  
  45. Now erase the file and go into DEBUG again and compare your print-out
  46. with the new conditions in FAT and Directory. Try it with and without
  47. doing a CHKDSK after erasing. Each FAT entry is 12 chars in HEX. The
  48. last cluster used ( in our case the first cluster) times 1.5 produces
  49. an offset into FAT using the whole number result of the multiplication.
  50.  
  51. Did you find out if there was any information remaining in FAT that
  52. could be reconstructed for the erased file? The only alternative left
  53. is to take the next logical choice and try the next sectors in orderly
  54. sequence. It is a monumental task if they are scattered through the
  55. disk, but it might be worth your trouble if the file is that important.
  56.  
  57. With DEBUG you can load 80 sectors from the disk and view them with
  58. a dump command noting the addresses of those that belong to the file
  59. and then rebuild the file a sector or two  at a time, using write
  60. commands when you find the correct sectors. Peter Norton's UNERASE
  61. makes this much easier to do. 
  62.  
  63. See the IBM DOS manual for instructions for computing the next cluster
  64. number. Appendix C pages 6-9.
  65.  
  66. If you don't have a specific file already erased to practise on -- just
  67. erase one on the DISKCOPY to experiment with. If you have a NORTON 
  68. DISKLOOK utility you can verify these operations and check your work
  69. by an independent means. (In fact, if you have a NORTON UNERASE you
  70. probably have done this operation without knowing what had happened.)
  71.  
  72. Use your DOS disk to load DEBUG without any parameters. When you get
  73. the DEBUG prompt (a hyphen) put your DISKCOPY into Dr A: and type
  74. this command exactly as shown here   -L  04B5:0100  0    3   4  <ENTER>
  75.  
  76. The command above means  L (load)  04B5:0100 (hex addr)  0 (Dr A:)  
  77. sector 3 (start) sectors 4 (load 4 sectors from disk). Remember the
  78. address and the sectors must be in HEXadecimal. The S.S. directory is 
  79. contained in absolute sectors 3,4,5,6. So the HEX is the same as 
  80. decimal. You will find this all explained in your DOS manual.
  81.  
  82. Meanwhile back at the range -- we can now safely Dump the memory sector
  83. that we loaded from the directory with the  command  -D 04B5:0100 in
  84. DOS 1.1 and subsequent  -D  <ENTER> will move us through the directory
  85. until we find our file with the missing first letter and a little  e
  86. in place of the letter that belongs there.
  87.  
  88. Check for a corresponding  E5  in the  bytes to the left of the ASCII.
  89. Now note the correct address of byte you want to change. The address
  90. shown in the offset (to right of the colon) starts at the first byte
  91. to the right of  offset. Count them across in HEX 0 1 2 3 4 5 6 7 8 9 
  92. A B C D E F and you should be to the end of the row. Notice the hyphen
  93. in between the first 8 bytes and the last 8 bytes. (Each line is a HEX
  94. paragraph (16 bytes) and is identified by the last 0 in the offset,
  95. which is generally omitted in IBM-PC addressing of 1 Mbyte with FFFF.)
  96.  
  97. Write down the address 04B5:HHHH of the E5 that must be changed to lets
  98. say an  "F" . Now check it for accuracy one more time. We are ready.
  99.  
  100. At the DEBUG prompt hyphen type in this command   -E 04B5:HHHH "F" 
  101. and enter it. It says E(nter) at HEXaddr 04B5:HHHH "F" the HEXcode for
  102. "F".   Study the DEBUG commands we are using if you are not familiar
  103. with them in detail.
  104.  
  105. Now lets see what we did. Type at next hyphen prompt -D 04B5:HHHH and
  106. enter it and you should see a dump beginning with the line you changed.
  107. Check it carefully. Is everything just the way it was except for the
  108. change from  E5 to  46  (in HEX) if so, you are ready to close, Doctor.
  109.  
  110. The process of writing the sectors back to the disk is just the same
  111. as loading them into DEBUG. Compare the format of the WRITE command 
  112. with the LOAD command in DEBUG and you will find OPTION 1 (which we
  113. used) identical. Type at the hyphen  -W 04B5:0100 0 3 4  and enter.
  114. The disk will whir and the light will light and we will now QUIT
  115. DEBUG with  -Q and try  A>DIR to see what IBM-PC hath wrought.
  116.  
  117. YUP -- There it is -- isn't it? That was easy enough to do over again.
  118. Pick another file and try the same procedure, but this time monitor it
  119. with Peter Norton's DISKLOOK to see how you are progressing.
  120. Remember you are probably only saving the starting sector (up to 512
  121. bytes). 
  122.  
  123. DOS 2.0 may produce a segment address that is different from 04B5:0100
  124. please, get familiar with it so that when you need it you will be 
  125. prepared.
  126.  
  127. You can print out a copy of the D(ump) before and after modification
  128. simply by pressing Shift and pressing PrtSc at the same time. Keep it
  129. for your records. Save it with a hard copy of this program. Of course,
  130. to print-out this in DOS enter   A>type  DISKMOD.DBG <Ctrl-PrtSc>
  131.  
  132. Happy DEBUGGING !
  133.