From abbcf413256544c4674c821a3c18a76768fd3319 Mon Sep 17 00:00:00 2001 From: Jukka Heinonen Date: Tue, 30 Sep 2003 00:22:12 +0000 Subject: [PATCH] Use correct linear pointer when accessing BIOS data area. --- dlls/winedos/devices.c | 2 +- dlls/winedos/dosexe.h | 3 +-- dlls/winedos/dosvm.c | 20 ++++++++++++++++++++ dlls/winedos/int09.c | 2 +- dlls/winedos/int10.c | 6 +++--- dlls/winedos/int16.c | 6 +++--- dlls/winedos/int1a.c | 2 +- dlls/winedos/timer.c | 2 +- 8 files changed, 31 insertions(+), 12 deletions(-) diff --git a/dlls/winedos/devices.c b/dlls/winedos/devices.c index fe58d6d940b..d40eed1d360 100644 --- a/dlls/winedos/devices.c +++ b/dlls/winedos/devices.c @@ -219,7 +219,7 @@ static void WINAPI con_interrupt(CONTEXT86*ctx) { int *scan; REQUEST_HEADER *hdr = get_hdr(SYSTEM_STRATEGY_CON,(void **)&scan); - BIOSDATA *bios = BIOS_DATA; + BIOSDATA *bios = DOSVM_BiosData(); WORD CurOfs = bios->NextKbdCharPtr; DOS_LISTOFLISTS *lol = DOSMEM_LOL(); DOS_DATASEG *dataseg = (DOS_DATASEG *)lol; diff --git a/dlls/winedos/dosexe.h b/dlls/winedos/dosexe.h index 1dba03a6db4..2020196ef25 100644 --- a/dlls/winedos/dosexe.h +++ b/dlls/winedos/dosexe.h @@ -100,8 +100,6 @@ extern struct DPMI_segments *DOSVM_dpmi_segments; #define VIF_MASK 0x00080000 #define VIP_MASK 0x00100000 -#define BIOS_DATA ((void *)0x400) - #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val))) /* module.c */ @@ -123,6 +121,7 @@ extern void WINAPI DOSVM_QueueEvent( INT irq, INT priority, DOSRELAY relay, LPVO extern void WINAPI DOSVM_PIC_ioport_out( WORD port, BYTE val ); extern void WINAPI DOSVM_SetTimer( UINT ticks ); extern UINT WINAPI DOSVM_GetTimer( void ); +extern BIOSDATA *DOSVM_BiosData( void ); /* devices.c */ extern void DOSDEV_InstallDOSDevices(void); diff --git a/dlls/winedos/dosvm.c b/dlls/winedos/dosvm.c index 811f004d38e..96faff56ebe 100644 --- a/dlls/winedos/dosvm.c +++ b/dlls/winedos/dosvm.c @@ -706,6 +706,26 @@ void WINAPI DOSVM_AcknowledgeIRQ( CONTEXT86 *context ) } +/********************************************************************** + * DOSVM_BiosData + * + * Get pointer to BIOS data area. This is not at fixed location + * because those Win16 programs that do not use any real mode code have + * protected NULL pointer catching block at low linear memory and + * BIOS data has been moved to another location. + */ +BIOSDATA *DOSVM_BiosData( void ) +{ + LDT_ENTRY entry; + FARPROC16 proc; + + proc = GetProcAddress16( GetModuleHandle16( "KERNEL" ), + (LPCSTR)(ULONG_PTR)193 ); + wine_ldt_get_entry( LOWORD(proc), &entry ); + return (BIOSDATA *)wine_ldt_get_base( &entry ); +} + + /********************************************************************** * DllMain (DOSVM.Init) */ diff --git a/dlls/winedos/int09.c b/dlls/winedos/int09.c index e9a6b6477bc..1ebe2722f02 100644 --- a/dlls/winedos/int09.c +++ b/dlls/winedos/int09.c @@ -150,7 +150,7 @@ void DOSVM_Int09UpdateKbdStatusFlags(BYTE scan, BOOL extended, BIOSDATA *data, B */ void WINAPI DOSVM_Int09Handler( CONTEXT86 *context ) { - BIOSDATA *data = BIOS_DATA; + BIOSDATA *data = DOSVM_BiosData(); BYTE ascii, scan = DOSVM_Int09ReadScan(&ascii); BYTE realscan = scan & 0x7f; /* remove 0x80 make/break flag */ BOOL modifier = FALSE; diff --git a/dlls/winedos/int10.c b/dlls/winedos/int10.c index f28fd72a0e4..410765b449e 100644 --- a/dlls/winedos/int10.c +++ b/dlls/winedos/int10.c @@ -789,7 +789,7 @@ static void INT10_InitializeVideoMode( BIOSDATA *data ) */ static void INT10_HandleVESA( CONTEXT86 *context ) { - BIOSDATA *data = BIOS_DATA; + BIOSDATA *data = DOSVM_BiosData(); switch(AL_reg(context)) { @@ -954,7 +954,7 @@ static void INT10_HandleVESA( CONTEXT86 *context ) */ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context ) { - BIOSDATA *data = BIOS_DATA; + BIOSDATA *data = DOSVM_BiosData(); INT10_InitializeVideoMode( data ); @@ -1403,7 +1403,7 @@ void WINAPI DOSVM_Int10Handler( CONTEXT86 *context ) */ void WINAPI DOSVM_PutChar( BYTE ascii ) { - BIOSDATA *data = BIOS_DATA; + BIOSDATA *data = DOSVM_BiosData(); unsigned xpos, ypos; TRACE("char: 0x%02x(%c)\n", ascii, ascii); diff --git a/dlls/winedos/int16.c b/dlls/winedos/int16.c index 47ea02826da..d68384299ae 100644 --- a/dlls/winedos/int16.c +++ b/dlls/winedos/int16.c @@ -87,7 +87,7 @@ void WINAPI DOSVM_Int16Handler( CONTEXT86 *context ) case 0x02: /* Get Shift Flags */ /* read value from BIOS data segment's keyboard status flags field */ - data = BIOS_DATA; + data = DOSVM_BiosData(); SET_AL( context, data->KbdFlags1 ); TRACE("Get Shift Flags: returning 0x%02x\n", AL_reg(context)); @@ -159,7 +159,7 @@ void WINAPI DOSVM_Int16Handler( CONTEXT86 *context ) */ int WINAPI DOSVM_Int16ReadChar(BYTE *ascii, BYTE *scan, CONTEXT86 *waitctx) { - BIOSDATA *data = BIOS_DATA; + BIOSDATA *data = DOSVM_BiosData(); WORD CurOfs = data->NextKbdCharPtr; /* check if there's data in buffer */ @@ -194,7 +194,7 @@ int WINAPI DOSVM_Int16ReadChar(BYTE *ascii, BYTE *scan, CONTEXT86 *waitctx) int WINAPI DOSVM_Int16AddChar(BYTE ascii,BYTE scan) { - BIOSDATA *data = BIOS_DATA; + BIOSDATA *data = DOSVM_BiosData(); WORD CurOfs = data->FirstKbdCharPtr; WORD NextOfs = CurOfs + 2; diff --git a/dlls/winedos/int1a.c b/dlls/winedos/int1a.c index 56e9d0a0f61..27f30938ffb 100644 --- a/dlls/winedos/int1a.c +++ b/dlls/winedos/int1a.c @@ -40,7 +40,7 @@ void WINAPI DOSVM_Int1aHandler( CONTEXT86 *context ) { case 0x00: /* GET SYSTEM TIME */ { - BIOSDATA *data = BIOS_DATA; + BIOSDATA *data = DOSVM_BiosData(); SET_CX( context, HIWORD(data->Ticks) ); SET_DX( context, LOWORD(data->Ticks) ); SET_AL( context, 0 ); /* FIXME: midnight flag is unsupported */ diff --git a/dlls/winedos/timer.c b/dlls/winedos/timer.c index 29756de241d..1200b249035 100644 --- a/dlls/winedos/timer.c +++ b/dlls/winedos/timer.c @@ -131,7 +131,7 @@ void WINAPI DOSVM_SetTimer( UINT ticks ) */ void WINAPI DOSVM_Int08Handler( CONTEXT86 *context ) { - BIOSDATA *bios_data = BIOS_DATA; + BIOSDATA *bios_data = DOSVM_BiosData(); CONTEXT86 nested_context = *context; FARPROC16 int1c_proc = DOSVM_GetRMHandler( 0x1c );