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"
28 #include <sys/types.h>
42 #include "stackframe.h"
43 #include "wine/server.h"
44 #include "wine/debug.h"
47 #include <sys/ioctl.h>
50 # include <linux/fd.h>
54 WINE_DEFAULT_DEBUG_CHANNEL(file
);
57 static BOOL
DeviceIo_VTDAPI(DWORD dwIoControlCode
,
58 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
59 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
60 LPDWORD lpcbBytesReturned
,
61 LPOVERLAPPED lpOverlapped
);
62 static BOOL
DeviceIo_MONODEBG(DWORD dwIoControlCode
,
63 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
64 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
65 LPDWORD lpcbBytesReturned
,
66 LPOVERLAPPED lpOverlapped
);
67 static BOOL
DeviceIo_MMDEVLDR(DWORD dwIoControlCode
,
68 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
69 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
70 LPDWORD lpcbBytesReturned
,
71 LPOVERLAPPED lpOverlapped
);
73 static DWORD
VxDCall_VMM( DWORD service
, CONTEXT86
*context
);
75 static BOOL
DeviceIo_IFSMgr(DWORD dwIoControlCode
,
76 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
77 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
78 LPDWORD lpcbBytesReturned
,
79 LPOVERLAPPED lpOverlapped
);
81 static BOOL
DeviceIo_VCD(DWORD dwIoControlCode
,
82 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
83 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
84 LPDWORD lpcbBytesReturned
,
85 LPOVERLAPPED lpOverlapped
);
87 static DWORD
VxDCall_VWin32( DWORD service
, CONTEXT86
*context
);
89 static BOOL
DeviceIo_VWin32(DWORD dwIoControlCode
,
90 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
91 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
92 LPDWORD lpcbBytesReturned
,
93 LPOVERLAPPED lpOverlapped
);
95 static BOOL
DeviceIo_PCCARD (DWORD dwIoControlCode
,
96 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
97 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
98 LPDWORD lpcbBytesReturned
,
99 LPOVERLAPPED lpOverlapped
);
101 static BOOL
DeviceIo_HASP (DWORD dwIoControlCode
,
102 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
103 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
104 LPDWORD lpcbBytesReturned
,
105 LPOVERLAPPED lpOverlapped
);
107 * VxD names are taken from the Win95 DDK
114 DWORD (*vxdcall
)(DWORD
, CONTEXT86
*);
115 BOOL (*deviceio
)(DWORD
, LPVOID
, DWORD
,
116 LPVOID
, DWORD
, LPDWORD
, LPOVERLAPPED
);
119 static const struct VxDInfo VxDList
[] =
121 /* Standard VxD IDs */
122 { "VMM", 0x0001, VxDCall_VMM
, NULL
},
123 { "DEBUG", 0x0002, NULL
, NULL
},
124 { "VPICD", 0x0003, NULL
, NULL
},
125 { "VDMAD", 0x0004, NULL
, NULL
},
126 { "VTD", 0x0005, NULL
, NULL
},
127 { "V86MMGR", 0x0006, NULL
, NULL
},
128 { "PAGESWAP", 0x0007, NULL
, NULL
},
129 { "PARITY", 0x0008, NULL
, NULL
},
130 { "REBOOT", 0x0009, NULL
, NULL
},
131 { "VDD", 0x000A, NULL
, NULL
},
132 { "VSD", 0x000B, NULL
, NULL
},
133 { "VMD", 0x000C, NULL
, NULL
},
134 { "VKD", 0x000D, NULL
, NULL
},
135 { "VCD", 0x000E, NULL
, DeviceIo_VCD
},
136 { "VPD", 0x000F, NULL
, NULL
},
137 { "BLOCKDEV", 0x0010, NULL
, NULL
},
138 { "VMCPD", 0x0011, NULL
, NULL
},
139 { "EBIOS", 0x0012, NULL
, NULL
},
140 { "BIOSXLAT", 0x0013, NULL
, NULL
},
141 { "VNETBIOS", 0x0014, NULL
, NULL
},
142 { "DOSMGR", 0x0015, NULL
, NULL
},
143 { "WINLOAD", 0x0016, NULL
, NULL
},
144 { "SHELL", 0x0017, NULL
, NULL
},
145 { "VMPOLL", 0x0018, NULL
, NULL
},
146 { "VPROD", 0x0019, NULL
, NULL
},
147 { "DOSNET", 0x001A, NULL
, NULL
},
148 { "VFD", 0x001B, NULL
, NULL
},
149 { "VDD2", 0x001C, NULL
, NULL
},
150 { "WINDEBUG", 0x001D, NULL
, NULL
},
151 { "TSRLOAD", 0x001E, NULL
, NULL
},
152 { "BIOSHOOK", 0x001F, NULL
, NULL
},
153 { "INT13", 0x0020, NULL
, NULL
},
154 { "PAGEFILE", 0x0021, NULL
, NULL
},
155 { "SCSI", 0x0022, NULL
, NULL
},
156 { "MCA_POS", 0x0023, NULL
, NULL
},
157 { "SCSIFD", 0x0024, NULL
, NULL
},
158 { "VPEND", 0x0025, NULL
, NULL
},
159 { "VPOWERD", 0x0026, NULL
, NULL
},
160 { "VXDLDR", 0x0027, NULL
, NULL
},
161 { "NDIS", 0x0028, NULL
, NULL
},
162 { "BIOS_EXT", 0x0029, NULL
, NULL
},
163 { "VWIN32", 0x002A, VxDCall_VWin32
, DeviceIo_VWin32
},
164 { "VCOMM", 0x002B, NULL
, NULL
},
165 { "SPOOLER", 0x002C, NULL
, NULL
},
166 { "WIN32S", 0x002D, NULL
, NULL
},
167 { "DEBUGCMD", 0x002E, NULL
, NULL
},
169 { "VNB", 0x0031, NULL
, NULL
},
170 { "SERVER", 0x0032, NULL
, NULL
},
171 { "CONFIGMG", 0x0033, NULL
, NULL
},
172 { "DWCFGMG", 0x0034, NULL
, NULL
},
173 { "SCSIPORT", 0x0035, NULL
, NULL
},
174 { "VFBACKUP", 0x0036, NULL
, NULL
},
175 { "ENABLE", 0x0037, NULL
, NULL
},
176 { "VCOND", 0x0038, NULL
, NULL
},
178 { "EFAX", 0x003A, NULL
, NULL
},
179 { "DSVXD", 0x003B, NULL
, NULL
},
180 { "ISAPNP", 0x003C, NULL
, NULL
},
181 { "BIOS", 0x003D, NULL
, NULL
},
182 { "WINSOCK", 0x003E, NULL
, NULL
},
183 { "WSOCK", 0x003E, NULL
, NULL
},
184 { "WSIPX", 0x003F, NULL
, NULL
},
185 { "IFSMgr", 0x0040, NULL
, DeviceIo_IFSMgr
},
186 { "VCDFSD", 0x0041, NULL
, NULL
},
187 { "MRCI2", 0x0042, NULL
, NULL
},
188 { "PCI", 0x0043, NULL
, NULL
},
189 { "PELOADER", 0x0044, NULL
, NULL
},
190 { "EISA", 0x0045, NULL
, NULL
},
191 { "DRAGCLI", 0x0046, NULL
, NULL
},
192 { "DRAGSRV", 0x0047, NULL
, NULL
},
193 { "PERF", 0x0048, NULL
, NULL
},
194 { "AWREDIR", 0x0049, NULL
, NULL
},
196 /* Far East support */
197 { "ETEN", 0x0060, NULL
, NULL
},
198 { "CHBIOS", 0x0061, NULL
, NULL
},
199 { "VMSGD", 0x0062, NULL
, NULL
},
200 { "VPPID", 0x0063, NULL
, NULL
},
201 { "VIME", 0x0064, NULL
, NULL
},
202 { "VHBIOSD", 0x0065, NULL
, NULL
},
204 /* Multimedia OEM IDs */
205 { "VTDAPI", 0x0442, NULL
, DeviceIo_VTDAPI
},
206 { "MMDEVLDR", 0x044A, NULL
, DeviceIo_MMDEVLDR
},
208 /* Network Device IDs */
209 { "VNetSup", 0x0480, NULL
, NULL
},
210 { "VRedir", 0x0481, NULL
, NULL
},
211 { "VBrowse", 0x0482, NULL
, NULL
},
212 { "VSHARE", 0x0483, NULL
, NULL
},
213 { "IFSMgr", 0x0484, NULL
, NULL
},
214 { "MEMPROBE", 0x0485, NULL
, NULL
},
215 { "VFAT", 0x0486, NULL
, NULL
},
216 { "NWLINK", 0x0487, NULL
, NULL
},
217 { "VNWLINK", 0x0487, NULL
, NULL
},
218 { "NWSUP", 0x0487, NULL
, NULL
},
219 { "VTDI", 0x0488, NULL
, NULL
},
220 { "VIP", 0x0489, NULL
, NULL
},
221 { "VTCP", 0x048A, NULL
, NULL
},
222 { "VCache", 0x048B, NULL
, NULL
},
223 { "VUDP", 0x048C, NULL
, NULL
},
224 { "VAsync", 0x048D, NULL
, NULL
},
225 { "NWREDIR", 0x048E, NULL
, NULL
},
226 { "STAT80", 0x048F, NULL
, NULL
},
227 { "SCSIPORT", 0x0490, NULL
, NULL
},
228 { "FILESEC", 0x0491, NULL
, NULL
},
229 { "NWSERVER", 0x0492, NULL
, NULL
},
230 { "SECPROV", 0x0493, NULL
, NULL
},
231 { "NSCL", 0x0494, NULL
, NULL
},
232 { "WSTCP", 0x0495, NULL
, NULL
},
233 { "NDIS2SUP", 0x0496, NULL
, NULL
},
234 { "MSODISUP", 0x0497, NULL
, NULL
},
235 { "Splitter", 0x0498, NULL
, NULL
},
236 { "PPP", 0x0499, NULL
, NULL
},
237 { "VDHCP", 0x049A, NULL
, NULL
},
238 { "VNBT", 0x049B, NULL
, NULL
},
239 { "LOGGER", 0x049D, NULL
, NULL
},
240 { "EFILTER", 0x049E, NULL
, NULL
},
241 { "FFILTER", 0x049F, NULL
, NULL
},
242 { "TFILTER", 0x04A0, NULL
, NULL
},
243 { "AFILTER", 0x04A1, NULL
, NULL
},
244 { "IRLAMP", 0x04A2, NULL
, NULL
},
246 { "PCCARD", 0x097C, NULL
, DeviceIo_PCCARD
},
247 { "HASP95", 0x3721, NULL
, DeviceIo_HASP
},
249 /* WINE additions, ids unknown */
250 { "MONODEBG.VXD", 0x4242, NULL
, DeviceIo_MONODEBG
},
252 { NULL
, 0, NULL
, NULL
}
256 * VMM VxDCall service names are (mostly) taken from Stan Mitchell's
257 * "Inside the Windows 95 File System"
260 #define N_VMM_SERVICE 41
262 LPCSTR VMM_Service_Name
[N_VMM_SERVICE
] =
264 "PageReserve", /* 0x0000 */
265 "PageCommit", /* 0x0001 */
266 "PageDecommit", /* 0x0002 */
267 "PagerRegister", /* 0x0003 */
268 "PagerQuery", /* 0x0004 */
269 "HeapAllocate", /* 0x0005 */
270 "ContextCreate", /* 0x0006 */
271 "ContextDestroy", /* 0x0007 */
272 "PageAttach", /* 0x0008 */
273 "PageFlush", /* 0x0009 */
274 "PageFree", /* 0x000A */
275 "ContextSwitch", /* 0x000B */
276 "HeapReAllocate", /* 0x000C */
277 "PageModifyPermissions", /* 0x000D */
278 "PageQuery", /* 0x000E */
279 "GetCurrentContext", /* 0x000F */
280 "HeapFree", /* 0x0010 */
281 "RegOpenKey", /* 0x0011 */
282 "RegCreateKey", /* 0x0012 */
283 "RegCloseKey", /* 0x0013 */
284 "RegDeleteKey", /* 0x0014 */
285 "RegSetValue", /* 0x0015 */
286 "RegDeleteValue", /* 0x0016 */
287 "RegQueryValue", /* 0x0017 */
288 "RegEnumKey", /* 0x0018 */
289 "RegEnumValue", /* 0x0019 */
290 "RegQueryValueEx", /* 0x001A */
291 "RegSetValueEx", /* 0x001B */
292 "RegFlushKey", /* 0x001C */
293 "RegQueryInfoKey", /* 0x001D */
294 "GetDemandPageInfo", /* 0x001E */
295 "BlockOnID", /* 0x001F */
296 "SignalID", /* 0x0020 */
297 "RegLoadKey", /* 0x0021 */
298 "RegUnLoadKey", /* 0x0022 */
299 "RegSaveKey", /* 0x0023 */
300 "RegRemapPreDefKey", /* 0x0024 */
301 "PageChangePager", /* 0x0025 */
302 "RegQueryMultipleValues", /* 0x0026 */
303 "RegReplaceKey", /* 0x0027 */
304 "<KERNEL32.101>" /* 0x0028 -- What does this do??? */
307 /* PageReserve arena values */
308 #define PR_PRIVATE 0x80000400 /* anywhere in private arena */
309 #define PR_SHARED 0x80060000 /* anywhere in shared arena */
310 #define PR_SYSTEM 0x80080000 /* anywhere in system arena */
312 /* PageReserve flags */
313 #define PR_FIXED 0x00000008 /* don't move during PageReAllocate */
314 #define PR_4MEG 0x00000001 /* allocate on 4mb boundary */
315 #define PR_STATIC 0x00000010 /* see PageReserve documentation */
317 /* PageCommit default pager handle values */
318 #define PD_ZEROINIT 0x00000001 /* swappable zero-initialized pages */
319 #define PD_NOINIT 0x00000002 /* swappable uninitialized pages */
320 #define PD_FIXEDZERO 0x00000003 /* fixed zero-initialized pages */
321 #define PD_FIXED 0x00000004 /* fixed uninitialized pages */
323 /* PageCommit flags */
324 #define PC_FIXED 0x00000008 /* pages are permanently locked */
325 #define PC_LOCKED 0x00000080 /* pages are made present and locked */
326 #define PC_LOCKEDIFDP 0x00000100 /* pages are locked if swap via DOS */
327 #define PC_WRITEABLE 0x00020000 /* make the pages writeable */
328 #define PC_USER 0x00040000 /* make the pages ring 3 accessible */
329 #define PC_INCR 0x40000000 /* increment "pagerdata" each page */
330 #define PC_PRESENT 0x80000000 /* make pages initially present */
331 #define PC_STATIC 0x20000000 /* allow commit in PR_STATIC object */
332 #define PC_DIRTY 0x08000000 /* make pages initially dirty */
333 #define PC_CACHEDIS 0x00100000 /* Allocate uncached pages - new for WDM */
334 #define PC_CACHEWT 0x00080000 /* Allocate write through cache pages - new for WDM */
335 #define PC_PAGEFLUSH 0x00008000 /* Touch device mapped pages on alloc - new for WDM */
337 /* PageCommitContig additional flags */
338 #define PCC_ZEROINIT 0x00000001 /* zero-initialize new pages */
339 #define PCC_NOLIN 0x10000000 /* don't map to any linear address */
343 HANDLE
DEVICE_Open( LPCSTR filename
, DWORD access
, LPSECURITY_ATTRIBUTES sa
)
345 const struct VxDInfo
*info
;
347 for (info
= VxDList
; info
->name
; info
++)
348 if (!strncasecmp( info
->name
, filename
, strlen(info
->name
) ))
349 return FILE_CreateDevice( info
->id
| 0x10000, access
, sa
);
351 FIXME( "Unknown/unsupported VxD %s. Try --winver nt40 or win31 !\n", filename
);
352 SetLastError( ERROR_FILE_NOT_FOUND
);
356 static DWORD
DEVICE_GetClientID( HANDLE handle
)
359 SERVER_START_REQ( get_file_info
)
361 req
->handle
= handle
;
362 if (!wine_server_call( req
) && (reply
->type
== FILE_TYPE_UNKNOWN
))
369 static const struct VxDInfo
*DEVICE_GetInfo( DWORD clientID
)
371 const struct VxDInfo
*info
= NULL
;
373 if (clientID
& 0x10000)
375 for (info
= VxDList
; info
->name
; info
++)
376 if (info
->id
== LOWORD(clientID
)) break;
381 /****************************************************************************
382 * DeviceIoControl (KERNEL32.@)
383 * This is one of those big ugly nasty procedure which can do
384 * a million and one things when it comes to devices. It can also be
385 * used for VxD communication.
387 * A return value of FALSE indicates that something has gone wrong which
388 * GetLastError can decipher.
390 BOOL WINAPI
DeviceIoControl(HANDLE hDevice
, DWORD dwIoControlCode
,
391 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
392 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
393 LPDWORD lpcbBytesReturned
,
394 LPOVERLAPPED lpOverlapped
)
398 TRACE( "(%d,%ld,%p,%ld,%p,%ld,%p,%p)\n",
399 hDevice
,dwIoControlCode
,lpvInBuffer
,cbInBuffer
,
400 lpvOutBuffer
,cbOutBuffer
,lpcbBytesReturned
,lpOverlapped
);
402 if (!(clientID
= DEVICE_GetClientID( hDevice
)))
404 SetLastError( ERROR_INVALID_PARAMETER
);
408 /* Check if this is a user defined control code for a VxD */
409 if( HIWORD( dwIoControlCode
) == 0 )
411 const struct VxDInfo
*info
;
412 if (!(info
= DEVICE_GetInfo( clientID
)))
414 FIXME( "No device found for id %lx\n", clientID
);
416 else if ( info
->deviceio
)
418 return info
->deviceio( dwIoControlCode
,
419 lpvInBuffer
, cbInBuffer
,
420 lpvOutBuffer
, cbOutBuffer
,
421 lpcbBytesReturned
, lpOverlapped
);
425 FIXME( "Unimplemented control %ld for VxD device %s\n",
426 dwIoControlCode
, info
->name
? info
->name
: "???" );
427 /* FIXME: this is for invalid calls on W98SE,
428 * but maybe we should use ERROR_CALL_NOT_IMPLEMENTED
430 SetLastError( ERROR_INVALID_FUNCTION
);
438 str
[0] += LOBYTE(clientID
);
439 if (GetDriveTypeA(str
) == DRIVE_CDROM
)
440 return CDROM_DeviceIoControl(clientID
, hDevice
, dwIoControlCode
, lpvInBuffer
, cbInBuffer
,
441 lpvOutBuffer
, cbOutBuffer
, lpcbBytesReturned
,
443 else switch( dwIoControlCode
)
445 case FSCTL_DELETE_REPARSE_POINT
:
446 case FSCTL_DISMOUNT_VOLUME
:
447 case FSCTL_GET_COMPRESSION
:
448 case FSCTL_GET_REPARSE_POINT
:
449 case FSCTL_LOCK_VOLUME
:
450 case FSCTL_QUERY_ALLOCATED_RANGES
:
451 case FSCTL_SET_COMPRESSION
:
452 case FSCTL_SET_REPARSE_POINT
:
453 case FSCTL_SET_SPARSE
:
454 case FSCTL_SET_ZERO_DATA
:
455 case FSCTL_UNLOCK_VOLUME
:
456 case IOCTL_DISK_CHECK_VERIFY
:
457 case IOCTL_DISK_EJECT_MEDIA
:
458 case IOCTL_DISK_FORMAT_TRACKS
:
459 case IOCTL_DISK_GET_DRIVE_GEOMETRY
:
460 case IOCTL_DISK_GET_DRIVE_LAYOUT
:
461 case IOCTL_DISK_GET_MEDIA_TYPES
:
462 case IOCTL_DISK_GET_PARTITION_INFO
:
463 case IOCTL_DISK_LOAD_MEDIA
:
464 case IOCTL_DISK_MEDIA_REMOVAL
:
465 case IOCTL_DISK_PERFORMANCE
:
466 case IOCTL_DISK_REASSIGN_BLOCKS
:
467 case IOCTL_DISK_SET_DRIVE_LAYOUT
:
468 case IOCTL_DISK_SET_PARTITION_INFO
:
469 case IOCTL_DISK_VERIFY
:
470 case IOCTL_SERIAL_LSRMST_INSERT
:
471 case IOCTL_STORAGE_CHECK_VERIFY
:
472 case IOCTL_STORAGE_EJECT_MEDIA
:
473 case IOCTL_STORAGE_GET_MEDIA_TYPES
:
474 case IOCTL_STORAGE_LOAD_MEDIA
:
475 case IOCTL_STORAGE_MEDIA_REMOVAL
:
476 FIXME( "unimplemented dwIoControlCode=%08lx\n", dwIoControlCode
);
477 SetLastError( ERROR_CALL_NOT_IMPLEMENTED
);
481 FIXME( "ignored dwIoControlCode=%08lx\n",dwIoControlCode
);
482 SetLastError( ERROR_CALL_NOT_IMPLEMENTED
);
490 /***********************************************************************
493 static BOOL
DeviceIo_VTDAPI(DWORD dwIoControlCode
, LPVOID lpvInBuffer
, DWORD cbInBuffer
,
494 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
495 LPDWORD lpcbBytesReturned
,
496 LPOVERLAPPED lpOverlapped
)
500 switch (dwIoControlCode
)
503 if (lpvOutBuffer
&& (cbOutBuffer
>=4))
504 *(DWORD
*)lpvOutBuffer
= GetTickCount();
506 if (lpcbBytesReturned
)
507 *lpcbBytesReturned
= 4;
512 FIXME( "Control %ld not implemented\n", dwIoControlCode
);
520 /***********************************************************************
521 * VxDCall0 (KERNEL32.1)
522 * VxDCall1 (KERNEL32.2)
523 * VxDCall2 (KERNEL32.3)
524 * VxDCall3 (KERNEL32.4)
525 * VxDCall4 (KERNEL32.5)
526 * VxDCall5 (KERNEL32.6)
527 * VxDCall6 (KERNEL32.7)
528 * VxDCall7 (KERNEL32.8)
529 * VxDCall8 (KERNEL32.9)
531 void VxDCall( DWORD service
, CONTEXT86
*context
)
533 DWORD ret
= 0xffffffff; /* FIXME */
536 TRACE( "(%08lx, ...)\n", service
);
538 for (i
= 0; VxDList
[i
].name
; i
++)
539 if (VxDList
[i
].id
== HIWORD(service
))
542 if (!VxDList
[i
].name
)
543 FIXME( "Unknown VxD (%08lx)\n", service
);
544 else if (!VxDList
[i
].vxdcall
)
545 FIXME( "Unimplemented VxD (%08lx)\n", service
);
547 ret
= VxDList
[i
].vxdcall( service
, context
);
553 /***********************************************************************
556 static DWORD
VxDCall_VMM( DWORD service
, CONTEXT86
*context
)
558 switch ( LOWORD(service
) )
560 case 0x0011: /* RegOpenKey */
562 HKEY hkey
= (HKEY
) stack32_pop( context
);
563 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
564 LPHKEY retkey
= (LPHKEY
)stack32_pop( context
);
565 return RegOpenKeyA( hkey
, lpszSubKey
, retkey
);
568 case 0x0012: /* RegCreateKey */
570 HKEY hkey
= (HKEY
) stack32_pop( context
);
571 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
572 LPHKEY retkey
= (LPHKEY
)stack32_pop( context
);
573 return RegCreateKeyA( hkey
, lpszSubKey
, retkey
);
576 case 0x0013: /* RegCloseKey */
578 HKEY hkey
= (HKEY
)stack32_pop( context
);
579 return RegCloseKey( hkey
);
582 case 0x0014: /* RegDeleteKey */
584 HKEY hkey
= (HKEY
) stack32_pop( context
);
585 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
586 return RegDeleteKeyA( hkey
, lpszSubKey
);
589 case 0x0015: /* RegSetValue */
591 HKEY hkey
= (HKEY
) stack32_pop( context
);
592 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
593 DWORD dwType
= (DWORD
) stack32_pop( context
);
594 LPCSTR lpszData
= (LPCSTR
)stack32_pop( context
);
595 DWORD cbData
= (DWORD
) stack32_pop( context
);
596 return RegSetValueA( hkey
, lpszSubKey
, dwType
, lpszData
, cbData
);
599 case 0x0016: /* RegDeleteValue */
601 HKEY hkey
= (HKEY
) stack32_pop( context
);
602 LPSTR lpszValue
= (LPSTR
)stack32_pop( context
);
603 return RegDeleteValueA( hkey
, lpszValue
);
606 case 0x0017: /* RegQueryValue */
608 HKEY hkey
= (HKEY
) stack32_pop( context
);
609 LPSTR lpszSubKey
= (LPSTR
) stack32_pop( context
);
610 LPSTR lpszData
= (LPSTR
) stack32_pop( context
);
611 LPDWORD lpcbData
= (LPDWORD
)stack32_pop( context
);
612 return RegQueryValueA( hkey
, lpszSubKey
, lpszData
, lpcbData
);
615 case 0x0018: /* RegEnumKey */
617 HKEY hkey
= (HKEY
) stack32_pop( context
);
618 DWORD iSubkey
= (DWORD
)stack32_pop( context
);
619 LPSTR lpszName
= (LPSTR
)stack32_pop( context
);
620 DWORD lpcchName
= (DWORD
)stack32_pop( context
);
621 return RegEnumKeyA( hkey
, iSubkey
, lpszName
, lpcchName
);
624 case 0x0019: /* RegEnumValue */
626 HKEY hkey
= (HKEY
) stack32_pop( context
);
627 DWORD iValue
= (DWORD
) stack32_pop( context
);
628 LPSTR lpszValue
= (LPSTR
) stack32_pop( context
);
629 LPDWORD lpcchValue
= (LPDWORD
)stack32_pop( context
);
630 LPDWORD lpReserved
= (LPDWORD
)stack32_pop( context
);
631 LPDWORD lpdwType
= (LPDWORD
)stack32_pop( context
);
632 LPBYTE lpbData
= (LPBYTE
) stack32_pop( context
);
633 LPDWORD lpcbData
= (LPDWORD
)stack32_pop( context
);
634 return RegEnumValueA( hkey
, iValue
, lpszValue
, lpcchValue
,
635 lpReserved
, lpdwType
, lpbData
, lpcbData
);
638 case 0x001A: /* RegQueryValueEx */
640 HKEY hkey
= (HKEY
) stack32_pop( context
);
641 LPSTR lpszValue
= (LPSTR
) stack32_pop( context
);
642 LPDWORD lpReserved
= (LPDWORD
)stack32_pop( context
);
643 LPDWORD lpdwType
= (LPDWORD
)stack32_pop( context
);
644 LPBYTE lpbData
= (LPBYTE
) stack32_pop( context
);
645 LPDWORD lpcbData
= (LPDWORD
)stack32_pop( context
);
646 return RegQueryValueExA( hkey
, lpszValue
, lpReserved
,
647 lpdwType
, lpbData
, lpcbData
);
650 case 0x001B: /* RegSetValueEx */
652 HKEY hkey
= (HKEY
) stack32_pop( context
);
653 LPSTR lpszValue
= (LPSTR
) stack32_pop( context
);
654 DWORD dwReserved
= (DWORD
) stack32_pop( context
);
655 DWORD dwType
= (DWORD
) stack32_pop( context
);
656 LPBYTE lpbData
= (LPBYTE
)stack32_pop( context
);
657 DWORD cbData
= (DWORD
) stack32_pop( context
);
658 return RegSetValueExA( hkey
, lpszValue
, dwReserved
,
659 dwType
, lpbData
, cbData
);
662 case 0x001C: /* RegFlushKey */
664 HKEY hkey
= (HKEY
)stack32_pop( context
);
665 return RegFlushKey( hkey
);
668 case 0x001D: /* RegQueryInfoKey */
670 /* NOTE: This VxDCall takes only a subset of the parameters that the
671 corresponding Win32 API call does. The implementation in Win95
672 ADVAPI32 sets all output parameters not mentioned here to zero. */
674 HKEY hkey
= (HKEY
) stack32_pop( context
);
675 LPDWORD lpcSubKeys
= (LPDWORD
)stack32_pop( context
);
676 LPDWORD lpcchMaxSubKey
= (LPDWORD
)stack32_pop( context
);
677 LPDWORD lpcValues
= (LPDWORD
)stack32_pop( context
);
678 LPDWORD lpcchMaxValueName
= (LPDWORD
)stack32_pop( context
);
679 LPDWORD lpcchMaxValueData
= (LPDWORD
)stack32_pop( context
);
680 return RegQueryInfoKeyA( hkey
, NULL
, NULL
, NULL
, lpcSubKeys
, lpcchMaxSubKey
,
681 NULL
, lpcValues
, lpcchMaxValueName
, lpcchMaxValueData
,
685 case 0x0021: /* RegLoadKey */
687 HKEY hkey
= (HKEY
) stack32_pop( context
);
688 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
689 LPCSTR lpszFile
= (LPCSTR
)stack32_pop( context
);
690 return RegLoadKeyA( hkey
, lpszSubKey
, lpszFile
);
693 case 0x0022: /* RegUnLoadKey */
695 HKEY hkey
= (HKEY
) stack32_pop( context
);
696 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
697 return RegUnLoadKeyA( hkey
, lpszSubKey
);
700 case 0x0023: /* RegSaveKey */
702 HKEY hkey
= (HKEY
) stack32_pop( context
);
703 LPCSTR lpszFile
= (LPCSTR
)stack32_pop( context
);
704 LPSECURITY_ATTRIBUTES sa
= (LPSECURITY_ATTRIBUTES
)stack32_pop( context
);
705 return RegSaveKeyA( hkey
, lpszFile
, sa
);
708 #if 0 /* Functions are not yet implemented in misc/registry.c */
709 case 0x0024: /* RegRemapPreDefKey */
710 case 0x0026: /* RegQueryMultipleValues */
713 case 0x0027: /* RegReplaceKey */
715 HKEY hkey
= (HKEY
) stack32_pop( context
);
716 LPCSTR lpszSubKey
= (LPCSTR
)stack32_pop( context
);
717 LPCSTR lpszNewFile
= (LPCSTR
)stack32_pop( context
);
718 LPCSTR lpszOldFile
= (LPCSTR
)stack32_pop( context
);
719 return RegReplaceKeyA( hkey
, lpszSubKey
, lpszNewFile
, lpszOldFile
);
721 case 0x0000: /* PageReserve */
725 DWORD psize
= getpagesize();
726 ULONG page
= (ULONG
) stack32_pop( context
);
727 ULONG npages
= (ULONG
) stack32_pop( context
);
728 ULONG flags
= (ULONG
) stack32_pop( context
);
730 TRACE("PageReserve: page: %08lx, npages: %08lx, flags: %08lx partial stub!\n",
731 page
, npages
, flags
);
733 if ( page
== PR_SYSTEM
) {
734 ERR("Can't reserve ring 1 memory\n");
737 /* FIXME: This has to be handled separately for the separate
738 address-spaces we now have */
739 if ( page
== PR_PRIVATE
|| page
== PR_SHARED
) page
= 0;
740 /* FIXME: Handle flags in some way */
741 address
= (LPVOID
)(page
* psize
);
742 ret
= VirtualAlloc ( address
, ( npages
* psize
), MEM_RESERVE
, 0 );
743 TRACE("PageReserve: returning: %08lx\n", (DWORD
)ret
);
750 case 0x0001: /* PageCommit */
755 DWORD psize
= getpagesize();
756 ULONG page
= (ULONG
) stack32_pop( context
);
757 ULONG npages
= (ULONG
) stack32_pop( context
);
758 ULONG hpd
= (ULONG
) stack32_pop( context
);
759 ULONG pagerdata
= (ULONG
) stack32_pop( context
);
760 ULONG flags
= (ULONG
) stack32_pop( context
);
762 TRACE("PageCommit: page: %08lx, npages: %08lx, hpd: %08lx pagerdata: "
763 "%08lx, flags: %08lx partial stub\n",
764 page
, npages
, hpd
, pagerdata
, flags
);
766 if ( flags
& PC_USER
)
767 if ( flags
& PC_WRITEABLE
)
768 virt_perm
= PAGE_EXECUTE_READWRITE
;
770 virt_perm
= PAGE_EXECUTE_READ
;
772 virt_perm
= PAGE_NOACCESS
;
774 address
= (LPVOID
)(page
* psize
);
775 ret
= VirtualAlloc ( address
, ( npages
* psize
), MEM_COMMIT
, virt_perm
);
776 TRACE("PageCommit: Returning: %08lx\n", (DWORD
)ret
);
780 case 0x0002: /* PageDecommit */
784 DWORD psize
= getpagesize();
785 ULONG page
= (ULONG
) stack32_pop( context
);
786 ULONG npages
= (ULONG
) stack32_pop( context
);
787 ULONG flags
= (ULONG
) stack32_pop( context
);
789 TRACE("PageDecommit: page: %08lx, npages: %08lx, flags: %08lx partial stub\n",
790 page
, npages
, flags
);
791 address
= (LPVOID
)( page
* psize
);
792 ret
= VirtualFree ( address
, ( npages
* psize
), MEM_DECOMMIT
);
793 TRACE("PageDecommit: Returning: %s\n", ret
? "TRUE" : "FALSE" );
796 case 0x000d: /* PageModifyPermissions */
802 MEMORY_BASIC_INFORMATION mbi
;
804 DWORD psize
= getpagesize();
805 ULONG page
= stack32_pop ( context
);
806 ULONG npages
= stack32_pop ( context
);
807 ULONG permand
= stack32_pop ( context
);
808 ULONG permor
= stack32_pop ( context
);
810 TRACE("PageModifyPermissions %08lx %08lx %08lx %08lx partial stub\n",
811 page
, npages
, permand
, permor
);
812 address
= (LPVOID
)( page
* psize
);
814 VirtualQuery ( address
, &mbi
, sizeof ( MEMORY_BASIC_INFORMATION
));
815 virt_old_perm
= mbi
.Protect
;
817 switch ( virt_old_perm
& mbi
.Protect
) {
820 case PAGE_EXECUTE_READ
:
821 pg_old_perm
= PC_USER
;
825 case PAGE_EXECUTE_READWRITE
:
826 case PAGE_EXECUTE_WRITECOPY
:
827 pg_old_perm
= PC_USER
| PC_WRITEABLE
;
834 pg_new_perm
= pg_old_perm
;
835 pg_new_perm
&= permand
& ~PC_STATIC
;
836 pg_new_perm
|= permor
& ~PC_STATIC
;
838 virt_new_perm
= ( virt_old_perm
) & ~0xff;
839 if ( pg_new_perm
& PC_USER
)
841 if ( pg_new_perm
& PC_WRITEABLE
)
842 virt_new_perm
|= PAGE_EXECUTE_READWRITE
;
844 virt_new_perm
|= PAGE_EXECUTE_READ
;
847 if ( ! VirtualProtect ( address
, ( npages
* psize
), virt_new_perm
, &virt_old_perm
) ) {
848 ERR("Can't change page permissions for %08lx\n", (DWORD
)address
);
851 TRACE("Returning: %08lx\n", pg_old_perm
);
854 case 0x000a: /* PageFree */
857 LPVOID hmem
= (LPVOID
) stack32_pop( context
);
858 DWORD flags
= (DWORD
) stack32_pop( context
);
860 TRACE("PageFree: hmem: %08lx, flags: %08lx partial stub\n",
861 (DWORD
)hmem
, flags
);
863 ret
= VirtualFree ( hmem
, 0, MEM_RELEASE
);
865 TRACE("Returning: %d\n", ret
);
869 case 0x001e: /* GetDemandPageInfo */
871 DWORD dinfo
= (DWORD
)stack32_pop( context
);
872 DWORD flags
= (DWORD
)stack32_pop( context
);
874 /* GetDemandPageInfo is supposed to fill out the struct at
875 * "dinfo" with various low-level memory management information.
876 * Apps are certainly not supposed to call this, although it's
877 * demoed and documented by Pietrek on pages 441-443 of "Windows
878 * 95 System Programming Secrets" if any program needs a real
879 * implementation of this.
882 FIXME("GetDemandPageInfo(%08lx %08lx): stub!\n", dinfo
, flags
);
887 if (LOWORD(service
) < N_VMM_SERVICE
)
888 FIXME( "Unimplemented service %s (%08lx)\n",
889 VMM_Service_Name
[LOWORD(service
)], service
);
891 FIXME( "Unknown service %08lx\n", service
);
895 return 0xffffffff; /* FIXME */
898 /***********************************************************************
901 * These ioctls are used by 'MSNET32.DLL'.
903 * I have been unable to uncover any documentation about the ioctls so
904 * the implementation of the cases IFS_IOCTL_21 and IFS_IOCTL_2F are
905 * based on reasonable guesses on information found in the Windows 95 DDK.
910 * IFSMgr DeviceIO service
913 #define IFS_IOCTL_21 100
914 #define IFS_IOCTL_2F 101
915 #define IFS_IOCTL_GET_RES 102
916 #define IFS_IOCTL_GET_NETPRO_NAME_A 103
919 unsigned long ar_proid
;
920 unsigned long ar_eax
;
921 unsigned long ar_ebx
;
922 unsigned long ar_ecx
;
923 unsigned long ar_edx
;
924 unsigned long ar_esi
;
925 unsigned long ar_edi
;
926 unsigned long ar_ebp
;
927 unsigned short ar_error
;
928 unsigned short ar_pad
;
931 static void win32apieq_2_CONTEXT(struct win32apireq
*pIn
,CONTEXT86
*pCxt
)
933 memset(pCxt
,0,sizeof(*pCxt
));
935 pCxt
->ContextFlags
=CONTEXT86_INTEGER
|CONTEXT86_CONTROL
;
936 pCxt
->Eax
= pIn
->ar_eax
;
937 pCxt
->Ebx
= pIn
->ar_ebx
;
938 pCxt
->Ecx
= pIn
->ar_ecx
;
939 pCxt
->Edx
= pIn
->ar_edx
;
940 pCxt
->Esi
= pIn
->ar_esi
;
941 pCxt
->Edi
= pIn
->ar_edi
;
943 /* FIXME: Only partial CONTEXT86_CONTROL */
944 pCxt
->Ebp
= pIn
->ar_ebp
;
946 /* FIXME: pIn->ar_proid ignored */
947 /* FIXME: pIn->ar_error ignored */
948 /* FIXME: pIn->ar_pad ignored */
951 static void CONTEXT_2_win32apieq(CONTEXT86
*pCxt
,struct win32apireq
*pOut
)
953 memset(pOut
,0,sizeof(struct win32apireq
));
955 pOut
->ar_eax
= pCxt
->Eax
;
956 pOut
->ar_ebx
= pCxt
->Ebx
;
957 pOut
->ar_ecx
= pCxt
->Ecx
;
958 pOut
->ar_edx
= pCxt
->Edx
;
959 pOut
->ar_esi
= pCxt
->Esi
;
960 pOut
->ar_edi
= pCxt
->Edi
;
962 /* FIXME: Only partial CONTEXT86_CONTROL */
963 pOut
->ar_ebp
= pCxt
->Ebp
;
965 /* FIXME: pOut->ar_proid ignored */
966 /* FIXME: pOut->ar_error ignored */
967 /* FIXME: pOut->ar_pad ignored */
970 static BOOL
DeviceIo_IFSMgr(DWORD dwIoControlCode
, LPVOID lpvInBuffer
, DWORD cbInBuffer
,
971 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
972 LPDWORD lpcbBytesReturned
,
973 LPOVERLAPPED lpOverlapped
)
976 TRACE("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
978 lpvInBuffer
,cbInBuffer
,
979 lpvOutBuffer
,cbOutBuffer
,
983 switch (dwIoControlCode
)
988 struct win32apireq
*pIn
=(struct win32apireq
*) lpvInBuffer
;
989 struct win32apireq
*pOut
=(struct win32apireq
*) lpvOutBuffer
;
993 "proid=0x%08lx, eax=0x%08lx, ebx=0x%08lx, ecx=0x%08lx, "
994 "edx=0x%08lx, esi=0x%08lx, edi=0x%08lx, ebp=0x%08lx, "
995 "error=0x%04x, pad=0x%04x\n",
996 (dwIoControlCode
==IFS_IOCTL_21
)?"IFS_IOCTL_21":"IFS_IOCTL_2F",
997 pIn
->ar_proid
, pIn
->ar_eax
, pIn
->ar_ebx
, pIn
->ar_ecx
,
998 pIn
->ar_edx
, pIn
->ar_esi
, pIn
->ar_edi
, pIn
->ar_ebp
,
999 pIn
->ar_error
, pIn
->ar_pad
1002 win32apieq_2_CONTEXT(pIn
,&cxt
);
1004 if(dwIoControlCode
==IFS_IOCTL_21
)
1006 DOS3Call(&cxt
); /* Call int 21h */
1008 INT_Int2fHandler(&cxt
); /* Call int 2Fh */
1011 CONTEXT_2_win32apieq(&cxt
,pOut
);
1015 case IFS_IOCTL_GET_RES
:{
1016 FIXME( "Control 'IFS_IOCTL_GET_RES' not implemented\n");
1019 case IFS_IOCTL_GET_NETPRO_NAME_A
:{
1020 FIXME( "Control 'IFS_IOCTL_GET_NETPRO_NAME_A' not implemented\n");
1024 FIXME( "Control %ld not implemented\n", dwIoControlCode
);
1031 /********************************************************************************
1034 * Service numbers taken from page 448 of Pietrek's "Windows 95 System
1035 * Programming Secrets". Parameters from experimentation on real Win98.
1039 static DWORD
VxDCall_VWin32( DWORD service
, CONTEXT86
*context
)
1041 switch ( LOWORD(service
) )
1043 case 0x0000: /* GetVersion */
1045 DWORD vers
= GetVersion();
1046 return (LOBYTE(vers
) << 8) | HIBYTE(vers
);
1050 case 0x0020: /* Get VMCPD Version */
1052 DWORD parm
= (DWORD
) stack32_pop(context
);
1054 FIXME("Get VMCPD Version(%08lx): partial stub!\n", parm
);
1056 /* FIXME: This is what Win98 returns, it may
1057 * not be correct in all situations.
1058 * It makes Bleem! happy though.
1064 case 0x0029: /* Int31/DPMI dispatch */
1066 DWORD callnum
= (DWORD
) stack32_pop(context
);
1067 DWORD parm
= (DWORD
) stack32_pop(context
);
1069 TRACE("Int31/DPMI dispatch(%08lx)\n", callnum
);
1071 AX_reg(context
) = callnum
;
1072 CX_reg(context
) = parm
;
1073 INT_Int31Handler(context
);
1075 return LOWORD(context
->Eax
);
1079 case 0x002a: /* Int41 dispatch - parm = int41 service number */
1081 DWORD callnum
= (DWORD
) stack32_pop(context
);
1083 return callnum
; /* FIXME: should really call INT_Int41Handler() */
1088 FIXME("Unknown VWin32 service %08lx\n", service
);
1096 /***********************************************************************
1099 static BOOL
DeviceIo_VCD(DWORD dwIoControlCode
,
1100 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1101 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1102 LPDWORD lpcbBytesReturned
,
1103 LPOVERLAPPED lpOverlapped
)
1107 switch (dwIoControlCode
)
1109 case IOCTL_SERIAL_LSRMST_INSERT
:
1111 FIXME( "IOCTL_SERIAL_LSRMST_INSERT NIY !\n");
1117 FIXME( "Unknown Control %ld\n", dwIoControlCode
);
1126 /***********************************************************************
1130 static void DIOCRegs_2_CONTEXT( DIOC_REGISTERS
*pIn
, CONTEXT86
*pCxt
)
1132 memset( pCxt
, 0, sizeof(*pCxt
) );
1133 /* Note: segment registers == 0 means that CTX_SEG_OFF_TO_LIN
1134 will interpret 32-bit register contents as linear pointers */
1136 pCxt
->ContextFlags
=CONTEXT86_INTEGER
|CONTEXT86_CONTROL
;
1137 pCxt
->Eax
= pIn
->reg_EAX
;
1138 pCxt
->Ebx
= pIn
->reg_EBX
;
1139 pCxt
->Ecx
= pIn
->reg_ECX
;
1140 pCxt
->Edx
= pIn
->reg_EDX
;
1141 pCxt
->Esi
= pIn
->reg_ESI
;
1142 pCxt
->Edi
= pIn
->reg_EDI
;
1144 /* FIXME: Only partial CONTEXT86_CONTROL */
1145 pCxt
->EFlags
= pIn
->reg_Flags
;
1148 static void CONTEXT_2_DIOCRegs( CONTEXT86
*pCxt
, DIOC_REGISTERS
*pOut
)
1150 memset( pOut
, 0, sizeof(DIOC_REGISTERS
) );
1152 pOut
->reg_EAX
= pCxt
->Eax
;
1153 pOut
->reg_EBX
= pCxt
->Ebx
;
1154 pOut
->reg_ECX
= pCxt
->Ecx
;
1155 pOut
->reg_EDX
= pCxt
->Edx
;
1156 pOut
->reg_ESI
= pCxt
->Esi
;
1157 pOut
->reg_EDI
= pCxt
->Edi
;
1159 /* FIXME: Only partial CONTEXT86_CONTROL */
1160 pOut
->reg_Flags
= pCxt
->EFlags
;
1163 #define DIOC_AH(regs) (((unsigned char*)&((regs)->reg_EAX))[1])
1164 #define DIOC_AL(regs) (((unsigned char*)&((regs)->reg_EAX))[0])
1165 #define DIOC_BH(regs) (((unsigned char*)&((regs)->reg_EBX))[1])
1166 #define DIOC_BL(regs) (((unsigned char*)&((regs)->reg_EBX))[0])
1167 #define DIOC_DH(regs) (((unsigned char*)&((regs)->reg_EDX))[1])
1168 #define DIOC_DL(regs) (((unsigned char*)&((regs)->reg_EDX))[0])
1170 #define DIOC_AX(regs) (((unsigned short*)&((regs)->reg_EAX))[0])
1171 #define DIOC_BX(regs) (((unsigned short*)&((regs)->reg_EBX))[0])
1172 #define DIOC_CX(regs) (((unsigned short*)&((regs)->reg_ECX))[0])
1173 #define DIOC_DX(regs) (((unsigned short*)&((regs)->reg_EDX))[0])
1175 #define DIOC_SET_CARRY(regs) (((regs)->reg_Flags)|=0x00000001)
1177 static const DWORD VWIN32_DriveTypeInfo
[7]={
1182 0x4f12, /* 1.44 M */
1183 0x4f24, /* 2.88 M */
1187 static BYTE floppy_params
[2][13] =
1189 { 0xaf, 0x02, 0x25, 0x02, 0x12, 0x1b, 0xff, 0x6c, 0xf6, 0x0f, 0x08 },
1190 { 0xaf, 0x02, 0x25, 0x02, 0x12, 0x1b, 0xff, 0x6c, 0xf6, 0x0f, 0x08 }
1193 /**********************************************************************
1194 * VWIN32_ReadFloppyParams
1196 * Handler for int 13h (disk I/O).
1198 static VOID
VWIN32_ReadFloppyParams(DIOC_REGISTERS
*regs
)
1201 unsigned int i
, nr_of_drives
= 0;
1202 BYTE drive_nr
= DIOC_DL(regs
);
1204 struct floppy_drive_params floppy_parm
;
1205 char root
[] = "A:\\";
1207 TRACE("in [ EDX=%08lx ]\n", regs
->reg_EDX
);
1209 DIOC_AH(regs
) = 0x00; /* success */
1211 for (i
= 0; i
< MAX_DOS_DRIVES
; i
++, root
[0]++)
1212 if (GetDriveTypeA(root
) == DRIVE_REMOVABLE
) nr_of_drives
++;
1213 DIOC_DL(regs
) = nr_of_drives
;
1215 if (drive_nr
> 1) { /* invalid drive ? */
1219 DIOC_SET_CARRY(regs
);
1223 if ( (floppy_fd
= DRIVE_OpenDevice( drive_nr
, O_NONBLOCK
)) == -1)
1225 WARN("Can't determine floppy geometry !\n");
1229 DIOC_SET_CARRY(regs
);
1232 r
= ioctl(floppy_fd
, FDGETDRVPRM
, &floppy_parm
);
1238 DIOC_SET_CARRY(regs
);
1244 DIOC_BL(regs
) = floppy_parm
.cmos
;
1246 /* CH = low eight bits of max cyl
1247 CL = max sec nr (bits 5-0),
1248 hi two bits of max cyl (bits 7-6)
1250 if(DIOC_BL(regs
) && (DIOC_BL(regs
)<7))
1252 DIOC_DH(regs
) = 0x01;
1253 DIOC_CX(regs
) = VWIN32_DriveTypeInfo
[DIOC_BL(regs
)];
1257 DIOC_CX(regs
) = 0x0;
1258 DIOC_DX(regs
) = 0x0;
1261 regs
->reg_EDI
= (DWORD
)floppy_params
[drive_nr
];
1265 ERR("Get floppy params failed for drive %d\n",drive_nr
);
1266 DIOC_SET_CARRY(regs
);
1269 TRACE("out [ EAX=%08lx EBX=%08lx ECX=%08lx EDX=%08lx EDI=%08lx ]\n",
1270 regs
->reg_EAX
, regs
->reg_EBX
, regs
->reg_ECX
, regs
->reg_EDX
, regs
->reg_EDI
);
1272 /* FIXME: Word exits quietly if we return with no error. Why? */
1273 FIXME("Returned ERROR!\n");
1274 DIOC_SET_CARRY(regs
);
1277 DIOC_AH(regs
) = 0x01;
1278 DIOC_SET_CARRY(regs
);
1282 /**********************************************************************
1283 * VWIN32_Int13Handler
1285 * Handler for VWIN32_DIOC_DOS_INT13 (disk I/O).
1287 static VOID
VWIN32_Int13Handler( DIOC_REGISTERS
*regs
)
1289 TRACE("AH=%02x\n",DIOC_AH(regs
));
1290 switch(DIOC_AH(regs
)) /* AH */
1292 case 0x00: /* RESET DISK SYSTEM */
1293 break; /* no return ? */
1295 case 0x01: /* STATUS OF DISK SYSTEM */
1296 DIOC_AL(regs
) = 0; /* successful completion */
1299 case 0x02: /* READ SECTORS INTO MEMORY */
1300 DIOC_AL(regs
) = 0; /* number of sectors read */
1301 DIOC_AH(regs
) = 0; /* status */
1304 case 0x03: /* WRITE SECTORS FROM MEMORY */
1305 break; /* no return ? */
1307 case 0x04: /* VERIFY DISK SECTOR(S) */
1308 DIOC_AL(regs
) = 0; /* number of sectors verified */
1312 case 0x05: /* FORMAT TRACK */
1313 case 0x06: /* FORMAT TRACK AND SET BAD SECTOR FLAGS */
1314 case 0x07: /* FORMAT DRIVE STARTING AT GIVEN TRACK */
1315 /* despite what Ralf Brown says, 0x06 and 0x07 seem to
1316 * set CFLAG, too (at least my BIOS does that) */
1317 DIOC_AH(regs
) = 0x0c;
1318 DIOC_SET_CARRY(regs
);
1321 case 0x08: /* GET DRIVE PARAMETERS */
1322 if (DIOC_DL(regs
) & 0x80) { /* hard disk ? */
1323 DIOC_AH(regs
) = 0x07;
1324 DIOC_SET_CARRY(regs
);
1326 else /* floppy disk */
1327 VWIN32_ReadFloppyParams(regs
);
1330 case 0x09: /* INITIALIZE CONTROLLER WITH DRIVE PARAMETERS */
1331 case 0x0a: /* FIXED DISK - READ LONG (XT,AT,XT286,PS) */
1332 case 0x0b: /* FIXED DISK - WRITE LONG (XT,AT,XT286,PS) */
1333 case 0x0c: /* SEEK TO CYLINDER */
1334 case 0x0d: /* ALTERNATE RESET HARD DISKS */
1335 case 0x10: /* CHECK IF DRIVE READY */
1336 case 0x11: /* RECALIBRATE DRIVE */
1337 case 0x14: /* CONTROLLER INTERNAL DIAGNOSTIC */
1341 case 0x15: /* GET DISK TYPE (AT,XT2,XT286,CONV,PS) */
1342 if (DIOC_DL(regs
) & 0x80) { /* hard disk ? */
1343 DIOC_AH(regs
) = 3; /* fixed disk */
1344 DIOC_SET_CARRY(regs
);
1346 else { /* floppy disk ? */
1347 DIOC_AH(regs
) = 2; /* floppy with change detection */
1348 DIOC_SET_CARRY(regs
);
1352 case 0x0e: /* READ SECTOR BUFFER (XT only) */
1353 case 0x0f: /* WRITE SECTOR BUFFER (XT only) */
1354 case 0x12: /* CONTROLLER RAM DIAGNOSTIC (XT,PS) */
1355 case 0x13: /* DRIVE DIAGNOSTIC (XT,PS) */
1356 DIOC_AH(regs
) = 0x01;
1357 DIOC_SET_CARRY(regs
);
1360 case 0x16: /* FLOPPY - CHANGE OF DISK STATUS */
1361 DIOC_AH(regs
) = 0; /* FIXME - no change */
1364 case 0x17: /* SET DISK TYPE FOR FORMAT */
1365 if (DIOC_DL(regs
) < 4)
1366 DIOC_AH(regs
) = 0x00; /* successful completion */
1368 DIOC_AH(regs
) = 0x01; /* error */
1371 case 0x18: /* SET MEDIA TYPE FOR FORMAT */
1372 if (DIOC_DL(regs
) < 4)
1373 DIOC_AH(regs
) = 0x00; /* successful completion */
1375 DIOC_AH(regs
) = 0x01; /* error */
1378 case 0x19: /* FIXED DISK - PARK HEADS */
1382 FIXME("Unknown VWIN32 INT13 call AX=%04X\n",DIOC_AX(regs
));
1386 static BOOL
DeviceIo_VWin32(DWORD dwIoControlCode
,
1387 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1388 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1389 LPDWORD lpcbBytesReturned
,
1390 LPOVERLAPPED lpOverlapped
)
1394 switch (dwIoControlCode
)
1396 case VWIN32_DIOC_DOS_INT13
:
1398 DIOC_REGISTERS
*pIn
= (DIOC_REGISTERS
*)lpvInBuffer
;
1399 DIOC_REGISTERS
*pOut
= (DIOC_REGISTERS
*)lpvOutBuffer
;
1401 memcpy(pOut
, pIn
, sizeof (DIOC_REGISTERS
));
1402 VWIN32_Int13Handler(pOut
);
1406 case VWIN32_DIOC_DOS_IOCTL
:
1407 case VWIN32_DIOC_DOS_INT25
:
1408 case VWIN32_DIOC_DOS_INT26
:
1409 case VWIN32_DIOC_DOS_DRIVEINFO
:
1412 DIOC_REGISTERS
*pIn
= (DIOC_REGISTERS
*)lpvInBuffer
;
1413 DIOC_REGISTERS
*pOut
= (DIOC_REGISTERS
*)lpvOutBuffer
;
1415 TRACE( "Control '%s': "
1416 "eax=0x%08lx, ebx=0x%08lx, ecx=0x%08lx, "
1417 "edx=0x%08lx, esi=0x%08lx, edi=0x%08lx \n",
1418 (dwIoControlCode
== VWIN32_DIOC_DOS_IOCTL
)? "VWIN32_DIOC_DOS_IOCTL" :
1419 (dwIoControlCode
== VWIN32_DIOC_DOS_INT25
)? "VWIN32_DIOC_DOS_INT25" :
1420 (dwIoControlCode
== VWIN32_DIOC_DOS_INT26
)? "VWIN32_DIOC_DOS_INT26" :
1421 (dwIoControlCode
== VWIN32_DIOC_DOS_DRIVEINFO
)? "VWIN32_DIOC_DOS_DRIVEINFO" : "???",
1422 pIn
->reg_EAX
, pIn
->reg_EBX
, pIn
->reg_ECX
,
1423 pIn
->reg_EDX
, pIn
->reg_ESI
, pIn
->reg_EDI
);
1425 DIOCRegs_2_CONTEXT( pIn
, &cxt
);
1427 switch (dwIoControlCode
)
1429 case VWIN32_DIOC_DOS_IOCTL
: DOS3Call( &cxt
); break; /* Call int 21h */
1430 case VWIN32_DIOC_DOS_INT25
: INT_Int25Handler( &cxt
); break;
1431 case VWIN32_DIOC_DOS_INT26
: INT_Int26Handler( &cxt
); break;
1432 case VWIN32_DIOC_DOS_DRIVEINFO
: DOS3Call( &cxt
); break; /* Call int 21h 730x */
1435 CONTEXT_2_DIOCRegs( &cxt
, pOut
);
1439 case VWIN32_DIOC_SIMCTRLC
:
1440 FIXME( "Control VWIN32_DIOC_SIMCTRLC not implemented\n");
1445 FIXME( "Unknown Control %ld\n", dwIoControlCode
);
1453 /* this is the main multimedia device loader */
1454 static BOOL
DeviceIo_MMDEVLDR(DWORD dwIoControlCode
,
1455 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1456 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1457 LPDWORD lpcbBytesReturned
,
1458 LPOVERLAPPED lpOverlapped
)
1460 FIXME("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
1462 lpvInBuffer
,cbInBuffer
,
1463 lpvOutBuffer
,cbOutBuffer
,
1467 switch (dwIoControlCode
) {
1470 *(DWORD
*)lpvOutBuffer
=0;
1471 *lpcbBytesReturned
=4;
1476 /* this is used by some Origin games */
1477 static BOOL
DeviceIo_MONODEBG(DWORD dwIoControlCode
,
1478 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1479 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1480 LPDWORD lpcbBytesReturned
,
1481 LPOVERLAPPED lpOverlapped
)
1483 switch (dwIoControlCode
) {
1484 case 1: /* version */
1485 *(LPDWORD
)lpvOutBuffer
= 0x20004; /* WC SecretOps */
1487 case 9: /* debug output */
1488 ERR("MONODEBG: %s\n",debugstr_a(lpvInBuffer
));
1491 FIXME("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
1493 lpvInBuffer
,cbInBuffer
,
1494 lpvOutBuffer
,cbOutBuffer
,
1503 static BOOL
DeviceIo_PCCARD (DWORD dwIoControlCode
,
1504 LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1505 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1506 LPDWORD lpcbBytesReturned
,
1507 LPOVERLAPPED lpOverlapped
)
1509 switch (dwIoControlCode
) {
1510 case 0x0000: /* PCCARD_Get_Version */
1511 case 0x0001: /* PCCARD_Card_Services */
1513 FIXME( "(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
1515 lpvInBuffer
,cbInBuffer
,
1516 lpvOutBuffer
,cbOutBuffer
,
1525 /***********************************************************************
1526 * OpenVxDHandle (KERNEL32.@)
1528 DWORD WINAPI
OpenVxDHandle(DWORD pmt
)
1530 FIXME( "(0x%08lx) stub!\n", pmt
);
1534 static BOOL
DeviceIo_HASP(DWORD dwIoControlCode
, LPVOID lpvInBuffer
, DWORD cbInBuffer
,
1535 LPVOID lpvOutBuffer
, DWORD cbOutBuffer
,
1536 LPDWORD lpcbBytesReturned
,
1537 LPOVERLAPPED lpOverlapped
)
1540 FIXME("(%ld,%p,%ld,%p,%ld,%p,%p): stub\n",
1542 lpvInBuffer
,cbInBuffer
,
1543 lpvOutBuffer
,cbOutBuffer
,