Fixed RGBQUAD/COLORREF mixup in CreateMappedBitmap().
[wine.git] / win32 / device.c
blobba7ab50dcde45ea56e8d1cc10e324f935acb28c7
1 /*
2 * Win32 device functions
4 * Copyright 1998 Marcus Meissner
5 * Copyright 1998 Ulrich Weigand
6 * Copyright 1998 Patrik Stridvall
8 */
10 #include <errno.h>
11 #include <assert.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14 #include <sys/types.h>
15 #include <sys/stat.h>
16 #ifdef HAVE_SYS_MMAN_H
17 #include <sys/mman.h>
18 #endif
19 #include <fcntl.h>
20 #include <string.h>
21 #include <stdarg.h>
22 #include <time.h>
23 #include "winbase.h"
24 #include "winreg.h"
25 #include "winerror.h"
26 #include "file.h"
27 #include "process.h"
28 #include "mmsystem.h"
29 #include "heap.h"
30 #include "winioctl.h"
31 #include "winnt.h"
32 #include "msdos.h"
33 #include "miscemu.h"
34 #include "server.h"
35 #include "debugtools.h"
37 DEFAULT_DEBUG_CHANNEL(win32)
40 static BOOL DeviceIo_VTDAPI(DWORD dwIoControlCode,
41 LPVOID lpvInBuffer, DWORD cbInBuffer,
42 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
43 LPDWORD lpcbBytesReturned,
44 LPOVERLAPPED lpOverlapped);
45 static BOOL DeviceIo_MONODEBG(DWORD dwIoControlCode,
46 LPVOID lpvInBuffer, DWORD cbInBuffer,
47 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
48 LPDWORD lpcbBytesReturned,
49 LPOVERLAPPED lpOverlapped);
50 static BOOL DeviceIo_MMDEVLDR(DWORD dwIoControlCode,
51 LPVOID lpvInBuffer, DWORD cbInBuffer,
52 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
53 LPDWORD lpcbBytesReturned,
54 LPOVERLAPPED lpOverlapped);
56 static DWORD VxDCall_VMM( DWORD service, va_list args );
58 static BOOL DeviceIo_IFSMgr(DWORD dwIoControlCode,
59 LPVOID lpvInBuffer, DWORD cbInBuffer,
60 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
61 LPDWORD lpcbBytesReturned,
62 LPOVERLAPPED lpOverlapped);
64 static BOOL DeviceIo_VWin32(DWORD dwIoControlCode,
65 LPVOID lpvInBuffer, DWORD cbInBuffer,
66 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
67 LPDWORD lpcbBytesReturned,
68 LPOVERLAPPED lpOverlapped);
70 static BOOL DeviceIo_PCCARD (DWORD dwIoControlCode,
71 LPVOID lpvInBuffer, DWORD cbInBuffer,
72 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
73 LPDWORD lpcbBytesReturned,
74 LPOVERLAPPED lpOverlapped);
76 * VxD names are taken from the Win95 DDK
79 struct VxDInfo
81 LPCSTR name;
82 WORD id;
83 DWORD (*vxdcall)(DWORD, va_list);
84 BOOL (*deviceio)(DWORD, LPVOID, DWORD,
85 LPVOID, DWORD, LPDWORD, LPOVERLAPPED);
88 static const struct VxDInfo VxDList[] =
90 /* Standard VxD IDs */
91 { "VMM", 0x0001, VxDCall_VMM, NULL },
92 { "DEBUG", 0x0002, NULL, NULL },
93 { "VPICD", 0x0003, NULL, NULL },
94 { "VDMAD", 0x0004, NULL, NULL },
95 { "VTD", 0x0005, NULL, NULL },
96 { "V86MMGR", 0x0006, NULL, NULL },
97 { "PAGESWAP", 0x0007, NULL, NULL },
98 { "PARITY", 0x0008, NULL, NULL },
99 { "REBOOT", 0x0009, NULL, NULL },
100 { "VDD", 0x000A, NULL, NULL },
101 { "VSD", 0x000B, NULL, NULL },
102 { "VMD", 0x000C, NULL, NULL },
103 { "VKD", 0x000D, NULL, NULL },
104 { "VCD", 0x000E, NULL, NULL },
105 { "VPD", 0x000F, NULL, NULL },
106 { "BLOCKDEV", 0x0010, NULL, NULL },
107 { "VMCPD", 0x0011, NULL, NULL },
108 { "EBIOS", 0x0012, NULL, NULL },
109 { "BIOSXLAT", 0x0013, NULL, NULL },
110 { "VNETBIOS", 0x0014, NULL, NULL },
111 { "DOSMGR", 0x0015, NULL, NULL },
112 { "WINLOAD", 0x0016, NULL, NULL },
113 { "SHELL", 0x0017, NULL, NULL },
114 { "VMPOLL", 0x0018, NULL, NULL },
115 { "VPROD", 0x0019, NULL, NULL },
116 { "DOSNET", 0x001A, NULL, NULL },
117 { "VFD", 0x001B, NULL, NULL },
118 { "VDD2", 0x001C, NULL, NULL },
119 { "WINDEBUG", 0x001D, NULL, NULL },
120 { "TSRLOAD", 0x001E, NULL, NULL },
121 { "BIOSHOOK", 0x001F, NULL, NULL },
122 { "INT13", 0x0020, NULL, NULL },
123 { "PAGEFILE", 0x0021, NULL, NULL },
124 { "SCSI", 0x0022, NULL, NULL },
125 { "MCA_POS", 0x0023, NULL, NULL },
126 { "SCSIFD", 0x0024, NULL, NULL },
127 { "VPEND", 0x0025, NULL, NULL },
128 { "VPOWERD", 0x0026, NULL, NULL },
129 { "VXDLDR", 0x0027, NULL, NULL },
130 { "NDIS", 0x0028, NULL, NULL },
131 { "BIOS_EXT", 0x0029, NULL, NULL },
132 { "VWIN32", 0x002A, NULL, DeviceIo_VWin32 },
133 { "VCOMM", 0x002B, NULL, NULL },
134 { "SPOOLER", 0x002C, NULL, NULL },
135 { "WIN32S", 0x002D, NULL, NULL },
136 { "DEBUGCMD", 0x002E, NULL, NULL },
138 { "VNB", 0x0031, NULL, NULL },
139 { "SERVER", 0x0032, NULL, NULL },
140 { "CONFIGMG", 0x0033, NULL, NULL },
141 { "DWCFGMG", 0x0034, NULL, NULL },
142 { "SCSIPORT", 0x0035, NULL, NULL },
143 { "VFBACKUP", 0x0036, NULL, NULL },
144 { "ENABLE", 0x0037, NULL, NULL },
145 { "VCOND", 0x0038, NULL, NULL },
147 { "EFAX", 0x003A, NULL, NULL },
148 { "DSVXD", 0x003B, NULL, NULL },
149 { "ISAPNP", 0x003C, NULL, NULL },
150 { "BIOS", 0x003D, NULL, NULL },
151 { "WINSOCK", 0x003E, NULL, NULL },
152 { "WSOCK", 0x003E, NULL, NULL },
153 { "WSIPX", 0x003F, NULL, NULL },
154 { "IFSMgr", 0x0040, NULL, DeviceIo_IFSMgr },
155 { "VCDFSD", 0x0041, NULL, NULL },
156 { "MRCI2", 0x0042, NULL, NULL },
157 { "PCI", 0x0043, NULL, NULL },
158 { "PELOADER", 0x0044, NULL, NULL },
159 { "EISA", 0x0045, NULL, NULL },
160 { "DRAGCLI", 0x0046, NULL, NULL },
161 { "DRAGSRV", 0x0047, NULL, NULL },
162 { "PERF", 0x0048, NULL, NULL },
163 { "AWREDIR", 0x0049, NULL, NULL },
165 /* Far East support */
166 { "ETEN", 0x0060, NULL, NULL },
167 { "CHBIOS", 0x0061, NULL, NULL },
168 { "VMSGD", 0x0062, NULL, NULL },
169 { "VPPID", 0x0063, NULL, NULL },
170 { "VIME", 0x0064, NULL, NULL },
171 { "VHBIOSD", 0x0065, NULL, NULL },
173 /* Multimedia OEM IDs */
174 { "VTDAPI", 0x0442, NULL, DeviceIo_VTDAPI },
175 { "MMDEVLDR", 0x044A, NULL, DeviceIo_MMDEVLDR },
177 /* Network Device IDs */
178 { "VNetSup", 0x0480, NULL, NULL },
179 { "VRedir", 0x0481, NULL, NULL },
180 { "VBrowse", 0x0482, NULL, NULL },
181 { "VSHARE", 0x0483, NULL, NULL },
182 { "IFSMgr", 0x0484, NULL, NULL },
183 { "MEMPROBE", 0x0485, NULL, NULL },
184 { "VFAT", 0x0486, NULL, NULL },
185 { "NWLINK", 0x0487, NULL, NULL },
186 { "VNWLINK", 0x0487, NULL, NULL },
187 { "NWSUP", 0x0487, NULL, NULL },
188 { "VTDI", 0x0488, NULL, NULL },
189 { "VIP", 0x0489, NULL, NULL },
190 { "VTCP", 0x048A, NULL, NULL },
191 { "VCache", 0x048B, NULL, NULL },
192 { "VUDP", 0x048C, NULL, NULL },
193 { "VAsync", 0x048D, NULL, NULL },
194 { "NWREDIR", 0x048E, NULL, NULL },
195 { "STAT80", 0x048F, NULL, NULL },
196 { "SCSIPORT", 0x0490, NULL, NULL },
197 { "FILESEC", 0x0491, NULL, NULL },
198 { "NWSERVER", 0x0492, NULL, NULL },
199 { "SECPROV", 0x0493, NULL, NULL },
200 { "NSCL", 0x0494, NULL, NULL },
201 { "WSTCP", 0x0495, NULL, NULL },
202 { "NDIS2SUP", 0x0496, NULL, NULL },
203 { "MSODISUP", 0x0497, NULL, NULL },
204 { "Splitter", 0x0498, NULL, NULL },
205 { "PPP", 0x0499, NULL, NULL },
206 { "VDHCP", 0x049A, NULL, NULL },
207 { "VNBT", 0x049B, NULL, NULL },
208 { "LOGGER", 0x049D, NULL, NULL },
209 { "EFILTER", 0x049E, NULL, NULL },
210 { "FFILTER", 0x049F, NULL, NULL },
211 { "TFILTER", 0x04A0, NULL, NULL },
212 { "AFILTER", 0x04A1, NULL, NULL },
213 { "IRLAMP", 0x04A2, NULL, NULL },
215 { "PCCARD", 0x097C, NULL, DeviceIo_PCCARD },
217 /* WINE additions, ids unknown */
218 { "MONODEBG.VXD", 0x4242, NULL, DeviceIo_MONODEBG },
220 { NULL, 0, NULL, NULL }
224 * VMM VxDCall service names are (mostly) taken from Stan Mitchell's
225 * "Inside the Windows 95 File System"
228 #define N_VMM_SERVICE 41
230 LPCSTR VMM_Service_Name[N_VMM_SERVICE] =
232 "PageReserve", /* 0x0000 */
233 "PageCommit", /* 0x0001 */
234 "PageDecommit", /* 0x0002 */
235 "PagerRegister", /* 0x0003 */
236 "PagerQuery", /* 0x0004 */
237 "HeapAllocate", /* 0x0005 */
238 "ContextCreate", /* 0x0006 */
239 "ContextDestroy", /* 0x0007 */
240 "PageAttach", /* 0x0008 */
241 "PageFlush", /* 0x0009 */
242 "PageFree", /* 0x000A */
243 "ContextSwitch", /* 0x000B */
244 "HeapReAllocate", /* 0x000C */
245 "PageModifyPerm", /* 0x000D */
246 "PageQuery", /* 0x000E */
247 "GetCurrentContext", /* 0x000F */
248 "HeapFree", /* 0x0010 */
249 "RegOpenKey", /* 0x0011 */
250 "RegCreateKey", /* 0x0012 */
251 "RegCloseKey", /* 0x0013 */
252 "RegDeleteKey", /* 0x0014 */
253 "RegSetValue", /* 0x0015 */
254 "RegDeleteValue", /* 0x0016 */
255 "RegQueryValue", /* 0x0017 */
256 "RegEnumKey", /* 0x0018 */
257 "RegEnumValue", /* 0x0019 */
258 "RegQueryValueEx", /* 0x001A */
259 "RegSetValueEx", /* 0x001B */
260 "RegFlushKey", /* 0x001C */
261 "RegQueryInfoKey", /* 0x001D */
262 "GetDemandPageInfo", /* 0x001E */
263 "BlockOnID", /* 0x001F */
264 "SignalID", /* 0x0020 */
265 "RegLoadKey", /* 0x0021 */
266 "RegUnLoadKey", /* 0x0022 */
267 "RegSaveKey", /* 0x0023 */
268 "RegRemapPreDefKey", /* 0x0024 */
269 "PageChangePager", /* 0x0025 */
270 "RegQueryMultipleValues", /* 0x0026 */
271 "RegReplaceKey", /* 0x0027 */
272 "<KERNEL32.101>" /* 0x0028 -- What does this do??? */
275 HANDLE DEVICE_Open( LPCSTR filename, DWORD access,
276 LPSECURITY_ATTRIBUTES sa )
278 const struct VxDInfo *info;
280 for (info = VxDList; info->name; info++)
281 if (!lstrcmpiA( info->name, filename ))
282 return FILE_CreateDevice( info->id | 0x10000, access, sa );
284 FIXME( "Unknown VxD %s\n", filename);
285 SetLastError( ERROR_PATH_NOT_FOUND );
286 return HFILE_ERROR;
289 static const struct VxDInfo *DEVICE_GetInfo( HANDLE handle )
291 struct get_file_info_request *req = get_req_buffer();
293 req->handle = handle;
294 if (!server_call( REQ_GET_FILE_INFO ) &&
295 (req->type == FILE_TYPE_UNKNOWN) &&
296 (req->attr & 0x10000))
298 const struct VxDInfo *info;
299 for (info = VxDList; info->name; info++)
300 if (info->id == LOWORD(req->attr)) return info;
302 return NULL;
305 /****************************************************************************
306 * DeviceIoControl (KERNEL32.188)
307 * This is one of those big ugly nasty procedure which can do
308 * a million and one things when it comes to devices. It can also be
309 * used for VxD communication.
311 * A return value of FALSE indicates that something has gone wrong which
312 * GetLastError can decypher.
314 BOOL WINAPI DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode,
315 LPVOID lpvInBuffer, DWORD cbInBuffer,
316 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
317 LPDWORD lpcbBytesReturned,
318 LPOVERLAPPED lpOverlapped)
320 const struct VxDInfo *info;
322 TRACE( "(%d,%ld,%p,%ld,%p,%ld,%p,%p)\n",
323 hDevice,dwIoControlCode,lpvInBuffer,cbInBuffer,
324 lpvOutBuffer,cbOutBuffer,lpcbBytesReturned,lpOverlapped );
326 if (!(info = DEVICE_GetInfo( hDevice )))
328 SetLastError( ERROR_INVALID_PARAMETER );
329 return FALSE;
332 /* Check if this is a user defined control code for a VxD */
333 if( HIWORD( dwIoControlCode ) == 0 )
335 if ( info->deviceio )
337 return info->deviceio( dwIoControlCode,
338 lpvInBuffer, cbInBuffer,
339 lpvOutBuffer, cbOutBuffer,
340 lpcbBytesReturned, lpOverlapped );
342 else
344 /* FIXME: Set appropriate error */
345 FIXME( "Unimplemented control %ld for VxD device %s\n",
346 dwIoControlCode, info->name ? info->name : "???" );
349 else
351 switch( dwIoControlCode )
353 case FSCTL_DELETE_REPARSE_POINT:
354 case FSCTL_DISMOUNT_VOLUME:
355 case FSCTL_GET_COMPRESSION:
356 case FSCTL_GET_REPARSE_POINT:
357 case FSCTL_LOCK_VOLUME:
358 case FSCTL_QUERY_ALLOCATED_RANGES:
359 case FSCTL_SET_COMPRESSION:
360 case FSCTL_SET_REPARSE_POINT:
361 case FSCTL_SET_SPARSE:
362 case FSCTL_SET_ZERO_DATA:
363 case FSCTL_UNLOCK_VOLUME:
364 case IOCTL_DISK_CHECK_VERIFY:
365 case IOCTL_DISK_EJECT_MEDIA:
366 case IOCTL_DISK_FORMAT_TRACKS:
367 case IOCTL_DISK_GET_DRIVE_GEOMETRY:
368 case IOCTL_DISK_GET_DRIVE_LAYOUT:
369 case IOCTL_DISK_GET_MEDIA_TYPES:
370 case IOCTL_DISK_GET_PARTITION_INFO:
371 case IOCTL_DISK_LOAD_MEDIA:
372 case IOCTL_DISK_MEDIA_REMOVAL:
373 case IOCTL_DISK_PERFORMANCE:
374 case IOCTL_DISK_REASSIGN_BLOCKS:
375 case IOCTL_DISK_SET_DRIVE_LAYOUT:
376 case IOCTL_DISK_SET_PARTITION_INFO:
377 case IOCTL_DISK_VERIFY:
378 case IOCTL_SERIAL_LSRMST_INSERT:
379 case IOCTL_STORAGE_CHECK_VERIFY:
380 case IOCTL_STORAGE_EJECT_MEDIA:
381 case IOCTL_STORAGE_GET_MEDIA_TYPES:
382 case IOCTL_STORAGE_LOAD_MEDIA:
383 case IOCTL_STORAGE_MEDIA_REMOVAL:
384 FIXME( "unimplemented dwIoControlCode=%08lx\n", dwIoControlCode);
385 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
386 return FALSE;
387 break;
388 default:
389 FIXME( "ignored dwIoControlCode=%08lx\n",dwIoControlCode);
390 SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
391 return FALSE;
392 break;
395 return FALSE;
398 /***********************************************************************
399 * DeviceIo_VTDAPI
401 static BOOL DeviceIo_VTDAPI(DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer,
402 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
403 LPDWORD lpcbBytesReturned,
404 LPOVERLAPPED lpOverlapped)
406 BOOL retv = TRUE;
408 switch (dwIoControlCode)
410 case 5:
411 if (lpvOutBuffer && (cbOutBuffer>=4))
412 *(DWORD*)lpvOutBuffer = timeGetTime();
414 if (lpcbBytesReturned)
415 *lpcbBytesReturned = 4;
417 break;
419 default:
420 FIXME( "Control %ld not implemented\n", dwIoControlCode);
421 retv = FALSE;
422 break;
425 return retv;
432 /***********************************************************************
433 * VxDCall (KERNEL32.[1-9])
435 static DWORD VxDCall( DWORD service, ... )
437 DWORD ret = 0xffffffff; /* FIXME */
438 int i;
440 TRACE( "(%08lx, ...)\n", service);
442 for (i = 0; VxDList[i].name; i++)
443 if (VxDList[i].id == HIWORD(service))
444 break;
446 if (!VxDList[i].name)
447 FIXME( "Unknown VxD (%08lx)\n", service);
448 else if (!VxDList[i].vxdcall)
449 FIXME( "Unimplemented VxD (%08lx)\n", service);
450 else
452 va_list args;
453 va_start( args, service );
454 ret = VxDList[i].vxdcall( service, args );
455 va_end( args );
457 return ret;
460 DWORD WINAPI VxDCall0( DWORD service )
462 return VxDCall( service );
465 DWORD WINAPI VxDCall1( DWORD service, DWORD arg1 )
467 return VxDCall( service, arg1 );
470 DWORD WINAPI VxDCall2( DWORD service, DWORD arg1, DWORD arg2 )
472 return VxDCall( service, arg1, arg2 );
475 DWORD WINAPI VxDCall3( DWORD service, DWORD arg1, DWORD arg2, DWORD arg3 )
477 return VxDCall( service, arg1, arg2, arg3 );
480 DWORD WINAPI VxDCall4( DWORD service, DWORD arg1, DWORD arg2, DWORD arg3, DWORD arg4 )
482 return VxDCall( service, arg1, arg2, arg3, arg4 );
485 DWORD WINAPI VxDCall5( DWORD service, DWORD arg1, DWORD arg2, DWORD arg3,
486 DWORD arg4, DWORD arg5 )
488 return VxDCall( service, arg1, arg2, arg3, arg4, arg5 );
491 DWORD WINAPI VxDCall6( DWORD service, DWORD arg1, DWORD arg2, DWORD arg3,
492 DWORD arg4, DWORD arg5, DWORD arg6 )
494 return VxDCall( service, arg1, arg2, arg3, arg4, arg5, arg6 );
497 DWORD WINAPI VxDCall7( DWORD service, DWORD arg1, DWORD arg2, DWORD arg3,
498 DWORD arg4, DWORD arg5, DWORD arg6, DWORD arg7 )
500 return VxDCall( service, arg1, arg2, arg3, arg4, arg5, arg6, arg7 );
503 DWORD WINAPI VxDCall8( DWORD service, DWORD arg1, DWORD arg2, DWORD arg3,
504 DWORD arg4, DWORD arg5, DWORD arg6, DWORD arg7, DWORD arg8 )
506 return VxDCall( service, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 );
509 /***********************************************************************
510 * VxDCall_VMM
512 static DWORD VxDCall_VMM( DWORD service, va_list args )
514 switch ( LOWORD(service) )
516 case 0x0011: /* RegOpenKey */
518 HKEY hkey = va_arg( args, HKEY );
519 LPCSTR lpszSubKey = va_arg( args, LPCSTR );
520 LPHKEY retkey = va_arg( args, LPHKEY );
521 return RegOpenKeyA( hkey, lpszSubKey, retkey );
524 case 0x0012: /* RegCreateKey */
526 HKEY hkey = va_arg( args, HKEY );
527 LPCSTR lpszSubKey = va_arg( args, LPCSTR );
528 LPHKEY retkey = va_arg( args, LPHKEY );
529 return RegCreateKeyA( hkey, lpszSubKey, retkey );
532 case 0x0013: /* RegCloseKey */
534 HKEY hkey = va_arg( args, HKEY );
535 return RegCloseKey( hkey );
538 case 0x0014: /* RegDeleteKey */
540 HKEY hkey = va_arg( args, HKEY );
541 LPCSTR lpszSubKey = va_arg( args, LPCSTR );
542 return RegDeleteKeyA( hkey, lpszSubKey );
545 case 0x0015: /* RegSetValue */
547 HKEY hkey = va_arg( args, HKEY );
548 LPCSTR lpszSubKey = va_arg( args, LPCSTR );
549 DWORD dwType = va_arg( args, DWORD );
550 LPCSTR lpszData = va_arg( args, LPCSTR );
551 DWORD cbData = va_arg( args, DWORD );
552 return RegSetValueA( hkey, lpszSubKey, dwType, lpszData, cbData );
555 case 0x0016: /* RegDeleteValue */
557 HKEY hkey = va_arg( args, HKEY );
558 LPSTR lpszValue = va_arg( args, LPSTR );
559 return RegDeleteValueA( hkey, lpszValue );
562 case 0x0017: /* RegQueryValue */
564 HKEY hkey = va_arg( args, HKEY );
565 LPSTR lpszSubKey = va_arg( args, LPSTR );
566 LPSTR lpszData = va_arg( args, LPSTR );
567 LPDWORD lpcbData = va_arg( args, LPDWORD );
568 return RegQueryValueA( hkey, lpszSubKey, lpszData, lpcbData );
571 case 0x0018: /* RegEnumKey */
573 HKEY hkey = va_arg( args, HKEY );
574 DWORD iSubkey = va_arg( args, DWORD );
575 LPSTR lpszName = va_arg( args, LPSTR );
576 DWORD lpcchName = va_arg( args, DWORD );
577 return RegEnumKeyA( hkey, iSubkey, lpszName, lpcchName );
580 case 0x0019: /* RegEnumValue */
582 HKEY hkey = va_arg( args, HKEY );
583 DWORD iValue = va_arg( args, DWORD );
584 LPSTR lpszValue = va_arg( args, LPSTR );
585 LPDWORD lpcchValue = va_arg( args, LPDWORD );
586 LPDWORD lpReserved = va_arg( args, LPDWORD );
587 LPDWORD lpdwType = va_arg( args, LPDWORD );
588 LPBYTE lpbData = va_arg( args, LPBYTE );
589 LPDWORD lpcbData = va_arg( args, LPDWORD );
590 return RegEnumValueA( hkey, iValue, lpszValue, lpcchValue,
591 lpReserved, lpdwType, lpbData, lpcbData );
594 case 0x001A: /* RegQueryValueEx */
596 HKEY hkey = va_arg( args, HKEY );
597 LPSTR lpszValue = va_arg( args, LPSTR );
598 LPDWORD lpReserved = va_arg( args, LPDWORD );
599 LPDWORD lpdwType = va_arg( args, LPDWORD );
600 LPBYTE lpbData = va_arg( args, LPBYTE );
601 LPDWORD lpcbData = va_arg( args, LPDWORD );
602 return RegQueryValueExA( hkey, lpszValue, lpReserved,
603 lpdwType, lpbData, lpcbData );
606 case 0x001B: /* RegSetValueEx */
608 HKEY hkey = va_arg( args, HKEY );
609 LPSTR lpszValue = va_arg( args, LPSTR );
610 DWORD dwReserved = va_arg( args, DWORD );
611 DWORD dwType = va_arg( args, DWORD );
612 LPBYTE lpbData = va_arg( args, LPBYTE );
613 DWORD cbData = va_arg( args, DWORD );
614 return RegSetValueExA( hkey, lpszValue, dwReserved,
615 dwType, lpbData, cbData );
618 case 0x001C: /* RegFlushKey */
620 HKEY hkey = va_arg( args, HKEY );
621 return RegFlushKey( hkey );
624 case 0x001D: /* RegQueryInfoKey */
626 /* NOTE: This VxDCall takes only a subset of the parameters that the
627 corresponding Win32 API call does. The implementation in Win95
628 ADVAPI32 sets all output parameters not mentioned here to zero. */
630 HKEY hkey = va_arg( args, HKEY );
631 LPDWORD lpcSubKeys = va_arg( args, LPDWORD );
632 LPDWORD lpcchMaxSubKey = va_arg( args, LPDWORD );
633 LPDWORD lpcValues = va_arg( args, LPDWORD );
634 LPDWORD lpcchMaxValueName = va_arg( args, LPDWORD );
635 LPDWORD lpcchMaxValueData = va_arg( args, LPDWORD );
636 return RegQueryInfoKeyA( hkey, NULL, NULL, NULL, lpcSubKeys, lpcchMaxSubKey,
637 NULL, lpcValues, lpcchMaxValueName, lpcchMaxValueData,
638 NULL, NULL );
641 case 0x0021: /* RegLoadKey */
643 HKEY hkey = va_arg( args, HKEY );
644 LPCSTR lpszSubKey = va_arg( args, LPCSTR );
645 LPCSTR lpszFile = va_arg( args, LPCSTR );
646 return RegLoadKeyA( hkey, lpszSubKey, lpszFile );
649 case 0x0022: /* RegUnLoadKey */
651 HKEY hkey = va_arg( args, HKEY );
652 LPCSTR lpszSubKey = va_arg( args, LPCSTR );
653 return RegUnLoadKeyA( hkey, lpszSubKey );
656 case 0x0023: /* RegSaveKey */
658 HKEY hkey = va_arg( args, HKEY );
659 LPCSTR lpszFile = va_arg( args, LPCSTR );
660 LPSECURITY_ATTRIBUTES sa = va_arg( args, LPSECURITY_ATTRIBUTES );
661 return RegSaveKeyA( hkey, lpszFile, sa );
664 #if 0 /* Functions are not yet implemented in misc/registry.c */
665 case 0x0024: /* RegRemapPreDefKey */
666 case 0x0026: /* RegQueryMultipleValues */
667 #endif
669 case 0x0027: /* RegReplaceKey */
671 HKEY hkey = va_arg( args, HKEY );
672 LPCSTR lpszSubKey = va_arg( args, LPCSTR );
673 LPCSTR lpszNewFile= va_arg( args, LPCSTR );
674 LPCSTR lpszOldFile= va_arg( args, LPCSTR );
675 return RegReplaceKeyA( hkey, lpszSubKey, lpszNewFile, lpszOldFile );
678 default:
679 if (LOWORD(service) < N_VMM_SERVICE)
680 FIXME( "Unimplemented service %s (%08lx)\n",
681 VMM_Service_Name[LOWORD(service)], service);
682 else
683 FIXME( "Unknown service %08lx\n", service);
684 break;
687 return 0xffffffff; /* FIXME */
690 /***********************************************************************
691 * DeviceIo_IFSMgr
692 * NOTES
693 * The ioctls is used by 'MSNET32.DLL'.
695 * I have been unable to uncover any documentation about the ioctls so
696 * the implementation of the cases IFS_IOCTL_21 and IFS_IOCTL_2F are
697 * based on a resonable guesses on information found in the Windows 95 DDK.
702 * IFSMgr DeviceIO service
705 #define IFS_IOCTL_21 100
706 #define IFS_IOCTL_2F 101
707 #define IFS_IOCTL_GET_RES 102
708 #define IFS_IOCTL_GET_NETPRO_NAME_A 103
710 struct win32apireq {
711 unsigned long ar_proid;
712 unsigned long ar_eax;
713 unsigned long ar_ebx;
714 unsigned long ar_ecx;
715 unsigned long ar_edx;
716 unsigned long ar_esi;
717 unsigned long ar_edi;
718 unsigned long ar_ebp;
719 unsigned short ar_error;
720 unsigned short ar_pad;
723 static void win32apieq_2_CONTEXT(struct win32apireq *pIn,CONTEXT86 *pCxt)
725 memset(pCxt,0,sizeof(*pCxt));
727 pCxt->ContextFlags=CONTEXT86_INTEGER|CONTEXT86_CONTROL;
728 pCxt->Eax = pIn->ar_eax;
729 pCxt->Ebx = pIn->ar_ebx;
730 pCxt->Ecx = pIn->ar_ecx;
731 pCxt->Edx = pIn->ar_edx;
732 pCxt->Esi = pIn->ar_esi;
733 pCxt->Edi = pIn->ar_edi;
735 /* FIXME: Only partial CONTEXT86_CONTROL */
736 pCxt->Ebp = pIn->ar_ebp;
738 /* FIXME: pIn->ar_proid ignored */
739 /* FIXME: pIn->ar_error ignored */
740 /* FIXME: pIn->ar_pad ignored */
743 static void CONTEXT_2_win32apieq(CONTEXT86 *pCxt,struct win32apireq *pOut)
745 memset(pOut,0,sizeof(struct win32apireq));
747 pOut->ar_eax = pCxt->Eax;
748 pOut->ar_ebx = pCxt->Ebx;
749 pOut->ar_ecx = pCxt->Ecx;
750 pOut->ar_edx = pCxt->Edx;
751 pOut->ar_esi = pCxt->Esi;
752 pOut->ar_edi = pCxt->Edi;
754 /* FIXME: Only partial CONTEXT86_CONTROL */
755 pOut->ar_ebp = pCxt->Ebp;
757 /* FIXME: pOut->ar_proid ignored */
758 /* FIXME: pOut->ar_error ignored */
759 /* FIXME: pOut->ar_pad ignored */
762 static BOOL DeviceIo_IFSMgr(DWORD dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer,
763 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
764 LPDWORD lpcbBytesReturned,
765 LPOVERLAPPED lpOverlapped)
767 BOOL retv = TRUE;
768 TRACE("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
769 dwIoControlCode,
770 lpvInBuffer,cbInBuffer,
771 lpvOutBuffer,cbOutBuffer,
772 lpcbBytesReturned,
773 lpOverlapped);
775 switch (dwIoControlCode)
777 case IFS_IOCTL_21:
778 case IFS_IOCTL_2F:{
779 CONTEXT86 cxt;
780 struct win32apireq *pIn=(struct win32apireq *) lpvInBuffer;
781 struct win32apireq *pOut=(struct win32apireq *) lpvOutBuffer;
783 TRACE(
784 "Control '%s': "
785 "proid=0x%08lx, eax=0x%08lx, ebx=0x%08lx, ecx=0x%08lx, "
786 "edx=0x%08lx, esi=0x%08lx, edi=0x%08lx, ebp=0x%08lx, "
787 "error=0x%04x, pad=0x%04x\n",
788 (dwIoControlCode==IFS_IOCTL_21)?"IFS_IOCTL_21":"IFS_IOCTL_2F",
789 pIn->ar_proid, pIn->ar_eax, pIn->ar_ebx, pIn->ar_ecx,
790 pIn->ar_edx, pIn->ar_esi, pIn->ar_edi, pIn->ar_ebp,
791 pIn->ar_error, pIn->ar_pad
794 win32apieq_2_CONTEXT(pIn,&cxt);
796 if(dwIoControlCode==IFS_IOCTL_21)
798 DOS3Call(&cxt); /* Call int 21h */
799 } else {
800 INT_Int2fHandler(&cxt); /* Call int 2Fh */
803 CONTEXT_2_win32apieq(&cxt,pOut);
805 retv = TRUE;
806 } break;
807 case IFS_IOCTL_GET_RES:{
808 FIXME( "Control 'IFS_IOCTL_GET_RES' not implemented\n");
809 retv = FALSE;
810 } break;
811 case IFS_IOCTL_GET_NETPRO_NAME_A:{
812 FIXME( "Control 'IFS_IOCTL_GET_NETPRO_NAME_A' not implemented\n");
813 retv = FALSE;
814 } break;
815 default:
816 FIXME( "Control %ld not implemented\n", dwIoControlCode);
817 retv = FALSE;
820 return retv;
824 /***********************************************************************
825 * DeviceIo_VWin32
828 static void DIOCRegs_2_CONTEXT( DIOC_REGISTERS *pIn, CONTEXT86 *pCxt )
830 memset( pCxt, 0, sizeof(*pCxt) );
831 /* Note: segment registers == 0 means that CTX_SEG_OFF_TO_LIN
832 will interpret 32-bit register contents as linear pointers */
834 pCxt->ContextFlags=CONTEXT86_INTEGER|CONTEXT86_CONTROL;
835 pCxt->Eax = pIn->reg_EAX;
836 pCxt->Ebx = pIn->reg_EBX;
837 pCxt->Ecx = pIn->reg_ECX;
838 pCxt->Edx = pIn->reg_EDX;
839 pCxt->Esi = pIn->reg_ESI;
840 pCxt->Edi = pIn->reg_EDI;
842 /* FIXME: Only partial CONTEXT86_CONTROL */
843 pCxt->EFlags = pIn->reg_Flags;
846 static void CONTEXT_2_DIOCRegs( CONTEXT86 *pCxt, DIOC_REGISTERS *pOut )
848 memset( pOut, 0, sizeof(DIOC_REGISTERS) );
850 pOut->reg_EAX = pCxt->Eax;
851 pOut->reg_EBX = pCxt->Ebx;
852 pOut->reg_ECX = pCxt->Ecx;
853 pOut->reg_EDX = pCxt->Edx;
854 pOut->reg_ESI = pCxt->Esi;
855 pOut->reg_EDI = pCxt->Edi;
857 /* FIXME: Only partial CONTEXT86_CONTROL */
858 pOut->reg_Flags = pCxt->EFlags;
862 static BOOL DeviceIo_VWin32(DWORD dwIoControlCode,
863 LPVOID lpvInBuffer, DWORD cbInBuffer,
864 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
865 LPDWORD lpcbBytesReturned,
866 LPOVERLAPPED lpOverlapped)
868 BOOL retv = TRUE;
870 switch (dwIoControlCode)
872 case VWIN32_DIOC_DOS_IOCTL:
873 case VWIN32_DIOC_DOS_INT13:
874 case VWIN32_DIOC_DOS_INT25:
875 case VWIN32_DIOC_DOS_INT26:
877 CONTEXT86 cxt;
878 DIOC_REGISTERS *pIn = (DIOC_REGISTERS *)lpvInBuffer;
879 DIOC_REGISTERS *pOut = (DIOC_REGISTERS *)lpvOutBuffer;
881 TRACE( "Control '%s': "
882 "eax=0x%08lx, ebx=0x%08lx, ecx=0x%08lx, "
883 "edx=0x%08lx, esi=0x%08lx, edi=0x%08lx ",
884 (dwIoControlCode == VWIN32_DIOC_DOS_IOCTL)? "VWIN32_DIOC_DOS_IOCTL" :
885 (dwIoControlCode == VWIN32_DIOC_DOS_INT13)? "VWIN32_DIOC_DOS_INT13" :
886 (dwIoControlCode == VWIN32_DIOC_DOS_INT25)? "VWIN32_DIOC_DOS_INT25" :
887 (dwIoControlCode == VWIN32_DIOC_DOS_INT26)? "VWIN32_DIOC_DOS_INT26" : "???",
888 pIn->reg_EAX, pIn->reg_EBX, pIn->reg_ECX,
889 pIn->reg_EDX, pIn->reg_ESI, pIn->reg_EDI );
891 DIOCRegs_2_CONTEXT( pIn, &cxt );
893 switch (dwIoControlCode)
895 case VWIN32_DIOC_DOS_IOCTL: DOS3Call( &cxt ); break; /* Call int 21h */
896 case VWIN32_DIOC_DOS_INT13: INT_Int13Handler( &cxt ); break;
897 case VWIN32_DIOC_DOS_INT25: INT_Int25Handler( &cxt ); break;
898 case VWIN32_DIOC_DOS_INT26: INT_Int26Handler( &cxt ); break;
901 CONTEXT_2_DIOCRegs( &cxt, pOut );
903 break;
905 case VWIN32_DIOC_SIMCTRLC:
906 FIXME( "Control VWIN32_DIOC_SIMCTRLC not implemented\n");
907 retv = FALSE;
908 break;
910 default:
911 FIXME( "Unknown Control %ld\n", dwIoControlCode);
912 retv = FALSE;
913 break;
916 return retv;
919 /* this is the main multimedia device loader */
920 static BOOL DeviceIo_MMDEVLDR(DWORD dwIoControlCode,
921 LPVOID lpvInBuffer, DWORD cbInBuffer,
922 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
923 LPDWORD lpcbBytesReturned,
924 LPOVERLAPPED lpOverlapped)
926 FIXME("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
927 dwIoControlCode,
928 lpvInBuffer,cbInBuffer,
929 lpvOutBuffer,cbOutBuffer,
930 lpcbBytesReturned,
931 lpOverlapped
933 switch (dwIoControlCode) {
934 case 5:
935 /* Hmm. */
936 *(DWORD*)lpvOutBuffer=0;
937 *lpcbBytesReturned=4;
938 return TRUE;
940 return FALSE;
942 /* this is used by some Origin games */
943 static BOOL DeviceIo_MONODEBG(DWORD dwIoControlCode,
944 LPVOID lpvInBuffer, DWORD cbInBuffer,
945 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
946 LPDWORD lpcbBytesReturned,
947 LPOVERLAPPED lpOverlapped)
949 switch (dwIoControlCode) {
950 case 1: /* version */
951 *(LPDWORD)lpvOutBuffer = 0x20004; /* WC SecretOps */
952 break;
953 case 9: /* debug output */
954 fprintf(stderr,"MONODEBG: %s\n",debugstr_a(lpvInBuffer));
955 break;
956 default:
957 FIXME("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
958 dwIoControlCode,
959 lpvInBuffer,cbInBuffer,
960 lpvOutBuffer,cbOutBuffer,
961 lpcbBytesReturned,
962 lpOverlapped
964 break;
966 return TRUE;
968 /* pccard */
969 static BOOL DeviceIo_PCCARD (DWORD dwIoControlCode,
970 LPVOID lpvInBuffer, DWORD cbInBuffer,
971 LPVOID lpvOutBuffer, DWORD cbOutBuffer,
972 LPDWORD lpcbBytesReturned,
973 LPOVERLAPPED lpOverlapped)
975 switch (dwIoControlCode) {
976 case 0x0000: /* PCCARD_Get_Version */
977 case 0x0001: /* PCCARD_Card_Services */
978 default:
979 FIXME( "(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
980 dwIoControlCode,
981 lpvInBuffer,cbInBuffer,
982 lpvOutBuffer,cbOutBuffer,
983 lpcbBytesReturned,
984 lpOverlapped
986 break;
988 return FALSE;
991 DWORD WINAPI OpenVxDHandle(DWORD pmt)
993 FIXME( "(0x%08lx) stub!\n", pmt);
994 return 0;