name restore
title restore.com 6.4 for MS DOS 2.0 - 7.0, and Windows DOS compatibility box
; Copyright: (c) 1989-2017 Roedy Green, Canadian Mind Products
Comment |
Written in Microsoft Assembler MASM 5.0 or OptAsm 1.61b
Last Updated: 2009-03-09 Roedy Green
Authors: Dan Wright and Roedy Green
Please report bugs and problems to:
Roedy Green
Canadian Mind Products
#101 - 2536 Wark Street
Victoria, BC Canada V8T 4G8
tel:(250) 361-9093
mailto:roedyg@mindprod.com
http://mindprod.com
Purpose
=======
To restore files backed up under any version of DOS to any other
version of DOS, Roedy Green wrote the original the Canadian Mind
Products RESTORE program. Versions 1 through 4.4 handled the
Backup format used by MS and PC DOS 2.0 through 3.2. CMP
Restore replaces the RESTORE program that comes with MS DOS or
IBM PC DOS.
Dan Wright wrote version 5 of Restore to further extend the
capability to include the new DOS backup format introduced with
DOS 3.3. With this version, either of the formats will be
recognized automatically and restored to any version of DOS from
2.0 to 5.0. It cannot restore backups created with DOS
6.0 through DOS 7.0 restore, but it can run under them.
CMP Restore corrects the 20 bugs in the official Restore. This
will allow people to restore from backups where before they
could not.
Restore is a free program.
Syntax
======
RESTORE A: [C:][path\][filespec] [/S] [/P] [/Q]
Where:
A: = source floppy drive, i.e. A:, B:, etc.
C: = target hard drive, i.e. C:, D:, etc.
path = the directory where the files will be placed.
filespec = the specification of files to be restored.
May include wildcard chars. * and ?.
/S = restore subdirectories also.
/P = prompt before restoring each file.
/Q = quiet, suppress advertising banner.
Samples of Use
==============
RESTORE A: C:\*.* /S /P -- restores all files, letting you
decide which ones to restore individually.
RESTORE A: C:\*.BAT/S -- restores all BAT files in all
subdirectories.
RESTORE A: C:\MySub\MyFile.Ext
RESTORE A: C:\MySub\*.*/P/S/Q
RESTORE A: C:\MySub/P
RESTORE A: C:\MySub
RESTORE A: \MySub -- presumes default drive
RESTORE A: C:*.* -- presumes default directory
RESTORE A: C:\*.BAT/S -- restores all BAT files in all
subdirectories.
It is not as elaborate as the commercial versions, only the /S
and /P switches are supported.
About the Authors
=================
Dan Wright is a legally blind programmer seeking work in the
field either on a contract or full-time basis. He is presenting
this version of RESTORE as an example of his work. This code
was written, and parts of it adapted from Canadian Mind Products
RESTORE version 4.4, using a speech synthesizer and a minimal
amount of visual feedback from the screen (not enough to read).
Information on DOS function calls, MASM, etc. was obtained using
Norton Guides and various reference books which I have had read
onto cassette tape. The integrity of restored files was
verified by redirecting the output of DIR commands and the
output of a CRC utility to files before and after restoring and
then comparing these using the DOS COMP and FC commands.
Roedy Green is the author of the public domain Abundance
Database compiler and the 32 bit BBL Forth compiler as well as a
suite of many small public domain utilities. He also writes for
The Computer Paper - a Vancouver free advertising paper.
WARNING TO HACKERS
==================
If you modify this program to look for existing files on hard
disk before restoring, beware the APPEND command. It will fool
you into thinking the file already exists when in fact it does
not, there is just a similarly named file in one of the APPEND
directories. The guys who wrote FastBack got fooled by this
one.
Notes an How BACKUP Works
=========================
BACKUP uses standard DOS-formatted disks (they must be
pre-formatted, but not necessarily cleared of all files).
Backup first erases all files in the root directory of the
diskette -- even read only files. (I have heard unconfirmed
reports that some versions of BACKUP have a bug and you have to
erase the hidden, system and read-only files yourself with QDOS
II first.) If they were not erased, they could confuse RESTORE
no end!
In addition BACKUP will not work if there are subdirectories on
the floppies. Instead of erasing them, it terminates with a
mysterious stack overflow error.
Notes on DOS 3.2 Backup Format
==============================
MS DOS and PC DOS 2.0 through 3.2 use this format. There is a
slight difference between MS and PC DOS formats -- the \ verses
the / in file names.
Each backup disk begins with a file called BackupId.@@@,
followed by one or more of the backed-up files. If two
identically named files are backed up onto the same physical
disk, the subsequent file extensions are listed as @01, @02,
etc. A file may be split across more than one disk, and in this
case the name of all subsequent chunks are the same as the first
chunk's (regardless of whether a non-unique name which had to be
modified on its initial disk is unique on a later disk).
Backup puts a file called \BackupId.@@@ on each diskette. In it
you can find the diskette sequence number and the date the
backup was done. There is also an indicator flag to tell if
this is the last diskette of the set.
offset len
01..01 1 -1 if this is last diskette in the set.
02..03 2 Sequence no. of diskette. In 8 bit BCD
04..05 2 Year e.g. 1986 backup done.
True 1900 form, not 1980 relative.
06..06 1 Day backup done, binary 1..31.
07..07 1 Month backup done, binary 1..12.
Each file is backed up with a 128 byte preamble. In the
preamble is the fully qualified name of the file. To make life
interesting, the subdirectories may be separated with either /
or \. This goofiness is 90% of the reason my version of RESTORE
had to be written.
If files are too big to fit on diskette, there are two other
numbers of interest in the preamble:
1. The sequence number of this chunk 1, 2 etc
2. A flag that indicates this is the last chunk.
offset len
01 .. 01 1 -1 if last fragment of file, 0 otherwise.
02 .. 03 2 Sequence no. of this fragment,
04 .. 05 2 Padding.
06 .. 69 64 Fully qualified filename on hard disk without drive specifier
padded on right with nuls. May have / instead \.
70 .. 83 14 Padding.
84 .. 84 1 Length of fully qualified name including one trailing nul.
85 ..129 45 Padding.
Note that the preamble does NOT contain any of the following
information that you might expect.
1. attribute byte of the file.
2. date and time file was last modified.
3. Length in bytes of the chunk.
4. offset in file where this chunk fits.
5. Length in bytes of the entire file.
6. Count of how many chunks there are supposed to be in total.
7. Checksum
To glean this information we must examine the date, time and
attribute bytes of the backup file itself. To figure out where
the chunk fits in, we simply have to start at the beginning and
keep track. Thus it is impossible to restore a file unless you
start at chunk 1 and work sequentially through. Bad news if one
of the chunks is unreadable.
Following the preamble is the file itself -- absolutely raw --
no compression of any kind.
When restoring a file we have four versions of the filename:
Fname -- from the floppy directory - part of the floppy file name
missing A:\ e.g. XXXXXX.XXX
InName -- the actual name of the floppy file
e.g. A:\XXXXXXXX.XXX
HardName -- the name in the floppy premamble
missing C:
e.g. \SUB1\SUB2\XXXXXXXX.XXX
OutName -- the actual name of the file on the hard disk
e.g. C:\SUB1\SUB2\XXXXXXXX.XXX
Notes on DOS 3.3 Backup Format
==============================
MS and PC DOS 3.3 through 5.0 use the following format. DOS 7.0
backup uses the proprietary Norton backup format.
On each backup diskette are two files
CONTROL.001 - list of files, subdirectories, sizes
BACKUP.001 - actual data files, not compressed, crammed together
end to end in a single file.
volume id is BACKUP 001
The diskettes are numbered in three places:
CONTROL.002
BACKUP.002
volume id is BACKUP 002
The Control file
****************
The control file begins with a 139 byte header:
offset len
00..00 1 8B=139 length of record
01..08 8 the word BACKUP signature padded on the right with spaces
09..0A 2 diskette number, simple binary starting at 1
Does not use the goofy BCD format of DOS 3.2
0B..89 127 zeroes
8A..8A 1 -1 if last diskette in set, 0 otherwise
Then come two types of entries: subdirectories and files. There
is no special marker for the end of file other than the file size
recorded in the directory.
Subdirectory entry
******************
A 70-byte subdirectory entry looks like this.
00..00 1 HEX 46=70 length of record
01..3F 63 subdirectory name, no drive, no lead \, with embedded \,
no trail \, zero padded on right
40..41 2 count of files following on this diskette in this subdir
42..45 4 offset in the Control file of the next subdirectory
record. If there is no further subdirectory on this
diskette, contains -1. The offset is absolute, not
relative to this record. This way if we are restoring
only some subdirectories, we can rapidly get on with
the next one.
The date, time and attribute byte of the subdirectory are NOT
recorded. Restore builds directories as needed with the current
date and time with a default attribute byte.
File entry
**********
Following a subdirectory entry are multiple file entries for the
files being backed up in that subdirectory.
A 34 byte file entry looks like this:
00..00 1 HEX 22=34 length of record
01..0C 12 file name with embedded dot, padded with 0s.
no embedded spaces.
0D..0D 1 02 = another fragment to come on another diskette after this one.
03 = this is the last (possibly only) fragment.
0E..11 4 total size of file in bytes
12..13 2 Sequence number of this fragment starting at 1.
14..17 4 offset into Backup.nnn of start of file.
18..1B 4 size of fragment of file in bytes on this diskette
1C..1C 1 attribute byte of file in directory format.
usually the archive bit is on.
1D..1D 1 zeroes
1E..1F 2 time in DOS directory format
20..21 2 date in DOS directory format
Note on register conventions
============================
Whenever we call a subroutine, the subroutine is permitted to
trash all registers. Thus the caller must save any registers
needed. The way the code is written, this is very rarely
necessary as all high level routines do nothing but calls and
comparisons of memory resident variables.
Setting the carry flag is often used by a subroutine to inform
its caller that trouble has occurred.
Callers often cheat when calling very simple routines. They
fail to save necessary registers knowing that the called routine
will not mess them up. If you make changes to low level
routines beware!
/*
Version History:
1.0 1985-11-01 not released to the public
restored all files ignoring the filespec
2.0 1986-12-25 /P /Q /S options.
allowed you to select files to be restored.
3.0 1987-01-28 released to Charware subscribers
fixed bug when restore had to handle 10 or more diskettes.
4.0 1987-03-05 fixed bug RESTORE A: C:*.* /S in root directory did not work.
was treated as RESTORE A: C:\\*.* /S instead of C:\*.* /S
fixed bug. Originally all disks in the backup set were
checked to makes sure they were created on the same day
to make sure they were part of the same set. Because backups
can be created with the /A option, it is possible each diskette
in the set is part of a different set. Thus the check was
removed.
4.1 1987-05-08 version number now prints as part of the "Screwed up" message
RESTORE.TXT documention separated from ASM source code
change mailing address
4.2 1987-07-09 beeps when wants disk
4.3 1988-04-09 change of mailing address in banner
4.4 1988-12-24 change of mailing address in banner
5.0 1989-03-03 very limited distribution
added support for DOS 3.3 through DOS 4.01
this was a major rewrite that took many times
longer to write than the original. For this
reason Version 5.0 is not Charware, but rather
ShareWare.
5.1 1989-05-24 more friendly, simpler, less technical error messages.
fancier prompts.
tidier source code.
bug fixed that restored a file fragment when you inserted
the wrong diskette.
avoid reprompting entire prompt when input bad.
Abort Retry Ignore keystrokes no longer echo.
/ options no longer picky about leading space.
warning message if source not A: or B:
warning message if target not C: through G:
fancier banner, with pause
5.2 1989-07-26 add extra blank line ahead of insert disk prompt
extra information on site licenses
separate registering text.
now assembled with Optasm
5.3 1990-02-05 there are bugs in DOS 2.0 and 2.1 that can
interfere with Restore.
changes to Default_Subdir now account for the
DOS bug when DOS gives mixed upper and lower
case for the current directory and when DOS
sometimes give directory names that are
too long.
5.4 1990-08-03 better explanation of registration in banner.
5.5 1990-10-13 new documentation warning that RESTORE cannot restore
to a different directory.
new docs on how to handle problem of a restoring a backup
when you don't know what is on it.
better heading in the docs
now works on LANS, no more IOCTL calls on hard drives.
^ now accepted as valid character in a filename.
You can now assemble RESTORE in a way that makes it
more suitable as an install program for multi-disk
software packages.
Some versions of DOS and some cachers have a bug that
they fail to notice when you change the diskette in a
floppy drive and thus give the program data from the previous
diskette instead of the current one. To bypass this
bug I added a disk reset just prior to each diskette
swap. The symptom is that the program claims diskette
1 is in the drive, and demands diskette 2, when in fact
you have already inserted diskette 2.
5.6 1992-02-06 notes that works on DOS 5.0
6.0 1993-06-17 notes on DOS 5 and DOS 6 use.
new address and phone number.
new information on site licensing.
6.1 1996 10-29 embed Quathiaski address
notes on DOS 7.0.
6.2 1998-11-08 embed Barker address
6.3 2007-07-21 now free
6.4 2009-03-09 bundled with ANT build script.
*/
| ; End of comment.
;==============================================================
; Generate either a restore program or an install program
INSTALLING equ 0 ; 0FFh = true if generating an install program
; install program has smaller alternate banner,
; makes no references to "restore diskettes"
; 0 = false if generating a restore program
if1
if INSTALLING
%out generating an INSTALL-style version of RESTORE.COM
else
%out generating a RESTORE-style version of RESTORE.COM
endif
endif
;==============================================================
ifdef DEBUG ;; Declared on MASM command line.
if1
%out Debug version.
endif
.xlist
.lall
else
if1
%out Production version.
endif
endif
;==============================================================
; E Q U A T E S
CR equ 0DH
LF equ 0AH
BEL equ 7
STD_IN equ 0 ; Handle for standard input device.
STD_OUT equ 1 ; Handle for standard output device.
STD_ERR equ 2 ; Handle for standard error device.
STACK_SIZE equ 256 ; Size of program stack in bytes. Used
; to check for sufficient memory.
BUFF_SIZE equ 512*9*10 ; Size of buffer for disk I/O. Size = 10
; tracks for 360K floppy.
HDR_REC_LEN equ 139 ; Length of header record in
; CONTROL.XXX.
SUBDIR_REC_LEN equ 70 ; Length of subdirectory records
; in CONTROL.XXX.
FILE_REC_LEN equ 34 ; Length of file records in
; CONTROL.XXX.
;==============================================================
dbln macro Message, Msg_Lbl
;; Define Message as one line of a message terminated by CR/LF. If the
;; message label Msg_Lbl is supplied, make sure it has been declared and use it
;; to calculate the length of the message after the current line is defined.
ifnb ;; If the message label has been supplied
ifndef Msg_Lbl ;; but not declared, declare it.
even
msg_lbl label byte
else
if $+1 eq Msg_Lbl ;; Ensure start address of message is
even ;; the same on both passes.
endif
endif
endif
ifnb ;; Define text of message.
db "&Message"
endif
db CR, LF ;; Terminate line.
ifnb ;; Calculate current length of message.
msg_lbl&_len = $ - Msg_Lbl
endif
endm ;; End of macro dbln.
;==============================================================
dbpl macro Prompt, Prompt_Lbl
;; Define partial line Prompt as a prompt with no terminating CR/LF. If
;; the prompt label Prompt_Lbl is supplied, make sure it has been declared and
;; use it to calculate the length of the prompt after the current line is
;; defined.
ifnb ;; If the label is supplied but not
ifndef Prompt_Lbl ;; declared, declare it.
even
prompt_lbl label byte
else
if $+1 eq Prompt_Lbl ;; Ensure start address of prompt is
even ;; the same for both passes.
endif
endif
endif
ifnb ;; Define text of prompt.
db "&Prompt"
endif
ifnb ;; Calculate current length of prompt
;; if label supplied.
prompt_lbl&_len = $ - Prompt_Lbl
endif
endm ;; End of macro dbpl
;==============================================================
dbs macro Len ;; Len spaces
db &Len DUP (" ") ;; define string of spaces
endm
;==============================================================
dbpr macro Prompt, Prompt_Lbl
;; Define Prompt as a prompt with no terminating CR/LF and one bell char. If
;; the prompt label Prompt_Lbl is supplied, make sure it has been declared and
;; use it to calculate the length of the prompt after the current line is
;; defined.
ifnb ;; If the label is supplied but not
ifndef Prompt_Lbl ;; declared, declare it.
even
prompt_lbl label byte
else
if $+1 eq Prompt_Lbl ;; Ensure start address of prompt is
even ;; the same for both passes.
endif
endif
endif
ifnb ;; Define text of prompt.
db "&Prompt"
endif
db BEL ;; Add one bell char.
ifnb ;; Calculate current length of prompt
;; if label supplied.
prompt_lbl&_len = $ - Prompt_Lbl
endif
endm ;; End of macro dbpr.
;==============================================================
dbzs macro Z_String, Z_String_Lbl
;; Define the contents of Z_String as an ASCII Z string with the label
;; Z_String_Lbl.
ifnb ;; Declare label for Z string.
even
z_string_lbl label byte
else ;; Force error if no label.
.err
endif
ifnb ;; Define Z string.
db "&Z_String"
endif
db 0 ;; Add terminating nul.
endm ;; End of macro dbzs.
;==============================================================
Patch_Num macro Hex_Num, Num_Start, Num_Width
local pn_more
;; Display the 16 bit quantity Hex_Num as a decimal integer right justified
;; in a field Num_Width characters wide with the right most digit at offset
;; Num_Start. It generally patches the number into an error message or prompt.
ifdif ,
mov ax, Hex_Num ;; Value to display in ASCII decimal.
endif
lea di, Num_Start ;; Location of right most digit.
mov cx, Num_Width ;; Width of field in which to place
;; Number.
call Patch_Sub
endm ;; End of macro Patch_Num.
;==============================================================
Say_Err_Msg macro Err_Msg
;; Print Err_Msg&_Len characters beginning at the address of Err_Msg
;; to the standard error device.
lea dx, Err_Msg
mov cx, Err_Msg&_Len
mov bx, STD_ERR
mov ah, 40H
int 21H ;; 40H=Write.
endm ;; End of macro Say_Err_Msg.
;==============================================================
Say_Msg macro Msg
;; Print Msg&_Len characters beginning at the address of Msg
;; to the standard output device. These can be redirected via Pipes.
lea dx, Msg
mov cx, Msg&_Len
mov bx, STD_OUT
mov ah, 40H
int 21H ;; 40H=Write.
endm ;; End of macro Say_Msg.
;==============================================================
D_Count = 0 ;; Initialize count of dangerous files.
Test_Count = 0 ;; Used to detect incorrect parameters.
;==============================================================
Def_D_File macro D_Filename, DC
;; Define an ASCII Z string containing the filename passed in D_File and
;; calculate its length.
;; Keep track of the number of filenames processed in D_Count and use this
;; value to generate unique symbols for the address and length of each
;; Z string.
;; Only the first parameter, the filename of a file which could be dangerous
;; to restore to the root directory, should be supplied when calling this
;; macro.
ifb ;; This part executes on initial call.
d_count = D_Count + 1 ;; Increment count of dangerous files.
;; Now the macro calls itself passing the value of D_Count as a second
;; parameter. This enables the generation of symbol names made unique by
;; including the current value of D_Count for the address of the string and
;; its length.
def_d_file , %D_Count
else ;; This part executes when the macro
;; calls itself.
if Test_Count eq D_Count ;; This occurs if the macro was
.err ;; erroneously called with a second
exitm ;; parameter supplied.
endif
even
d_file&dc label byte ;; Generate label for string address.
ifnb ;; The first parameter can't be blank.
db "&D_Filename" ;; Define string.
db 0 ;; Add terminating nul.
else
.err
endif
d_file&dc&_len = $ - D_File&DC ;; Generate symbol containing string
;; length.
;; Test_Count follows the value of D_Count to prohibit the execution of the
;; second part of the macro before the first part which would happen if a
;; second parameter was included in the initial call. D_Count is incremented
;; on execution of the first part allowing subsequent error free execution of
;; the second part. Incrementing Test_Count at the end of the second part
;; ensures that the first part must be executed before the second part may
;; be executed again.
test_count = Test_Count + 1
endif
endm ;; End of macro Def_D_File.
;==============================================================
Blank_Extension macro Ext_Start
;; Patch a filename extension with wild card characters. Ext_Start points
;; at the beginning of the file extension.
lea di, Ext_Start
mov cx, 3 ;; Length of a file extension.
mov al, '?'
cld
rep stosb
endm ;; End of macro Blank_Extension.
;==============================================================
DTA equ 80H ;; offset in PSP of default DTA.
; Template for DTa after call to dir. search functions 4EH and 4FH.
Dir_Search struc
DS_Reserved db 21 dup (?) ; Reserved for DOS.
DS_Attr db ? ; File attribute in dir. format.
DS_Time dw ? ; File time in dir. format.
DS_Date dw ? ; File date in dir. format.
DS_Size dd ? ; file size.
DS_Name db 13 dup (?) ; Filename as ASCII Z string.
Dir_Search ends
;==============================================================
; BACKUPID.@@@ file format in DOS 3.2
Bkp_ID_Rec struc ; 7 bytes of interesting info in
; \BACKUPID.@@@.
BI_Last db ? ; -1 if this is last diskette in the set.
BI_Seq dw ? ; Sequence no. of diskette. This is
; originally in 8 bit BCD form but
; will be converted to true binary.
BI_YYYY dw ? ; Year e.g. 1986 backup done.
; True 1900 form, not 1980 relative.
BI_DD db ? ; Day backup done, binary 1..31.
BI_MM db ? ; Month backup done, binary 1..12.
Bkp_ID_Rec ends
;==============================================================
; 128 byte header at the beginning of every DOS 3.2 backup file.
Preamble struc
P_Last db ? ; -1 if last fragment of file, 0
; otherwise.
P_Frag_Seq dw ? ; Sequence no. of this fragment,
; 1 = first, 2 = second, etc.
dw ? ; Padding.
P_Hard_Name db 64 dup (?) ; Fully qualified filename on hard disk
; without drive specifier, padded on
; right with nuls. May have / instead
; of \.
db 14 dup (?) ; Padding.
P_Hard_Len db ? ; Length of fully qualified name
; including one trailing nul.
db 45 dup (?) ; Padding.
Preamble ends
;==============================================================
; Header Record in DOS 3.3 Control.XXX file
Hdr_Rec struc
Hdr_Len db ? ; Length of header record.
Hdr_Sig db "BACKUP " ; Backup signature.
Hdr_Seq dw ? ; Disk number in set, 1=first, 2=
; second, etc.
db 127 dup (?) ; Padding.
HDR_Last db ? ; -1 if last diskette in set, 0 otherwise
Hdr_Rec ends
;==============================================================
; Subdir Record in DOS 3.3 Control.XXX file
Subdir_Rec struc
Subdir_Len db ? ; Length of subdirectory record.
Subdir_Name db 61 dup (?) ; Subdirectory name. No leading or
; trailing backslash, 0 padded on right.
dw ? ; Padding.
Subdir_Count dw ? ; Count of files following in this
; subdirectory on this diskette.
Subdir_Next dd ? ; Absolute offset in CONTROL.XXX of next
; subdirectory record. (-1 if no more
; subdir entries)
Subdir_Rec ends
;==============================================================
; File Record in DOS 3.3 Control.XXX file
File_Rec struc
File_Len db ? ; Length of file record.
File_Name db 12 dup (?) ; file name with embedded dot, zero
; padded, no embedded spaces.
File_More db ? ; 2=another fragment on next diskette, 3=
; last and possibly only fragment.
File_Size dd ? ; Size of file in bytes.
File_Frag_Seq dw ? ; Sequence number of this fragment,
; 1=first, 2=second, etc.
File_Frag_Start dd ? ; offset in BACKUP.XXX where frag.
; starts.
File_Frag_Size dd ? ; Size of fragment of file on this
; diskette.
File_Attr db ? ; File attributes in dir. format.
db ? ; Padding.
File_Time dw ? ; File time in dir. format.
File_Date dw ? ; File date in dir. format.
File_Rec ends
;==============================================================
Code segment para
assume cs : Code, ds : Code, ss : Code, es : Code
org 100H
Start: jmp Restore_Main
;==============================================================
; V A R I A B L E S
even
Rest_Count dw 0 ; count of files restored.
Want_Seq dw 1 ; Expected disk sequence no.
Want_Frag_Seq dw 1 ; Expected fragment sequence no.
Want_Size dd 0 ; Expected file size for multiple
; fragment files and for verifying copy.
Bkp_Seq dw 1 ; Current Diskette sequence no.
Ctl_Hndl dw -1 ; CONTROL.XXX or BACKUPID.@@@ handle.
Bkp_Hndl dw -1 ; Handle for backup data files.
Out_Hndl dw -1 ; Output file handle.
Format_Flags db 0 ; Used to indicate format of backup
; diskettes being restored.
DOS32 equ 1 ; Bit 0 set = DOS 3.2 format.
DOS33 equ 2 ; Bit 1 set = DOS 3.3 format.
Flags db 01H ; If bit set:
LastFrag equ 01H ; bit 0 = last file fragment.
LastDisk equ 02H ; bit 1 = last diskette in set.
NewDisk equ 04H ; Bit 2 = New Diskette.
WrongOk equ 08H ; Bit 3 = user OKed diskette out of seq.
SkipFile equ 10H ; Bit 4 = Do not restore file.
FileMatched equ 20H ; Bit 5 = filename was matched.
WildCards equ 40H ; Bit 6 = wild card chars. in command
; line pathspec.
WasPeriod equ 80H ; Bit 7 = period processed in command
; line pathspec.
Cmd_Flags db 0 ; Flags for command line switches.
Prompt_Needed equ 01h ; Bit 0 set = prompted restore (/p)
RestoreSubs equ 04h ; Bit 2 set = restore subdirectories (/s)
Quietly equ 08h ; Bit 3 set = quiet, suppress banner (/Q)
Bkp_Sig db "BACKUP " ; Valid backup control file signature.
Bkp_Sig_Len equ $ - Bkp_Sig
; Define filenames used in both backup schemes. X's will be patched later with
; correct values.
; this is strange MASM syntax. Symbol name is on right.
dbzs Bkp_ID_Name ; Backup ID filename (DOS 3.2).
dbzs All_Pattern ; Pattern to find files on floppy in
; DOS 3.2 backup scheme.
dbzs Ctl_Filename ; Backup control file name (DOS 3.3).
dbzs Bkp_Filename ; Backup data filename (DOS 3.3).
; allocate two more bytes so kp_Filename can be used to hold floppy filenames
; in DOS 3.2 scheme.
db 2 dup (0)
Rest_Name label byte ; Pathspec to be restored.
Rest_Drive db 'X:' ; Hard disk drive letter. Patched later.
db '\' ; Not supplied in subdir records.
Rest_Path db 75 dup (0)
Filespec_Ptr dw 0 ; Ptr. to start of filespec in Rest_Path.
Rest_Name_Len dw 0 ; Length of drive and pathspec to be
; restored not including terminating nul.
Match_File db "XXXXXXXX.XXX" ; Name of file proposed to be restored.
; Extracted from Rest_Path in format
; comparable with command line pattern.
CL_Subdir_Pattern db 64 dup (0) ; Subdirectory pattern from command line
; of files to be restored.
Subdir_Pat_Len dw 0 ; Length of subdirectory pattern
; including trailing backslash, but
; excluding leading backslash and
; trailing nul.
CL_File_Pattern db "????????.???" ; Pattern from command line of files
; to be restored.
; Files dangerous to restore to the root directory.
def_d_file
def_d_file
def_d_file
def_d_file
def_d_file
; Define prompts and informational and error messages.
Wrong_Ver db "RESTORE requires DOS 2.0 or later.$"
; Not done with dbline since handles may not work.
Part_X_Msg db " part "
Part_X db "XXX"
Part_X_Msg_Len equ $ - Part_X_Msg
dbpl ,echochar
db 08 ; allow keystroke echo
dbpl ,echochar
; Embedded tabs are ok, since DOS will expand them again.
; Always leave RestBanner in code, even if not displayed.
dbln < ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»>, RestBanner
dbln < º RESTORE 6.3 for PC DOS and MS DOS 2.0 through 7.00 º>
dbln < ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ>
dbln
dbln < Copyright: (c) 1986-2017 Roedy Green, Dan Wright, Canadian Mind Products>
dbln
dbln < °±²Û Canadian Mind Products Û²±°>
dbln < #101 - 2536 Wark Street>
dbln < Victoria, BC Canada V8T 4G8>
dbln < tel:(250) 361-9093>
dbln < mailto:roedyg@mindprod.com>
dbln < http://mindprod.com>
dbln
dbln
dbln
dbln
dbln
dbln
dbln
dbln ,RestBanner
if INSTALLING
;; Roll your own banner here!!
dbln <ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»>, InstBanner
dbln <º °±²Û Project Discovery Main Install Program Û²±° º>
dbln <ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ>
dbln
dbln ,InstBanner
endif
dbln <úääääääääääääääääääääääääääääääääääääääääääääääääää¿> ,Help_Msg
dbln <³ RESTORE A: [C:][\path\][filespec] [/S] [/P] [/Q] ³>
dbln <ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ>
dbln
dbln
dbln
dbln
dbln < May include wildcard chars. * and ?.>
dbln
dbln
dbln
dbln
dbln
dbln
dbln < Restore A: C:\MySub\MyFile.Ext>
dbln < Restore A: C:\M???.Bat/P/S/Q>
dbln < Restore A: C:\*.*/S>
dbln < Restore A: C:\MySub\>
dbln < RESTORE A: C:\MySub\MyFile.> ,Help_Msg
if INSTALLING
dbln ,insert
dbln
dbln <ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿>
dbpl <³ Insert diskette >
Insert_Seq db "XXX in drive "
Insert_Drive db "X: ³"
dbln
dbln <ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ>
dbln ,Insert
else ; Restoring
dbln ,insert
dbln
dbln <ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿>
dbpl <³ Insert backup diskette >
Insert_Seq db "XXX in drive "
Insert_Drive db "X: ³"
dbln
dbln <ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ>
dbln ,Insert
endif
dbpr ,strike_any
dbln ,Strike_Any
dbln ,announce_bkp_msg
dbs 3
dbpl
ABM_Seq db "XXX"
dbpl < into drive >
ABM_Drive db "X:"
dbln
dbs 3
dbpl
ABM_MM db "XX-"
ABM_DD db "XX-"
ABM_YYYY db "XXXX"
dbln ,Announce_Bkp_Msg
dbpl ,old_bkp_format
dbs 3
dbln
dbln ,Old_Bkp_Format
dbpl ,new_bkp_format
dbs 3
dbln
dbln ,New_Bkp_Format
dbln <°±²û Usually the source floppy drive is A: or B: Are you sure? Û²±°> ,Strange_Source
dbln <°±²û Usually the target hard drive is C: D: ... G: Are you sure? Û²±°> ,Strange_Target
dbln <°±²û Your request to restore was ambiguous. Û²±°>, Ambiguous
dbln