Commit 7129d9f6 authored by Ulrich Weigand's avatar Ulrich Weigand Committed by Alexandre Julliard

Changed CTX_SEG_OFF_TO_LIN to allow linear addresses in 32-bit

registers (used by DeviceIoControl). Adapted all users.
parent 12980625
......@@ -9,6 +9,7 @@
#include <stdio.h>
#include "winnt.h"
#include "ldt.h"
/* msdos/dosmem.c */
extern HANDLE16 DOSMEM_BiosSeg;
......@@ -71,12 +72,12 @@ extern void WINAPI INT_Int20Handler(CONTEXT*);
/* msdos/int25.c */
extern void WINAPI INT_Int25Handler(CONTEXT*);
/* msdos/int26.c */
extern void WINAPI INT_Int26Handler(CONTEXT*);
/* msdos/int29.c */
extern void WINAPI INT_Int29Handler(CONTEXT*);
/* msdos/int25.c */
extern void WINAPI INT_Int25Handler(CONTEXT*);
/* msdos/int2f.c */
extern void WINAPI INT_Int2fHandler(CONTEXT*);
......@@ -97,9 +98,24 @@ extern BOOL32 SIGNAL_InitEmulator(void);
/* misc/aspi.c */
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) \
(ISV86(context) ? (void*)(V86BASE(context)+((seg)<<4)+off) \
: PTR_SEG_OFF_TO_LIN(seg,off))
(ISV86(context) ? (void*)(V86BASE(context)+((seg)<<4)+(off&0xffff)) : \
(!seg || IS_SELECTOR_SYSTEM(seg))? (void *)off : PTR_SEG_OFF_TO_LIN(seg,off&0xffff))
#define INT_BARF(context,num) \
fprintf( stderr, "int%x: unknown/not implemented parameters:\n" \
......
......@@ -222,7 +222,7 @@ int DPMI_CallRMProc( CONTEXT *context, LPWORD stack, int args, int iret )
return 1;
}
} 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 */
}
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");
if (alloc) DOSMEM_FreeBlock( pModule->self, addr );
#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 );
seg_addr = PTR_SEG_OFF_TO_SEGPTR( sel, 0 );
......
......@@ -19,7 +19,7 @@
*/
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;
int fd;
......@@ -35,7 +35,7 @@ void WINAPI INT_Int25Handler( CONTEXT *context )
begin = *(DWORD *)dataptr;
length = *(WORD *)(dataptr + 4);
dataptr = (BYTE *)CTX_SEG_OFF_TO_LIN( context,
*(WORD *)(dataptr + 8), *(WORD *)(dataptr + 6) );
*(WORD *)(dataptr + 8), *(DWORD *)(dataptr + 6) );
}
else
{
......
......@@ -18,7 +18,7 @@
*/
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;
int fd;
......@@ -33,7 +33,8 @@ void WINAPI INT_Int26Handler( CONTEXT *context )
{
begin = *(DWORD *)dataptr;
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
{
......
......@@ -370,7 +370,7 @@ void do_mscdex( CONTEXT *context )
break;
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 );
for (drive = 0; drive < MAX_DOS_DRIVES; drive++)
{
......
......@@ -72,7 +72,7 @@ void WINAPI XMS_Handler( CONTEXT *context )
case 0x0b: /* Move Extended Memory Block */
{
MOVESTRUCT*move=CTX_SEG_OFF_TO_LIN(context,
DS_reg(context),SI_reg(context));
DS_reg(context),ESI_reg(context));
BYTE*src,*dst;
TRACE(int31, "move extended memory block\n");
src=XMS_Offset(&move->Source);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment