tony@joshua.math.ucla.edu (01/15/89)
I'd like to replace the MS DOS critical error handler with one of my own in a C program I am writing but I can't seem to get it right. I've been trying to use the intdosx() function in MSC 5.1 but after numerous system hang-ups I've decided to ask for help. Can somebidy explain how I can go about doing this in C? I have some code in assembly but I really would like to do it in C.
nts0699@dsacg1.UUCP (Gene McManus) (01/20/89)
From article <336@sunset.MATH.UCLA.EDU>, by tony@joshua.math.ucla.edu: > I'd like to replace the MS DOS critical error handler with one > of my own in a C program I am writing but I can't seem to get it right. > > I've been trying to use the intdosx() function in MSC 5.1 but after > numerous system hang-ups I've decided to ask for help. > > Can somebidy explain how I can go about doing this in C? I have > some code in assembly but I really would like to do it in C. I'm running into the same problems with MSC and INT 24H. I'm presently using a C rewrite of some Pascal code that was in one of the magazines, with no success. Please put me on a response mailing if someone has code that works. Thanx... Gene Gene McManus @ Defense Logistics Agency Systems Automation Center, Columbus, OH 43215 (614) 238-9403, Autovon 850- UUCP: {uunet!gould,cbosgd!osu-cis}!dsacg1!gmcmanus The views expressed are my own, not those of The Agency, or Dept. of Defense
mdfreed@ziebmef.uucp (Mark Freedman) (01/22/89)
In article <336@sunset.MATH.UCLA.EDU> tony@MATH.UCLA.EDU () writes: >I'd like to replace the MS DOS critical error handler with one >of my own in a C program I am writing but I can't seem to get it right. > >I've been trying to use the intdosx() function in MSC 5.1 but after >numerous system hang-ups I've decided to ask for help. > >Can somebidy explain how I can go about doing this in C? I have >some code in assembly but I really would like to do it in C. This seems to work in Turbo C 2.0 (small model). Turbo Debugger seems to have problems with it (fortunately, IBM didn't put a reset button on the PC :-( ). According to Al Stevens' article on writing TSR's (Computer Language March 1988), Quick C generates code for an interrupt function which trashes the ax register upon entry. This might cause some problems (I don't have MSC). He also mentions a problem with _chain_intr. I haven't been able to chain to the old critical error handler without crashing. I suspect that one must to restore everything (including the stack) to its state upon entry. In consideration for my power switch, I'll leave further experimentation as "an excercise for the reader". /********************************************************/ /* Turbo C 2.0 - replace critical error handler (0x24 ) */ #include "dos.h" #include "stdio.h" void interrupt newcrit(bp,di,si,ds,es,dx,cx,bx,ax,ip,cs,flgs) /* These parameters point to the values saved on the stack upon entry, */ /* and popped from the stack before a return-from-interrupt is issued */ { /* an int24 handler can only use DOS functions 0x00 - 0x0c */ do /* display prompt. return key in ax register */ { bdosptr (0x09, "\n\rEnter 0 (ignore), 1(retry), 2(abort): $", 0); bdosptr (0x01, NULL, 0); } while (_AL != '0' && _AL != '1' && _AL != '2'); ax = (_AX & 0x000f); /* al specifies DOS action upon return */ /* values are popped before returning */ } void main() { FILE *in; setvect (0x24, newcrit); fputs ("\n open door of drive a: to cause critical error\n", stderr); in = fopen ("a:zot", "rt"); fputs ("\n back to main AFTER the critical-error handler\n", stderr); }
mason@tc.fluke.COM (Nick Mason) (01/26/89)
In article <622@dsacg1.UUCP> nts0699@dsacg1.UUCP (Gene McManus) writes: >From article <336@sunset.MATH.UCLA.EDU>, by tony@joshua.math.ucla.edu: >> I've been trying to use the intdosx() function in MSC 5.1 but after >> numerous system hang-ups I've decided to ask for help. Well, its very simple with MSC 5.1. Turn to page 348 in the Run-Time reference Manual and observe the _harderr function. It installs your function that you write as the new INT24 routine. You should also look at _dos_setvec. These have saved me a lot of time. (What? You mean you haven't read the manuals?!? |-) ) Nick Mason/ms272G/John Fluke Mfg Co/Box C9090/Everett WA 98206 USA mason@tc.fluke.COM UUCP: {{cornell,decvax,sdcsvax,tektronix,utcsrgv}!uw-beaver} \ {microsoft,gatech!sb1,hplabs!lbl-csam,decwrl!sun,sunup} - !fluke!mason {ssc-vax,hplsla,wavetek,uw-vlsi,tikal} / ARPA: fluke!mason@uw-beaver.ARPA BITNET: "fluke!mason@uw-beaver.ARPA"@PSUVAX1.bitnet "Avoid the Dull and Ignorant"
vic@zen.UUCP (Victor Gavin) (01/28/89)
In article <6734@fluke.COM> mason@tc.fluke.COM (Nick Mason) writes: >In article <622@dsacg1.UUCP> nts0699@dsacg1.UUCP (Gene McManus) writes: >>From article <336@sunset.MATH.UCLA.EDU>, by tony@joshua.math.ucla.edu: >>> I've been trying to use the intdosx() function in MSC 5.1 but after >>> numerous system hang-ups I've decided to ask for help. >You should also look at _dos_setvec. These have saved me a lot of time. >(What? You mean you haven't read the manuals?!? |-) ) Don't be the first to toss a brick, coz someone'll drop a house on you :-) I upgraded from MS C v4.0 to v5.1 and I didn't get any *new* manuals which explain about these new funky library routines. vic