Changed CTX_SEG_OFF_TO_LIN to allow linear addresses in 32-bit

registers (used by DeviceIoControl). Adapted all users.
This commit is contained in:
Ulrich Weigand 1998-11-25 10:29:22 +00:00 committed by Alexandre Julliard
parent 1298062519
commit 7129d9f696
7 changed files with 102 additions and 85 deletions

View File

@ -9,6 +9,7 @@
#include <stdio.h> #include <stdio.h>
#include "winnt.h" #include "winnt.h"
#include "ldt.h"
/* msdos/dosmem.c */ /* msdos/dosmem.c */
extern HANDLE16 DOSMEM_BiosSeg; extern HANDLE16 DOSMEM_BiosSeg;
@ -71,12 +72,12 @@ extern void WINAPI INT_Int20Handler(CONTEXT*);
/* msdos/int25.c */ /* msdos/int25.c */
extern void WINAPI INT_Int25Handler(CONTEXT*); extern void WINAPI INT_Int25Handler(CONTEXT*);
/* msdos/int26.c */
extern void WINAPI INT_Int26Handler(CONTEXT*);
/* msdos/int29.c */ /* msdos/int29.c */
extern void WINAPI INT_Int29Handler(CONTEXT*); extern void WINAPI INT_Int29Handler(CONTEXT*);
/* msdos/int25.c */
extern void WINAPI INT_Int25Handler(CONTEXT*);
/* msdos/int2f.c */ /* msdos/int2f.c */
extern void WINAPI INT_Int2fHandler(CONTEXT*); extern void WINAPI INT_Int2fHandler(CONTEXT*);
@ -97,9 +98,24 @@ extern BOOL32 SIGNAL_InitEmulator(void);
/* misc/aspi.c */ /* misc/aspi.c */
extern void ASPI_DOS_HandleInt(CONTEXT *context); extern void ASPI_DOS_HandleInt(CONTEXT *context);
/* NOTE: Interrupts might get called from three modes: real mode, 16-bit, and
* (via DeviceIoControl) 32-bit. For automatic conversion of pointer
* parameters, interrupt handlers should use CTX_SEG_OFF_TO_LIN with
* the contents of a segement register as second and the contents of
* a *32-bit* general register as third parameter, e.g.
* CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EDX_reg(context) )
* This will generate a linear pointer in all three cases:
* Real-Mode: Seg*16 + LOWORD(Offset) + V86BASE
* 16-bit: convert (Seg, LOWORD(Offset)) to linear
* 32-bit: use Offset as linear address (DeviceIoControl!)
*
* Real-mode is recognized by checking the V86 bit in the flags register,
* 32-bit mode is recognized by checking whether 'seg' is a system selector
* (0 counts also as 32-bit segment).
*/
#define CTX_SEG_OFF_TO_LIN(context,seg,off) \ #define CTX_SEG_OFF_TO_LIN(context,seg,off) \
(ISV86(context) ? (void*)(V86BASE(context)+((seg)<<4)+off) \ (ISV86(context) ? (void*)(V86BASE(context)+((seg)<<4)+(off&0xffff)) : \
: PTR_SEG_OFF_TO_LIN(seg,off)) (!seg || IS_SELECTOR_SYSTEM(seg))? (void *)off : PTR_SEG_OFF_TO_LIN(seg,off&0xffff))
#define INT_BARF(context,num) \ #define INT_BARF(context,num) \
fprintf( stderr, "int%x: unknown/not implemented parameters:\n" \ fprintf( stderr, "int%x: unknown/not implemented parameters:\n" \

View File

@ -222,7 +222,7 @@ int DPMI_CallRMProc( CONTEXT *context, LPWORD stack, int args, int iret )
return 1; return 1;
} }
} else { } else {
stack16 = CTX_SEG_OFF_TO_LIN(context, SS_reg(context), SP_reg(context)); stack16 = CTX_SEG_OFF_TO_LIN(context, SS_reg(context), ESP_reg(context));
addr = NULL; /* avoid gcc warning */ addr = NULL; /* avoid gcc warning */
} }
SP_reg(context) -= args*sizeof(WORD) + (iret?1:0); SP_reg(context) -= args*sizeof(WORD) + (iret?1:0);
@ -253,7 +253,7 @@ int DPMI_CallRMProc( CONTEXT *context, LPWORD stack, int args, int iret )
TRACE(int31,"returned from real-mode call\n"); TRACE(int31,"returned from real-mode call\n");
if (alloc) DOSMEM_FreeBlock( pModule->self, addr ); if (alloc) DOSMEM_FreeBlock( pModule->self, addr );
#else #else
addr = CTX_SEG_OFF_TO_LIN(context, CS_reg(context), IP_reg(context)); addr = CTX_SEG_OFF_TO_LIN(context, CS_reg(context), EIP_reg(context));
sel = SELECTOR_AllocBlock( addr, 0x10000, SEGMENT_CODE, FALSE, FALSE ); sel = SELECTOR_AllocBlock( addr, 0x10000, SEGMENT_CODE, FALSE, FALSE );
seg_addr = PTR_SEG_OFF_TO_SEGPTR( sel, 0 ); seg_addr = PTR_SEG_OFF_TO_SEGPTR( sel, 0 );

