2 * Win32 device functions
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "wine/port.h"
30 #include <sys/types.h>
44 #include "stackframe.h"
45 #include "wine/server.h"
46 #include "wine/debug.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(file
);
52 static BOOL
DeviceIo_VTDAPI(DWORD dwIoControlCode
,
53 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
54 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
55 LPDWORD lpcbBytesReturned
,
56 LPOVERLAPPED lpOverlapped
);
57 static BOOL
DeviceIo_MONODEBG(DWORD dwIoControlCode
,
58 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
59 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
60 LPDWORD lpcbBytesReturned
,
61 LPOVERLAPPED lpOverlapped
);
62 static BOOL
DeviceIo_MMDEVLDR(DWORD dwIoControlCode
,
63 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
64 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
65 LPDWORD lpcbBytesReturned
,
66 LPOVERLAPPED lpOverlapped
);
68 static DWORD
VxDCall_VMM( DWORD service
, CONTEXT86
*context
);
70 static BOOL
DeviceIo_IFSMgr(DWORD dwIoControlCode
,
71 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
72 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
73 LPDWORD lpcbBytesReturned
,
74 LPOVERLAPPED lpOverlapped
);
76 static BOOL
DeviceIo_VCD(DWORD dwIoControlCode
,
77 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
78 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
79 LPDWORD lpcbBytesReturned
,
80 LPOVERLAPPED lpOverlapped
);
82 static DWORD
VxDCall_VWin32( DWORD service
, CONTEXT86
*context
);
84 static BOOL
DeviceIo_VWin32(DWORD dwIoControlCode
,
85 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
86 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
87 LPDWORD lpcbBytesReturned
,
88 LPOVERLAPPED lpOverlapped
);
90 static BOOL
DeviceIo_PCCARD (DWORD dwIoControlCode
,
91 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
92 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
93 LPDWORD lpcbBytesReturned
,
94 LPOVERLAPPED lpOverlapped
);
96 static BOOL
DeviceIo_HASP (DWORD dwIoControlCode
,
97 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
98 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
99 LPDWORD lpcbBytesReturned
,
100 LPOVERLAPPED lpOverlapped
);
102 * VxD names are taken from the Win95 DDK
109 DWORD (*vxdcall
)(DWORD
, CONTEXT86
*);
110 BOOL (*deviceio
)(DWORD
, LPVOID
, DWORD
,
111 LPVOID
, DWORD
, LPDWORD
, LPOVERLAPPED
);
114 static const struct VxDInfo VxDList
[] =
116 /* Standard VxD IDs */
117 { "VMM", 0x0001, VxDCall_VMM
, NULL
},
118 { "DEBUG", 0x0002, NULL
, NULL
},
119 { "VPICD", 0x0003, NULL
, NULL
},
120 { "VDMAD", 0x0004, NULL
, NULL
},
121 { "VTD", 0x0005, NULL
, NULL
},
122 { "V86MMGR", 0x0006, NULL
, NULL
},
123 { "PAGESWAP", 0x0007, NULL
, NULL
},
124 { "PARITY", 0x0008, NULL
, NULL
},
125 { "REBOOT", 0x0009, NULL
, NULL
},
126 { "VDD", 0x000A, NULL
, NULL
},
127 { "VSD", 0x000B, NULL
, NULL
},
128 { "VMD", 0x000C, NULL
, NULL
},
129 { "VKD", 0x000D, NULL
, NULL
},
130 { "VCD", 0x000E, NULL
, DeviceIo_VCD
},
131 { "VPD", 0x000F, NULL
, NULL
},
132 { "BLOCKDEV", 0x0010, NULL
, NULL
},
133 { "VMCPD", 0x0011, NULL
, NULL
},
134 { "EBIOS", 0x0012, NULL
, NULL
},
135 { "BIOSXLAT", 0x0013, NULL
, NULL
},
136 { "VNETBIOS", 0x0014, NULL
, NULL
},
137 { "DOSMGR", 0x0015, NULL
, NULL
},
138 { "WINLOAD", 0x0016, NULL
, NULL
},
139 { "SHELL", 0x0017, NULL
, NULL
},
140 { "VMPOLL", 0x0018, NULL
, NULL
},
141 { "VPROD", 0x0019, NULL
, NULL
},
142 { "DOSNET", 0x001A, NULL
, NULL
},
143 { "VFD", 0x001B, NULL
, NULL
},
144 { "VDD2", 0x001C, NULL
, NULL
},
145 { "WINDEBUG", 0x001D, NULL
, NULL
},
146 { "TSRLOAD", 0x001E, NULL
, NULL
},
147 { "BIOSHOOK", 0x001F, NULL
, NULL
},
148 { "INT13", 0x0020, NULL
, NULL
},
149 { "PAGEFILE", 0x0021, NULL
, NULL
},
150 { "SCSI", 0x0022, NULL
, NULL
},
151 { "MCA_POS", 0x0023, NULL
, NULL
},
152 { "SCSIFD", 0x0024, NULL
, NULL
},
153 { "VPEND", 0x0025, NULL
, NULL
},
154 { "VPOWERD", 0x0026, NULL
, NULL
},
155 { "VXDLDR", 0x0027, NULL
, NULL
},
156 { "NDIS", 0x0028, NULL
, NULL
},
157 { "BIOS_EXT", 0x0029, NULL
, NULL
},
158 { "VWIN32", 0x002A, VxDCall_VWin32
, DeviceIo_VWin32
},
159 { "VCOMM", 0x002B, NULL
, NULL
},
160 { "SPOOLER", 0x002C, NULL
, NULL
},
161 { "WIN32S", 0x002D, NULL
, NULL
},
162 { "DEBUGCMD", 0x002E, NULL
, NULL
},
164 { "VNB", 0x0031, NULL
, NULL
},
165 { "SERVER", 0x0032, NULL
, NULL
},
166 { "CONFIGMG", 0x0033, NULL
, NULL
},
167 { "DWCFGMG", 0x0034, NULL
, NULL
},
168 { "SCSIPORT", 0x0035, NULL
, NULL
},
169 { "VFBACKUP", 0x0036, NULL
, NULL
},
170 { "ENABLE", 0x0037, NULL
, NULL
},
171 { "VCOND", 0x0038, NULL
, NULL
},
173 { "EFAX", 0x003A, NULL
, NULL
},
174 { "DSVXD", 0x003B, NULL
, NULL
},
175 { "ISAPNP", 0x003C, NULL
, NULL
},
176 { "BIOS", 0x003D, NULL
, NULL
},
177 { "WINSOCK", 0x003E, NULL
, NULL
},
178 { "WSOCK", 0x003E, NULL
, NULL
},
179 { "WSIPX", 0x003F, NULL
, NULL
},
180 { "IFSMgr", 0x0040, NULL
, DeviceIo_IFSMgr
},
181 { "VCDFSD", 0x0041, NULL
, NULL
},
182 { "MRCI2", 0x0042, NULL
, NULL
},
183 { "PCI", 0x0043, NULL
, NULL
},
184 { "PELOADER", 0x0044, NULL
, NULL
},
185 { "EISA", 0x0045, NULL
, NULL
},
186 { "DRAGCLI", 0x0046, NULL
, NULL
},
187 { "DRAGSRV", 0x0047, NULL
, NULL
},
188 { "PERF", 0x0048, NULL
, NULL
},
189 { "AWREDIR", 0x0049, NULL
, NULL
},
191 /* Far East support */
192 { "ETEN", 0x0060, NULL
, NULL
},
193 { "CHBIOS", 0x0061, NULL
, NULL
},
194 { "VMSGD", 0x0062, NULL
, NULL
},
195 { "VPPID", 0x0063, NULL
, NULL
},
196 { "VIME", 0x0064, NULL
, NULL
},
197 { "VHBIOSD", 0x0065, NULL
, NULL
},
199 /* Multimedia OEM IDs */
200 { "VTDAPI", 0x0442, NULL
, DeviceIo_VTDAPI
},
201 { "MMDEVLDR", 0x044A, NULL
, DeviceIo_MMDEVLDR
},
203 /* Network Device IDs */
204 { "VNetSup", 0x0480, NULL
, NULL
},
205 { "VRedir", 0x0481, NULL
, NULL
},
206 { "VBrowse", 0x0482, NULL
, NULL
},
207 { "VSHARE", 0x0483, NULL
, NULL
},
208 { "IFSMgr", 0x0484, NULL
, NULL
},
209 { "MEMPROBE", 0x0485, NULL
, NULL
},
210 { "VFAT", 0x0486, NULL
, NULL
},
211 { "NWLINK", 0x0487, NULL
, NULL
},
212 { "VNWLINK", 0x0487, NULL
, NULL
},
213 { "NWSUP", 0x0487, NULL
, NULL
},
214 { "VTDI", 0x0488, NULL
, NULL
},
215 { "VIP", 0x0489, NULL
, NULL
},
216 { "VTCP", 0x048A, NULL
, NULL
},
217 { "VCache", 0x048B, NULL
, NULL
},
218 { "VUDP", 0x048C, NULL
, NULL
},
219 { "VAsync", 0x048D, NULL
, NULL
},
220 { "NWREDIR", 0x048E, NULL
, NULL
},
221 { "STAT80", 0x048F, NULL
, NULL
},
222 { "SCSIPORT", 0x0490, NULL
, NULL
},
223 { "FILESEC", 0x0491, NULL
, NULL
},
224 { "NWSERVER", 0x0492, NULL
, NULL
},
225 { "SECPROV", 0x0493, NULL
, NULL
},
226 { "NSCL", 0x0494, NULL
, NULL
},
227 { "WSTCP", 0x0495, NULL
, NULL
},
228 { "NDIS2SUP", 0x0496, NULL
, NULL
},
229 { "MSODISUP", 0x0497, NULL
, NULL
},
230 { "Splitter", 0x0498, NULL
, NULL
},
231 { "PPP", 0x0499, NULL
, NULL
},
232 { "VDHCP", 0x049A, NULL
, NULL
},
233 { "VNBT", 0x049B, NULL
, NULL
},
234 { "LOGGER", 0x049D, NULL
, NULL
},
235 { "EFILTER", 0x049E, NULL
, NULL
},
236 { "FFILTER", 0x049F, NULL
, NULL
},
237 { "TFILTER", 0x04A0, NULL
, NULL
},
238 { "AFILTER", 0x04A1, NULL
, NULL
},
239 { "IRLAMP", 0x04A2, NULL
, NULL
},
241 { "PCCARD", 0x097C, NULL
, DeviceIo_PCCARD
},
242 { "HASP95", 0x3721, NULL
, DeviceIo_HASP
},
244 /* WINE additions, ids unknown */
245 { "MONODEBG.VXD", 0x4242, NULL
, DeviceIo_MONODEBG
},
247 { NULL
, 0, NULL
, NULL
}
251 * VMM VxDCall service names are (mostly) taken from Stan Mitchell's
252 * "Inside the Windows 95 File System"
255 #define N_VMM_SERVICE 41
257 LPCSTR VMM_Service_Name
[N_VMM_SERVICE
] =
259 "PageReserve", /* 0x0000 */
260 "PageCommit", /* 0x0001 */
261 "PageDecommit", /* 0x0002 */
262 "PagerRegister", /* 0x0003 */
263 "PagerQuery", /* 0x0004 */
264 "HeapAllocate", /* 0x0005 */
265 "ContextCreate", /* 0x0006 */
266 "ContextDestroy", /* 0x0007 */
267 "PageAttach", /* 0x0008 */
268 "PageFlush", /* 0x0009 */
269 "PageFree", /* 0x000A */
270 "ContextSwitch", /* 0x000B */
271 "HeapReAllocate", /* 0x000C */
272 "PageModifyPermissions", /* 0x000D */
273 "PageQuery", /* 0x000E */
274 "GetCurrentContext", /* 0x000F */
275 "HeapFree", /* 0x0010 */
276 "RegOpenKey", /* 0x0011 */
277 "RegCreateKey", /* 0x0012 */
278 "RegCloseKey", /* 0x0013 */
279 "RegDeleteKey", /* 0x0014 */
280 "RegSetValue", /* 0x0015 */
281 "RegDeleteValue", /* 0x0016 */
282 "RegQueryValue", /* 0x0017 */
283 "RegEnumKey", /* 0x0018 */
284 "RegEnumValue", /* 0x0019 */
285 "RegQueryValueEx", /* 0x001A */
286 "RegSetValueEx", /* 0x001B */
287 "RegFlushKey", /* 0x001C */
288 "RegQueryInfoKey", /* 0x001D */
289 "GetDemandPageInfo", /* 0x001E */
290 "BlockOnID", /* 0x001F */
291 "SignalID", /* 0x0020 */
292 "RegLoadKey", /* 0x0021 */
293 "RegUnLoadKey", /* 0x0022 */
294 "RegSaveKey", /* 0x0023 */
295 "RegRemapPreDefKey", /* 0x0024 */
296 "PageChangePager", /* 0x0025 */
297 "RegQueryMultipleValues", /* 0x0026 */
298 "RegReplaceKey", /* 0x0027 */
299 "<KERNEL32.101>" /* 0x0028 -- What does this do??? */
302 /* PageReserve arena values */
303 #define PR_PRIVATE 0x80000400 /* anywhere in private arena */
304 #define PR_SHARED 0x80060000 /* anywhere in shared arena */
305 #define PR_SYSTEM 0x80080000 /* anywhere in system arena */
307 /* PageReserve flags */
308 #define PR_FIXED 0x00000008 /* don't move during PageReAllocate */
309 #define PR_4MEG 0x00000001 /* allocate on 4mb boundary */
310 #define PR_STATIC 0x00000010 /* see PageReserve documentation */
312 /* PageCommit default pager handle values */
313 #define PD_ZEROINIT 0x00000001 /* swappable zero-initialized pages */
314 #define PD_NOINIT 0x00000002 /* swappable uninitialized pages */
315 #define PD_FIXEDZERO 0x00000003 /* fixed zero-initialized pages */
316 #define PD_FIXED 0x00000004 /* fixed uninitialized pages */
318 /* PageCommit flags */
319 #define PC_FIXED 0x00000008 /* pages are permanently locked */
320 #define PC_LOCKED 0x00000080 /* pages are made present and locked */
321 #define PC_LOCKEDIFDP 0x00000100 /* pages are locked if swap via DOS */
322 #define PC_WRITEABLE 0x00020000 /* make the pages writeable */
323 #define PC_USER 0x00040000 /* make the pages ring 3 accessible */
324 #define PC_INCR 0x40000000 /* increment "pagerdata" each page */
325 #define PC_PRESENT 0x80000000 /* make pages initially present */
326 #define PC_STATIC 0x20000000 /* allow commit in PR_STATIC object */
327 #define PC_DIRTY 0x08000000 /* make pages initially dirty */
328 #define PC_CACHEDIS 0x00100000 /* Allocate uncached pages - new for WDM */
329 #define PC_CACHEWT 0x00080000 /* Allocate write through cache pages - new for WDM */
330 #define PC_PAGEFLUSH 0x00008000 /* Touch device mapped pages on alloc - new for WDM */
332 /* PageCommitContig additional flags */
333 #define PCC_ZEROINIT 0x00000001 /* zero-initialize new pages */
334 #define PCC_NOLIN 0x10000000 /* don't map to any linear address */
338 HANDLE
DEVICE_Open( LPCWSTR filenameW
, DWORD access
, LPSECURITY_ATTRIBUTES sa
)
340 const struct VxDInfo
*info
;
341 char filename
[MAX_PATH
];
343 if (!WideCharToMultiByte(CP_ACP
, 0, filenameW
, -1, filename
, MAX_PATH
, NULL
, NULL
))
345 SetLastError( ERROR_FILE_NOT_FOUND
);
349 for (info
= VxDList
; info
->name
; info
++)
350 if (!strncasecmp( info
->name
, filename
, strlen(info
->name
) ))
351 return FILE_CreateDevice( info
->id
| 0x10000, access
, sa
);
353 FIXME( "Unknown/unsupported VxD %s. Try setting Windows version to 'nt40' or 'win31'.\n",
355 SetLastError( ERROR_FILE_NOT_FOUND
);
359 static DWORD
DEVICE_GetClientID( HANDLE handle
)
362 SERVER_START_REQ( get_device_id
)
364 req
->handle
= handle
;
365 if (!wine_server_call( req
)) ret
= reply
->id
;
371 static const struct VxDInfo
*DEVICE_GetInfo( DWORD clientID
)
373 const struct VxDInfo
*info
= NULL
;
375 if (clientID
& 0x10000)
377 for (info
= VxDList
; info
->name
; info
++)
378 if (info
->id
== LOWORD(clientID
)) break;
383 /****************************************************************************
384 * DeviceIoControl (KERNEL32.@)
385 * This is one of those big ugly nasty procedure which can do
386 * a million and one things when it comes to devices. It can also be
387 * used for VxD communication.
389 * A return value of FALSE indicates that something has gone wrong which
390 * GetLastError can decipher.
392 BOOL WINAPI
DeviceIoControl(HANDLE hDevice
, DWORD dwIoControlCode
,
393 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
394 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
395 LPDWORD lpcbBytesReturned
,
396 LPOVERLAPPED lpOverlapped
)
400 TRACE( "(%p,%ld,%p,%ld,%p,%ld,%p,%p)\n",
401 hDevice
,dwIoControlCode
,lpvInBuffer
,cbInBuffer
,
402 lpvOutBuffer
,cbOutBuffer
,lpcbBytesReturned
,lpOverlapped
);
404 if (!(clientID
= DEVICE_GetClientID( hDevice
)))
406 SetLastError( ERROR_INVALID_PARAMETER
);
410 /* Check if this is a user defined control code for a VxD */
411 if( HIWORD( dwIoControlCode
) == 0 )
413 const struct VxDInfo
*info
;
414 if (!(info
= DEVICE_GetInfo( clientID
)))
416 FIXME( "No device found for id %lx\n", clientID
);
418 else if ( info
->deviceio
)
420 return info
->deviceio( dwIoControlCode
,
421 lpvInBuffer
, cbInBuffer
,
422 lpvOutBuffer
, cbOutBuffer
,
423 lpcbBytesReturned
, lpOverlapped
);
427 FIXME( "Unimplemented control %ld for VxD device %s\n",
428 dwIoControlCode
, info
->name
? info
->name
: "???" );
429 /* FIXME: this is for invalid calls on W98SE,
430 * but maybe we should use ERROR_CALL_NOT_IMPLEMENTED
432 SetLastError( ERROR_INVALID_FUNCTION
);
440 str
[0] += LOBYTE(clientID
);
441 if (GetDriveTypeA(str
) == DRIVE_CDROM
)
444 status
= CDROM_DeviceIoControl(clientID
, hDevice
, dwIoControlCode
, lpvInBuffer
, cbInBuffer
,
445 lpvOutBuffer
, cbOutBuffer
, lpcbBytesReturned
,
447 if (status
) SetLastError(RtlNtStatusToDosError(status
));
450 else switch( dwIoControlCode
)
452 case FSCTL_DELETE_REPARSE_POINT
:
453 case FSCTL_DISMOUNT_VOLUME
:
454 case FSCTL_GET_COMPRESSION
:
455 case FSCTL_GET_REPARSE_POINT
:
456 case FSCTL_LOCK_VOLUME
:
457 case FSCTL_QUERY_ALLOCATED_RANGES
:
458 case FSCTL_SET_COMPRESSION
:
459 case FSCTL_SET_REPARSE_POINT
:
460 case FSCTL_SET_SPARSE
:
461 case FSCTL_SET_ZERO_DATA
:
462 case FSCTL_UNLOCK_VOLUME
:
463 case IOCTL_DISK_CHECK_VERIFY
:
464 case IOCTL_DISK_EJECT_MEDIA
:
465 case IOCTL_DISK_FORMAT_TRACKS
:
466 case IOCTL_DISK_GET_DRIVE_GEOMETRY
:
467 case IOCTL_DISK_GET_DRIVE_LAYOUT
:
468 case IOCTL_DISK_GET_MEDIA_TYPES
:
469 case IOCTL_DISK_GET_PARTITION_INFO
:
470 case IOCTL_DISK_LOAD_MEDIA
:
471 case IOCTL_DISK_MEDIA_REMOVAL
:
472 case IOCTL_DISK_PERFORMANCE
:
473 case IOCTL_DISK_REASSIGN_BLOCKS
:
474 case IOCTL_DISK_SET_DRIVE_LAYOUT
:
475 case IOCTL_DISK_SET_PARTITION_INFO
:
476 case IOCTL_DISK_VERIFY
:
477 case IOCTL_SERIAL_LSRMST_INSERT
:
478 case IOCTL_STORAGE_CHECK_VERIFY
:
479 case IOCTL_STORAGE_EJECT_MEDIA
:
480 case IOCTL_STORAGE_GET_MEDIA_TYPES
:
481 case IOCTL_STORAGE_LOAD_MEDIA
:
482 case IOCTL_STORAGE_MEDIA_REMOVAL
:
483 FIXME( "unimplemented dwIoControlCode=%08lx\n", dwIoControlCode
);
484 SetLastError( ERROR_CALL_NOT_IMPLEMENTED
);
488 FIXME( "ignored dwIoControlCode=%08lx\n",dwIoControlCode
);
489 SetLastError( ERROR_CALL_NOT_IMPLEMENTED
);
497 /***********************************************************************
500 static BOOL
DeviceIo_VTDAPI(DWORD dwIoControlCode
, LPVOID lpvInBuffer
, DWORD cbInBuffer
,
501 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
502 LPDWORD lpcbBytesReturned
,
503 LPOVERLAPPED lpOverlapped
)
507 switch (dwIoControlCode
)
510 if (lpvOutBuffer
&& (cbOutBuffer
>=4))
511 *(DWORD
*)lpvOutBuffer
= GetTickCount();
513 if (lpcbBytesReturned
)
514 *lpcbBytesReturned
= 4;
519 FIXME( "Control %ld not implemented\n", dwIoControlCode
);
527 /***********************************************************************
528 * VxDCall0 (KERNEL32.1)
529 * VxDCall1 (KERNEL32.2)
530 * VxDCall2 (KERNEL32.3)
531 * VxDCall3 (KERNEL32.4)
532 * VxDCall4 (KERNEL32.5)
533 * VxDCall5 (KERNEL32.6)
534 * VxDCall6 (KERNEL32.7)
535 * VxDCall7 (KERNEL32.8)
536 * VxDCall8 (KERNEL32.9)
538 void VxDCall( DWORD service
, CONTEXT86
*context
)
540 DWORD ret
= 0xffffffff; /* FIXME */
543 TRACE( "(%08lx, ...)\n", service
);
545 for (i
= 0; VxDList
[i
].name
; i
++)
546 if (VxDList
[i
].id
== HIWORD(service
))
549 if (!VxDList
[i
].name
)
550 FIXME( "Unknown VxD (%08lx)\n", service
);
551 else if (!VxDList
[i
].vxdcall
)
552 FIXME( "Unimplemented VxD (%08lx)\n", service
);
554 ret
= VxDList
[i
].vxdcall( service
, context
);
560 /******************************************************************************
561 * The following is a massive duplication of the advapi32 code.
562 * Unfortunately sharing the code is not possible since the native
563 * Win95 advapi32 depends on it. Someday we should probably stop
564 * supporting native Win95 advapi32 altogether...
568 #define HKEY_SPECIAL_ROOT_FIRST HKEY_CLASSES_ROOT
569 #define HKEY_SPECIAL_ROOT_LAST HKEY_DYN_DATA
570 #define NB_SPECIAL_ROOT_KEYS ((UINT)HKEY_SPECIAL_ROOT_LAST - (UINT)HKEY_SPECIAL_ROOT_FIRST + 1)
572 static HKEY special_root_keys
[NB_SPECIAL_ROOT_KEYS
];
574 static const WCHAR name_CLASSES_ROOT
[] =
575 {'M','a','c','h','i','n','e','\\',
576 'S','o','f','t','w','a','r','e','\\',
577 'C','l','a','s','s','e','s',0};
578 static const WCHAR name_LOCAL_MACHINE
[] =
579 {'M','a','c','h','i','n','e',0};
580 static const WCHAR name_USERS
[] =
582 static const WCHAR name_PERFORMANCE_DATA
[] =
583 {'P','e','r','f','D','a','t','a',0};
584 static const WCHAR name_CURRENT_CONFIG
[] =
585 {'M','a','c','h','i','n','e','\\',
586 'S','y','s','t','e','m','\\',
587 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
588 'H','a','r','d','w','a','r','e','P','r','o','f','i','l','e','s','\\',
589 'C','u','r','r','e','n','t',0};
590 static const WCHAR name_DYN_DATA
[] =
591 {'D','y','n','D','a','t','a',0};
593 #define DECL_STR(key) { sizeof(name_##key)-sizeof(WCHAR), sizeof(name_##key), (LPWSTR)name_##key }
594 static UNICODE_STRING root_key_names
[NB_SPECIAL_ROOT_KEYS
] =
596 DECL_STR(CLASSES_ROOT
),
597 { 0, 0, NULL
}, /* HKEY_CURRENT_USER is determined dynamically */
598 DECL_STR(LOCAL_MACHINE
),
600 DECL_STR(PERFORMANCE_DATA
),
601 DECL_STR(CURRENT_CONFIG
),
607 /* check if value type needs string conversion (Ansi<->Unicode) */
608 inline static int is_string( DWORD type
)
610 return (type
== REG_SZ
) || (type
== REG_EXPAND_SZ
) || (type
== REG_MULTI_SZ
);
613 /* create one of the HKEY_* special root keys */
614 static HKEY
create_special_root_hkey( HKEY hkey
, DWORD access
)
617 int idx
= (UINT
)hkey
- (UINT
)HKEY_SPECIAL_ROOT_FIRST
;
619 if (hkey
== HKEY_CURRENT_USER
)
621 if (RtlOpenCurrentUser( access
, &hkey
)) return 0;
625 OBJECT_ATTRIBUTES attr
;
627 attr
.Length
= sizeof(attr
);
628 attr
.RootDirectory
= 0;
629 attr
.ObjectName
= &root_key_names
[idx
];
631 attr
.SecurityDescriptor
= NULL
;
632 attr
.SecurityQualityOfService
= NULL
;
633 if (NtCreateKey( &hkey
, access
, &attr
, 0, NULL
, 0, NULL
)) return 0;
636 if (!(ret
= InterlockedCompareExchangePointer( (PVOID
) &special_root_keys
[idx
], hkey
, 0 )))
639 NtClose( hkey
); /* somebody beat us to it */
643 /* map the hkey from special root to normal key if necessary */
644 inline static HKEY
get_special_root_hkey( HKEY hkey
)
648 if ((hkey
>= HKEY_SPECIAL_ROOT_FIRST
) && (hkey
<= HKEY_SPECIAL_ROOT_LAST
))
650 if (!(ret
= special_root_keys
[(UINT
)hkey
- (UINT
)HKEY_SPECIAL_ROOT_FIRST
]))
651 ret
= create_special_root_hkey( hkey
, KEY_ALL_ACCESS
);
657 /******************************************************************************
660 static DWORD
VMM_RegCreateKeyA( HKEY hkey
, LPCSTR name
, PHKEY retkey
)
662 OBJECT_ATTRIBUTES attr
;
663 UNICODE_STRING nameW
;
667 if (!(hkey
= get_special_root_hkey( hkey
))) return ERROR_INVALID_HANDLE
;
669 attr
.Length
= sizeof(attr
);
670 attr
.RootDirectory
= hkey
;
671 attr
.ObjectName
= &nameW
;
673 attr
.SecurityDescriptor
= NULL
;
674 attr
.SecurityQualityOfService
= NULL
;
675 RtlInitAnsiString( &nameA
, name
);
677 if (!(status
= RtlAnsiStringToUnicodeString( &nameW
, &nameA
, TRUE
)))
679 status
= NtCreateKey( retkey
, KEY_ALL_ACCESS
, &attr
, 0, NULL
,
680 REG_OPTION_NON_VOLATILE
, NULL
);
681 RtlFreeUnicodeString( &nameW
);
683 return RtlNtStatusToDosError( status
);
687 /******************************************************************************
690 DWORD WINAPI
VMM_RegOpenKeyExA(HKEY hkey
, LPCSTR name
, DWORD reserved
, REGSAM access
, PHKEY retkey
)
692 OBJECT_ATTRIBUTES attr
;
693 UNICODE_STRING nameW
;
697 if (!(hkey
= get_special_root_hkey( hkey
))) return ERROR_INVALID_HANDLE
;
699 attr
.Length
= sizeof(attr
);
700 attr
.RootDirectory
= hkey
;
701 attr
.ObjectName
= &nameW
;
703 attr
.SecurityDescriptor
= NULL
;
704 attr
.SecurityQualityOfService
= NULL
;
706 RtlInitAnsiString( &nameA
, name
);
707 if (!(status
= RtlAnsiStringToUnicodeString( &nameW
, &nameA
, TRUE
)))
709 status
= NtOpenKey( retkey
, access
, &attr
);
710 RtlFreeUnicodeString( &nameW
);
712 return RtlNtStatusToDosError( status
);
716 /******************************************************************************
719 static DWORD
VMM_RegCloseKey( HKEY hkey
)
721 if (!hkey
|| hkey
>= (HKEY
)0x80000000) return ERROR_SUCCESS
;
722 return RtlNtStatusToDosError( NtClose( hkey
) );
726 /******************************************************************************
729 static DWORD
VMM_RegDeleteKeyA( HKEY hkey
, LPCSTR name
)
734 if (!(hkey
= get_special_root_hkey( hkey
))) return ERROR_INVALID_HANDLE
;
736 if (!name
|| !*name
) return RtlNtStatusToDosError( NtDeleteKey( hkey
) );
737 if (!(ret
= VMM_RegOpenKeyExA( hkey
, name
, 0, 0, &tmp
)))
739 ret
= RtlNtStatusToDosError( NtDeleteKey( tmp
) );
746 /******************************************************************************
749 static DWORD
VMM_RegSetValueExA( HKEY hkey
, LPCSTR name
, DWORD reserved
, DWORD type
,
750 CONST BYTE
*data
, DWORD count
)
752 UNICODE_STRING nameW
;
757 if (!(hkey
= get_special_root_hkey( hkey
))) return ERROR_INVALID_HANDLE
;
765 /* if user forgot to count terminating null, add it (yes NT does this) */
766 if (data
[count
-1] && !data
[count
]) count
++;
768 RtlMultiByteToUnicodeSize( &lenW
, data
, count
);
769 if (!(dataW
= HeapAlloc( GetProcessHeap(), 0, lenW
))) return ERROR_OUTOFMEMORY
;
770 RtlMultiByteToUnicodeN( dataW
, lenW
, NULL
, data
, count
);
772 data
= (BYTE
*)dataW
;
775 RtlInitAnsiString( &nameA
, name
);
776 if (!(status
= RtlAnsiStringToUnicodeString( &nameW
, &nameA
, TRUE
)))
778 status
= NtSetValueKey( hkey
, &nameW
, 0, type
, data
, count
);
779 RtlFreeUnicodeString( &nameW
);
781 if (dataW
) HeapFree( GetProcessHeap(), 0, dataW
);
782 return RtlNtStatusToDosError( status
);
786 /******************************************************************************
789 static DWORD
VMM_RegSetValueA( HKEY hkey
, LPCSTR name
, DWORD type
, LPCSTR data
, DWORD count
)
794 if (type
!= REG_SZ
) return ERROR_INVALID_PARAMETER
;
796 if (name
&& name
[0]) /* need to create the subkey */
798 if ((ret
= VMM_RegCreateKeyA( hkey
, name
, &subkey
)) != ERROR_SUCCESS
) return ret
;
800 ret
= VMM_RegSetValueExA( subkey
, NULL
, 0, REG_SZ
, (LPBYTE
)data
, strlen(data
)+1 );
801 if (subkey
!= hkey
) NtClose( subkey
);
806 /******************************************************************************
807 * VMM_RegDeleteValueA
809 static DWORD
VMM_RegDeleteValueA( HKEY hkey
, LPCSTR name
)
811 UNICODE_STRING nameW
;
815 if (!(hkey
= get_special_root_hkey( hkey
))) return ERROR_INVALID_HANDLE
;
817 RtlInitAnsiString( &nameA
, name
);
818 if (!(status
= RtlAnsiStringToUnicodeString( &nameW
, &nameA
, TRUE
)))
820 status
= NtDeleteValueKey( hkey
, &nameW
);
821 RtlFreeUnicodeString( &nameW
);
823 return RtlNtStatusToDosError( status
);
827 /******************************************************************************
828 * VMM_RegQueryValueExA
830 static DWORD
VMM_RegQueryValueExA( HKEY hkey
, LPCSTR name
, LPDWORD reserved
, LPDWORD type
,
831 LPBYTE data
, LPDWORD count
)
835 UNICODE_STRING nameW
;
837 char buffer
[256], *buf_ptr
= buffer
;
838 KEY_VALUE_PARTIAL_INFORMATION
*info
= (KEY_VALUE_PARTIAL_INFORMATION
*)buffer
;
839 static const int info_size
= offsetof( KEY_VALUE_PARTIAL_INFORMATION
, Data
);
841 if ((data
&& !count
) || reserved
) return ERROR_INVALID_PARAMETER
;
842 if (!(hkey
= get_special_root_hkey( hkey
))) return ERROR_INVALID_HANDLE
;
844 RtlInitAnsiString( &nameA
, name
);
845 if ((status
= RtlAnsiStringToUnicodeString( &nameW
, &nameA
, TRUE
)))
846 return RtlNtStatusToDosError(status
);
848 status
= NtQueryValueKey( hkey
, &nameW
, KeyValuePartialInformation
,
849 buffer
, sizeof(buffer
), &total_size
);
850 if (status
&& status
!= STATUS_BUFFER_OVERFLOW
) goto done
;
852 /* we need to fetch the contents for a string type even if not requested,
853 * because we need to compute the length of the ASCII string. */
854 if (data
|| is_string(info
->Type
))
856 /* retry with a dynamically allocated buffer */
857 while (status
== STATUS_BUFFER_OVERFLOW
)
859 if (buf_ptr
!= buffer
) HeapFree( GetProcessHeap(), 0, buf_ptr
);
860 if (!(buf_ptr
= HeapAlloc( GetProcessHeap(), 0, total_size
)))
862 status
= STATUS_NO_MEMORY
;
865 info
= (KEY_VALUE_PARTIAL_INFORMATION
*)buf_ptr
;
866 status
= NtQueryValueKey( hkey
, &nameW
, KeyValuePartialInformation
,
867 buf_ptr
, total_size
, &total_size
);
872 if (is_string(info
->Type
))
874 DWORD len
= WideCharToMultiByte( CP_ACP
, 0, (WCHAR
*)(buf_ptr
+ info_size
),
875 (total_size
- info_size
) /sizeof(WCHAR
),
876 NULL
, 0, NULL
, NULL
);
879 if (len
> *count
) status
= STATUS_BUFFER_OVERFLOW
;
882 WideCharToMultiByte( CP_ACP
, 0, (WCHAR
*)(buf_ptr
+ info_size
),
883 (total_size
- info_size
) /sizeof(WCHAR
),
884 data
, len
, NULL
, NULL
);
885 /* if the type is REG_SZ and data is not 0-terminated
886 * and there is enough space in the buffer NT appends a \0 */
887 if (len
< *count
&& data
[len
-1]) data
[len
] = 0;
890 total_size
= len
+ info_size
;
894 if (total_size
- info_size
> *count
) status
= STATUS_BUFFER_OVERFLOW
;
895 else memcpy( data
, buf_ptr
+ info_size
, total_size
- info_size
);
898 else if (status
!= STATUS_BUFFER_OVERFLOW
) goto done
;
901 if (type
) *type
= info
->Type
;
902 if (count
) *count
= total_size
- info_size
;
905 if (buf_ptr
!= buffer
) HeapFree( GetProcessHeap(), 0, buf_ptr
);
906 RtlFreeUnicodeString( &nameW
);
907 return RtlNtStatusToDosError(status
);
911 /******************************************************************************
914 static DWORD
VMM_RegQueryValueA( HKEY hkey
, LPCSTR name
, LPSTR data
, LPLONG count
)
921 if ((ret
= VMM_RegOpenKeyExA( hkey
, name
, 0, KEY_ALL_ACCESS
, &subkey
)) != ERROR_SUCCESS
)
924 ret
= VMM_RegQueryValueExA( subkey
, NULL
, NULL
, NULL
, (LPBYTE
)data
, count
);
925 if (subkey
!= hkey
) NtClose( subkey
);
926 if (ret
== ERROR_FILE_NOT_FOUND
)
928 /* return empty string if default value not found */
930 if (count
) *count
= 1;
937 /******************************************************************************
940 static DWORD
VMM_RegEnumValueA( HKEY hkey
, DWORD index
, LPSTR value
, LPDWORD val_count
,
941 LPDWORD reserved
, LPDWORD type
, LPBYTE data
, LPDWORD count
)
945 char buffer
[256], *buf_ptr
= buffer
;
946 KEY_VALUE_FULL_INFORMATION
*info
= (KEY_VALUE_FULL_INFORMATION
*)buffer
;
947 static const int info_size
= offsetof( KEY_VALUE_FULL_INFORMATION
, Name
);
949 TRACE("(%p,%ld,%p,%p,%p,%p,%p,%p)\n",
950 hkey
, index
, value
, val_count
, reserved
, type
, data
, count
);
952 /* NT only checks count, not val_count */
953 if ((data
&& !count
) || reserved
) return ERROR_INVALID_PARAMETER
;
954 if (!(hkey
= get_special_root_hkey( hkey
))) return ERROR_INVALID_HANDLE
;
956 total_size
= info_size
+ (MAX_PATH
+ 1) * sizeof(WCHAR
);
957 if (data
) total_size
+= *count
;
958 total_size
= min( sizeof(buffer
), total_size
);
960 status
= NtEnumerateValueKey( hkey
, index
, KeyValueFullInformation
,
961 buffer
, total_size
, &total_size
);
962 if (status
&& status
!= STATUS_BUFFER_OVERFLOW
) goto done
;
964 /* we need to fetch the contents for a string type even if not requested,
965 * because we need to compute the length of the ASCII string. */
966 if (value
|| data
|| is_string(info
->Type
))
968 /* retry with a dynamically allocated buffer */
969 while (status
== STATUS_BUFFER_OVERFLOW
)
971 if (buf_ptr
!= buffer
) HeapFree( GetProcessHeap(), 0, buf_ptr
);
972 if (!(buf_ptr
= HeapAlloc( GetProcessHeap(), 0, total_size
)))
973 return ERROR_NOT_ENOUGH_MEMORY
;
974 info
= (KEY_VALUE_FULL_INFORMATION
*)buf_ptr
;
975 status
= NtEnumerateValueKey( hkey
, index
, KeyValueFullInformation
,
976 buf_ptr
, total_size
, &total_size
);
979 if (status
) goto done
;
981 if (is_string(info
->Type
))
984 RtlUnicodeToMultiByteSize( &len
, (WCHAR
*)(buf_ptr
+ info
->DataOffset
),
985 total_size
- info
->DataOffset
);
988 if (len
> *count
) status
= STATUS_BUFFER_OVERFLOW
;
991 RtlUnicodeToMultiByteN( data
, len
, NULL
, (WCHAR
*)(buf_ptr
+ info
->DataOffset
),
992 total_size
- info
->DataOffset
);
993 /* if the type is REG_SZ and data is not 0-terminated
994 * and there is enough space in the buffer NT appends a \0 */
995 if (len
< *count
&& data
[len
-1]) data
[len
] = 0;
998 info
->DataLength
= len
;
1002 if (total_size
- info
->DataOffset
> *count
) status
= STATUS_BUFFER_OVERFLOW
;
1003 else memcpy( data
, buf_ptr
+ info
->DataOffset
, total_size
- info
->DataOffset
);
1006 if (value
&& !status
)
1010 RtlUnicodeToMultiByteSize( &len
, info
->Name
, info
->NameLength
);
1011 if (len
>= *val_count
)
1013 status
= STATUS_BUFFER_OVERFLOW
;
1016 len
= *val_count
- 1;
1017 RtlUnicodeToMultiByteN( value
, len
, NULL
, info
->Name
, info
->NameLength
);
1023 RtlUnicodeToMultiByteN( value
, len
, NULL
, info
->Name
, info
->NameLength
);
1029 else status
= STATUS_SUCCESS
;
1031 if (type
) *type
= info
->Type
;
1032 if (count
) *count
= info
->DataLength
;
1035 if (buf_ptr
!= buffer
) HeapFree( GetProcessHeap(), 0, buf_ptr
);
1036 return RtlNtStatusToDosError(status
);
1040 /******************************************************************************
1043 static DWORD
VMM_RegEnumKeyA( HKEY hkey
, DWORD index
, LPSTR name
, DWORD name_len
)
1046 char buffer
[256], *buf_ptr
= buffer
;
1047 KEY_NODE_INFORMATION
*info
= (KEY_NODE_INFORMATION
*)buffer
;
1050 if (!(hkey
= get_special_root_hkey( hkey
))) return ERROR_INVALID_HANDLE
;
1052 status
= NtEnumerateKey( hkey
, index
, KeyNodeInformation
,
1053 buffer
, sizeof(buffer
), &total_size
);
1055 while (status
== STATUS_BUFFER_OVERFLOW
)
1057 /* retry with a dynamically allocated buffer */
1058 if (buf_ptr
!= buffer
) HeapFree( GetProcessHeap(), 0, buf_ptr
);
1059 if (!(buf_ptr
= HeapAlloc( GetProcessHeap(), 0, total_size
)))
1060 return ERROR_NOT_ENOUGH_MEMORY
;
1061 info
= (KEY_NODE_INFORMATION
*)buf_ptr
;
1062 status
= NtEnumerateKey( hkey
, index
, KeyNodeInformation
,
1063 buf_ptr
, total_size
, &total_size
);
1070 RtlUnicodeToMultiByteSize( &len
, info
->Name
, info
->NameLength
);
1071 if (len
>= name_len
) status
= STATUS_BUFFER_OVERFLOW
;
1074 RtlUnicodeToMultiByteN( name
, len
, NULL
, info
->Name
, info
->NameLength
);
1079 if (buf_ptr
!= buffer
) HeapFree( GetProcessHeap(), 0, buf_ptr
);
1080 return RtlNtStatusToDosError( status
);
1084 /******************************************************************************
1085 * VMM_RegQueryInfoKeyA
1087 * NOTE: This VxDCall takes only a subset of the parameters that the
1088 * corresponding Win32 API call does. The implementation in Win95
1089 * ADVAPI32 sets all output parameters not mentioned here to zero.
1091 static DWORD
VMM_RegQueryInfoKeyA( HKEY hkey
, LPDWORD subkeys
, LPDWORD max_subkey
,
1092 LPDWORD values
, LPDWORD max_value
, LPDWORD max_data
)
1095 KEY_FULL_INFORMATION info
;
1098 if (!(hkey
= get_special_root_hkey( hkey
))) return ERROR_INVALID_HANDLE
;
1100 status
= NtQueryKey( hkey
, KeyFullInformation
, &info
, sizeof(info
), &total_size
);
1101 if (status
&& status
!= STATUS_BUFFER_OVERFLOW
) return RtlNtStatusToDosError( status
);
1103 if (subkeys
) *subkeys
= info
.SubKeys
;
1104 if (max_subkey
) *max_subkey
= info
.MaxNameLen
;
1105 if (values
) *values
= info
.Values
;
1106 if (max_value
) *max_value
= info
.MaxValueNameLen
;
1107 if (max_data
) *max_data
= info
.MaxValueDataLen
;
1108 return ERROR_SUCCESS
;
1112 /***********************************************************************
1115 static DWORD
VxDCall_VMM( DWORD service
, CONTEXT86
*context
)
1117 switch ( LOWORD(service
) )
1119 case 0x0011: /* RegOpenKey */
1121 HKEY hkey
= (HKEY
) stack32_pop( context
);
1122 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
1123 PHKEY retkey
= (PHKEY
)stack32_pop( context
);
1124 return VMM_RegOpenKeyExA( hkey
, lpszSubKey
, 0, KEY_ALL_ACCESS
, retkey
);
1127 case 0x0012: /* RegCreateKey */
1129 HKEY hkey
= (HKEY
) stack32_pop( context
);
1130 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
1131 PHKEY retkey
= (PHKEY
)stack32_pop( context
);
1132 return VMM_RegCreateKeyA( hkey
, lpszSubKey
, retkey
);
1135 case 0x0013: /* RegCloseKey */
1137 HKEY hkey
= (HKEY
)stack32_pop( context
);
1138 return VMM_RegCloseKey( hkey
);
1141 case 0x0014: /* RegDeleteKey */
1143 HKEY hkey
= (HKEY
) stack32_pop( context
);
1144 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
1145 return VMM_RegDeleteKeyA( hkey
, lpszSubKey
);
1148 case 0x0015: /* RegSetValue */
1150 HKEY hkey
= (HKEY
) stack32_pop( context
);
1151 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
1152 DWORD dwType
= (DWORD
) stack32_pop( context
);
1153 LPCSTR lpszData
= (LPCSTR
)stack32_pop( context
);
1154 DWORD cbData
= (DWORD
) stack32_pop( context
);
1155 return VMM_RegSetValueA( hkey
, lpszSubKey
, dwType
, lpszData
, cbData
);
1158 case 0x0016: /* RegDeleteValue */
1160 HKEY hkey
= (HKEY
) stack32_pop( context
);
1161 LPSTR lpszValue
= (LPSTR
)stack32_pop( context
);
1162 return VMM_RegDeleteValueA( hkey
, lpszValue
);
1165 case 0x0017: /* RegQueryValue */
1167 HKEY hkey
= (HKEY
) stack32_pop( context
);
1168 LPSTR lpszSubKey
= (LPSTR
) stack32_pop( context
);
1169 LPSTR lpszData
= (LPSTR
) stack32_pop( context
);
1170 LPDWORD lpcbData
= (LPDWORD
)stack32_pop( context
);
1171 return VMM_RegQueryValueA( hkey
, lpszSubKey
, lpszData
, lpcbData
);
1174 case 0x0018: /* RegEnumKey */
1176 HKEY hkey
= (HKEY
) stack32_pop( context
);
1177 DWORD iSubkey
= (DWORD
)stack32_pop( context
);
1178 LPSTR lpszName
= (LPSTR
)stack32_pop( context
);
1179 DWORD lpcchName
= (DWORD
)stack32_pop( context
);
1180 return VMM_RegEnumKeyA( hkey
, iSubkey
, lpszName
, lpcchName
);
1183 case 0x0019: /* RegEnumValue */
1185 HKEY hkey
= (HKEY
) stack32_pop( context
);
1186 DWORD iValue
= (DWORD
) stack32_pop( context
);
1187 LPSTR lpszValue
= (LPSTR
) stack32_pop( context
);
1188 LPDWORD lpcchValue
= (LPDWORD
)stack32_pop( context
);
1189 LPDWORD lpReserved
= (LPDWORD
)stack32_pop( context
);
1190 LPDWORD lpdwType
= (LPDWORD
)stack32_pop( context
);
1191 LPBYTE lpbData
= (LPBYTE
) stack32_pop( context
);
1192 LPDWORD lpcbData
= (LPDWORD
)stack32_pop( context
);
1193 return VMM_RegEnumValueA( hkey
, iValue
, lpszValue
, lpcchValue
,
1194 lpReserved
, lpdwType
, lpbData
, lpcbData
);
1197 case 0x001A: /* RegQueryValueEx */
1199 HKEY hkey
= (HKEY
) stack32_pop( context
);
1200 LPSTR lpszValue
= (LPSTR
) stack32_pop( context
);
1201 LPDWORD lpReserved
= (LPDWORD
)stack32_pop( context
);
1202 LPDWORD lpdwType
= (LPDWORD
)stack32_pop( context
);
1203 LPBYTE lpbData
= (LPBYTE
) stack32_pop( context
);
1204 LPDWORD lpcbData
= (LPDWORD
)stack32_pop( context
);
1205 return VMM_RegQueryValueExA( hkey
, lpszValue
, lpReserved
,
1206 lpdwType
, lpbData
, lpcbData
);
1209 case 0x001B: /* RegSetValueEx */
1211 HKEY hkey
= (HKEY
) stack32_pop( context
);
1212 LPSTR lpszValue
= (LPSTR
) stack32_pop( context
);
1213 DWORD dwReserved
= (DWORD
) stack32_pop( context
);
1214 DWORD dwType
= (DWORD
) stack32_pop( context
);
1215 LPBYTE lpbData
= (LPBYTE
)stack32_pop( context
);
1216 DWORD cbData
= (DWORD
) stack32_pop( context
);
1217 return VMM_RegSetValueExA( hkey
, lpszValue
, dwReserved
,
1218 dwType
, lpbData
, cbData
);
1221 case 0x001C: /* RegFlushKey */
1223 HKEY hkey
= (HKEY
)stack32_pop( context
);
1224 FIXME( "RegFlushKey(%p): stub\n", hkey
);
1225 return ERROR_SUCCESS
;
1228 case 0x001D: /* RegQueryInfoKey */
1230 /* NOTE: This VxDCall takes only a subset of the parameters that the
1231 corresponding Win32 API call does. The implementation in Win95
1232 ADVAPI32 sets all output parameters not mentioned here to zero. */
1234 HKEY hkey
= (HKEY
) stack32_pop( context
);
1235 LPDWORD lpcSubKeys
= (LPDWORD
)stack32_pop( context
);
1236 LPDWORD lpcchMaxSubKey
= (LPDWORD
)stack32_pop( context
);
1237 LPDWORD lpcValues
= (LPDWORD
)stack32_pop( context
);
1238 LPDWORD lpcchMaxValueName
= (LPDWORD
)stack32_pop( context
);
1239 LPDWORD lpcchMaxValueData
= (LPDWORD
)stack32_pop( context
);
1240 return VMM_RegQueryInfoKeyA( hkey
, lpcSubKeys
, lpcchMaxSubKey
,
1241 lpcValues
, lpcchMaxValueName
, lpcchMaxValueData
);
1244 case 0x0021: /* RegLoadKey */
1246 HKEY hkey
= (HKEY
) stack32_pop( context
);
1247 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
1248 LPCSTR lpszFile
= (LPCSTR
)stack32_pop( context
);
1249 FIXME("RegLoadKey(%p,%s,%s): stub\n",hkey
, debugstr_a(lpszSubKey
), debugstr_a(lpszFile
));
1250 return ERROR_SUCCESS
;
1253 case 0x0022: /* RegUnLoadKey */
1255 HKEY hkey
= (HKEY
) stack32_pop( context
);
1256 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
1257 FIXME("RegUnLoadKey(%p,%s): stub\n",hkey
, debugstr_a(lpszSubKey
));
1258 return ERROR_SUCCESS
;
1261 case 0x0023: /* RegSaveKey */
1263 HKEY hkey
= (HKEY
) stack32_pop( context
);
1264 LPCSTR lpszFile
= (LPCSTR
)stack32_pop( context
);
1265 LPSECURITY_ATTRIBUTES sa
= (LPSECURITY_ATTRIBUTES
)stack32_pop( context
);
1266 FIXME("RegSaveKey(%p,%s,%p): stub\n",hkey
, debugstr_a(lpszFile
),sa
);
1267 return ERROR_SUCCESS
;
1270 #if 0 /* Functions are not yet implemented in misc/registry.c */
1271 case 0x0024: /* RegRemapPreDefKey */
1272 case 0x0026: /* RegQueryMultipleValues */
1275 case 0x0027: /* RegReplaceKey */
1277 HKEY hkey
= (HKEY
) stack32_pop( context
);
1278 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
1279 LPCSTR lpszNewFile
= (LPCSTR
)stack32_pop( context
);
1280 LPCSTR lpszOldFile
= (LPCSTR
)stack32_pop( context
);
1281 FIXME("RegReplaceKey(%p,%s,%s,%s): stub\n", hkey
, debugstr_a(lpszSubKey
),
1282 debugstr_a(lpszNewFile
),debugstr_a(lpszOldFile
));
1283 return ERROR_SUCCESS
;
1286 case 0x0000: /* PageReserve */
1290 DWORD psize
= getpagesize();
1291 ULONG page
= (ULONG
) stack32_pop( context
);
1292 ULONG npages
= (ULONG
) stack32_pop( context
);
1293 ULONG flags
= (ULONG
) stack32_pop( context
);
1295 TRACE("PageReserve: page: %08lx, npages: %08lx, flags: %08lx partial stub!\n",
1296 page
, npages
, flags
);
1298 if ( page
== PR_SYSTEM
) {
1299 ERR("Can't reserve ring 1 memory\n");
1302 /* FIXME: This has to be handled separately for the separate
1303 address-spaces we now have */
1304 if ( page
== PR_PRIVATE
|| page
== PR_SHARED
) page
= 0;
1305 /* FIXME: Handle flags in some way */
1306 address
= (LPVOID
)(page
* psize
);
1307 ret
= VirtualAlloc ( address
, ( npages
* psize
), MEM_RESERVE
, 0 );
1308 TRACE("PageReserve: returning: %08lx\n", (DWORD
)ret
);
1315 case 0x0001: /* PageCommit */
1320 DWORD psize
= getpagesize();
1321 ULONG page
= (ULONG
) stack32_pop( context
);
1322 ULONG npages
= (ULONG
) stack32_pop( context
);
1323 ULONG hpd
= (ULONG
) stack32_pop( context
);
1324 ULONG pagerdata
= (ULONG
) stack32_pop( context
);
1325 ULONG flags
= (ULONG
) stack32_pop( context
);
1327 TRACE("PageCommit: page: %08lx, npages: %08lx, hpd: %08lx pagerdata: "
1328 "%08lx, flags: %08lx partial stub\n",
1329 page
, npages
, hpd
, pagerdata
, flags
);
1331 if ( flags
& PC_USER
)
1332 if ( flags
& PC_WRITEABLE
)
1333 virt_perm
= PAGE_EXECUTE_READWRITE
;
1335 virt_perm
= PAGE_EXECUTE_READ
;
1337 virt_perm
= PAGE_NOACCESS
;
1339 address
= (LPVOID
)(page
* psize
);
1340 ret
= VirtualAlloc ( address
, ( npages
* psize
), MEM_COMMIT
, virt_perm
);
1341 TRACE("PageCommit: Returning: %08lx\n", (DWORD
)ret
);
1345 case 0x0002: /* PageDecommit */
1349 DWORD psize
= getpagesize();
1350 ULONG page
= (ULONG
) stack32_pop( context
);
1351 ULONG npages
= (ULONG
) stack32_pop( context
);
1352 ULONG flags
= (ULONG
) stack32_pop( context
);
1354 TRACE("PageDecommit: page: %08lx, npages: %08lx, flags: %08lx partial stub\n",
1355 page
, npages
, flags
);
1356 address
= (LPVOID
)( page
* psize
);
1357 ret
= VirtualFree ( address
, ( npages
* psize
), MEM_DECOMMIT
);
1358 TRACE("PageDecommit: Returning: %s\n", ret
? "TRUE" : "FALSE" );
1361 case 0x000d: /* PageModifyPermissions */
1365 DWORD virt_old_perm
;
1366 DWORD virt_new_perm
;
1367 MEMORY_BASIC_INFORMATION mbi
;
1369 DWORD psize
= getpagesize();
1370 ULONG page
= stack32_pop ( context
);
1371 ULONG npages
= stack32_pop ( context
);
1372 ULONG permand
= stack32_pop ( context
);
1373 ULONG permor
= stack32_pop ( context
);
1375 TRACE("PageModifyPermissions %08lx %08lx %08lx %08lx partial stub\n",
1376 page
, npages
, permand
, permor
);
1377 address
= (LPVOID
)( page
* psize
);
1379 VirtualQuery ( address
, &mbi
, sizeof ( MEMORY_BASIC_INFORMATION
));
1380 virt_old_perm
= mbi
.Protect
;
1382 switch ( virt_old_perm
& mbi
.Protect
) {
1385 case PAGE_EXECUTE_READ
:
1386 pg_old_perm
= PC_USER
;
1388 case PAGE_READWRITE
:
1389 case PAGE_WRITECOPY
:
1390 case PAGE_EXECUTE_READWRITE
:
1391 case PAGE_EXECUTE_WRITECOPY
:
1392 pg_old_perm
= PC_USER
| PC_WRITEABLE
;
1399 pg_new_perm
= pg_old_perm
;
1400 pg_new_perm
&= permand
& ~PC_STATIC
;
1401 pg_new_perm
|= permor
& ~PC_STATIC
;
1403 virt_new_perm
= ( virt_old_perm
) & ~0xff;
1404 if ( pg_new_perm
& PC_USER
)
1406 if ( pg_new_perm
& PC_WRITEABLE
)
1407 virt_new_perm
|= PAGE_EXECUTE_READWRITE
;
1409 virt_new_perm
|= PAGE_EXECUTE_READ
;
1412 if ( ! VirtualProtect ( address
, ( npages
* psize
), virt_new_perm
, &virt_old_perm
) ) {
1413 ERR("Can't change page permissions for %08lx\n", (DWORD
)address
);
1416 TRACE("Returning: %08lx\n", pg_old_perm
);
1419 case 0x000a: /* PageFree */
1422 LPVOID hmem
= (LPVOID
) stack32_pop( context
);
1423 DWORD flags
= (DWORD
) stack32_pop( context
);
1425 TRACE("PageFree: hmem: %08lx, flags: %08lx partial stub\n",
1426 (DWORD
)hmem
, flags
);
1428 ret
= VirtualFree ( hmem
, 0, MEM_RELEASE
);
1430 TRACE("Returning: %d\n", ret
);
1434 case 0x001e: /* GetDemandPageInfo */
1436 DWORD dinfo
= (DWORD
)stack32_pop( context
);
1437 DWORD flags
= (DWORD
)stack32_pop( context
);
1439 /* GetDemandPageInfo is supposed to fill out the struct at
1440 * "dinfo" with various low-level memory management information.
1441 * Apps are certainly not supposed to call this, although it's
1442 * demoed and documented by Pietrek on pages 441-443 of "Windows
1443 * 95 System Programming Secrets" if any program needs a real
1444 * implementation of this.
1447 FIXME("GetDemandPageInfo(%08lx %08lx): stub!\n", dinfo
, flags
);
1452 if (LOWORD(service
) < N_VMM_SERVICE
)
1453 FIXME( "Unimplemented service %s (%08lx)\n",
1454 VMM_Service_Name
[LOWORD(service
)], service
);
1456 FIXME( "Unknown service %08lx\n", service
);
1460 return 0xffffffff; /* FIXME */
1463 /***********************************************************************
1466 * These ioctls are used by 'MSNET32.DLL'.
1468 * I have been unable to uncover any documentation about the ioctls so
1469 * the implementation of the cases IFS_IOCTL_21 and IFS_IOCTL_2F are
1470 * based on reasonable guesses on information found in the Windows 95 DDK.
1475 * IFSMgr DeviceIO service
1478 #define IFS_IOCTL_21 100
1479 #define IFS_IOCTL_2F 101
1480 #define IFS_IOCTL_GET_RES 102
1481 #define IFS_IOCTL_GET_NETPRO_NAME_A 103
1483 struct win32apireq
{
1484 unsigned long ar_proid
;
1485 unsigned long ar_eax
;
1486 unsigned long ar_ebx
;
1487 unsigned long ar_ecx
;
1488 unsigned long ar_edx
;
1489 unsigned long ar_esi
;
1490 unsigned long ar_edi
;
1491 unsigned long ar_ebp
;
1492 unsigned short ar_error
;
1493 unsigned short ar_pad
;
1496 static void win32apieq_2_CONTEXT(struct win32apireq
*pIn
,CONTEXT86
*pCxt
)
1498 memset(pCxt
,0,sizeof(*pCxt
));
1500 pCxt
->ContextFlags
=CONTEXT86_INTEGER
|CONTEXT86_CONTROL
;
1501 pCxt
->Eax
= pIn
->ar_eax
;
1502 pCxt
->Ebx
= pIn
->ar_ebx
;
1503 pCxt
->Ecx
= pIn
->ar_ecx
;
1504 pCxt
->Edx
= pIn
->ar_edx
;
1505 pCxt
->Esi
= pIn
->ar_esi
;
1506 pCxt
->Edi
= pIn
->ar_edi
;
1508 /* FIXME: Only partial CONTEXT86_CONTROL */
1509 pCxt
->Ebp
= pIn
->ar_ebp
;
1511 /* FIXME: pIn->ar_proid ignored */
1512 /* FIXME: pIn->ar_error ignored */
1513 /* FIXME: pIn->ar_pad ignored */
1516 static void CONTEXT_2_win32apieq(CONTEXT86
*pCxt
,struct win32apireq
*pOut
)
1518 memset(pOut
,0,sizeof(struct win32apireq
));
1520 pOut
->ar_eax
= pCxt
->Eax
;
1521 pOut
->ar_ebx
= pCxt
->Ebx
;
1522 pOut
->ar_ecx
= pCxt
->Ecx
;
1523 pOut
->ar_edx
= pCxt
->Edx
;
1524 pOut
->ar_esi
= pCxt
->Esi
;
1525 pOut
->ar_edi
= pCxt
->Edi
;
1527 /* FIXME: Only partial CONTEXT86_CONTROL */
1528 pOut
->ar_ebp
= pCxt
->Ebp
;
1530 /* FIXME: pOut->ar_proid ignored */
1531 /* FIXME: pOut->ar_error ignored */
1532 /* FIXME: pOut->ar_pad ignored */
1535 static BOOL
DeviceIo_IFSMgr(DWORD dwIoControlCode
, LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1536 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1537 LPDWORD lpcbBytesReturned
,
1538 LPOVERLAPPED lpOverlapped
)
1541 TRACE("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
1543 lpvInBuffer
,cbInBuffer
,
1544 lpvOutBuffer
,cbOutBuffer
,
1548 switch (dwIoControlCode
)
1553 struct win32apireq
*pIn
=(struct win32apireq
*) lpvInBuffer
;
1554 struct win32apireq
*pOut
=(struct win32apireq
*) lpvOutBuffer
;
1558 "proid=0x%08lx, eax=0x%08lx, ebx=0x%08lx, ecx=0x%08lx, "
1559 "edx=0x%08lx, esi=0x%08lx, edi=0x%08lx, ebp=0x%08lx, "
1560 "error=0x%04x, pad=0x%04x\n",
1561 (dwIoControlCode
==IFS_IOCTL_21
)?"IFS_IOCTL_21":"IFS_IOCTL_2F",
1562 pIn
->ar_proid
, pIn
->ar_eax
, pIn
->ar_ebx
, pIn
->ar_ecx
,
1563 pIn
->ar_edx
, pIn
->ar_esi
, pIn
->ar_edi
, pIn
->ar_ebp
,
1564 pIn
->ar_error
, pIn
->ar_pad
1567 win32apieq_2_CONTEXT(pIn
,&cxt
);
1569 if(dwIoControlCode
==IFS_IOCTL_21
)
1571 if(Dosvm
.CallBuiltinHandler
|| DPMI_LoadDosSystem())
1572 Dosvm
.CallBuiltinHandler( &cxt
, 0x21 );
1576 if(Dosvm
.CallBuiltinHandler
|| DPMI_LoadDosSystem())
1577 Dosvm
.CallBuiltinHandler( &cxt
, 0x2f );
1580 CONTEXT_2_win32apieq(&cxt
,pOut
);
1584 case IFS_IOCTL_GET_RES
:{
1585 FIXME( "Control 'IFS_IOCTL_GET_RES' not implemented\n");
1588 case IFS_IOCTL_GET_NETPRO_NAME_A
:{
1589 FIXME( "Control 'IFS_IOCTL_GET_NETPRO_NAME_A' not implemented\n");
1593 FIXME( "Control %ld not implemented\n", dwIoControlCode
);
1600 /********************************************************************************
1603 * Service numbers taken from page 448 of Pietrek's "Windows 95 System
1604 * Programming Secrets". Parameters from experimentation on real Win98.
1608 static DWORD
VxDCall_VWin32( DWORD service
, CONTEXT86
*context
)
1610 switch ( LOWORD(service
) )
1612 case 0x0000: /* GetVersion */
1614 DWORD vers
= GetVersion();
1615 return (LOBYTE(vers
) << 8) | HIBYTE(vers
);
1619 case 0x0020: /* Get VMCPD Version */
1621 DWORD parm
= (DWORD
) stack32_pop(context
);
1623 FIXME("Get VMCPD Version(%08lx): partial stub!\n", parm
);
1625 /* FIXME: This is what Win98 returns, it may
1626 * not be correct in all situations.
1627 * It makes Bleem! happy though.
1633 case 0x0029: /* Int31/DPMI dispatch */
1635 DWORD callnum
= (DWORD
) stack32_pop(context
);
1636 DWORD parm
= (DWORD
) stack32_pop(context
);
1638 TRACE("Int31/DPMI dispatch(%08lx)\n", callnum
);
1640 SET_AX( context
, callnum
);
1641 SET_CX( context
, parm
);
1642 if(Dosvm
.CallBuiltinHandler
|| DPMI_LoadDosSystem())
1643 Dosvm
.CallBuiltinHandler( context
, 0x31 );
1645 return LOWORD(context
->Eax
);
1649 case 0x002a: /* Int41 dispatch - parm = int41 service number */
1651 DWORD callnum
= (DWORD
) stack32_pop(context
);
1653 return callnum
; /* FIXME: should really call INT_Int41Handler() */
1658 FIXME("Unknown VWin32 service %08lx\n", service
);
1666 /***********************************************************************
1669 static BOOL
DeviceIo_VCD(DWORD dwIoControlCode
,
1670 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1671 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1672 LPDWORD lpcbBytesReturned
,
1673 LPOVERLAPPED lpOverlapped
)
1677 switch (dwIoControlCode
)
1679 case IOCTL_SERIAL_LSRMST_INSERT
:
1681 FIXME( "IOCTL_SERIAL_LSRMST_INSERT NIY !\n");
1687 FIXME( "Unknown Control %ld\n", dwIoControlCode
);
1696 /***********************************************************************
1700 static void DIOCRegs_2_CONTEXT( DIOC_REGISTERS
*pIn
, CONTEXT86
*pCxt
)
1702 memset( pCxt
, 0, sizeof(*pCxt
) );
1703 /* Note: segment registers == 0 means that CTX_SEG_OFF_TO_LIN
1704 will interpret 32-bit register contents as linear pointers */
1706 pCxt
->ContextFlags
=CONTEXT86_INTEGER
|CONTEXT86_CONTROL
;
1707 pCxt
->Eax
= pIn
->reg_EAX
;
1708 pCxt
->Ebx
= pIn
->reg_EBX
;
1709 pCxt
->Ecx
= pIn
->reg_ECX
;
1710 pCxt
->Edx
= pIn
->reg_EDX
;
1711 pCxt
->Esi
= pIn
->reg_ESI
;
1712 pCxt
->Edi
= pIn
->reg_EDI
;
1714 /* FIXME: Only partial CONTEXT86_CONTROL */
1715 pCxt
->EFlags
= pIn
->reg_Flags
;
1718 static void CONTEXT_2_DIOCRegs( CONTEXT86
*pCxt
, DIOC_REGISTERS
*pOut
)
1720 memset( pOut
, 0, sizeof(DIOC_REGISTERS
) );
1722 pOut
->reg_EAX
= pCxt
->Eax
;
1723 pOut
->reg_EBX
= pCxt
->Ebx
;
1724 pOut
->reg_ECX
= pCxt
->Ecx
;
1725 pOut
->reg_EDX
= pCxt
->Edx
;
1726 pOut
->reg_ESI
= pCxt
->Esi
;
1727 pOut
->reg_EDI
= pCxt
->Edi
;
1729 /* FIXME: Only partial CONTEXT86_CONTROL */
1730 pOut
->reg_Flags
= pCxt
->EFlags
;
1733 #define DIOC_AH(regs) (((unsigned char*)&((regs)->reg_EAX))[1])
1734 #define DIOC_AL(regs) (((unsigned char*)&((regs)->reg_EAX))[0])
1735 #define DIOC_BH(regs) (((unsigned char*)&((regs)->reg_EBX))[1])
1736 #define DIOC_BL(regs) (((unsigned char*)&((regs)->reg_EBX))[0])
1737 #define DIOC_DH(regs) (((unsigned char*)&((regs)->reg_EDX))[1])
1738 #define DIOC_DL(regs) (((unsigned char*)&((regs)->reg_EDX))[0])
1740 #define DIOC_AX(regs) (((unsigned short*)&((regs)->reg_EAX))[0])
1741 #define DIOC_BX(regs) (((unsigned short*)&((regs)->reg_EBX))[0])
1742 #define DIOC_CX(regs) (((unsigned short*)&((regs)->reg_ECX))[0])
1743 #define DIOC_DX(regs) (((unsigned short*)&((regs)->reg_EDX))[0])
1745 #define DIOC_SET_CARRY(regs) (((regs)->reg_Flags)|=0x00000001)
1747 static BOOL
DeviceIo_VWin32(DWORD dwIoControlCode
,
1748 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1749 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1750 LPDWORD lpcbBytesReturned
,
1751 LPOVERLAPPED lpOverlapped
)
1755 switch (dwIoControlCode
)
1757 case VWIN32_DIOC_DOS_IOCTL
:
1758 case 0x10: /* Int 0x21 call, call it VWIN_DIOC_INT21 ? */
1759 case VWIN32_DIOC_DOS_INT13
:
1760 case VWIN32_DIOC_DOS_INT25
:
1761 case VWIN32_DIOC_DOS_INT26
:
1762 case 0x29: /* Int 0x31 call, call it VWIN_DIOC_INT31 ? */
1763 case VWIN32_DIOC_DOS_DRIVEINFO
:
1766 DIOC_REGISTERS
*pIn
= (DIOC_REGISTERS
*)lpvInBuffer
;
1767 DIOC_REGISTERS
*pOut
= (DIOC_REGISTERS
*)lpvOutBuffer
;
1770 TRACE( "Control '%s': "
1771 "eax=0x%08lx, ebx=0x%08lx, ecx=0x%08lx, "
1772 "edx=0x%08lx, esi=0x%08lx, edi=0x%08lx \n",
1773 (dwIoControlCode
== VWIN32_DIOC_DOS_IOCTL
)? "VWIN32_DIOC_DOS_IOCTL" :
1774 (dwIoControlCode
== VWIN32_DIOC_DOS_INT25
)? "VWIN32_DIOC_DOS_INT25" :
1775 (dwIoControlCode
== VWIN32_DIOC_DOS_INT26
)? "VWIN32_DIOC_DOS_INT26" :
1776 (dwIoControlCode
== VWIN32_DIOC_DOS_DRIVEINFO
)? "VWIN32_DIOC_DOS_DRIVEINFO" : "???",
1777 pIn
->reg_EAX
, pIn
->reg_EBX
, pIn
->reg_ECX
,
1778 pIn
->reg_EDX
, pIn
->reg_ESI
, pIn
->reg_EDI
);
1780 DIOCRegs_2_CONTEXT( pIn
, &cxt
);
1782 switch (dwIoControlCode
)
1784 case VWIN32_DIOC_DOS_IOCTL
: /* Call int 21h */
1785 case 0x10: /* Int 0x21 call, call it VWIN_DIOC_INT21 ? */
1786 case VWIN32_DIOC_DOS_DRIVEINFO
: /* Call int 21h 730x */
1789 case VWIN32_DIOC_DOS_INT13
:
1792 case VWIN32_DIOC_DOS_INT25
:
1795 case VWIN32_DIOC_DOS_INT26
:
1798 case 0x29: /* Int 0x31 call, call it VWIN_DIOC_INT31 ? */
1803 if(Dosvm
.CallBuiltinHandler
|| DPMI_LoadDosSystem())
1804 Dosvm
.CallBuiltinHandler( &cxt
, intnum
);
1806 CONTEXT_2_DIOCRegs( &cxt
, pOut
);
1810 case VWIN32_DIOC_SIMCTRLC
:
1811 FIXME( "Control VWIN32_DIOC_SIMCTRLC not implemented\n");
1816 FIXME( "Unknown Control %ld\n", dwIoControlCode
);
1824 /* this is the main multimedia device loader */
1825 static BOOL
DeviceIo_MMDEVLDR(DWORD dwIoControlCode
,
1826 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1827 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1828 LPDWORD lpcbBytesReturned
,
1829 LPOVERLAPPED lpOverlapped
)
1831 FIXME("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
1833 lpvInBuffer
,cbInBuffer
,
1834 lpvOutBuffer
,cbOutBuffer
,
1838 switch (dwIoControlCode
) {
1841 *(DWORD
*)lpvOutBuffer
=0;
1842 *lpcbBytesReturned
=4;
1847 /* this is used by some Origin games */
1848 static BOOL
DeviceIo_MONODEBG(DWORD dwIoControlCode
,
1849 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1850 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1851 LPDWORD lpcbBytesReturned
,
1852 LPOVERLAPPED lpOverlapped
)
1854 switch (dwIoControlCode
) {
1855 case 1: /* version */
1856 *(LPDWORD
)lpvOutBuffer
= 0x20004; /* WC SecretOps */
1858 case 9: /* debug output */
1859 ERR("MONODEBG: %s\n",debugstr_a(lpvInBuffer
));
1862 FIXME("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
1864 lpvInBuffer
,cbInBuffer
,
1865 lpvOutBuffer
,cbOutBuffer
,
1874 static BOOL
DeviceIo_PCCARD (DWORD dwIoControlCode
,
1875 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1876 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1877 LPDWORD lpcbBytesReturned
,
1878 LPOVERLAPPED lpOverlapped
)
1880 switch (dwIoControlCode
) {
1881 case 0x0000: /* PCCARD_Get_Version */
1882 case 0x0001: /* PCCARD_Card_Services */
1884 FIXME( "(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
1886 lpvInBuffer
,cbInBuffer
,
1887 lpvOutBuffer
,cbOutBuffer
,
1896 /***********************************************************************
1897 * OpenVxDHandle (KERNEL32.@)
1899 * This function is supposed to return the corresponding Ring 0
1900 * ("kernel") handle for a Ring 3 handle in Win9x.
1901 * Evidently, Wine will have problems with this. But we try anyway,
1904 HANDLE WINAPI
OpenVxDHandle(HANDLE hHandleRing3
)
1906 FIXME( "(%p), stub! (returning Ring 3 handle instead of Ring 0)\n", hHandleRing3
);
1907 return hHandleRing3
;
1910 static BOOL
DeviceIo_HASP(DWORD dwIoControlCode
, LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1911 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1912 LPDWORD lpcbBytesReturned
,
1913 LPOVERLAPPED lpOverlapped
)
1916 FIXME("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
1918 lpvInBuffer
,cbInBuffer
,
1919 lpvOutBuffer
,cbOutBuffer
,