To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: GO32 DPMI problem? Date: Sat, 30 Jul 94 16:56:25 +0300 From: eliz AT is DOT elta DOT co DOT il Hi, I need help with simulating int 21h from protected mode. What's wrong with the following program: -------------- file drv.c ---------------------- #include <dir.h> #include <dos.h> #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <dpmi.h> int is_remote_drive(int drv_no) { _go32_dpmi_registers regs; /* INT 21H/AX=4409H returns DX with 12th bit set, if drive is remote. */ regs.h.ah = 0x44; /* IOCTL, Subfunction 09h */ regs.h.al = 9; regs.h.bl = drv_no + 1; /* 0 = default, 1 = 'A', etc. */ _go32_dpmi_simulate_int(0x21, ®s); if (regs.x.flags & 1) { errno = ENODEV; return -1; } if (regs.x.dx & 0x1000) return 1; return 0; } void main(void) { int disk = getdisk(); printf("%d Disk %c: is \n", disk, disk + 'A'); if (is_remote_drive(disk)) puts("a REMOTE disk"); else puts("a LOCAL disk"); exit(0); } -------- end of drv.c ------------------------ If the answer is "Nothing wrong", then why does this program crash my machine? When invoked under DPMI mode of GO32, it causes Exception 12 to QEMM, which prints: Exception 12: [QEMM apology text deleted] Exception #12 at 25DB:06D6, error code: 0000 AX=4409 BX=0003 CX=40DF DX=0000 SI=1902 DI=189C BP=0001 DS=213C ES=0000 SS=1759 SP=0001 Flags=3046 Instruction: 52 06 8A 1E 50 04 32 FF C1 E3 02 8B 97 7F 1D [end of QEMM message] The values of CX, DI and SS vary if I include the is_remote_drive() function in a larger program (this is what I actually am trying to do, not playing with semi-trivial programs), and BP sometimes comes out as 0000, but the other registers always have the shown values. I use QEMM 7.04 and QDPMI 1.05; go32 is 1.11maint5. The AX=4409 and BX=0003 shows that the program crashes somewhere in the process of calling INT 21H with AX=4409, BL=3, which is exactly what I'm trying to do. But why does it crash? Am I missing something? Or is there something wrong with GO32? If the program doesn't crash for you, be sure there is no ``nodpmi'' word in your GO32 environment variable. When ``nodpmi'' *is* set, this small program works OK, but I have other very strange effects, and until the smaller program works under DPMI, I can't continue debugging. Please help!!!! Btw, if it doesn't crash under DPMI either, try playing with the printf() statement: add some more variables to it. At my place, if I delete the %d from the format string and the first occurence of `disk', it works OK. Thanks in advance for any help! Eli Zaretskii For the record, I attach here the contents of my a.bat, c.sys and the output of SET command: -------------------- config.sys ------------------- rem rem ************************************************************************ rem rem On the following QEMM line: rem rem FB:N UFP:N VHI:N F10:N for BodyWorks program not to hang rem rem ************************************************************************ rem rem DEVICE=C:\QEMM\QEMM386.SYS ON MA=0 DEVICE=C:\QEMM\DOSDATA.SYS DEVICE=C:\QEMM\QEMM386.SYS RAM ST:M FB:N UFP:N VHI:N F10:N R:1 DEVICE=C:\QEMM\DOS-UP.SYS @C:\QEMM\DOS-UP.DAT DEVICE=C:\QEMM\LOADHI.SYS /R:1 /SIZE=8592 C:\QEMM\QDPMI.SYS SWAPFILE=DPMI.SWP SWAPSIZE=40000 rem DEVICE=C:\QEMM\LOADHI.SYS /R:1 /SIZE=6176 C:\DOS\RAMDRIVE.SYS 1536 /E DEVICE=C:\QEMM\LOADHI.SYS /R:2 /SIZE=2784 C:\BIN\SRDEMSS.SYS DOS=HIGH FILES=8 BUFFERS=15 STACKS=9,256 rem LASTDRIVE=M DEVICE=c:\qemm\loadhi.sys /r:2 /size=2592 c:\usr\hardw\superio\dc2000.sys /t SHELL=c:\qemm\loadhi.com /r:2 /envhi c:\dos\command.com c:\dos /P /E:1536 /F ------------- autoexec.bat ------------------------- @ECHO OFF c:\qemm\loadhi /r:2 c:\bin\watch c:\qemm\loadhi /r:2 c:\dos\smartdrv.exe 2048 c:\qemm\loadhi /r:2 c:\qemm\files=30 c:\qemm\loadhi /r:2 c:\bin\anarkey -a1000 -h3000 -e -iof -x\ -xbak -$$$ <c:\anarkey.inp C:\QEMM\LOADHI /R:2 C:\WINDOWS\mouse.COM /Y rem c:\usr\hardw\mouse\mouse.com c:\qemm\loadhi /r:1 c:\bin\pcspool /i /1 /dc:\tmp c:\qemm\loadhi /r:2 c:\bin\chi\vegainit -v set EXPLOSIV=c:\bin\explosiv c:\qemm\loadhi /r:2 c:\bin\explosiv - c:\bin\load \anarkey.ini c:\bin\srdisk /e 512 c:\dos\smartdrv.exe %SRDISK1%- /q PATH C:\BIN\GCC\BIN;C:\BIN;C:\DOS;C:\BIN\VIRUS;C:\;C:\WINDOWS;C:\USR\DIC\MI set TMPDIR=%SRDISK1%:/ set GO32=driver c:/bin/gcc/drivers/vga.grd nodpmi call c:\bin\gcc\bin\setdjgpp c:\bin\gcc c:/bin/gcc set 387=YES prompt $p$_) set CHIFILES=C:\BIN\CHI set DSAVER=\BIN\NORTON\fr /SAVE set DPARKER=\BIN\pcpark set PAGER=c:\bin\less set MANPATH=c:\usr\man\ set MANEXT=.hf set EPSILON=-fsc:\tmp -vl40 -e0 -ef0 -x1536k -xu set EPSPATH=c:\bin\epsilon;c:\bin\epsilon\info set EPSDISP=c:\bin\epsilon\oak0x7.b set USERNAME=EZaretskii set TEMP=c:\tmp set INFOPATH=c:/bin/epsilon/info set WBLIB=c:\usr\eli\undoc set DIRCMD=/w/l/o set SCAN=c:\bin\virus\scan.exe set KILL=c:\bin\virus\clean.exe set HELP@=c:\usr\man\anarkey.sum set LESS=-icsqM set EDITOR=mx -p0 set LESSHELP=c:/lib/less.hlp VER cd \hdm hdm -n cd\ cls -------------- output of SET ----------------- COMSPEC=C:\DOS\COMMAND.COM EXPLOSIV=c:\bin\explosiv SRDISK1=D PATH=C:\BIN\GCC\BIN;C:\BIN;C:\DOS;C:\BIN\VIRUS;C:\;C:\WINDOWS;C:\USR\DIC\MI TMPDIR=D:/ GO32=driver c:/bin/gcc/drivers/vga.grd nodpmi BISON_HAIRY=c:/bin/gcc/lib/bison.hairy BISON_SIMPLE=c:/bin/gcc/lib/bison.simple FLEX_SKELETON=c:/bin/gcc/lib/flex.skeleton COMPILER_PATH=c:/bin/gcc/bin C_INCLUDE_PATH=c:/bin/gcc/include CPLUS_INCLUDE_PATH=c:/bin/gcc/cplusinc;c:/bin/gcc/include OBJC_INCLUDE_PATH=c:/bin/gcc/include;c:/bin/gcc/include/objc OBJCPLUS_INCLUDE_PATH=c:/bin/gcc/include;c:/bin/gcc/include/objc LIBRARY_PATH=c:/bin/gcc/lib GO32TMP=c:/bin/gcc/tmp 387=YES PROMPT=$p$_) CHIFILES=C:\BIN\CHI DSAVER=\BIN\NORTON\fr /SAVE DPARKER=\BIN\pcpark PAGER=c:\bin\less MANPATH=c:\usr\man\ MANEXT=.hf EPSILON=-fsc:\tmp -vl40 -e0 -ef0 -x1536k -xu EPSPATH=c:\bin\epsilon;c:\bin\epsilon\info EPSDISP=c:\bin\epsilon\oak0x7.b USERNAME=EZaretskii TEMP=c:\tmp INFOPATH=c:/bin/epsilon/info WBLIB=c:\usr\eli\undoc DIRCMD=/w/l/o SCAN=c:\bin\virus\scan.exe KILL=c:\bin\virus\clean.exe HELP@=c:\usr\man\anarkey.sum LESS=-icsqM EDITOR=mx -p0 LESSHELP=c:/lib/less.hlp