Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.msdos.programmer > #102
| From | pete@nospam.demon.co.uk |
|---|---|
| Newsgroups | comp.os.msdos.programmer |
| Subject | Re: Overriding the Critical Handler |
| Date | 2011-06-04 07:29 +0000 |
| Organization | PDL |
| Message-ID | <1307172579snz@nospam.demon.co.uk> (permalink) |
| References | <6VVFp.26962$ar1.4099@newsfe08.iad> <1307079395snz@nospam.demon.co.uk> |
In article <1307079395snz@nospam.demon.co.uk> pete@nospam.demon.co.uk wrote:
[Some hurriedly written example code which did a half-baked job in
that it only worked for removable drives A: and B:]
Here is a rather better, simpler version of ISDISKIN that ought to
work for any drive...
Usage is:
int result = isdiskavl(drv_num);
where 'drv_num' is 1 for A:, 2 for B:, 3 for C: etc.
------- ISDISKIN.ASM --------
.286c
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _isdiskavl
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_isdiskavl proc near ;small model
push bp
mov bp, sp
push 1 ;default (TRUE) return value at -2[bp]
push ds ;save our DS
mov ax, 3524h ;get critical error vector
int 21h ;
push bx ;save it on stack
push es ;
mov ax, cs ;set DS = CS
mov ds, ax ;
lea dx, criterr ;install our own crit err handler
mov ax, 2524h ;
int 21h ;
mov dx, 4[bp] ;get drive number (A=1, B=2, etc.)
mov ah, 36h ;DOS "get disk free" service
int 21h ;AX set to 0FFFFh if invalid drive
inc ax ;now 0 if error
jne resetv ;so far so good
mov -2[bp], ax ;flag invalid drive
resetv: pop ds ;reset original handler
pop dx
mov ax, 2524h
int 21h
;clean up for exit
pop ds ;restore DS
pop ax ;return value
pop bp ;
ret ;
_isdiskavl endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
criterr proc far
xor ax, ax ;ignore error
iret
criterr endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_TEXT ENDS
END
------- ISDISKIN.ASM --------
This version doesn't rely on the replacement critical error handler
being called (and setting the error flag) but rather checks the result
of the DOS "disk free" service call to work out if the drive is valid.
Apologies if anyone had trouble with the earlier version.
Pete
--
"We have not inherited the earth from our ancestors,
we have borrowed it from our descendants."
Back to comp.os.msdos.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
Overriding the Critical Handler Brian Dude <aaa97@hotSPAM.com> - 2011-06-02 20:28 -0400
Re: Overriding the Critical Handler pete@nospam.demon.co.uk - 2011-06-03 05:36 +0000
Re: Overriding the Critical Handler pete@nospam.demon.co.uk - 2011-06-04 07:29 +0000
Re: Overriding the Critical Handler Brian Dude <aaa97@hotSPAM.com> - 2011-06-07 14:28 -0400
Re: Overriding the Critical Handler pete@nospam.demon.co.uk - 2011-06-08 04:59 +0000
Re: Overriding the Critical Handler Brian Dude <aaa97@hotSPAM.com> - 2011-06-15 20:18 -0400
Re: Overriding the Critical Handler Ross Ridge <rridge@csclub.uwaterloo.ca> - 2011-06-10 11:08 -0400
Re: Overriding the Critical Handler Brian Dude <aaa97@hotSPAM.com> - 2011-06-15 20:22 -0400
Re: Overriding the Critical Handler Ross Ridge <rridge@csclub.uwaterloo.ca> - 2011-06-15 20:41 -0400
Re: Overriding the Critical Handler Brian Dude <aaa97@hotSPAM.com> - 2011-06-16 05:10 -0400
Re: Overriding the Critical Handler Ross Ridge <rridge@csclub.uwaterloo.ca> - 2011-06-16 11:45 -0400
Re: Overriding the Critical Handler Brian Dude <aaa97@hotSPAM.com> - 2011-06-16 20:44 -0400
csiph-web