home *** CD-ROM | disk | FTP | other *** search
- PROGRAM SECDUMP;
- (* Sector dump program by Bruce J. Savaglio (c) 1986 *)
- (* This program is given away freely -- enjoy
- This program will read the sectors on any disk -- even one that is unformatted.
- I use it to see if there is something on a disk the operating system
- won't read before I reformat it and lose it forever.
- It will read The sectors on a CP/M disk, on anything(haven't tried Commodore,
- but I think it will work). Don't forget, reading sectors doesn't mean you
- can read a file into your IBM compatible. But you can look at what is
- on the disk. The program uses Dos Interrupt 25h (read sector). Be careful if
- you decide to modify the program to change sectors and include your own INT 26h
- procedure. Modifying sectors indiscrimintately can cause errors from which even
- Peter Norton can't save you.
-
- To use this program simply answer the responses. The sector bytes are given in
- decimal relative to 0 byte which is the first byte of 0 sector all the way to
- sector 711 the first byte of which is 364,032. The actual byte values of
- the sectors (the DATA) is in hex. Fell Free to mess with this pro-
- gram. If you come up with something nifty let me know. *)
-
- (* Turbo Pascal if you haven't guessed *)
-
- uses crt,dos;
- {**** Ascii tables below contains position for the 127 characters. The table
- is used to quickly translate a byte into a printable character. The first
- 32 numbers are the ASCII number for a period "." because the first 32 are
- not printable (escape, null, LF, ect.). }
-
- const ASCII : array[0..127] OF BYTE =
- (46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,
- 46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,
- 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,
- 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,
- 64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,
- 80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
- 96,97,98,99,100,101,102,103,104,105,106,107,108,
- 109,110,111,112,113,114,115,116,117,118,119,120,
- 121,122,123,124,125,126,127);
-
- CONST HEXCHR: ARRAY[0..15] OF CHAR = '0123456789ABCDEF';
-
- VAR
- NUM_SECS :INTEGER; {The number of sectors to look at (only 1)}
- InSec_num : integer; {The sector input by the user also the starting sector}
- SECTOR : ARRAY[0..511] OF BYTE; {Buffer to hold sector}
- ASCI_TAB : ARRAY[0..15] OF CHAR; {Holds a line of ASCII bytes}
- BPHOLD,SPHOLD: INTEGER; {Used to hold Stack and Base pointer for
- inline assembler code because Interrupt 25 doesn't
- clear the stack}
- INDX : INTEGER; {INDEX into hex table and contains a byte of
- data from sector}
- Sec_loc :real; {Sector offset printed on each line }
- Inchar : char;
- drive : byte; {must be global variable to work with inline code}
- drive_char: char;
- ATTR:BYTE;
- {$I BOXMAKER.PAS}
-
- Procedure top_line;
-
- BEGIN
- gotoxy(2,2);
- writeLN(' S E C D U M P (c) 1988 B.J. SAVAGLIO ')
- END;
-
- PROCEDURE GET_SEC;
-
- BEGIN
- top_line;
- NUM_SECS := 1;
- gotoxy(2,4);
- WRITE('Enter sector number: ');
- readLN(inSec_num);
- write('Now enter drive letter (one character no ":" )');
- READLN(drive_char);
- end; {get_sec}
-
- Procedure read_sec;
- begin
- drive_char := upcase(drive_char);
- drive := ord(drive_char);
-
- drive := drive - 65; {Ascii A starts at 65}
- Sec_loc := inSec_num;
- Sec_loc := 512 * Sec_loc;
- {inSec_num := inSec_num * 512;}
-
- (* THIS IS THE ASSEMBLER PROCEDURE THAT READS THE RAW SECTORS *)
- {Dos Interrupt 25h !!! NOT function 25h of interrupt 21h!!!!}
- INLINE
- ($89/$2E/BPHOLD/ {MOV BPHOLD,BP}
- $89/$26/SPHOLD/ {MOV SPHOLD,SP}
- $A0/drive/ {MOV AL,drive -- drive b: 00 is A,
- 2 is c, etc.}
- $8D/$1E/inSec_num/ {LEA BX,[inSec_num]}
- $8B/$17/ {MOV DX,[BX]}
- $8D/$1E/NUM_SECS/ {LEA BX,[NUM_SECS]}
- $8B/$0F/ {MOV CX,[BX]}
- $8D/$1E/SECTOR/ {LEA BX,SECTOR} {LEA BX,SECTOR}
- $CD/$25/ {INT 25}
- $8B/$2E/BPHOLD/ {MOV BP,BPHOLD if you don't restore these}
- $8B/$26/SPHOLD); {MOV SP,SPHOLD two the stack grows un-}
- END; {get_sec} {controllably }
-
- PROCEDURE DISPLAY_SEC;
-
- VAR PASS_2,INDSEC_NUM,SEC_NUM,LIN_NUM: INTEGER;
- second_half : integer; {to look at second 256 bytes}
- INDXR : REAL;
- INSTR :CHAR;
-
- BEGIN {******* Display_Sec starts here *****************}
- PASS_2 := 0;
- second_half := 0;
- SEC_NUM := 0;
- LIN_NUM := 0;
- CLRSCR;
-
-
-
- While Pass_2 < 2 do
- begin
- gotoxy(2,3);
-
- writeln;
- WRITELN(' Sector Number: ',inSec_num,' Drive: ',drive_char,':');
- writeln;
- WRITELN(' BYTE: 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15');
- WRITELN;
- WHILE LIN_NUM < 256 DO { do for entire screen}
- BEGIN
- WRITE(Sec_loc:06:0,': ');
- WHILE SEC_NUM <> 16 DO {do for a single line}
- BEGIN
- INDSEC_NUM := SEC_NUM + LIN_NUM + second_half;
- INDX := SECTOR[INDSEC_NUM];
- IF INDX < 128 THEN
- ASCI_TAB[SEC_NUM] := CHR(ASCII[INDX])
- ELSE
- ASCI_TAB[SEC_NUM] := '.';
- INDX := INDX AND $F0;
- INDXR := INDX / 16;
- INDX := TRUNC(INDXR);
- WRITE(HEXCHR[INDX]);
- INDX := SECTOR[INDSEC_NUM];
- INDX := INDX AND $0F;
- WRITE(HEXCHR[INDX]);
- WRITE(' ');
- SEC_NUM := SEC_NUM + 1;
- END; {While}
- WRITE(ASCI_TAB);
- WRITELN;
- LIN_NUM := LIN_NUM + SEC_NUM;
- Sec_loc := Sec_loc + 16;
- SEC_NUM := 0;
- END;{while}
- IF PASS_2 = 0 THEN
- BEGIN
- WRITE('press any key to see second half of Sector ');
- instr := readkey;
- second_half := lin_num;
- end
- else
- begin
- write('Press "N" or "n" to see next sector or any key to continue');
- instr := readkey;
- if (instr = 'n') or (instr = 'N') then
- begin
- Pass_2 := -1;
- InSec_num := InSec_num +1;
- second_half := 0;
- read_sec;
- end;
- end; {else}
- CLRSCR;
- PASS_2 := pass_2 +1;
- LIN_NUM :=0;
- END; {while}
- END; {Display Sec}
-
- BEGIN {************* Begin Program **************}
- window(1,1,80,25);
- BOXMAKER(1,1,79,23,blue);
- WINDOW(2,3,76,23);
- inchar := ' ';
- while (inchar <> 'q') and (inchar <> 'Q') do
- begin
- inSec_num := inSec_num + 1;
- GET_SEC;
- read_sec;
- DISPLAY_SEC;
- Write('Enter "Q" or "q" to quit (any key to go again)');
- inchar := readkey;
- clrscr;
- end;
- WINDOW(1,1,80,24);
- END. {Secdump}