d3dx9_42: Implement d3dx9_42 and forward the functions to d3dx9_36.
[wine.git] / dlls / vwin32.vxd / vwin32.c
blobba78f74b945c39bf7f253a1a98dde86c1bac1bc4
1 /*
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
23 #include <stdarg.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winioctl.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(vxd);
32 typedef struct tagDIOCRegs {
33 DWORD reg_EBX;
34 DWORD reg_EDX;
35 DWORD reg_ECX;
36 DWORD reg_EAX;
37 DWORD reg_EDI;
38 DWORD reg_ESI;
39 DWORD reg_Flags;
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 */
49 #include <pshpack1.h>
50 typedef struct tagMID {
51 WORD midInfoLevel;
52 DWORD midSerialNum;
53 BYTE midVolLabel[11];
54 BYTE midFileSysType[8];
55 } MID, *PMID;
56 #include <poppack.h>
58 typedef void (WINAPI *CallBuiltinHandler)( CONTEXT *context, BYTE intnum );
60 static CallBuiltinHandler load_builtin_handler(void)
62 static CallBuiltinHandler handler;
63 static BOOL init_done;
65 if (!init_done)
67 HMODULE mod = LoadLibraryA( "winedos.dll" );
68 if (mod) handler = (void *)GetProcAddress( mod, "CallBuiltinHandler" );
69 if (!handler) FIXME( "DOS calls not supported\n" );
70 init_done = TRUE;
72 return handler;
75 /* Pop a DWORD from the 32-bit stack */
76 static inline DWORD stack32_pop( CONTEXT86 *context )
78 DWORD ret = *(DWORD *)context->Esp;
79 context->Esp += sizeof(DWORD);
80 return ret;
83 static void DIOCRegs_2_CONTEXT( DIOC_REGISTERS *pIn, CONTEXT86 *pCxt )
85 memset( pCxt, 0, sizeof(*pCxt) );
86 /* Note: segment registers == 0 means that CTX_SEG_OFF_TO_LIN
87 will interpret 32-bit register contents as linear pointers */
89 pCxt->ContextFlags=CONTEXT86_INTEGER|CONTEXT86_CONTROL;
90 pCxt->Eax = pIn->reg_EAX;
91 pCxt->Ebx = pIn->reg_EBX;
92 pCxt->Ecx = pIn->reg_ECX;
93 pCxt->Edx = pIn->reg_EDX;
94 pCxt->Esi = pIn->reg_ESI;
95 pCxt->Edi = pIn->reg_EDI;
97 /* FIXME: Only partial CONTEXT86_CONTROL */
99 pCxt->EFlags = pIn->reg_Flags & ~0x00020000; /* clear vm86 mode */
102 static void CONTEXT_2_DIOCRegs( CONTEXT86 *pCxt, DIOC_REGISTERS *pOut )
104 memset( pOut, 0, sizeof(DIOC_REGISTERS) );
106 pOut->reg_EAX = pCxt->Eax;
107 pOut->reg_EBX = pCxt->Ebx;
108 pOut->reg_ECX = pCxt->Ecx;
109 pOut->reg_EDX = pCxt->Edx;
110 pOut->reg_ESI = pCxt->Esi;
111 pOut->reg_EDI = pCxt->Edi;
113 /* FIXME: Only partial CONTEXT86_CONTROL */
114 pOut->reg_Flags = pCxt->EFlags;
117 /***********************************************************************
118 * DeviceIoControl (VWIN32.VXD.@)
120 BOOL WINAPI VWIN32_DeviceIoControl(DWORD dwIoControlCode,
121 LPVOID lpvInBuffer, DWORD cbInBuffer,
122 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
123 LPDWORD lpcbBytesReturned, LPOVERLAPPED lpOverlapped)
125 switch (dwIoControlCode)
127 case VWIN32_DIOC_DOS_IOCTL:
128 case 0x10: /* Int 0x21 call, call it VWIN_DIOC_INT21 ? */
129 case VWIN32_DIOC_DOS_INT13:
130 case VWIN32_DIOC_DOS_INT25:
131 case VWIN32_DIOC_DOS_INT26:
132 case 0x29: /* Int 0x31 call, call it VWIN_DIOC_INT31 ? */
133 case VWIN32_DIOC_DOS_DRIVEINFO:
135 CONTEXT86 cxt;
136 DIOC_REGISTERS *pIn = lpvInBuffer;
137 DIOC_REGISTERS *pOut = lpvOutBuffer;
138 BYTE intnum = 0;
139 CallBuiltinHandler handler;
141 if (!(handler = load_builtin_handler()))
143 pOut->reg_Flags |= 0x0001;
144 return FALSE;
147 TRACE( "Control '%s': "
148 "eax=0x%08x, ebx=0x%08x, ecx=0x%08x, "
149 "edx=0x%08x, esi=0x%08x, edi=0x%08x\n",
150 (dwIoControlCode == VWIN32_DIOC_DOS_IOCTL)? "VWIN32_DIOC_DOS_IOCTL" :
151 (dwIoControlCode == VWIN32_DIOC_DOS_INT25)? "VWIN32_DIOC_DOS_INT25" :
152 (dwIoControlCode == VWIN32_DIOC_DOS_INT26)? "VWIN32_DIOC_DOS_INT26" :
153 (dwIoControlCode == VWIN32_DIOC_DOS_DRIVEINFO)? "VWIN32_DIOC_DOS_DRIVEINFO" : "???",
154 pIn->reg_EAX, pIn->reg_EBX, pIn->reg_ECX,
155 pIn->reg_EDX, pIn->reg_ESI, pIn->reg_EDI );
157 DIOCRegs_2_CONTEXT( pIn, &cxt );
159 switch (dwIoControlCode)
161 case VWIN32_DIOC_DOS_IOCTL: /* Call int 21h */
162 case 0x10: /* Int 0x21 call, call it VWIN_DIOC_INT21 ? */
163 case VWIN32_DIOC_DOS_DRIVEINFO: /* Call int 21h 730x */
164 intnum = 0x21;
165 break;
166 case VWIN32_DIOC_DOS_INT13:
167 intnum = 0x13;
168 break;
169 case VWIN32_DIOC_DOS_INT25:
170 intnum = 0x25;
171 break;
172 case VWIN32_DIOC_DOS_INT26:
173 intnum = 0x26;
174 break;
175 case 0x29: /* Int 0x31 call, call it VWIN_DIOC_INT31 ? */
176 intnum = 0x31;
177 break;
180 handler( &cxt, intnum );
181 CONTEXT_2_DIOCRegs( &cxt, pOut );
183 return TRUE;
185 case VWIN32_DIOC_SIMCTRLC:
186 FIXME( "Control VWIN32_DIOC_SIMCTRLC not implemented\n");
187 return FALSE;
189 default:
190 FIXME( "Unknown Control %d\n", dwIoControlCode);
191 return FALSE;
196 /***********************************************************************
197 * VxDCall (VWIN32.VXD.@)
199 * Service numbers taken from page 448 of Pietrek's "Windows 95 System
200 * Programming Secrets". Parameters from experimentation on real Win98.
203 DWORD WINAPI VWIN32_VxDCall( DWORD service, CONTEXT86 *context )
205 switch ( LOWORD(service) )
207 case 0x0000: /* GetVersion */
209 DWORD vers = GetVersion();
210 return (LOBYTE(vers) << 8) | HIBYTE(vers);
212 case 0x0020: /* Get VMCPD Version */
214 DWORD parm = stack32_pop(context);
216 FIXME("Get VMCPD Version(%08x): partial stub!\n", parm);
218 /* FIXME: This is what Win98 returns, it may
219 * not be correct in all situations.
220 * It makes Bleem! happy though.
222 return 0x0405;
224 case 0x0029: /* Int31/DPMI dispatch */
226 DWORD callnum = stack32_pop(context);
227 DWORD parm = stack32_pop(context);
228 CallBuiltinHandler handler;
230 TRACE("Int31/DPMI dispatch(%08x)\n", callnum);
232 if (!(handler = load_builtin_handler()))
234 context->EFlags |= 0x0001;
235 return 0;
238 context->Eax = callnum;
239 context->Ecx = parm;
240 handler( context, 0x31 );
241 return LOWORD(context->Eax);
243 case 0x002a: /* Int41 dispatch - parm = int41 service number */
245 DWORD callnum = stack32_pop(context);
246 return callnum; /* FIXME: should really call INT_Int41Handler() */
248 default:
249 FIXME("Unknown service %08x\n", service);
250 return 0xffffffff;