Removed a few Callout functions by doing a GetProcAddress at the time we actually need the function.
diff --git a/dlls/winedos/dosvm.c b/dlls/winedos/dosvm.c index ac48c3d..67402bf 100644 --- a/dlls/winedos/dosvm.c +++ b/dlls/winedos/dosvm.c
@@ -28,7 +28,6 @@ #include "winnt.h" #include "wincon.h" -#include "callback.h" #include "msdos.h" #include "file.h" #include "miscemu.h" @@ -426,13 +425,13 @@ objc=hObject?2:1; do { /* 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 */ DOSVM_ProcessMessage(&msg); /* we don't need a TranslateMessage here */ - Callout.DispatchMessageA(&msg); + DispatchMessageA(&msg); got_msg = TRUE; } } @@ -465,8 +464,8 @@ break; } /* nothing yet, block while waiting for something to do */ - if (Callout.MsgWaitForMultipleObjects) - waitret = Callout.MsgWaitForMultipleObjects(objc,objs,FALSE,INFINITE,QS_ALLINPUT); + if (MsgWaitForMultipleObjects) + waitret = MsgWaitForMultipleObjects(objc,objs,FALSE,INFINITE,QS_ALLINPUT); else waitret = WaitForMultipleObjects(objc,objs,FALSE,INFINITE);
diff --git a/if1632/thunk.c b/if1632/thunk.c index 5155193..47e2bb5 100644 --- a/if1632/thunk.c +++ b/if1632/thunk.c
@@ -37,23 +37,13 @@ static THUNK *firstThunk = NULL; CALLOUT_TABLE Callout = { - /* PeekMessageA */ NULL, - /* GetMessageA */ NULL, - /* SendMessageA */ NULL, /* PostMessageA */ NULL, - /* TranslateMessage */ NULL, - /* DispatchMessageA */ NULL, - /* RedrawWindow */ NULL, /* UserSignalProc */ NULL, /* FinalUserInit16 */ NULL, /* InitThreadInput16 */ NULL, /* UserYield16) */ NULL, /* DestroyIcon32 */ NULL, - /* WaitForInputIdle */ NULL, - /* MsgWaitForMultipleObjects */ NULL, - /* WindowFromDC */ NULL, - /* MessageBoxA */ NULL, - /* MessageBoxW */ NULL + /* WaitForInputIdle */ NULL }; /*********************************************************************** @@ -171,18 +161,8 @@ #define GETADDR( name ) \ *(FARPROC *)&Callout.name = GetProcAddress( hModule, #name ) - GETADDR( PeekMessageA ); - GETADDR( GetMessageA ); - GETADDR( SendMessageA ); GETADDR( PostMessageA ); - GETADDR( TranslateMessage ); - GETADDR( DispatchMessageA ); - GETADDR( RedrawWindow ); GETADDR( WaitForInputIdle ); - GETADDR( MsgWaitForMultipleObjects ); - GETADDR( WindowFromDC ); - GETADDR( MessageBoxA ); - GETADDR( MessageBoxW ); #undef GETADDR } else WARN("no 32-bit USER\n");
diff --git a/include/callback.h b/include/callback.h index 5be74d0..ec3a17d 100644 --- a/include/callback.h +++ b/include/callback.h
@@ -23,23 +23,13 @@ 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 (*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 ); void WINAPI (*FinalUserInit16)( void ); HQUEUE16 WINAPI (*InitThreadInput16)( WORD, WORD ); void WINAPI (*UserYield16)( void ); WORD WINAPI (*DestroyIcon32)( HGLOBAL16, UINT16 ); 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; extern CALLOUT_TABLE Callout;
diff --git a/loader/task.c b/loader/task.c index 09213dd..a9661c4 100644 --- a/loader/task.c +++ b/loader/task.c
@@ -1573,6 +1573,8 @@ } +typedef INT (WINAPI *MessageBoxA_funcptr)(HWND hWnd, LPCSTR text, LPCSTR title, UINT type); + /************************************************************************** * FatalAppExit16 (KERNEL.137) */ @@ -1582,11 +1584,19 @@ if (!pTask || !(pTask->error_mode & SEM_NOGPFAULTERRORBOX)) { - if (Callout.MessageBoxA) - Callout.MessageBoxA( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); - else - ERR( "%s\n", debugstr_a(str) ); + HMODULE mod = GetModuleHandleA( "user32.dll" ); + if (mod) + { + 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) ); } + done: ExitThread(0xff); }
diff --git a/miscemu/main.c b/miscemu/main.c index 43bb028..942b315 100644 --- a/miscemu/main.c +++ b/miscemu/main.c
@@ -17,6 +17,10 @@ static char main_exe_name[MAX_PATH]; 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, HANDLE *win16_exe_file ) WINE_NORETURN; extern HINSTANCE16 NE_StartMain( LPCSTR name, HANDLE file ); @@ -28,12 +32,16 @@ { MSG msg; HINSTANCE16 instance; + HMODULE user32; - if (!LoadLibraryA( "user32.dll" )) + if (!(user32 = LoadLibraryA( "user32.dll" ))) { MESSAGE( "Cannot load user32.dll\n" ); ExitProcess( GetLastError() ); } + pGetMessageA = (void *)GetProcAddress( user32, "GetMessageA" ); + pTranslateMessage = (void *)GetProcAddress( user32, "TranslateMessage" ); + pDispatchMessageA = (void *)GetProcAddress( user32, "DispatchMessageA" ); THUNK_InitCallout(); if ((instance = NE_StartMain( main_exe_name, main_exe_file )) < 32) @@ -59,10 +67,10 @@ /* 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 ); - Callout.DispatchMessageA( &msg ); + pTranslateMessage( &msg ); + pDispatchMessageA( &msg ); } ExitProcess( 0 );
diff --git a/objects/palette.c b/objects/palette.c index 3187a54..78ed5b6 100644 --- a/objects/palette.c +++ b/objects/palette.c
@@ -19,7 +19,6 @@ #include "color.h" #include "palette.h" #include "debugtools.h" -#include "callback.h" #include "winerror.h" DEFAULT_DEBUG_CHANNEL(palette); @@ -775,28 +774,40 @@ } +typedef HWND WINAPI (*WindowFromDC_funcptr)( HDC ); +typedef BOOL WINAPI (*RedrawWindow_funcptr)( HWND, const RECT *, HRGN, UINT ); + /********************************************************************** * UpdateColors16 (DISPLAY.366) * UpdateColors16 (GDI.366) */ INT16 WINAPI UpdateColors16( HDC16 hDC ) { + HMODULE mod; DC *dc; - HWND hWnd; int size; if (!(dc = DC_GetDCPtr( hDC ))) return 0; size = dc->devCaps->sizePalette; GDI_ReleaseObj( hDC ); - if (Callout.WindowFromDC) - { - hWnd = Callout.WindowFromDC( hDC ); - /* Docs say that we have to remap current drawable pixel by pixel - * but it would take forever given the speed of XGet/PutPixel. - */ - if (hWnd && size) - Callout.RedrawWindow( hWnd, NULL, 0, RDW_INVALIDATE ); + mod = GetModuleHandleA("user32.dll"); + if (mod) + { + WindowFromDC_funcptr pWindowFromDC = (WindowFromDC_funcptr)GetProcAddress(mod,"WindowFromDC"); + if (pWindowFromDC) + { + HWND hWnd = pWindowFromDC( hDC ); + + /* Docs say that we have to remap current drawable pixel by pixel + * but it would take forever given the speed of XGet/PutPixel. + */ + if (hWnd && size) + { + RedrawWindow_funcptr pRedrawWindow = GetProcAddress( mod, "RedrawWindow" ); + if (pRedrawWindow) pRedrawWindow( hWnd, NULL, 0, RDW_INVALIDATE ); + } + } } return 0x666; }
diff --git a/win32/except.c b/win32/except.c index 120afd5..aaa3933 100644 --- a/win32/except.c +++ b/win32/except.c
@@ -26,8 +26,9 @@ #include "windef.h" #include "winerror.h" #include "ntddk.h" +#include "wingdi.h" +#include "winuser.h" #include "wine/exception.h" -#include "callback.h" #include "thread.h" #include "stackframe.h" #include "server.h" @@ -37,6 +38,8 @@ 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.@) @@ -241,14 +244,22 @@ strcpy(format, "debugger/winedbg %ld %ld"); } - if (!bAuto && Callout.MessageBoxA) { - format_exception_msg( epointers, buffer ); - if (Callout.MessageBoxA( 0, buffer, "Error", MB_YESNO | MB_ICONHAND ) == IDNO) { - TRACE("Killing process\n"); - return EXCEPTION_EXECUTE_HANDLER; - } + 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 ); + if (pMessageBoxA( 0, buffer, "Error", MB_YESNO | MB_ICONHAND ) == IDNO) + { + TRACE("Killing process\n"); + return EXCEPTION_EXECUTE_HANDLER; + } + } } - + if (format[0]) { HANDLE hEvent; PROCESS_INFORMATION info; @@ -304,11 +315,14 @@ */ void WINAPI FatalAppExitA( UINT action, LPCSTR str ) { + HMODULE mod = GetModuleHandleA( "user32.dll" ); + MessageBoxA_funcptr pMessageBoxA = NULL; + WARN("AppExit\n"); - if (Callout.MessageBoxA) - Callout.MessageBoxA( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); - else - ERR( "%s\n", debugstr_a(str) ); + + if (mod) pMessageBoxA = (MessageBoxA_funcptr)GetProcAddress( mod, "MessageBoxA" ); + if (pMessageBoxA) pMessageBoxA( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); + else ERR( "%s\n", debugstr_a(str) ); ExitProcess(0); } @@ -318,10 +332,13 @@ */ void WINAPI FatalAppExitW( UINT action, LPCWSTR str ) { + HMODULE mod = GetModuleHandleA( "user32.dll" ); + MessageBoxW_funcptr pMessageBoxW = NULL; + WARN("AppExit\n"); - if (Callout.MessageBoxW) - Callout.MessageBoxW( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); - else - ERR( "%s\n", debugstr_w(str) ); + + if (mod) pMessageBoxW = (MessageBoxW_funcptr)GetProcAddress( mod, "MessageBoxW" ); + if (pMessageBoxW) pMessageBoxW( 0, str, NULL, MB_SYSTEMMODAL | MB_OK ); + else ERR( "%s\n", debugstr_w(str) ); ExitProcess(0); }