2 * VWIN32 VxD implementation
4 * Copyright 1998 Marcus Meissner
5 * Copyright 1998 Ulrich Weigand
6 * Copyright 1998 Patrik Stridvall
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(vxd);
32 typedef struct tagDIOCRegs {
40 } DIOC_REGISTERS, *PDIOC_REGISTERS;
42 #define VWIN32_DIOC_DOS_IOCTL 1 /* This is the specified MS-DOS device I/O ctl - Interrupt 21h Function 4400h - 4411h */
43 #define VWIN32_DIOC_DOS_INT25 2 /* This is the Absolute Disk Read command - Interrupt 25h */
44 #define VWIN32_DIOC_DOS_INT26 3 /* This is the Absolute Disk Write command - Interrupt 25h */
45 #define VWIN32_DIOC_DOS_INT13 4 /* This is Interrupt 13h commands */
46 #define VWIN32_DIOC_SIMCTRLC 5 /* Simulate Ctrl-C */
47 #define VWIN32_DIOC_DOS_DRIVEINFO 6 /* This is Interrupt 21h Function 730X commands */
50 typedef struct tagMID {
54 BYTE midFileSysType[8];
58 extern void __wine_call_int_handler( CONTEXT *context, BYTE intnum );
60 /* Pop a DWORD from the 32-bit stack */
61 static inline DWORD stack32_pop( CONTEXT86 *context )
63 DWORD ret = *(DWORD *)context->Esp;
64 context->Esp += sizeof(DWORD);
68 static void DIOCRegs_2_CONTEXT( DIOC_REGISTERS *pIn, CONTEXT86 *pCxt )
70 memset( pCxt, 0, sizeof(*pCxt) );
71 /* Note: segment registers == 0 means that CTX_SEG_OFF_TO_LIN
72 will interpret 32-bit register contents as linear pointers */
74 pCxt->ContextFlags=CONTEXT86_INTEGER|CONTEXT86_CONTROL;
75 pCxt->Eax = pIn->reg_EAX;
76 pCxt->Ebx = pIn->reg_EBX;
77 pCxt->Ecx = pIn->reg_ECX;
78 pCxt->Edx = pIn->reg_EDX;
79 pCxt->Esi = pIn->reg_ESI;
80 pCxt->Edi = pIn->reg_EDI;
82 /* FIXME: Only partial CONTEXT86_CONTROL */
84 pCxt->EFlags = pIn->reg_Flags & ~0x00020000; /* clear vm86 mode */
87 static void CONTEXT_2_DIOCRegs( CONTEXT86 *pCxt, DIOC_REGISTERS *pOut )
89 memset( pOut, 0, sizeof(DIOC_REGISTERS) );
91 pOut->reg_EAX = pCxt->Eax;
92 pOut->reg_EBX = pCxt->Ebx;
93 pOut->reg_ECX = pCxt->Ecx;
94 pOut->reg_EDX = pCxt->Edx;
95 pOut->reg_ESI = pCxt->Esi;
96 pOut->reg_EDI = pCxt->Edi;
98 /* FIXME: Only partial CONTEXT86_CONTROL */
99 pOut->reg_Flags = pCxt->EFlags;
102 /***********************************************************************
103 * DeviceIoControl (VWIN32.VXD.@)
105 BOOL WINAPI VWIN32_DeviceIoControl(DWORD dwIoControlCode,
106 LPVOID lpvInBuffer, DWORD cbInBuffer,
107 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
108 LPDWORD lpcbBytesReturned, LPOVERLAPPED lpOverlapped)
110 switch (dwIoControlCode)
112 case VWIN32_DIOC_DOS_IOCTL:
113 case 0x10: /* Int 0x21 call, call it VWIN_DIOC_INT21 ? */
114 case VWIN32_DIOC_DOS_INT13:
115 case VWIN32_DIOC_DOS_INT25:
116 case VWIN32_DIOC_DOS_INT26:
117 case 0x29: /* Int 0x31 call, call it VWIN_DIOC_INT31 ? */
118 case VWIN32_DIOC_DOS_DRIVEINFO:
121 DIOC_REGISTERS *pIn = lpvInBuffer;
122 DIOC_REGISTERS *pOut = lpvOutBuffer;
125 TRACE( "Control '%s': "
126 "eax=0x%08x, ebx=0x%08x, ecx=0x%08x, "
127 "edx=0x%08x, esi=0x%08x, edi=0x%08x\n",
128 (dwIoControlCode == VWIN32_DIOC_DOS_IOCTL)? "VWIN32_DIOC_DOS_IOCTL" :
129 (dwIoControlCode == VWIN32_DIOC_DOS_INT25)? "VWIN32_DIOC_DOS_INT25" :
130 (dwIoControlCode == VWIN32_DIOC_DOS_INT26)? "VWIN32_DIOC_DOS_INT26" :
131 (dwIoControlCode == VWIN32_DIOC_DOS_DRIVEINFO)? "VWIN32_DIOC_DOS_DRIVEINFO" : "???",
132 pIn->reg_EAX, pIn->reg_EBX, pIn->reg_ECX,
133 pIn->reg_EDX, pIn->reg_ESI, pIn->reg_EDI );
135 DIOCRegs_2_CONTEXT( pIn, &cxt );
137 switch (dwIoControlCode)
139 case VWIN32_DIOC_DOS_IOCTL: /* Call int 21h */
140 case 0x10: /* Int 0x21 call, call it VWIN_DIOC_INT21 ? */
141 case VWIN32_DIOC_DOS_DRIVEINFO: /* Call int 21h 730x */
144 case VWIN32_DIOC_DOS_INT13:
147 case VWIN32_DIOC_DOS_INT25:
150 case VWIN32_DIOC_DOS_INT26:
153 case 0x29: /* Int 0x31 call, call it VWIN_DIOC_INT31 ? */
158 __wine_call_int_handler( &cxt, intnum );
159 CONTEXT_2_DIOCRegs( &cxt, pOut );
163 case VWIN32_DIOC_SIMCTRLC:
164 FIXME( "Control VWIN32_DIOC_SIMCTRLC not implemented\n");
168 FIXME( "Unknown Control %d\n", dwIoControlCode);
174 /***********************************************************************
175 * VxDCall (VWIN32.VXD.@)
177 * Service numbers taken from page 448 of Pietrek's "Windows 95 System
178 * Programming Secrets". Parameters from experimentation on real Win98.
181 DWORD WINAPI VWIN32_VxDCall( DWORD service, CONTEXT86 *context )
183 switch ( LOWORD(service) )
185 case 0x0000: /* GetVersion */
187 DWORD vers = GetVersion();
188 return (LOBYTE(vers) << 8) | HIBYTE(vers);
190 case 0x0020: /* Get VMCPD Version */
192 DWORD parm = stack32_pop(context);
194 FIXME("Get VMCPD Version(%08x): partial stub!\n", parm);
196 /* FIXME: This is what Win98 returns, it may
197 * not be correct in all situations.
198 * It makes Bleem! happy though.
202 case 0x0029: /* Int31/DPMI dispatch */
204 DWORD callnum = stack32_pop(context);
205 DWORD parm = stack32_pop(context);
207 TRACE("Int31/DPMI dispatch(%08x)\n", callnum);
209 context->Eax = callnum;
211 __wine_call_int_handler( context, 0x31 );
212 return LOWORD(context->Eax);
214 case 0x002a: /* Int41 dispatch - parm = int41 service number */
216 DWORD callnum = stack32_pop(context);
217 return callnum; /* FIXME: should really call INT_Int41Handler() */
220 FIXME("Unknown service %08x\n", service);