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
#include
#include
#include
#include
#include
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 -$$$