home *** CD-ROM | disk | FTP | other *** search
- /*
- LD386.C -- undocumented DOS call from 386|DOS-Extender
-
- Watcom C/386: wcl386 ld386
- 386|DOS-Extender: run386 ld386
- */
-
- #include <stdlib.h>
- #include <stdio.h>
- #include <dos.h>
-
- #ifndef __WATCOMC__
- #error This program requires Watcom C/386
- #endif
-
- typedef struct {
- unsigned short intno, ds, es, fs, gs;
- unsigned eax, edx;
- } RMODE_PARAM_BLOCK;
-
- main()
- {
- RMODE_PARAM_BLOCK rpb;
- union REGS r;
- struct SREGS s;
- char far *doslist;
- unsigned lastdrv;
-
- /* load real-mode param block for INT 21h AH=52h */
- memset(&rpb, 0, sizeof(RMODE_PARAM_BLOCK)); /* zero it out */
- rpb.intno = 0x21;
- rpb.eax = 0x5200;
-
- /* call 386|DOS-Extender service to "Issue Real Mode Interrupt,
- Registers Specified" (INT 21h AX=2511h). */
- r.x.eax = 0x2511;
- r.x.edx = &rpb;
- segread(&s);
- int386x(0x21, &r, &r, &s);
-
- /* use 386|DOS-Extender selector 34h (writeable data segment that
- maps the entire first megabyte of memory used by MS-DOS) */
- doslist = MK_FP(0x34, (rpb.es << 4) + r.x.ebx);
-
- /* we now have protected-mode ptr to DOS List Of Lists --
- use normally */
- lastdrv = doslist[_osmajor==3 && _osminor==0 ? 0x1B : 0x21];
- fputs("LASTDRIVE=", stdout);
- putchar('A' - 1 + lastdrv);
- putchar('\n');
- return lastdrv;
- }
-