View File

@ -248,7 +248,7 @@ static void ioctlGetDeviceInfo( CONTEXT *context )
static BOOL32 ioctlGenericBlkDevReq( CONTEXT *context ) static BOOL32 ioctlGenericBlkDevReq( CONTEXT *context )
{ {
BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context)); BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
int drive = DOS_GET_DRIVE( BL_reg(context) ); int drive = DOS_GET_DRIVE( BL_reg(context) );
if (!DRIVE_IsValid(drive)) if (!DRIVE_IsValid(drive))
@ -397,14 +397,14 @@ char *INT21_DriveName(int drive)
static BOOL32 INT21_CreateFile( CONTEXT *context ) static BOOL32 INT21_CreateFile( CONTEXT *context )
{ {
AX_reg(context) = _lcreat16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context), AX_reg(context) = _lcreat16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) ), CX_reg(context) ); EDX_reg(context) ), CX_reg(context) );
return (AX_reg(context) == (WORD)HFILE_ERROR16); return (AX_reg(context) == (WORD)HFILE_ERROR16);
} }
static void OpenExistingFile( CONTEXT *context ) static void OpenExistingFile( CONTEXT *context )
{ {
AX_reg(context) = _lopen16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context)), AX_reg(context) = _lopen16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)),
AL_reg(context) ); AL_reg(context) );
if (AX_reg(context) == (WORD)HFILE_ERROR16) if (AX_reg(context) == (WORD)HFILE_ERROR16)
{ {
@ -426,7 +426,7 @@ static void OpenExistingFile( CONTEXT *context )
case 0x30: /* DENYREAD */ case 0x30: /* DENYREAD */
TRACE(int21, "(%s): DENYREAD changed to DENYALL\n", TRACE(int21, "(%s): DENYREAD changed to DENYALL\n",
(char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context))); (char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)));
case 0x10: /* DENYALL */ case 0x10: /* DENYALL */
lock = LOCK_EX; lock = LOCK_EX;
break; break;
@ -593,7 +593,7 @@ static BOOL32 INT21_ExtendedOpenCreateFile(CONTEXT *context )
static BOOL32 INT21_ChangeDir( CONTEXT *context ) static BOOL32 INT21_ChangeDir( CONTEXT *context )
{ {
int drive; int drive;
char *dirname = CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context)); char *dirname = CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context));
TRACE(int21,"changedir %s\n", dirname); TRACE(int21,"changedir %s\n", dirname);
if (dirname[0] && (dirname[1] == ':')) if (dirname[0] && (dirname[1] == ':'))
@ -613,7 +613,7 @@ static int INT21_FindFirst( CONTEXT *context )
DOS_FULL_NAME full_name; DOS_FULL_NAME full_name;
FINDFILE_DTA *dta = (FINDFILE_DTA *)GetCurrentDTA(context); FINDFILE_DTA *dta = (FINDFILE_DTA *)GetCurrentDTA(context);
path = (const char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context)); path = (const char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
dta->unixPath = NULL; dta->unixPath = NULL;
if (!DOSFS_GetFullName( path, FALSE, &full_name )) if (!DOSFS_GetFullName( path, FALSE, &full_name ))
{ {
@ -686,7 +686,7 @@ static int INT21_FindNext( CONTEXT *context )
static BOOL32 INT21_CreateTempFile( CONTEXT *context ) static BOOL32 INT21_CreateTempFile( CONTEXT *context )
{ {
static int counter = 0; static int counter = 0;
char *name = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context) ); char *name = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context) );
char *p = name + strlen(name); char *p = name + strlen(name);
/* despite what Ralf Brown says, some programs seem to call without /* despite what Ralf Brown says, some programs seem to call without
@ -711,7 +711,7 @@ static BOOL32 INT21_CreateTempFile( CONTEXT *context )
static BOOL32 INT21_GetCurrentDirectory( CONTEXT *context ) static BOOL32 INT21_GetCurrentDirectory( CONTEXT *context )
{ {
int drive = DOS_GET_DRIVE( DL_reg(context) ); int drive = DOS_GET_DRIVE( DL_reg(context) );
char *ptr = (char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), SI_reg(context) ); char *ptr = (char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), ESI_reg(context) );
if (!DRIVE_IsValid(drive)) if (!DRIVE_IsValid(drive))
{ {
@ -741,7 +741,7 @@ static void INT21_GetDBCSLeadTable( CONTEXT *context )
static int INT21_GetDiskSerialNumber( CONTEXT *context ) static int INT21_GetDiskSerialNumber( CONTEXT *context )
{ {
BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context)); BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
int drive = DOS_GET_DRIVE( BL_reg(context) ); int drive = DOS_GET_DRIVE( BL_reg(context) );
if (!DRIVE_IsValid(drive)) if (!DRIVE_IsValid(drive))
@ -760,7 +760,7 @@ static int INT21_GetDiskSerialNumber( CONTEXT *context )
static int INT21_SetDiskSerialNumber( CONTEXT *context ) static int INT21_SetDiskSerialNumber( CONTEXT *context )
{ {
BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context)); BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
int drive = DOS_GET_DRIVE( BL_reg(context) ); int drive = DOS_GET_DRIVE( BL_reg(context) );
if (!DRIVE_IsValid(drive)) if (!DRIVE_IsValid(drive))
@ -779,7 +779,7 @@ static int INT21_SetDiskSerialNumber( CONTEXT *context )
static int INT21_FindFirstFCB( CONTEXT *context ) static int INT21_FindFirstFCB( CONTEXT *context )
{ {
BYTE *fcb = (BYTE *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context)); BYTE *fcb = (BYTE *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
FINDFILE_FCB *pFCB; FINDFILE_FCB *pFCB;
LPCSTR root, cwd; LPCSTR root, cwd;
int drive; int drive;
@ -803,7 +803,7 @@ static int INT21_FindFirstFCB( CONTEXT *context )
static int INT21_FindNextFCB( CONTEXT *context ) static int INT21_FindNextFCB( CONTEXT *context )
{ {
BYTE *fcb = (BYTE *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context)); BYTE *fcb = (BYTE *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context));
FINDFILE_FCB *pFCB; FINDFILE_FCB *pFCB;
DOS_DIRENTRY_LAYOUT *pResult = (DOS_DIRENTRY_LAYOUT *)GetCurrentDTA(context); DOS_DIRENTRY_LAYOUT *pResult = (DOS_DIRENTRY_LAYOUT *)GetCurrentDTA(context);
WIN32_FIND_DATA32A entry; WIN32_FIND_DATA32A entry;
@ -925,7 +925,7 @@ INT21_networkfunc (CONTEXT *context)
switch (AL_reg(context)) { switch (AL_reg(context)) {
case 0x00: /* Get machine name. */ case 0x00: /* Get machine name. */
{ {
char *dst = CTX_SEG_OFF_TO_LIN (context,DS_reg(context),DX_reg(context)); char *dst = CTX_SEG_OFF_TO_LIN (context,DS_reg(context),EDX_reg(context));
TRACE(int21, "getting machine name to %p\n", dst); TRACE(int21, "getting machine name to %p\n", dst);
if (gethostname (dst, 15)) if (gethostname (dst, 15))
{ {
@ -1120,7 +1120,7 @@ void WINAPI DOS3Call( CONTEXT *context )
TRACE(int21,"WRITE '$'-terminated string from %04lX:%04X to stdout\n", TRACE(int21,"WRITE '$'-terminated string from %04lX:%04X to stdout\n",
DS_reg(context),DX_reg(context) ); DS_reg(context),DX_reg(context) );
{ {
LPSTR data = CTX_SEG_OFF_TO_LIN(context,DS_reg(context),DX_reg(context)); LPSTR data = CTX_SEG_OFF_TO_LIN(context,DS_reg(context),EDX_reg(context));
LONG length = strchr(data,'$')-data; LONG length = strchr(data,'$')-data;
_hwrite16( 1, data, length); _hwrite16( 1, data, length);
AL_reg(context) = '$'; /* yes, '$' (0x24) gets returned in AL */ AL_reg(context) = '$'; /* yes, '$' (0x24) gets returned in AL */
@ -1130,7 +1130,7 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x0a: /* BUFFERED INPUT */ case 0x0a: /* BUFFERED INPUT */
{ {
char *buffer = ((char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), char *buffer = ((char *)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) )); EDX_reg(context) ));
int res; int res;
TRACE(int21,"BUFFERED INPUT (size=%d)\n",buffer[0]); TRACE(int21,"BUFFERED INPUT (size=%d)\n",buffer[0]);
@ -1173,7 +1173,7 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x11: /* FIND FIRST MATCHING FILE USING FCB */ case 0x11: /* FIND FIRST MATCHING FILE USING FCB */
TRACE(int21,"FIND FIRST MATCHING FILE USING FCB %p\n", TRACE(int21,"FIND FIRST MATCHING FILE USING FCB %p\n",
CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
if (!INT21_FindFirstFCB(context)) if (!INT21_FindFirstFCB(context))
{ {
AL_reg(context) = 0xff; AL_reg(context) = 0xff;
@ -1371,35 +1371,35 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x39: /* "MKDIR" - CREATE SUBDIRECTORY */ case 0x39: /* "MKDIR" - CREATE SUBDIRECTORY */
TRACE(int21,"MKDIR %s\n", TRACE(int21,"MKDIR %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
bSetDOSExtendedError = (!CreateDirectory16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context), bSetDOSExtendedError = (!CreateDirectory16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) ), NULL)); EDX_reg(context) ), NULL));
break; break;
case 0x3a: /* "RMDIR" - REMOVE SUBDIRECTORY */ case 0x3a: /* "RMDIR" - REMOVE SUBDIRECTORY */
TRACE(int21,"RMDIR %s\n", TRACE(int21,"RMDIR %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
bSetDOSExtendedError = (!RemoveDirectory16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context), bSetDOSExtendedError = (!RemoveDirectory16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) ))); EDX_reg(context) )));
break; break;
case 0x3b: /* "CHDIR" - SET CURRENT DIRECTORY */ case 0x3b: /* "CHDIR" - SET CURRENT DIRECTORY */
TRACE(int21,"CHDIR %s\n", TRACE(int21,"CHDIR %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
bSetDOSExtendedError = !INT21_ChangeDir(context); bSetDOSExtendedError = !INT21_ChangeDir(context);
break; break;
case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */ case 0x3c: /* "CREAT" - CREATE OR TRUNCATE FILE */
TRACE(int21,"CREAT flag 0x%02x %s\n",CX_reg(context), TRACE(int21,"CREAT flag 0x%02x %s\n",CX_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
AX_reg(context) = _lcreat16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context), AX_reg(context) = _lcreat16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) ), CX_reg(context) ); EDX_reg(context) ), CX_reg(context) );
bSetDOSExtendedError = (AX_reg(context) == (WORD)HFILE_ERROR16); bSetDOSExtendedError = (AX_reg(context) == (WORD)HFILE_ERROR16);
break; break;
case 0x3d: /* "OPEN" - OPEN EXISTING FILE */ case 0x3d: /* "OPEN" - OPEN EXISTING FILE */
TRACE(int21,"OPEN mode 0x%02x %s\n",AL_reg(context), TRACE(int21,"OPEN mode 0x%02x %s\n",AL_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
OpenExistingFile(context); OpenExistingFile(context);
break; break;
@ -1426,12 +1426,12 @@ void WINAPI DOS3Call( CONTEXT *context )
if (ISV86(context)) if (ISV86(context))
result = _hread16( BX_reg(context), result = _hread16( BX_reg(context),
CTX_SEG_OFF_TO_LIN(context, DS_reg(context), CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) ), EDX_reg(context) ),
CX_reg(context) ); CX_reg(context) );
else else
result = WIN16_hread( BX_reg(context), result = WIN16_hread( BX_reg(context),
PTR_SEG_OFF_TO_SEGPTR( DS_reg(context), PTR_SEG_OFF_TO_SEGPTR( DS_reg(context),
DX_reg(context) ), EDX_reg(context) ),
CX_reg(context) ); CX_reg(context) );
if (result == -1) bSetDOSExtendedError = TRUE; if (result == -1) bSetDOSExtendedError = TRUE;
else AX_reg(context) = (WORD)result; else AX_reg(context) = (WORD)result;
@ -1444,7 +1444,7 @@ void WINAPI DOS3Call( CONTEXT *context )
{ {
LONG result = _hwrite16( BX_reg(context), LONG result = _hwrite16( BX_reg(context),
CTX_SEG_OFF_TO_LIN(context, DS_reg(context), CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) ), EDX_reg(context) ),
CX_reg(context) ); CX_reg(context) );
if (result == -1) bSetDOSExtendedError = TRUE; if (result == -1) bSetDOSExtendedError = TRUE;
else AX_reg(context) = (WORD)result; else AX_reg(context) = (WORD)result;
@ -1453,9 +1453,9 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x41: /* "UNLINK" - DELETE FILE */ case 0x41: /* "UNLINK" - DELETE FILE */
TRACE(int21,"UNLINK%s\n", TRACE(int21,"UNLINK%s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
bSetDOSExtendedError = (!DeleteFile32A( CTX_SEG_OFF_TO_LIN(context, DS_reg(context), bSetDOSExtendedError = (!DeleteFile32A( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) ))); EDX_reg(context) )));
break; break;
case 0x42: /* "LSEEK" - SET CURRENT FILE POSITION */ case 0x42: /* "LSEEK" - SET CURRENT FILE POSITION */
@ -1481,25 +1481,25 @@ void WINAPI DOS3Call( CONTEXT *context )
{ {
case 0x00: case 0x00:
TRACE(int21,"GET FILE ATTRIBUTES for %s\n", TRACE(int21,"GET FILE ATTRIBUTES for %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
AX_reg(context) = (WORD)GetFileAttributes32A( AX_reg(context) = (WORD)GetFileAttributes32A(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context), CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context))); EDX_reg(context)));
if (AX_reg(context) == 0xffff) bSetDOSExtendedError = TRUE; if (AX_reg(context) == 0xffff) bSetDOSExtendedError = TRUE;
else CX_reg(context) = AX_reg(context); else CX_reg(context) = AX_reg(context);
break; break;
case 0x01: case 0x01:
TRACE(int21,"SET FILE ATTRIBUTES 0x%02x for %s\n", CX_reg(context), TRACE(int21,"SET FILE ATTRIBUTES 0x%02x for %s\n", CX_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
bSetDOSExtendedError = bSetDOSExtendedError =
(!SetFileAttributes32A( CTX_SEG_OFF_TO_LIN(context, DS_reg(context), (!SetFileAttributes32A( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context)), EDX_reg(context)),
CX_reg(context) )); CX_reg(context) ));
break; break;
case 0x02: case 0x02:
TRACE(int21,"GET COMPRESSED FILE SIZE for %s stub\n", TRACE(int21,"GET COMPRESSED FILE SIZE for %s stub\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
} }
break; break;
@ -1521,7 +1521,7 @@ void WINAPI DOS3Call( CONTEXT *context )
break; break;
} }
case 0x05:{ /* IOCTL - WRITE TO BLOCK DEVICE CONTROL CHANNEL */ case 0x05:{ /* IOCTL - WRITE TO BLOCK DEVICE CONTROL CHANNEL */
/*BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context));*/ /*BYTE *dataptr = CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context));*/
int drive = DOS_GET_DRIVE(BL_reg(context)); int drive = DOS_GET_DRIVE(BL_reg(context));
FIXME(int21,"program tried to write to block device control channel of drive %d:\n",drive); FIXME(int21,"program tried to write to block device control channel of drive %d:\n",drive);
@ -1710,9 +1710,9 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x4b: /* "EXEC" - LOAD AND/OR EXECUTE PROGRAM */ case 0x4b: /* "EXEC" - LOAD AND/OR EXECUTE PROGRAM */
TRACE(int21,"EXEC %s\n", TRACE(int21,"EXEC %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context) )); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context) ));
AX_reg(context) = WinExec16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context), AX_reg(context) = WinExec16( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) ), EDX_reg(context) ),
SW_NORMAL ); SW_NORMAL );
if (AX_reg(context) < 32) SET_CFLAG(context); if (AX_reg(context) < 32) SET_CFLAG(context);
break; break;
@ -1729,7 +1729,7 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x4e: /* "FINDFIRST" - FIND FIRST MATCHING FILE */ case 0x4e: /* "FINDFIRST" - FIND FIRST MATCHING FILE */
TRACE(int21,"FINDFIRST mask 0x%04x spec %s\n",CX_reg(context), TRACE(int21,"FINDFIRST mask 0x%04x spec %s\n",CX_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
if (!INT21_FindFirst(context)) break; if (!INT21_FindFirst(context)) break;
/* fall through */ /* fall through */
@ -1772,11 +1772,11 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x56: /* "RENAME" - RENAME FILE */ case 0x56: /* "RENAME" - RENAME FILE */
TRACE(int21,"RENAME %s to %s\n", TRACE(int21,"RENAME %s to %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context)), (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, ES_reg(context),DI_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, ES_reg(context),EDI_reg(context)));
bSetDOSExtendedError = bSetDOSExtendedError =
(!MoveFile32A( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context)), (!MoveFile32A( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)),
CTX_SEG_OFF_TO_LIN(context, ES_reg(context),DI_reg(context)))); CTX_SEG_OFF_TO_LIN(context, ES_reg(context),EDI_reg(context))));
break; break;
case 0x57: /* FILE DATE AND TIME */ case 0x57: /* FILE DATE AND TIME */
@ -1833,9 +1833,9 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x5b: /* CREATE NEW FILE */ case 0x5b: /* CREATE NEW FILE */
TRACE(int21,"CREATE NEW FILE 0x%02x for %s\n", CX_reg(context), TRACE(int21,"CREATE NEW FILE 0x%02x for %s\n", CX_reg(context),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
bSetDOSExtendedError = ((AX_reg(context) = bSetDOSExtendedError = ((AX_reg(context) =
HFILE32_TO_HFILE16(_lcreat_uniq( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context)), 0 ))) HFILE32_TO_HFILE16(_lcreat_uniq( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)), 0 )))
== (WORD)HFILE_ERROR16); == (WORD)HFILE_ERROR16);
break; break;
@ -1882,12 +1882,12 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x60: /* "TRUENAME" - CANONICALIZE FILENAME OR PATH */ case 0x60: /* "TRUENAME" - CANONICALIZE FILENAME OR PATH */
TRACE(int21,"TRUENAME %s\n", TRACE(int21,"TRUENAME %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),SI_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),ESI_reg(context)));
{ {
if (!GetFullPathName32A( CTX_SEG_OFF_TO_LIN(context, DS_reg(context), if (!GetFullPathName32A( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
SI_reg(context)), 128, ESI_reg(context)), 128,
CTX_SEG_OFF_TO_LIN(context, ES_reg(context), CTX_SEG_OFF_TO_LIN(context, ES_reg(context),
DI_reg(context)),NULL)) EDI_reg(context)),NULL))
bSetDOSExtendedError = TRUE; bSetDOSExtendedError = TRUE;
else AX_reg(context) = 0; else AX_reg(context) = 0;
} }
@ -1908,7 +1908,7 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x65:{/* GET EXTENDED COUNTRY INFORMATION */ case 0x65:{/* GET EXTENDED COUNTRY INFORMATION */
extern WORD WINE_LanguageId; extern WORD WINE_LanguageId;
BYTE *dataptr=CTX_SEG_OFF_TO_LIN(context, ES_reg(context),DI_reg(context)); BYTE *dataptr=CTX_SEG_OFF_TO_LIN(context, ES_reg(context),EDI_reg(context));
TRACE(int21,"GET EXTENDED COUNTRY INFORMATION code page %d country %d\n", TRACE(int21,"GET EXTENDED COUNTRY INFORMATION code page %d country %d\n",
BX_reg(context), DX_reg(context)); BX_reg(context), DX_reg(context));
switch (AL_reg(context)) { switch (AL_reg(context)) {
@ -1984,7 +1984,7 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x6C: /* Extended Open/Create*/ case 0x6C: /* Extended Open/Create*/
TRACE(int21,"EXTENDED OPEN/CREATE %s\n", TRACE(int21,"EXTENDED OPEN/CREATE %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DI_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDI_reg(context)));
bSetDOSExtendedError = INT21_ExtendedOpenCreateFile(context); bSetDOSExtendedError = INT21_ExtendedOpenCreateFile(context);
break; break;
@ -1999,35 +1999,35 @@ void WINAPI DOS3Call( CONTEXT *context )
{ {
case 0x39: /* Create directory */ case 0x39: /* Create directory */
TRACE(int21,"LONG FILENAME - MAKE DIRECTORY %s\n", TRACE(int21,"LONG FILENAME - MAKE DIRECTORY %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)));
bSetDOSExtendedError = (!CreateDirectory32A( bSetDOSExtendedError = (!CreateDirectory32A(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context), CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) ), NULL)); EDX_reg(context) ), NULL));
break; break;
case 0x3a: /* Remove directory */ case 0x3a: /* Remove directory */
TRACE(int21,"LONG FILENAME - REMOVE DIRECTORY %s\n", TRACE(int21,"LONG FILENAME - REMOVE DIRECTORY %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)));
bSetDOSExtendedError = (!RemoveDirectory32A( bSetDOSExtendedError = (!RemoveDirectory32A(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context), CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context) ))); EDX_reg(context) )));
break; break;
case 0x43: /* Get/Set file attributes */ case 0x43: /* Get/Set file attributes */
TRACE(int21,"LONG FILENAME -EXTENDED GET/SET FILE ATTRIBUTES %s\n", TRACE(int21,"LONG FILENAME -EXTENDED GET/SET FILE ATTRIBUTES %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)));
switch (BL_reg(context)) switch (BL_reg(context))
{ {
case 0x00: /* Get file attributes */ case 0x00: /* Get file attributes */
TRACE(int21,"\tretrieve attributes\n"); TRACE(int21,"\tretrieve attributes\n");
CX_reg(context) = (WORD)GetFileAttributes32A( CX_reg(context) = (WORD)GetFileAttributes32A(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context), CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context))); EDX_reg(context)));
if (CX_reg(context) == 0xffff) bSetDOSExtendedError = TRUE; if (CX_reg(context) == 0xffff) bSetDOSExtendedError = TRUE;
break; break;
case 0x01: case 0x01:
TRACE(int21,"\tset attributes 0x%04x\n",CX_reg(context)); TRACE(int21,"\tset attributes 0x%04x\n",CX_reg(context));
bSetDOSExtendedError = (!SetFileAttributes32A( bSetDOSExtendedError = (!SetFileAttributes32A(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context), CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
DX_reg(context)), EDX_reg(context)),
CX_reg(context) ) ); CX_reg(context) ) );
break; break;
default: default:
@ -2046,12 +2046,12 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x4e: /* Find first file */ case 0x4e: /* Find first file */
TRACE(int21," LONG FILENAME - FIND FIRST MATCHING FILE for %s\n", TRACE(int21," LONG FILENAME - FIND FIRST MATCHING FILE for %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)));
/* FIXME: use attributes in CX */ /* FIXME: use attributes in CX */
if ((AX_reg(context) = FindFirstFile16( if ((AX_reg(context) = FindFirstFile16(
CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context)), CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)),
(WIN32_FIND_DATA32A *)CTX_SEG_OFF_TO_LIN(context, ES_reg(context), (WIN32_FIND_DATA32A *)CTX_SEG_OFF_TO_LIN(context, ES_reg(context),
DI_reg(context)))) EDI_reg(context))))
== INVALID_HANDLE_VALUE16) == INVALID_HANDLE_VALUE16)
bSetDOSExtendedError = TRUE; bSetDOSExtendedError = TRUE;
break; break;
@ -2060,7 +2060,7 @@ void WINAPI DOS3Call( CONTEXT *context )
BX_reg(context)); BX_reg(context));
if (!FindNextFile16( BX_reg(context), if (!FindNextFile16( BX_reg(context),
(WIN32_FIND_DATA32A *)CTX_SEG_OFF_TO_LIN(context, ES_reg(context), (WIN32_FIND_DATA32A *)CTX_SEG_OFF_TO_LIN(context, ES_reg(context),
DI_reg(context)))) EDI_reg(context))))
bSetDOSExtendedError = TRUE; bSetDOSExtendedError = TRUE;
break; break;
case 0xa1: /* Find close */ case 0xa1: /* Find close */
@ -2070,7 +2070,7 @@ void WINAPI DOS3Call( CONTEXT *context )
break; break;
case 0xa0: case 0xa0:
TRACE(int21,"LONG FILENAME - GET VOLUME INFORMATION for drive %s stub\n", TRACE(int21,"LONG FILENAME - GET VOLUME INFORMATION for drive %s stub\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context),EDX_reg(context)));
break; break;
case 0x60: case 0x60:
switch(CL_reg(context)) switch(CL_reg(context))
@ -2078,18 +2078,18 @@ void WINAPI DOS3Call( CONTEXT *context )
case 0x01: /*Get short filename or path */ case 0x01: /*Get short filename or path */
if (!GetShortPathName32A if (!GetShortPathName32A
( CTX_SEG_OFF_TO_LIN(context, DS_reg(context), ( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
SI_reg(context)), ESI_reg(context)),
CTX_SEG_OFF_TO_LIN(context, ES_reg(context), CTX_SEG_OFF_TO_LIN(context, ES_reg(context),
DI_reg(context)), 67)) EDI_reg(context)), 67))
bSetDOSExtendedError = TRUE; bSetDOSExtendedError = TRUE;
else AX_reg(context) = 0; else AX_reg(context) = 0;
break; break;
case 0x02: /*Get canonical long filename or path */ case 0x02: /*Get canonical long filename or path */
if (!GetFullPathName32A if (!GetFullPathName32A
( CTX_SEG_OFF_TO_LIN(context, DS_reg(context), ( CTX_SEG_OFF_TO_LIN(context, DS_reg(context),
SI_reg(context)), 128, ESI_reg(context)), 128,
CTX_SEG_OFF_TO_LIN(context, ES_reg(context), CTX_SEG_OFF_TO_LIN(context, ES_reg(context),
DI_reg(context)),NULL)) EDI_reg(context)),NULL))
bSetDOSExtendedError = TRUE; bSetDOSExtendedError = TRUE;
else AX_reg(context) = 0; else AX_reg(context) = 0;
break; break;
@ -2103,17 +2103,17 @@ void WINAPI DOS3Call( CONTEXT *context )
break; break;
case 0x6c: /* Create or open file */ case 0x6c: /* Create or open file */
TRACE(int21,"LONG FILENAME - CREATE OR OPEN FILE %s\n", TRACE(int21,"LONG FILENAME - CREATE OR OPEN FILE %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), SI_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), ESI_reg(context)));
/* translate Dos 7 action to Dos 6 action */ /* translate Dos 7 action to Dos 6 action */
bSetDOSExtendedError = INT21_ExtendedOpenCreateFile(context); bSetDOSExtendedError = INT21_ExtendedOpenCreateFile(context);
break; break;
case 0x3b: /* Change directory */ case 0x3b: /* Change directory */
TRACE(int21,"LONG FILENAME - CHANGE DIRECTORY %s\n", TRACE(int21,"LONG FILENAME - CHANGE DIRECTORY %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
if (!SetCurrentDirectory32A(CTX_SEG_OFF_TO_LIN(context, if (!SetCurrentDirectory32A(CTX_SEG_OFF_TO_LIN(context,
DS_reg(context), DS_reg(context),
DX_reg(context) EDX_reg(context)
)) ))
) { ) {
SET_CFLAG(context); SET_CFLAG(context);
@ -2122,10 +2122,10 @@ void WINAPI DOS3Call( CONTEXT *context )
break; break;
case 0x41: /* Delete file */ case 0x41: /* Delete file */
TRACE(int21,"LONG FILENAME - DELETE FILE %s\n", TRACE(int21,"LONG FILENAME - DELETE FILE %s\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)));
if (!DeleteFile32A(CTX_SEG_OFF_TO_LIN(context, if (!DeleteFile32A(CTX_SEG_OFF_TO_LIN(context,
DS_reg(context), DS_reg(context),
DX_reg(context)) EDX_reg(context))
)) { )) {
SET_CFLAG(context); SET_CFLAG(context);
AL_reg(context) = DOS_ExtendedError; AL_reg(context) = DOS_ExtendedError;
@ -2133,8 +2133,8 @@ void WINAPI DOS3Call( CONTEXT *context )
break; break;
case 0x56: /* Move (rename) file */ case 0x56: /* Move (rename) file */
TRACE(int21,"LONG FILENAME - RENAME FILE %s to %s stub\n", TRACE(int21,"LONG FILENAME - RENAME FILE %s to %s stub\n",
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), DX_reg(context)), (LPCSTR)CTX_SEG_OFF_TO_LIN(context, DS_reg(context), EDX_reg(context)),
(LPCSTR)CTX_SEG_OFF_TO_LIN(context, ES_reg(context), DI_reg(context))); (LPCSTR)CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EDI_reg(context)));
default: default:
FIXME(int21, "Unimplemented long file name function:\n"); FIXME(int21, "Unimplemented long file name function:\n");
INT_BARF( context, 0x21 ); INT_BARF( context, 0x21 );

View File

@ -19,7 +19,7 @@
*/ */
void WINAPI INT_Int25Handler( CONTEXT *context ) void WINAPI INT_Int25Handler( CONTEXT *context )
{ {
BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, DS_reg(context), BX_reg(context) ); BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EBX_reg(context) );
DWORD begin, length; DWORD begin, length;
int fd; int fd;
@ -35,7 +35,7 @@ void WINAPI INT_Int25Handler( CONTEXT *context )
begin = *(DWORD *)dataptr; begin = *(DWORD *)dataptr;
length = *(WORD *)(dataptr + 4); length = *(WORD *)(dataptr + 4);
dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context, dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
*(WORD *)(dataptr + 8), *(WORD *)(dataptr + 6) ); *(WORD *)(dataptr + 8), *(DWORD *)(dataptr + 6) );
} }
else else
{ {

View File

@ -18,7 +18,7 @@
*/ */
void WINAPI INT_Int26Handler( CONTEXT *context ) void WINAPI INT_Int26Handler( CONTEXT *context )
{ {
BYTE *dataptr = PTR_SEG_OFF_TO_LIN( DS_reg(context), BX_reg(context) ); BYTE *dataptr = CTX_SEG_OFF_TO_LIN( context, DS_reg(context), EBX_reg(context) );
DWORD begin, length; DWORD begin, length;
int fd; int fd;
@ -33,7 +33,8 @@ void WINAPI INT_Int26Handler( CONTEXT *context )
{ {
begin = *(DWORD *)dataptr; begin = *(DWORD *)dataptr;
length = *(WORD *)(dataptr + 4); length = *(WORD *)(dataptr + 4);
dataptr = (BYTE *)PTR_SEG_TO_LIN( *(SEGPTR *)(dataptr + 6) ); dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
*(WORD *)(dataptr + 8), *(DWORD *)(dataptr + 6) );
} }
else else
{ {

View File

@ -370,7 +370,7 @@ void do_mscdex( CONTEXT *context )
break; break;
case 0x0D: /* get drive letters */ case 0x0D: /* get drive letters */
p = CTX_SEG_OFF_TO_LIN(context, ES_reg(context), BX_reg(context)); p = CTX_SEG_OFF_TO_LIN(context, ES_reg(context), EBX_reg(context));
memset( p, 0, MAX_DOS_DRIVES ); memset( p, 0, MAX_DOS_DRIVES );
for (drive = 0; drive < MAX_DOS_DRIVES; drive++) for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
{ {

View File

@ -72,7 +72,7 @@ void WINAPI XMS_Handler( CONTEXT *context )
case 0x0b: /* Move Extended Memory Block */ case 0x0b: /* Move Extended Memory Block */
{ {
MOVESTRUCT*move=CTX_SEG_OFF_TO_LIN(context, MOVESTRUCT*move=CTX_SEG_OFF_TO_LIN(context,
DS_reg(context),SI_reg(context)); DS_reg(context),ESI_reg(context));
BYTE*src,*dst; BYTE*src,*dst;
TRACE(int31, "move extended memory block\n"); TRACE(int31, "move extended memory block\n");
src=XMS_Offset(&move->Source); src=XMS_Offset(&move->Source);