[arachne] The fixup for accessing "inaccessible" drives
- From: Andrej Cuckov <andrej@xxxxxxxxxxxxxx>
- To: ArachneDevelopment@xxxxxxxxxxxxxxx, arachne <arachne@xxxxxxxxxxxxx>
- Date: Mon, 07 Nov 2005 14:40:59 +0000
Hello from andrej,
i made something today, to start the week in a good mood.
enjoy.
regards to all,
andrej cuckov
/*---------------------------
INT 24 handler for Arachne
by A. Cuckov 7 Nov 2005, sunny Lisboa, Portugal.
1. include this file (INT24.C) in the project (you also need INT24.H)
and do not overay this module.
2. modify in INIT.C to have a call to Install_Our_Nice_Int_24_handler()
like this:
#ifndef POSIX
#include "int24.h"
Install_Our_Nice_Int_24_handler();
#endif
in the Initialize_Arachne(...) section
3. enjoy !
----------------------------*/
#include <dos.h>
#ifndef POSIX
// glob
void Install_Our_Nice_Int_24_handler(void); // call it from init.c !!!
/*
According to the documentation of what int 24 handler does,
in short (my opinion) it is like the following example:
You call int 21 with a funcion to say read a file.
Int 21 handler will workout from where to read this file by executing
the right software for the device driver that "drives' the file.
The device driver will issue int 24h in case it has "serious" problems
with the hardware. (because it is a "serious business" believe it or not)
The "default" int 24 handler (it comes from DOS, not BIOS), will
issue a message "Abort, retry, fail?" and read a key.
:---(((
This is not what we want here, as our Arachne gets interrupted.
It would be better that we do not get this interruption, but produce
a silent error which Arachne will treat as a file reading error,
pretty much as a dropout of comms line while we receive a file from www.
According to the Int 24h documentation, if we take over this interrupt
we can do our own error handling and we can return value in AL to the
caller of the Int 24h with the following meaning:
AL=0: ingnore the error
AL=1: retry the operation
AL=2: abort (that is: abort the application Arachne via int
23h=Ctrl-Break)
AL=3: return to the application indicating failed DOS function.
Right'o daarling !
I take the option AL=3, please.
We write our INT 24h handler and return AL=3 to the caller.
*/
void interrupt Our_Nice_Int_24_handler()
{
asm {
//On stack are "our" saved registers, as the "interrupt" directive generated
code for them
//They are es ds bp di si dx cx bx ax (es at lowest, ax highest)
//We will modify the stacked AL to value of 3.
mov bp,sp //establish local addressibility on the stack
mov ax,[bp+16] //that's where AX is
mov al,3
mov [bp+16],ax //store back
}
/*
Well folks, what happens now is what our nice c compiler does for us,
and that is to pop all the registers from the stack and do IRET.
However as we have fixed the AL on the stack with the magic "3",
we will after this comment never get "Abort, retry, fail?".
My pleasure.
Andrej Cuckov 7 Nov 2005.
*/
}
void Install_Our_Nice_Int_24_handler()
{
disable();
poke(0, 4 * 0x24 + 0, FP_OFF(Our_Nice_Int_24_handler));
poke(0, 4 * 0x24 + 2, FP_SEG(Our_Nice_Int_24_handler));
enable();
/*
NB. It is not necessary to uninstall int 24,
as any .exe program will restore the int 24 from PSP upon exit.
*/
}
#endif
void Install_Our_Nice_Int_24_handler(void);
- Follow-Ups:
- [arachne] Global fixup for accessing "inaccessible" drives without prompt
- From: Andrej Cuckov
Other related posts:
- » [arachne] The fixup for accessing "inaccessible" drives
- [arachne] Global fixup for accessing "inaccessible" drives without prompt
- From: Andrej Cuckov