page 60,132 NAME bootrest title BootRest restore the Master boot sector Comment | Version 2.9 Roedy Green works with MASM 6.0 and Optasm See BootSave.TXT for details on use. USAGE: Examples: ********* BootSave A:\MyBoot.Sav /Q BootRest A:\MyBoot.Sav /Q BootChk A:\ByBoot.Sav /Q These are DOS utilities, and thus can only use short 8.3 file names. Syntax errors or missing file trouble generates an ERRORLEVEL 4. BootChk generates an ERRORLEVEL 1 if the Boot record has changed since the BootSave was done. Version History *************** see bootsave.asm to Assemble *************** Manually set the GENERATING equate in embedded in the following code, then: to assemble with MASM 6.0 use: ML.EXE /AT /c /Fl /VM /Zf BOOT.Asm LINK.EXE /TINY /MAP BOOT.Obj,BOOT.com,BOOT.map; copy boot.com bootsave.com to assemble with OPTASM use: Optasm BOOT.Asm,BOOT.Obj,BOOT.Lst/L/N/G/S OLINK BOOT.Obj,BOOT.COM,/MAP/TINY; copy boot.com bootsave.com | ; end of comment .286 .model tiny ; this is a COM file stack segment stack ; keep MS link happy by providing null stack stack ends CODE segment PARA ; start off in code. ;============================================================== data segment byte ; provide a separate DATA segment ; actually all come after the code ;============================================================== ; V A R I A B L E S ParmIndex dw 0 Filename db 64 dup (0) ; asciiz filename SlashQuiet db 0 ; -1 means quiet mode /QQ CXSave dw 0 ; disk geometry from INT 13/08 DXSave dw 0 ; will be saved along with boot record Buffer dw 0 ; dynamic buffer will grow to 512 ; it hangs out past the end of the program Buffer2 equ Buffer+512 ; used to compare two versions of sector BannerMsg label byte db '°±²Û BootRest 2.9 Û²±°',13d,10d db 13d,10d db 'Restores hard disk master boot sector from a BootSave file on disk or floppy.',13,10 db 'Copyright: (c) 1991-2017 Roedy Green, Canadian Mind Products.',13,10 db '#101 - 2536 Wark Street, Victoria, BC Canada V8T 4G8',13,10 db 'Telephone:(250) 361-9093 mailto:roedyg@mindprod.com http://mindprod.com',13,10 db 'Freeware to freely distribute and use for any purpose except military.',13,10 db 13,10 db '$' UsageMsg db '°±²Û Error Û²±°',7,13,10 db 'Insert the diskette you used for BootSave.',13,10 db 'then try:',13,10 db 'BootRest A:\Boot.Sav',13,10 db 'or if the file is on hard disk try:',13,10 db 'BootRest C:\SAFE\Boot.Sav',13,10 db 'BootRest is a DOS utility, and thus can only use short 8.3 file names',13,10 db 'Read Boot.Txt to find how to use it properly.',13,10 db '$' GeomMsg db '°±²Û Error Û²±°',7,13,10 db 'The Boot.Sav file does not match the geometry of this hard disk.',13,10 db 'Either you have a Boot.Sav file from a different computer,',13,10 db 'or you have changed the disk drive since you did the BootSave,',13,10 db 'or your CMOS disk configuration is corrupted.',13,10 db 'Your hard disk boot sector has been left as is.',13,10 db '$' FileTroubleMsg db '°±²Û Error Û²±°',7,13,10 db 'Cannot find/read the 516-byte bootsave disk file.',13,10 db '$' BootTroubleMsg db '°±²Û Error Û²±°',7,13,10 db 'Cannot write the boot sector.',13,10 db '$' HardMsg db '°±²Û Error Û²±°',7,13,10 db 'Hard disk failed.',13,10 db '$' WorkedMsg db 'Hard disk master boot sector successfully restored',13,10 db '$' data ends com group code,data ; force data segment to go at the end assume CS:com,DS:com,ES:com,SS:com ; seg regs cover everything org 100H ; in Code segment ;========================== _Start proc near ; M A I N L I N E R O U T I N E call Parse ; get filename from command line lea dx,BannerMsg ; display the banner after have /Q call SayQ call ReadBootFromFile ; read Boot contents from file call CheckGeom ; make sure disk geometry matches ; safety check we have the right file. call PutBoot ; store buffer to Boot lea dx,WorkedMsg ; crow about success call Say Done: mov ax,4c00h int 21h ;normal termination _Start endp ;=============================================================== PutBoot proc near ; Write first sector, the boot block of hard disk C: mov ah,03 ; function 3 write mov dl,080h ; 80h = C: mov dh,0 ; head 0 mov ch,0 ; cyl 0 mov cl,1 ; sector 1 is first mov al,1 ; just 1 sector lea bx,Buffer ; ES:BX is buffer int 13h jc BootTrouble ret PutBoot endp ;=============================================================== FileTrouble proc near lea dx,FileTroubleMsg ; display file trouble call Say jmp Abort FileTrouble endp BootTrouble proc near lea dx,BootTroubleMsg ; display problems reading boot sector call Say jmp Abort BootTrouble endp SyntaxTrouble proc near lea dx,BannerMsg call Say ; always display banner on syntax error error lea dx,UsageMsg ; display usage message call Say jmp Abort SyntaxTrouble endp GeomTrouble proc near lea dx,GeomMsg ; display geometry trouble call Say jmp Abort GeomTrouble endp abort proc near ; error exit mov ax, 4c04h ; ERRORLEVEL = 4 int 21h ; DIE abort endp ;=============================================================== include bootinc0.asm include bootinc1.asm ;=============================================================== CODE ends ; end of code segment end _Start