home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
POLYBOOT.ZIP
/
PATCH401.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-09-16
|
11KB
|
435 lines
;*************************************************************************
;* *
;* #MODUL: PATCH401 *
;* *
;* #Aufgabe: Programm zum Patch von DOS 4.01 Systemdateien für *
;* POLYBOOT *
;* #Inhalt: *
;* *
;* #Fehlerbehandlung: - *
;* *
;*************************************************************************
bell equ 7
cr equ 0dh
lf equ 0ah
escchr equ 1bh
BYTCNT equ 20
code segment
assume cs:code, ds:code, es:nothing
offs0 label near ;benötigt für Adressberechnungen
org 100h
_main: cld
mov ax,ds
mov es,ax
mov si,80h
lodsb
mov cl,al
mov ch,0
mov byte ptr [drive],0FFh
patch01: jcxz patch03
lodsb
dec cx
cmp al,' '
je patch01
cmp al,'z'
ja usage
cmp al,'a'
jb patch02
and al,011011111b
patch02: cmp al,'Z'
ja usage
sub al,'A'
jb usage
cmp byte ptr[drive],0FFh
jne usage
mov byte ptr[drive],al
lodsb
dec cx
cmp al,':'
je patch01
usage: mov dx,offset [usemsg]
patcherr: mov ah,9
int 21h
mov ax,4C01h
int 21h
nothat: mov dx,offset [nosudr1]
mov ah,9
int 21h
mov dl,byte ptr [drive]
add dl,'A'
mov ah,2
int 21h
mov dx,offset [nosudr2]
jmp patcherr
patch03: cmp byte ptr[drive],0FFh
je usage
mov ah,8
mov dl,80h
int 13h
jnc @F
mov dl,0
@@: int 11h
rol al,1
rol al,1
and al,3
jnz patch04
inc ax
patch04: mov ah,byte ptr[drive]
sub ah,al
ja @F
push ax
mov dx,offset [nohard]
mov ah,9
int 21h
pop ax
mov ah,0
@@: mov byte ptr [hd_nro],ah
add al,dl
cmp byte ptr [drive],al
ja nothat
call testbio
jc noibm
call testdos
jnc patch05
noibm: mov dx,offset [ibmerr]
jmp patcherr
patch05: mov al,byte ptr [drive]
mov bx,offset [buffer]
mov cx,1
mov dx,0 ;read boot sector
int 25h
popf
mov ax,32
mul word ptr[bx+11h]
mov cx,word ptr[bx+0Bh]
add ax,cx
dec ax
div cx
mov word ptr[bioanf],ax
mov al,byte ptr[bx+0Dh]
cbw
mov word ptr[dosanf],ax
mov al,byte ptr [bx+10h]
cbw
mul word ptr [bx+16h]
add ax,word ptr [bx+0Eh]
add word ptr[bioanf],ax
mov dx,ax
mov cx,1
mov al,byte ptr [drive]
int 25h
popf
mov di,bx
mov cx,11
mov si,offset [ibmbio]
rep cmpsb
jnz notboot
lea di,[bx+20h]
mov cx,11
mov si,offset [ibmdos]
rep cmpsb
jz patch06
notboot: mov dx,offset [syserr]
jmp patcherr
patch06: mov ax,word ptr [bx+3Ah]
sub ax,2
mul word ptr [dosanf]
add ax,word ptr [bioanf]
mov word ptr [dosanf],ax
;--- compare sector and file-oriented read bytes
mov ah,0
call openbio
jc notboot
mov ax,word ptr [bioanf]
mov word ptr [cursec],ax
patch07: mov bx,word ptr [handle]
mov cx,12
mov dx,offset [buffer2]
mov ah,3Fh
int 21h
jc susperr
and ax,ax
jz patch08
push ax
call readsec
jc susperr
pop cx
mov si,offset [buffer]
mov di,offset [buffer2]
rep cmpsb
jnz notboot
mov dx,500
mov cx,0
mov bx,word ptr [handle]
mov ax,4201h
int 21h
jnc patch07
susperr: mov dx,offset [interr]
jmp patcherr
patch08: call closefl
mov ax,word ptr [dosanf]
cmp word ptr [cursec],ax
jnc patch09
mov word ptr [cursec],ax
mov ah,0
call opendos
jnc patch07
jmp notboot
patch09: mov byte ptr [buffer2],0
mov ah,0 ;READ ONLY
call openbio
jc susperr
mov si,offset [hd1org]
call testfl
jnc patch10
or byte ptr [buffer2],1
mov ah,0 ;READ ONLY
call openbio
jc susperr
mov si,offset [hd1pat]
call testfl
jnc patch10
jmp noibm
patch10: mov ah,0 ;READ ONLY
call openbio
jc susperr
mov si,offset [hd2org]
call testfl
jnc patch11
or byte ptr [buffer2],2
mov ah,0 ;READ ONLY
call openbio
jc susperr
mov si,offset [hd2pat]
call testfl
jnc patch11
jmp noibm
patch11: mov al,byte ptr [hd_nro]
xor al,byte ptr [buffer2]
jnz patch12
mov dx,offset [nopatch]
jmp patcherr
patch12: mov byte ptr [buffer2],al
mov dx,82h
mov ax,4300h ;GET ATTRIBUTES
int 21h
mov word ptr [cursec],cx
and cx,0FFE6h ;NO SUBDIR, NO VOL_ID, NO READ_ONLY
mov dx,82h
mov ax,4301h ;SET ATTRIBUTES
int 21h
mov ah,2 ;READ/WRITE
call openbio
test byte ptr [buffer2],1
jz patch14
mov si,offset [hd1org]
test byte ptr [hd_nro],1
jz patch13
mov si,offset [hd1pat]
patch13: call patcher
jnc patch14
jmp susperr
patch14: test byte ptr [buffer2],2
jz patch16
mov si,offset [hd2org]
test byte ptr [hd_nro],2
jz patch15
mov si,offset [hd2pat]
patch15: call patcher
jnc patch16
jmp susperr
patch16: call closefl
mov cx,word ptr [cursec]
and cx,0FFE7h ;NO SUBDIR, NO VOL_ID
mov dx,82h
mov ax,4301h ;SET ATTRIBUTES
int 21h
mov dx,offset [succmsg]
mov ah,9
int 21h
exit: mov ax,4C00h
int 21h
;------------------------------------------------------------
; READSEC: Liest Sektor (in CURSEC) in Buffer ein.
;------------------------------------------------------------
readsec: mov al,byte ptr [drive]
mov bx,offset [buffer]
mov cx,1
mov dx,word ptr [cursec]
int 25h
popf
jc endrsec
inc word ptr [cursec]
endrsec: ret
;------------------------------------------------------------
; TESTXXX: Testet IBMBIO und IBMDOS auf Version 4.01
;------------------------------------------------------------
testbio: mov ah,0 ; READ-ONLY
call openbio
mov si,offset [biocmp]
jmp testfl
testdos: mov ah,0 ; READ-ONLY
call opendos
mov si,offset [doscmp]
testfl: jc teste2
lodsw
mov dx,ax
mov cx,0
mov bx,word ptr [handle]
mov ax,4200h
int 21h
jc teste1
mov cx,word ptr[si]
mov dx,offset [buffer]
mov ah,3Fh
int 21h
jc teste1
mov cx,ax
lodsw
cmp ax,cx
jne teste1
mov di,offset [buffer]
rep cmpsb
jnz teste1
call closefl
ret
teste1: call closefl
teste2: stc
ret
;------------------------------------------------------------
; OPENXXX: Öffnet IBMBIO und IBMDOS
;------------------------------------------------------------
openbio: mov si,offset [biopath]
jmp openfl
opendos: mov si,offset [dospath]
openfl: mov di,84h
openfl1: lodsb
stosb
and al,al
jnz openfl1
mov dx,82h
mov al,ah
mov ah,3Dh
int 21h
jc openex
mov word ptr [handle],ax
openex: ret
;------------------------------------------------------------
; CLOSEFL: Schliesst IBMBIO und IBMDOS
;------------------------------------------------------------
closefl: mov bx,word ptr [handle]
mov ah,3Eh
ret
;------------------------------------------------------------
; PATCHER: Führt Patch durch
;------------------------------------------------------------
patcher: lodsw
mov dx,ax
mov cx,0
mov bx,word ptr [handle]
mov ax,4200h
int 21h
jc patche1
mov cx,word ptr[si]
lea dx,[si+2]
mov ah,40h
int 21h
jc patche1
cmp ax,word ptr [si]
je patche2
patche1: stc
patche2: ret
;------------------------------------------------------------
; Datenbereich fuer PATCH
;------------------------------------------------------------
usemsg: DB 'USAGE: PATCH401 d:',0Dh,0Ah,0Ah
DB 'Drive d: must be a physical harddisc drive or Floppy Disk',0Dh,0Ah,24h
nohard: DB 'This is not a harddisc drive - patching reversed for Floppy boot',0Dh,0Ah,24h
nosudr1: DB 'Drive $'
nosudr2: DB ': is not a physical harddisc drive',0Dh,0Ah,24h
syserr: DB 'DOS is not bootable (not transferred by SYS)',0Dh,0Ah,24h
ibmerr: DB 'DOS is not IBM PC-DOS 4.01',0Dh,0Ah,24h
nopatch: DB 'Patch already made, no further patch necessary !',0Dh,0Ah,24h
interr: DB 'Internal Error - Please Contact Markus Noller, W. Germany (07191) 59110 !',0Dh,0Ah,24h
succmsg: DB 'PC-DOS 4.01 successfully patched',0Dh,0Ah,24h
ibmbio: DB 'IBMBIO COM'
ibmdos: DB 'IBMDOS COM'
biopath: DB '\IBMBIO.COM',0
dospath: DB '\IBMDOS.COM',0
biocmp: DW 08021h ;Offset
DW 07h ;Länge
DB ' 4.00',0Dh,0Ah
doscmp: DW 08C87h ;Offset
DW 07h ;Länge
DB ' 4.00',0Dh,0Ah
hd1org: DW 7B49h ;Offset
DW 0Ch ;Länge
DB '\CONFIG.SYS',0
hd1pat: DW 7B49h ;Offset
DW 0Ch ;Länge
DB '\CONFIG.DOS',0
hd2org: DW 36CAh ;Offset
DW 14h ;Länge
DB 0D0h, 0C0h, 025h, 003h
DB 000h, 075h, 006h, 040h
DB 02Eh, 0FEh, 006h, 0C4h
DB 001h, 040h, 08Ah, 0C8h
DB 0F6h, 0C2h, 080h, 075h
hd2pat: DW 36CAh ;Offset
DW 14h ;Länge
DB 0D0h, 0C0h, 024h, 003h
DB 075h, 006h, 040h, 02Eh
DB 0FEh, 006h, 0C4h, 001h
DB 040h, 08Ah, 0C8h, 040h
DB 0F6h, 0C2h, 080h, 075h
bioanf: DW 0
dosanf: DW 0
handle: DW 0
cursec: DW 0
drive: DB 0
hd_nro: DB 0
buffer: DB 512 dup (?)
buffer2: DB 12 dup (?)
code ends
end _main