Commit 4324b477 authored by Alexandre Julliard's avatar Alexandre Julliard

Delay loading of interrupt table functions until they are needed.

parent de304909
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "heap.h" #include "heap.h"
#include "module.h" #include "module.h"
#include "miscemu.h" #include "miscemu.h"
#include "neexe.h"
#include "stackframe.h" #include "stackframe.h"
#include "user.h" #include "user.h"
#include "process.h" #include "process.h"
...@@ -42,21 +41,11 @@ typedef struct ...@@ -42,21 +41,11 @@ typedef struct
static const BUILTIN16_DESCRIPTOR *builtin_dlls[MAX_DLLS]; static const BUILTIN16_DESCRIPTOR *builtin_dlls[MAX_DLLS];
static int nb_dlls; static int nb_dlls;
/* list of DLLs that should always be loaded at startup */
static const char * const always_load[] =
{
"system", "display", "wprocs", NULL
};
/* Ordinal number for interrupt 0 handler in WPROCS.DLL */
#define FIRST_INTERRUPT_ORDINAL 100
/*********************************************************************** /***********************************************************************
* BUILTIN_DoLoadModule16 * BUILTIN_DoLoadModule16
* *
* Load a built-in Win16 module. Helper function for BUILTIN_LoadModule * Load a built-in Win16 module. Helper function for BUILTIN_LoadModule.
* and BUILTIN_Init.
*/ */
static HMODULE16 BUILTIN_DoLoadModule16( const BUILTIN16_DESCRIPTOR *descr ) static HMODULE16 BUILTIN_DoLoadModule16( const BUILTIN16_DESCRIPTOR *descr )
{ {
...@@ -144,38 +133,6 @@ static HMODULE16 BUILTIN_DoLoadModule16( const BUILTIN16_DESCRIPTOR *descr ) ...@@ -144,38 +133,6 @@ static HMODULE16 BUILTIN_DoLoadModule16( const BUILTIN16_DESCRIPTOR *descr )
/*********************************************************************** /***********************************************************************
* BUILTIN_Init
*
* Load all built-in modules marked as 'always used'.
*/
BOOL BUILTIN_Init(void)
{
WORD vector;
HMODULE16 hModule;
const char * const *ptr = always_load;
while (*ptr)
{
if (!BUILTIN_LoadModule( *ptr )) return FALSE;
ptr++;
}
/* Set interrupt vectors from entry points in WPROCS.DLL */
hModule = GetModuleHandle16( "WPROCS" );
for (vector = 0; vector < 256; vector++)
{
FARPROC16 proc = NE_GetEntryPoint( hModule,
FIRST_INTERRUPT_ORDINAL + vector );
assert(proc);
INT_SetPMHandler( vector, proc );
}
return TRUE;
}
/***********************************************************************
* BUILTIN_LoadModule * BUILTIN_LoadModule
* *
* Load a built-in module. * Load a built-in module.
...@@ -288,17 +245,3 @@ void BUILTIN_RegisterDLL( const BUILTIN16_DESCRIPTOR *descr ) ...@@ -288,17 +245,3 @@ void BUILTIN_RegisterDLL( const BUILTIN16_DESCRIPTOR *descr )
assert( nb_dlls < MAX_DLLS ); assert( nb_dlls < MAX_DLLS );
builtin_dlls[nb_dlls++] = descr; builtin_dlls[nb_dlls++] = descr;
} }
/**********************************************************************
* BUILTIN_DefaultIntHandler
*
* Default interrupt handler.
*/
void WINAPI BUILTIN_DefaultIntHandler( CONTEXT86 *context )
{
WORD ordinal;
char name[80];
BUILTIN_GetEntryPoint16( CURRENT_STACK16, name, &ordinal );
INT_BARF( context, ordinal - FIRST_INTERRUPT_ORDINAL );
}
...@@ -81,7 +81,6 @@ typedef struct ...@@ -81,7 +81,6 @@ typedef struct
const void *rsrc; /* resources data */ const void *rsrc; /* resources data */
} BUILTIN16_DESCRIPTOR; } BUILTIN16_DESCRIPTOR;
extern BOOL BUILTIN_Init(void);
extern HMODULE16 BUILTIN_LoadModule( LPCSTR name ); extern HMODULE16 BUILTIN_LoadModule( LPCSTR name );
extern LPCSTR BUILTIN_GetEntryPoint16( struct _STACK16FRAME *frame, LPSTR name, WORD *pOrd ); extern LPCSTR BUILTIN_GetEntryPoint16( struct _STACK16FRAME *frame, LPSTR name, WORD *pOrd );
extern void BUILTIN_RegisterDLL( const BUILTIN16_DESCRIPTOR *descr ); extern void BUILTIN_RegisterDLL( const BUILTIN16_DESCRIPTOR *descr );
......
...@@ -680,6 +680,12 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context ) ...@@ -680,6 +680,12 @@ BOOL INSTR_EmulateInstruction( CONTEXT86 *context )
{ {
FARPROC16 addr = INT_GetPMHandler( instr[1] ); FARPROC16 addr = INT_GetPMHandler( instr[1] );
WORD *stack = (WORD *)STACK_PTR( context ); WORD *stack = (WORD *)STACK_PTR( context );
if (!addr)
{
FIXME("no handler for interrupt %02x, ignoring it\n", instr[1]);
EIP_reg(context) += prefixlen + 2;
return TRUE;
}
/* Push the flags and return address on the stack */ /* Push the flags and return address on the stack */
*(--stack) = LOWORD(EFL_reg(context)); *(--stack) = LOWORD(EFL_reg(context));
*(--stack) = CS_reg(context); *(--stack) = CS_reg(context);
......
...@@ -6,14 +6,19 @@ ...@@ -6,14 +6,19 @@
#include <sys/types.h> #include <sys/types.h>
#include "windef.h" #include "windef.h"
#include "wine/winbase16.h"
#include "miscemu.h" #include "miscemu.h"
#include "msdos.h" #include "msdos.h"
#include "module.h"
#include "debugtools.h" #include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(int) DEFAULT_DEBUG_CHANNEL(int);
static FARPROC16 INT_Vectors[256]; static FARPROC16 INT_Vectors[256];
/* Ordinal number for interrupt 0 handler in WPROCS.DLL */
#define FIRST_INTERRUPT 100
/********************************************************************** /**********************************************************************
* INT_GetPMHandler * INT_GetPMHandler
...@@ -22,6 +27,19 @@ static FARPROC16 INT_Vectors[256]; ...@@ -22,6 +27,19 @@ static FARPROC16 INT_Vectors[256];
*/ */
FARPROC16 INT_GetPMHandler( BYTE intnum ) FARPROC16 INT_GetPMHandler( BYTE intnum )
{ {
if (!INT_Vectors[intnum])
{
static HMODULE16 wprocs;
if (!wprocs)
{
if ((wprocs = GetModuleHandle16( "wprocs" )) < 32)
{
ERR("could not load wprocs.dll\n");
return 0;
}
}
INT_Vectors[intnum] = NE_GetEntryPoint( wprocs, FIRST_INTERRUPT + intnum );
}
return INT_Vectors[intnum]; return INT_Vectors[intnum];
} }
......
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