Commit ea2a9a89 authored by Alexandre Julliard's avatar Alexandre Julliard

Removed a few Callout functions by doing a GetProcAddress at the time

we actually need the function.
parent fe5b19d1
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "winnt.h" #include "winnt.h"
#include "wincon.h" #include "wincon.h"
#include "callback.h"
#include "msdos.h" #include "msdos.h"
#include "file.h" #include "file.h"
#include "miscemu.h" #include "miscemu.h"
...@@ -426,13 +425,13 @@ void WINAPI DOSVM_Wait( INT read_pipe, HANDLE hObject ) ...@@ -426,13 +425,13 @@ void WINAPI DOSVM_Wait( INT read_pipe, HANDLE hObject )
objc=hObject?2:1; objc=hObject?2:1;
do { do {
/* check for messages (waste time before the response check below) */ /* check for messages (waste time before the response check below) */
if (Callout.PeekMessageA) if (PeekMessageA)
{ {
while (Callout.PeekMessageA(&msg,0,0,0,PM_REMOVE|PM_NOYIELD)) { while (PeekMessageA(&msg,0,0,0,PM_REMOVE|PM_NOYIELD)) {
/* got a message */ /* got a message */
DOSVM_ProcessMessage(&msg); DOSVM_ProcessMessage(&msg);
/* we don't need a TranslateMessage here */ /* we don't need a TranslateMessage here */
Callout.DispatchMessageA(&msg); DispatchMessageA(&msg);
got_msg = TRUE; got_msg = TRUE;
} }
} }
...@@ -465,8 +464,8 @@ chk_console_input: ...@@ -465,8 +464,8 @@ chk_console_input:
break; break;
} }
/* nothing yet, block while waiting for something to do */ /* nothing yet, block while waiting for something to do */
if (Callout.MsgWaitForMultipleObjects) if (MsgWaitForMultipleObjects)
waitret = Callout.MsgWaitForMultipleObjects(objc,objs,FALSE,INFINITE,QS_ALLINPUT); waitret = MsgWaitForMultipleObjects(objc,objs,FALSE,INFINITE,QS_ALLINPUT);
else else
waitret = WaitForMultipleObjects(objc,objs,FALSE,INFINITE); waitret = WaitForMultipleObjects(objc,objs,FALSE,INFINITE);
......
...@@ -37,23 +37,13 @@ extern WORD CALLBACK THUNK_CallTo16_word_wwwl (FARPROC16,WORD,WORD,WORD,LONG); ...@@ -37,23 +37,13 @@ extern WORD CALLBACK THUNK_CallTo16_word_wwwl (FARPROC16,WORD,WORD,WORD,LONG);
static THUNK *firstThunk = NULL; static THUNK *firstThunk = NULL;
CALLOUT_TABLE Callout = { CALLOUT_TABLE Callout = {
/* PeekMessageA */ NULL,
/* GetMessageA */ NULL,
/* SendMessageA */ NULL,
/* PostMessageA */ NULL, /* PostMessageA */ NULL,
/* TranslateMessage */ NULL,
/* DispatchMessageA */ NULL,
/* RedrawWindow */ NULL,
/* UserSignalProc */ NULL, /* UserSignalProc */ NULL,
/* FinalUserInit16 */ NULL, /* FinalUserInit16 */ NULL,
/* InitThreadInput16 */ NULL, /* InitThreadInput16 */ NULL,
/* UserYield16) */ NULL, /* UserYield16) */ NULL,
/* DestroyIcon32 */ NULL, /* DestroyIcon32 */ NULL,
/* WaitForInputIdle */ NULL, /* WaitForInputIdle */ NULL
/* MsgWaitForMultipleObjects */ NULL,
/* WindowFromDC */ NULL,
/* MessageBoxA */ NULL,
/* MessageBoxW */ NULL
}; };
/*********************************************************************** /***********************************************************************
...@@ -171,18 +161,8 @@ void THUNK_InitCallout(void) ...@@ -171,18 +161,8 @@ void THUNK_InitCallout(void)
#define GETADDR( name ) \ #define GETADDR( name ) \
*(FARPROC *)&Callout.name = GetProcAddress( hModule, #name ) *(FARPROC *)&Callout.name = GetProcAddress( hModule, #name )
GETADDR( PeekMessageA );
GETADDR( GetMessageA );
GETADDR( SendMessageA );
GETADDR( PostMessageA ); GETADDR( PostMessageA );
GETADDR( TranslateMessage );
GETADDR( DispatchMessageA );
GETADDR( RedrawWindow );
GETADDR( WaitForInputIdle ); GETADDR( WaitForInputIdle );
GETADDR( MsgWaitForMultipleObjects );
GETADDR( WindowFromDC );
GETADDR( MessageBoxA );
GETADDR( MessageBoxW );
#undef GETADDR #undef GETADDR
} }
else WARN("no 32-bit USER\n"); else WARN("no 32-bit USER\n");
......
...@@ -23,23 +23,13 @@ extern void THUNK_InitCallout(void); ...@@ -23,23 +23,13 @@ extern void THUNK_InitCallout(void);
typedef struct typedef struct
{ {
BOOL WINAPI (*PeekMessageA)( LPMSG, HWND, UINT, UINT, UINT );
BOOL WINAPI (*GetMessageA)( MSG*, HWND, UINT, UINT );
LRESULT WINAPI (*SendMessageA)( HWND, UINT, WPARAM, LPARAM );
BOOL WINAPI (*PostMessageA)( HWND, UINT, WPARAM, LPARAM ); BOOL WINAPI (*PostMessageA)( HWND, UINT, WPARAM, LPARAM );
BOOL WINAPI (*TranslateMessage)( const MSG *msg );
LONG WINAPI (*DispatchMessageA)( const MSG* msg );
BOOL WINAPI (*RedrawWindow)( HWND, const RECT *, HRGN, UINT );
WORD WINAPI (*UserSignalProc)( UINT, DWORD, DWORD, HMODULE16 ); WORD WINAPI (*UserSignalProc)( UINT, DWORD, DWORD, HMODULE16 );
void WINAPI (*FinalUserInit16)( void ); void WINAPI (*FinalUserInit16)( void );
HQUEUE16 WINAPI (*InitThreadInput16)( WORD, WORD ); HQUEUE16 WINAPI (*InitThreadInput16)( WORD, WORD );
void WINAPI (*UserYield16)( void ); void WINAPI (*UserYield16)( void );
WORD WINAPI (*DestroyIcon32)( HGLOBAL16, UINT16 ); WORD WINAPI (*DestroyIcon32)( HGLOBAL16, UINT16 );
DWORD WINAPI (*WaitForInputIdle)( HANDLE, DWORD ); DWORD WINAPI (*WaitForInputIdle)( HANDLE, DWORD );
DWORD WINAPI (*MsgWaitForMultipleObjects)( DWORD, HANDLE *, BOOL, DWORD, DWORD );
HWND WINAPI (*WindowFromDC)( HDC );
INT WINAPI (*MessageBoxA)( HWND, LPCSTR, LPCSTR, UINT );
INT WINAPI (*MessageBoxW)( HWND, LPCWSTR, LPCWSTR, UINT );
} CALLOUT_TABLE; } CALLOUT_TABLE;
extern CALLOUT_TABLE Callout; extern CALLOUT_TABLE Callout;
......
...@@ -1573,6 +1573,8 @@ BOOL16 WINAPI TaskFindHandle16( TASKENTRY *lpte, HTASK16 hTask ) ...@@ -1573,6 +1573,8 @@ BOOL16 WINAPI TaskFindHandle16( TASKENTRY *lpte, HTASK16 hTask )
} }
typedef INT (WINAPI *MessageBoxA_funcptr)(HWND hWnd, LPCSTR text, LPCSTR title, UINT type);
/************************************************************************** /**************************************************************************
* FatalAppExit16 (KERNEL.137) * FatalAppExit16 (KERNEL.137)
*/ */
...@@ -1582,11 +1584,19 @@ void WINAPI FatalAppExit16( UINT16 action, LPCSTR str ) ...@@ -1582,11 +1584,19 @@ void WINAPI FatalAppExit16( UINT16 action, LPCSTR str )
if (!pTask || !(pTask->error_mode & SEM_NOGPFAULTERRORBOX)) if (!pTask || !(pTask->error_mode & SEM_NOGPFAULTERRORBOX))
{ {
if (Callout.MessageBoxA) HMODULE mod = GetModuleHandleA( "user32.dll" );
Callout.MessageBoxA( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); if (mod)
else {
MessageBoxA_funcptr pMessageBoxA = (MessageBoxA_funcptr)GetProcAddress( mod, "MessageBoxA" );
if (pMessageBoxA)
{
pMessageBoxA( 0, str, NULL, MB_SYSTEMMODAL | MB_OK );
goto done;
}
}
ERR( "%s\n", debugstr_a(str) ); ERR( "%s\n", debugstr_a(str) );
} }
done:
ExitThread(0xff); ExitThread(0xff);
} }
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
static char main_exe_name[MAX_PATH]; static char main_exe_name[MAX_PATH];
static HANDLE main_exe_file; static HANDLE main_exe_file;
static BOOL (WINAPI *pGetMessageA)(LPMSG,HWND,UINT,UINT);
static BOOL (WINAPI *pTranslateMessage)(const MSG*);
static LONG (WINAPI *pDispatchMessageA)(const MSG*);
extern void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name, extern void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name,
HANDLE *win16_exe_file ) WINE_NORETURN; HANDLE *win16_exe_file ) WINE_NORETURN;
extern HINSTANCE16 NE_StartMain( LPCSTR name, HANDLE file ); extern HINSTANCE16 NE_StartMain( LPCSTR name, HANDLE file );
...@@ -28,12 +32,16 @@ int WINAPI wine_initial_task( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, INT ...@@ -28,12 +32,16 @@ int WINAPI wine_initial_task( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, INT
{ {
MSG msg; MSG msg;
HINSTANCE16 instance; HINSTANCE16 instance;
HMODULE user32;
if (!LoadLibraryA( "user32.dll" )) if (!(user32 = LoadLibraryA( "user32.dll" )))
{ {
MESSAGE( "Cannot load user32.dll\n" ); MESSAGE( "Cannot load user32.dll\n" );
ExitProcess( GetLastError() ); ExitProcess( GetLastError() );
} }
pGetMessageA = (void *)GetProcAddress( user32, "GetMessageA" );
pTranslateMessage = (void *)GetProcAddress( user32, "TranslateMessage" );
pDispatchMessageA = (void *)GetProcAddress( user32, "DispatchMessageA" );
THUNK_InitCallout(); THUNK_InitCallout();
if ((instance = NE_StartMain( main_exe_name, main_exe_file )) < 32) if ((instance = NE_StartMain( main_exe_name, main_exe_file )) < 32)
...@@ -59,10 +67,10 @@ int WINAPI wine_initial_task( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, INT ...@@ -59,10 +67,10 @@ int WINAPI wine_initial_task( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, INT
/* Start message loop for desktop window */ /* Start message loop for desktop window */
while ( GetNumTasks16() > 1 && Callout.GetMessageA( &msg, 0, 0, 0 ) ) while ( GetNumTasks16() > 1 && pGetMessageA( &msg, 0, 0, 0 ) )
{ {
Callout.TranslateMessage( &msg ); pTranslateMessage( &msg );
Callout.DispatchMessageA( &msg ); pDispatchMessageA( &msg );
} }
ExitProcess( 0 ); ExitProcess( 0 );
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "color.h" #include "color.h"
#include "palette.h" #include "palette.h"
#include "debugtools.h" #include "debugtools.h"
#include "callback.h"
#include "winerror.h" #include "winerror.h"
DEFAULT_DEBUG_CHANNEL(palette); DEFAULT_DEBUG_CHANNEL(palette);
...@@ -775,28 +774,40 @@ UINT WINAPI RealizePalette( ...@@ -775,28 +774,40 @@ UINT WINAPI RealizePalette(
} }
typedef HWND WINAPI (*WindowFromDC_funcptr)( HDC );
typedef BOOL WINAPI (*RedrawWindow_funcptr)( HWND, const RECT *, HRGN, UINT );
/********************************************************************** /**********************************************************************
* UpdateColors16 (DISPLAY.366) * UpdateColors16 (DISPLAY.366)
* UpdateColors16 (GDI.366) * UpdateColors16 (GDI.366)
*/ */
INT16 WINAPI UpdateColors16( HDC16 hDC ) INT16 WINAPI UpdateColors16( HDC16 hDC )
{ {
HMODULE mod;
DC *dc; DC *dc;
HWND hWnd;
int size; int size;
if (!(dc = DC_GetDCPtr( hDC ))) return 0; if (!(dc = DC_GetDCPtr( hDC ))) return 0;
size = dc->devCaps->sizePalette; size = dc->devCaps->sizePalette;
GDI_ReleaseObj( hDC ); GDI_ReleaseObj( hDC );
if (Callout.WindowFromDC)
mod = GetModuleHandleA("user32.dll");
if (mod)
{
WindowFromDC_funcptr pWindowFromDC = (WindowFromDC_funcptr)GetProcAddress(mod,"WindowFromDC");
if (pWindowFromDC)
{ {
hWnd = Callout.WindowFromDC( hDC ); HWND hWnd = pWindowFromDC( hDC );
/* Docs say that we have to remap current drawable pixel by pixel /* Docs say that we have to remap current drawable pixel by pixel
* but it would take forever given the speed of XGet/PutPixel. * but it would take forever given the speed of XGet/PutPixel.
*/ */
if (hWnd && size) if (hWnd && size)
Callout.RedrawWindow( hWnd, NULL, 0, RDW_INVALIDATE ); {
RedrawWindow_funcptr pRedrawWindow = GetProcAddress( mod, "RedrawWindow" );
if (pRedrawWindow) pRedrawWindow( hWnd, NULL, 0, RDW_INVALIDATE );
}
}
} }
return 0x666; return 0x666;
} }
......
...@@ -26,8 +26,9 @@ ...@@ -26,8 +26,9 @@
#include "windef.h" #include "windef.h"
#include "winerror.h" #include "winerror.h"
#include "ntddk.h" #include "ntddk.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/exception.h" #include "wine/exception.h"
#include "callback.h"
#include "thread.h" #include "thread.h"
#include "stackframe.h" #include "stackframe.h"
#include "server.h" #include "server.h"
...@@ -37,6 +38,8 @@ DEFAULT_DEBUG_CHANNEL(seh); ...@@ -37,6 +38,8 @@ DEFAULT_DEBUG_CHANNEL(seh);
static PTOP_LEVEL_EXCEPTION_FILTER top_filter; static PTOP_LEVEL_EXCEPTION_FILTER top_filter;
typedef INT (WINAPI *MessageBoxA_funcptr)(HWND,LPCSTR,LPCSTR,UINT);
typedef INT (WINAPI *MessageBoxW_funcptr)(HWND,LPCWSTR,LPCWSTR,UINT);
/******************************************************************* /*******************************************************************
* RaiseException (KERNEL32.@) * RaiseException (KERNEL32.@)
...@@ -241,13 +244,21 @@ DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers) ...@@ -241,13 +244,21 @@ DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
strcpy(format, "debugger/winedbg %ld %ld"); strcpy(format, "debugger/winedbg %ld %ld");
} }
if (!bAuto && Callout.MessageBoxA) { if (!bAuto)
{
HMODULE mod = GetModuleHandleA( "user32.dll" );
MessageBoxA_funcptr pMessageBoxA = NULL;
if (mod) pMessageBoxA = (MessageBoxA_funcptr)GetProcAddress( mod, "MessageBoxA" );
if (pMessageBoxA)
{
format_exception_msg( epointers, buffer ); format_exception_msg( epointers, buffer );
if (Callout.MessageBoxA( 0, buffer, "Error", MB_YESNO | MB_ICONHAND ) == IDNO) { if (pMessageBoxA( 0, buffer, "Error", MB_YESNO | MB_ICONHAND ) == IDNO)
{
TRACE("Killing process\n"); TRACE("Killing process\n");
return EXCEPTION_EXECUTE_HANDLER; return EXCEPTION_EXECUTE_HANDLER;
} }
} }
}
if (format[0]) { if (format[0]) {
HANDLE hEvent; HANDLE hEvent;
...@@ -304,11 +315,14 @@ LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter( ...@@ -304,11 +315,14 @@ LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter(
*/ */
void WINAPI FatalAppExitA( UINT action, LPCSTR str ) void WINAPI FatalAppExitA( UINT action, LPCSTR str )
{ {
HMODULE mod = GetModuleHandleA( "user32.dll" );
MessageBoxA_funcptr pMessageBoxA = NULL;
WARN("AppExit\n"); WARN("AppExit\n");
if (Callout.MessageBoxA)
Callout.MessageBoxA( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); if (mod) pMessageBoxA = (MessageBoxA_funcptr)GetProcAddress( mod, "MessageBoxA" );
else if (pMessageBoxA) pMessageBoxA( 0, str, NULL, MB_SYSTEMMODAL | MB_OK );
ERR( "%s\n", debugstr_a(str) ); else ERR( "%s\n", debugstr_a(str) );
ExitProcess(0); ExitProcess(0);
} }
...@@ -318,10 +332,13 @@ void WINAPI FatalAppExitA( UINT action, LPCSTR str ) ...@@ -318,10 +332,13 @@ void WINAPI FatalAppExitA( UINT action, LPCSTR str )
*/ */
void WINAPI FatalAppExitW( UINT action, LPCWSTR str ) void WINAPI FatalAppExitW( UINT action, LPCWSTR str )
{ {
HMODULE mod = GetModuleHandleA( "user32.dll" );
MessageBoxW_funcptr pMessageBoxW = NULL;
WARN("AppExit\n"); WARN("AppExit\n");
if (Callout.MessageBoxW)
Callout.MessageBoxW( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); if (mod) pMessageBoxW = (MessageBoxW_funcptr)GetProcAddress( mod, "MessageBoxW" );
else if (pMessageBoxW) pMessageBoxW( 0, str, NULL, MB_SYSTEMMODAL | MB_OK );
ERR( "%s\n", debugstr_w(str) ); else ERR( "%s\n", debugstr_w(str) );
ExitProcess(0); ExitProcess(0);
} }
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