;*****************************
;MBR Restore Utility 
;*****************************
;by Evil-E [CodeBreakers]

MODEL TINY
CODESEG
STARTUPCODE

mov     ah,9              ; display copyright text :-)
mov     dx,offset msg
int     21h

mov     ax,3D00h          ; open boot.bin for reading
mov     dx,offset file
int     21h
jc      error             ; error opening file ?
xchg    bx,ax             ; put file handle in bx

mov     ah,3Fh            ; read file into buffer
mov     cx,512
mov     dx,offset Buffer
int     21h

mov     ah,3eh            ; close file ;)
int     21h

xor     ax,ax             ; reset Disksystem
mov     dl,80h
int     13h

mov     bp,4              ; write MBR four times ...
write:
mov     ax,0301h          ; write buffer to the Harddisk MBR
mov     dx,0080h          ; Head 0, Harddisk
mov     cx,1              ; track 0, sector 1
mov     bx, offset buffer 
int     13h
dec     bp
jnz     write

int     20h               ; return to DOS ...

error:
mov     ah,9              ; display error message
mov     dx,offset error_msg
int     21h
int     20h               ; return to DOS ...

file       db 'BOOT.BIN',0  
msg        db 'RESTORE Version 1.0 by Evil-E [CB] (c) 1998',13,10
           db '-------------------------------------------',13,10
           db 'Now restoring MBR to HD...$',13,10
error_msg  db 'Error reading boot.bin !$'
buffer     db 512 dup (0)
END
