page 60,132 NAME bootchk title BootChk check that the Master boot sector has not changed. 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 How to Assemble *************** Use the ANT script or to assemble with MASM 6.0 use: ml.exe /AT /c /Fl /Zf bootchk.asm link.exe /TINY /MAP bootchk.obj,bootchk.com,bootchk.map; to assemble with OPTASM use: optasm bootchk.asm,bootchk.obj,bootchk.lst/L/N/G/S olink bootchk.obj,bootchk.com,/MAP/TINY; | ; 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 DB '°±²Û BootChk 2.9 Û²±°',13d,10d db 13d,10d db 'Ensures hard disk master boot sector not corrupted or changed.',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 'BootChk A:\Boot.Sav',13,10 db 'or if you have the file on hard disk try:',13,10 db 'BootChk C:\SAFE\Boot.Sav',13,10 db 'BootChk 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 '$' 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 read the boot sector from the hard disk.',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 'Try using CMOSREST to fix your CMOS.',13,10 db '$' MatchTroubleMsg db '°±²Û Error Û²±°',7,13,10 db 'Hard disk master boot sector has been corrupted!',13,10 db '$' WorkedMsg db 'Hard disk master boot sector is OK, i.e. unchanged since the last BootSave.',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 Duplicate ; make copy in Buffer2 call GetBoot ; get current boot into Buffer call CompareBoot ; compare buffer with Buffer2 lea dx,WorkedMsg ; crow about success call SayQ Done: mov ax,4c00h int 21h ;normal termination _Start endp ;=============================================================== CompareBoot proc near ; compares buffer version of Boot with contents of actual Boot ; Aborts if finds a mismatch lea si,Buffer lea di,Buffer2 mov cx,512/2 repe cmpsw ; keep looking as long as same. jne MatchTrouble ret CompareBoot endp ;=============================================================== Duplicate proc near ; Make a duplicate copy of Buffer in Buffer2 lea si,Buffer lea di,Buffer2 mov cx,512/2 rep movsw ret Duplicate 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 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 MatchTrouble proc near lea dx,MatchTroubleMsg ; display Boot mismatch call Say mov ax, 4c01h ; ERRORLEVEL = 1 int 21h ; DIE MatchTrouble 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