2004-02-20 02:18:43 +01:00
|
|
|
/*
|
|
|
|
* VWIN32 VxD implementation
|
|
|
|
*
|
|
|
|
* Copyright 1998 Marcus Meissner
|
|
|
|
* Copyright 1998 Ulrich Weigand
|
|
|
|
* Copyright 1998 Patrik Stridvall
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-02-20 02:18:43 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winioctl.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(vxd);
|
|
|
|
|
2009-02-09 12:57:39 +01:00
|
|
|
typedef struct tagDIOCRegs {
|
|
|
|
DWORD reg_EBX;
|
|
|
|
DWORD reg_EDX;
|
|
|
|
DWORD reg_ECX;
|
|
|
|
DWORD reg_EAX;
|
|
|
|
DWORD reg_EDI;
|
|
|
|
DWORD reg_ESI;
|
|
|
|
DWORD reg_Flags;
|
|
|
|
} DIOC_REGISTERS, *PDIOC_REGISTERS;
|
|
|
|
|
|
|
|
#define VWIN32_DIOC_DOS_IOCTL 1 /* This is the specified MS-DOS device I/O ctl - Interrupt 21h Function 4400h - 4411h */
|
|
|
|
#define VWIN32_DIOC_DOS_INT25 2 /* This is the Absolute Disk Read command - Interrupt 25h */
|
|
|
|
#define VWIN32_DIOC_DOS_INT26 3 /* This is the Absolute Disk Write command - Interrupt 25h */
|
|
|
|
#define VWIN32_DIOC_DOS_INT13 4 /* This is Interrupt 13h commands */
|
|
|
|
#define VWIN32_DIOC_SIMCTRLC 5 /* Simulate Ctrl-C */
|
|
|
|
#define VWIN32_DIOC_DOS_DRIVEINFO 6 /* This is Interrupt 21h Function 730X commands */
|
|
|
|
|
|
|
|
#include <pshpack1.h>
|
|
|
|
typedef struct tagMID {
|
|
|
|
WORD midInfoLevel;
|
|
|
|
DWORD midSerialNum;
|
|
|
|
BYTE midVolLabel[11];
|
|
|
|
BYTE midFileSysType[8];
|
|
|
|
} MID, *PMID;
|
|
|
|
#include <poppack.h>
|
|
|
|
|
2010-01-05 14:26:05 +01:00
|
|
|
extern void __wine_call_int_handler( CONTEXT *context, BYTE intnum );
|
2004-02-20 02:18:43 +01:00
|
|
|
|
2004-02-21 05:13:56 +01:00
|
|
|
/* Pop a DWORD from the 32-bit stack */
|
2010-10-20 15:36:35 +02:00
|
|
|
static inline DWORD stack32_pop( CONTEXT *context )
|
2004-02-21 05:13:56 +01:00
|
|
|
{
|
|
|
|
DWORD ret = *(DWORD *)context->Esp;
|
|
|
|
context->Esp += sizeof(DWORD);
|
|
|
|
return ret;
|
|
|
|
}
|
2004-02-20 02:18:43 +01:00
|
|
|
|
2010-10-20 15:36:35 +02:00
|
|
|
static void DIOCRegs_2_CONTEXT( DIOC_REGISTERS *pIn, CONTEXT *pCxt )
|
2004-02-20 02:18:43 +01:00
|
|
|
{
|
|
|
|
memset( pCxt, 0, sizeof(*pCxt) );
|
|
|
|
/* Note: segment registers == 0 means that CTX_SEG_OFF_TO_LIN
|
|
|
|
will interpret 32-bit register contents as linear pointers */
|
|
|
|
|
2010-10-20 15:36:35 +02:00
|
|
|
pCxt->ContextFlags=CONTEXT_INTEGER|CONTEXT_CONTROL;
|
2004-02-20 02:18:43 +01:00
|
|
|
pCxt->Eax = pIn->reg_EAX;
|
|
|
|
pCxt->Ebx = pIn->reg_EBX;
|
|
|
|
pCxt->Ecx = pIn->reg_ECX;
|
|
|
|
pCxt->Edx = pIn->reg_EDX;
|
|
|
|
pCxt->Esi = pIn->reg_ESI;
|
|
|
|
pCxt->Edi = pIn->reg_EDI;
|
|
|
|
|
2010-10-20 15:36:35 +02:00
|
|
|
/* FIXME: Only partial CONTEXT_CONTROL */
|
2004-02-20 02:18:43 +01:00
|
|
|
|
|
|
|
pCxt->EFlags = pIn->reg_Flags & ~0x00020000; /* clear vm86 mode */
|
|
|
|
}
|
|
|
|
|
2010-10-20 15:36:35 +02:00
|
|
|
static void CONTEXT_2_DIOCRegs( CONTEXT *pCxt, DIOC_REGISTERS *pOut )
|
2004-02-20 02:18:43 +01:00
|
|
|
{
|
|
|
|
memset( pOut, 0, sizeof(DIOC_REGISTERS) );
|
|
|
|
|
|
|
|
pOut->reg_EAX = pCxt->Eax;
|
|
|
|
pOut->reg_EBX = pCxt->Ebx;
|
|
|
|
pOut->reg_ECX = pCxt->Ecx;
|
|
|
|
pOut->reg_EDX = pCxt->Edx;
|
|
|
|
pOut->reg_ESI = pCxt->Esi;
|
|
|
|
pOut->reg_EDI = pCxt->Edi;
|
|
|
|
|
2010-10-20 15:36:35 +02:00
|
|
|
/* FIXME: Only partial CONTEXT_CONTROL */
|
2004-02-20 02:18:43 +01:00
|
|
|
pOut->reg_Flags = pCxt->EFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DeviceIoControl (VWIN32.VXD.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI VWIN32_DeviceIoControl(DWORD dwIoControlCode,
|
|
|
|
LPVOID lpvInBuffer, DWORD cbInBuffer,
|
|
|
|
LPVOID lpvOutBuffer, DWORD cbOutBuffer,
|
|
|
|
LPDWORD lpcbBytesReturned, LPOVERLAPPED lpOverlapped)
|
|
|
|
{
|
|
|
|
switch (dwIoControlCode)
|
|
|
|
{
|
|
|
|
case VWIN32_DIOC_DOS_IOCTL:
|
|
|
|
case 0x10: /* Int 0x21 call, call it VWIN_DIOC_INT21 ? */
|
|
|
|
case VWIN32_DIOC_DOS_INT13:
|
|
|
|
case VWIN32_DIOC_DOS_INT25:
|
|
|
|
case VWIN32_DIOC_DOS_INT26:
|
|
|
|
case 0x29: /* Int 0x31 call, call it VWIN_DIOC_INT31 ? */
|
|
|
|
case VWIN32_DIOC_DOS_DRIVEINFO:
|
|
|
|
{
|
2010-10-20 15:36:35 +02:00
|
|
|
CONTEXT cxt;
|
2009-02-16 09:53:59 +01:00
|
|
|
DIOC_REGISTERS *pIn = lpvInBuffer;
|
|
|
|
DIOC_REGISTERS *pOut = lpvOutBuffer;
|
2004-02-20 02:18:43 +01:00
|
|
|
BYTE intnum = 0;
|
|
|
|
|
|
|
|
TRACE( "Control '%s': "
|
2006-10-06 23:01:41 +02:00
|
|
|
"eax=0x%08x, ebx=0x%08x, ecx=0x%08x, "
|
|
|
|
"edx=0x%08x, esi=0x%08x, edi=0x%08x\n",
|
2004-02-20 02:18:43 +01:00
|
|
|
(dwIoControlCode == VWIN32_DIOC_DOS_IOCTL)? "VWIN32_DIOC_DOS_IOCTL" :
|
|
|
|
(dwIoControlCode == VWIN32_DIOC_DOS_INT25)? "VWIN32_DIOC_DOS_INT25" :
|
|
|
|
(dwIoControlCode == VWIN32_DIOC_DOS_INT26)? "VWIN32_DIOC_DOS_INT26" :
|
|
|
|
(dwIoControlCode == VWIN32_DIOC_DOS_DRIVEINFO)? "VWIN32_DIOC_DOS_DRIVEINFO" : "???",
|
|
|
|
pIn->reg_EAX, pIn->reg_EBX, pIn->reg_ECX,
|
|
|
|
pIn->reg_EDX, pIn->reg_ESI, pIn->reg_EDI );
|
|
|
|
|
|
|
|
DIOCRegs_2_CONTEXT( pIn, &cxt );
|
|
|
|
|
|
|
|
switch (dwIoControlCode)
|
|
|
|
{
|
|
|
|
case VWIN32_DIOC_DOS_IOCTL: /* Call int 21h */
|
|
|
|
case 0x10: /* Int 0x21 call, call it VWIN_DIOC_INT21 ? */
|
|
|
|
case VWIN32_DIOC_DOS_DRIVEINFO: /* Call int 21h 730x */
|
|
|
|
intnum = 0x21;
|
|
|
|
break;
|
|
|
|
case VWIN32_DIOC_DOS_INT13:
|
|
|
|
intnum = 0x13;
|
|
|
|
break;
|
|
|
|
case VWIN32_DIOC_DOS_INT25:
|
|
|
|
intnum = 0x25;
|
|
|
|
break;
|
|
|
|
case VWIN32_DIOC_DOS_INT26:
|
|
|
|
intnum = 0x26;
|
|
|
|
break;
|
|
|
|
case 0x29: /* Int 0x31 call, call it VWIN_DIOC_INT31 ? */
|
|
|
|
intnum = 0x31;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-01-05 14:26:05 +01:00
|
|
|
__wine_call_int_handler( &cxt, intnum );
|
2004-02-20 02:18:43 +01:00
|
|
|
CONTEXT_2_DIOCRegs( &cxt, pOut );
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case VWIN32_DIOC_SIMCTRLC:
|
|
|
|
FIXME( "Control VWIN32_DIOC_SIMCTRLC not implemented\n");
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
default:
|
2006-10-06 23:01:41 +02:00
|
|
|
FIXME( "Unknown Control %d\n", dwIoControlCode);
|
2004-02-20 02:18:43 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2004-02-21 05:13:56 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* VxDCall (VWIN32.VXD.@)
|
|
|
|
*
|
|
|
|
* Service numbers taken from page 448 of Pietrek's "Windows 95 System
|
|
|
|
* Programming Secrets". Parameters from experimentation on real Win98.
|
|
|
|
*
|
|
|
|
*/
|
2010-10-20 15:36:35 +02:00
|
|
|
DWORD WINAPI VWIN32_VxDCall( DWORD service, CONTEXT *context )
|
2004-02-21 05:13:56 +01:00
|
|
|
{
|
|
|
|
switch ( LOWORD(service) )
|
|
|
|
{
|
|
|
|
case 0x0000: /* GetVersion */
|
|
|
|
{
|
|
|
|
DWORD vers = GetVersion();
|
|
|
|
return (LOBYTE(vers) << 8) | HIBYTE(vers);
|
|
|
|
}
|
|
|
|
case 0x0020: /* Get VMCPD Version */
|
|
|
|
{
|
|
|
|
DWORD parm = stack32_pop(context);
|
|
|
|
|
2006-10-06 23:01:41 +02:00
|
|
|
FIXME("Get VMCPD Version(%08x): partial stub!\n", parm);
|
2004-02-21 05:13:56 +01:00
|
|
|
|
|
|
|
/* FIXME: This is what Win98 returns, it may
|
|
|
|
* not be correct in all situations.
|
|
|
|
* It makes Bleem! happy though.
|
|
|
|
*/
|
|
|
|
return 0x0405;
|
|
|
|
}
|
|
|
|
case 0x0029: /* Int31/DPMI dispatch */
|
|
|
|
{
|
|
|
|
DWORD callnum = stack32_pop(context);
|
|
|
|
DWORD parm = stack32_pop(context);
|
|
|
|
|
2006-10-06 23:01:41 +02:00
|
|
|
TRACE("Int31/DPMI dispatch(%08x)\n", callnum);
|
2004-02-21 05:13:56 +01:00
|
|
|
|
|
|
|
context->Eax = callnum;
|
|
|
|
context->Ecx = parm;
|
2010-01-05 14:26:05 +01:00
|
|
|
__wine_call_int_handler( context, 0x31 );
|
2004-02-21 05:13:56 +01:00
|
|
|
return LOWORD(context->Eax);
|
|
|
|
}
|
|
|
|
case 0x002a: /* Int41 dispatch - parm = int41 service number */
|
|
|
|
{
|
|
|
|
DWORD callnum = stack32_pop(context);
|
|
|
|
return callnum; /* FIXME: should really call INT_Int41Handler() */
|
|
|
|
}
|
|
|
|
default:
|
2006-10-06 23:01:41 +02:00
|
|
|
FIXME("Unknown service %08x\n", service);
|
2004-02-21 05:13:56 +01:00
|
|
|
return 0xffffffff;
|
|
|
|
}
|
|
|
|
}
|