From e392a0c97524c18137370fd7d60957c685c17dde Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Thu, 1 Apr 1999 11:44:52 +0000 Subject: [PATCH] Added USER32.UserSignalProc to Callout table. Implemented built-in UserSignalProc(). Don't announce Win3.1-style USER handler any more. --- if1632/thunk.c | 31 ++++---------- if1632/user.spec | 2 +- include/callback.h | 3 ++ include/task.h | 10 ++--- include/user.h | 4 +- loader/main.c | 3 -- misc/callback.c | 2 + relay32/user32.spec | 1 + windows/user.c | 102 +++++++++++++++++++++++++++++++------------- 9 files changed, 95 insertions(+), 63 deletions(-) diff --git a/if1632/thunk.c b/if1632/thunk.c index f91079f62e7..b1c394027fd 100644 --- a/if1632/thunk.c +++ b/if1632/thunk.c @@ -554,31 +554,15 @@ DWORD WINAPI THUNK_GetDCHook( HDC16 hdc, FARPROC16 *phookProc ) */ FARPROC16 WINAPI THUNK_SetTaskSignalProc( HTASK16 hTask, FARPROC16 proc ) { - static FARPROC16 defSignalProc16 = NULL; + THUNK *thunk = THUNK_Alloc( proc, (RELAY)CallTo16_word_wwwww ); + if ( !thunk ) return NULL; - THUNK *thunk = NULL; + thunk = (THUNK*)SetTaskSignalProc( hTask, (FARPROC16)thunk ); + if ( !thunk ) return NULL; - if( !defSignalProc16 ) - defSignalProc16 = NE_GetEntryPoint(GetModuleHandle16("USER"), 314 ); - - if( proc == defSignalProc16 ) - thunk = (THUNK*)SetTaskSignalProc( hTask, (FARPROC16)&USER_SignalProc ); - else - { - thunk = THUNK_Alloc( proc, (RELAY)CallTo16_word_wwwww ); - if( !thunk ) return FALSE; - thunk = (THUNK*)SetTaskSignalProc( hTask, (FARPROC16)thunk ); - } - - if( thunk != (THUNK*)USER_SignalProc ) - { - if( !thunk ) return NULL; - - proc = thunk->proc; - THUNK_Free( thunk ); - return proc; - } - return defSignalProc16; + proc = thunk->proc; + THUNK_Free( thunk ); + return proc; } /*********************************************************************** @@ -883,6 +867,7 @@ void THUNK_InitCallout(void) GETADDR( DispatchMessageW, "DispatchMessageW" ); GETADDR( DispatchMessageA, "DispatchMessageA" ); GETADDR( RedrawWindow, "RedrawWindow" ); + GETADDR( UserSignalProc, "UserSignalProc" ); #undef GETADDR } diff --git a/if1632/user.spec b/if1632/user.spec index 4a5c761d5a2..36dac48198d 100644 --- a/if1632/user.spec +++ b/if1632/user.spec @@ -361,7 +361,7 @@ file user.exe 385 pascal16 GetMenuContextHelpId(word) GetMenuContextHelpId16 389 pascal LoadImage(word segstr word word word word) LoadImage16 390 pascal16 CopyImage(word word word word word) CopyImage16 -391 stub SignalProc32 +391 pascal16 SignalProc32(long long long word) UserSignalProc 394 pascal16 DrawIconEx(word word word word word word word word word) DrawIconEx16 395 pascal16 GetIconInfo(word ptr) GetIconInfo16 397 pascal16 RegisterClassEx(ptr) RegisterClassEx16 diff --git a/include/callback.h b/include/callback.h index af0b4e70db4..c9365605d56 100644 --- a/include/callback.h +++ b/include/callback.h @@ -122,6 +122,9 @@ typedef struct BOOL WINAPI (*RedrawWindow)( HWND hwnd, const RECT *rectUpdate, HRGN hrgnUpdate, UINT flags ); + WORD WINAPI (*UserSignalProc)( UINT uCode, DWORD dwThreadOrProcessID, + DWORD dwFlags, HMODULE16 hModule ); + HQUEUE16 WINAPI (*InitThreadInput16)( WORD unknown, WORD flags ); void WINAPI (*UserYield16)( void ); WORD WINAPI (*DestroyIcon32)( HGLOBAL16 handle, UINT16 flags ); diff --git a/include/task.h b/include/task.h index 397b9ec5ded..c9f43a068f2 100644 --- a/include/task.h +++ b/include/task.h @@ -118,11 +118,11 @@ typedef struct _TDB #define TDBF_OS2APP 0x0008 #define TDBF_WIN32 0x0010 - /* USER signals */ -#define USIG_TERMINATION 0x0020 -#define USIG_DLL_LOAD 0x0040 -#define USIG_DLL_UNLOAD 0x0080 -#define USIG_GPF 0x0666 + /* Windows 3.1 USER signals */ +#define USIG16_TERMINATION 0x0020 +#define USIG16_DLL_LOAD 0x0040 +#define USIG16_DLL_UNLOAD 0x0080 +#define USIG16_GPF 0x0666 /* THHOOK Kernel Data Structure */ diff --git a/include/user.h b/include/user.h index f7ab2ba7c25..d7559270912 100644 --- a/include/user.h +++ b/include/user.h @@ -38,8 +38,8 @@ typedef struct tagUSER_DRIVER { extern USER_DRIVER *USER_Driver; -void WINAPI USER_SignalProc(HANDLE16, UINT16, UINT16, HINSTANCE16, HQUEUE16); void USER_ExitWindows(void); -void USER_QueueCleanup( HQUEUE16 hQueue ); +WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID, + DWORD dwFlags, HMODULE16 hModule ); #endif /* __WINE_USER_H */ diff --git a/loader/main.c b/loader/main.c index 44d8b77bac4..2d3447d8e56 100644 --- a/loader/main.c +++ b/loader/main.c @@ -251,9 +251,6 @@ BOOL WINAPI MAIN_UserInit(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserve /* Create desktop window */ if (!WIN_CreateDesktopWindow()) return FALSE; - /* Install default USER Signal Handler */ - SetTaskSignalProc( 0, (FARPROC16)USER_SignalProc ); - /* Initialize keyboard driver */ KEYBOARD_Enable( keybd_event, InputKeyStateTable ); diff --git a/misc/callback.c b/misc/callback.c index d6b08b298c9..69f605fdedb 100644 --- a/misc/callback.c +++ b/misc/callback.c @@ -10,6 +10,7 @@ #include "task.h" #include "syslevel.h" #include "cursoricon.h" +#include "user.h" #include "queue.h" #include "debug.h" @@ -321,6 +322,7 @@ CALLOUT_TABLE Callout = TranslateMessage16, TranslateMessage, DispatchMessage16, DispatchMessageA, DispatchMessageW, RedrawWindow16, RedrawWindow, + UserSignalProc, InitThreadInput16, UserYield16, CURSORICON_Destroy diff --git a/relay32/user32.spec b/relay32/user32.spec index ec422563fca..599119bdbe8 100644 --- a/relay32/user32.spec +++ b/relay32/user32.spec @@ -625,3 +625,4 @@ init MAIN_UserInit 620 stdcall GetTaskmanWindow () GetTaskmanWindow 621 stdcall SetTaskmanWindow (long) SetTaskmanWindow 622 stdcall GetProgmanWindow () GetProgmanWindow +623 stdcall UserSignalProc(long long long long) UserSignalProc diff --git a/windows/user.c b/windows/user.c index 081e0215195..d049ad4a7ac 100644 --- a/windows/user.c +++ b/windows/user.c @@ -27,6 +27,7 @@ #include "local.h" #include "class.h" #include "desktop.h" +#include "process.h" #include "debug.h" /*********************************************************************** @@ -125,12 +126,19 @@ static void USER_ModuleUnload( HMODULE16 hModule ) /********************************************************************** * USER_QueueCleanup */ -void USER_QueueCleanup( HQUEUE16 hQueue ) +static void USER_QueueCleanup( HQUEUE16 hQueue ) { if ( hQueue ) { WND* desktop = WIN_GetDesktop(); + /* Patch desktop window */ + if ( desktop->hmemTaskQ == hQueue ) + { + HTASK16 nextTask = TASK_GetNextTask( GetCurrentTask() ); + desktop->hmemTaskQ = GetTaskQueue16( nextTask ); + } + /* Patch resident popup menu window */ MENU_PatchResidentPopup( hQueue, NULL ); @@ -153,27 +161,17 @@ void USER_QueueCleanup( HQUEUE16 hQueue ) /********************************************************************** * USER_AppExit */ -static void USER_AppExit( HTASK16 hTask, HINSTANCE16 hInstance, HQUEUE16 hQueue ) +static void USER_AppExit( HINSTANCE16 hInstance ) { /* FIXME: empty clipboard if needed, maybe destroy menus (Windows * only complains about them but does nothing); */ - WND* desktop = WIN_GetDesktop(); - - /* Patch desktop window */ - if( desktop->hmemTaskQ == hQueue ) - desktop->hmemTaskQ = GetTaskQueue16(TASK_GetNextTask(hTask)); - - USER_QueueCleanup(hQueue); - /* ModuleUnload() in "Internals" */ hInstance = GetExePtr( hInstance ); if( GetModuleUsage16( hInstance ) <= 1 ) USER_ModuleUnload( hInstance ); - - WIN_ReleaseDesktop(); } @@ -202,25 +200,71 @@ void WINAPI USER_SignalProc( HANDLE16 hTaskOrModule, UINT16 uCode, UINT16 uExitFn, HINSTANCE16 hInstance, HQUEUE16 hQueue ) { - switch( uCode ) - { - case USIG_GPF: - case USIG_TERMINATION: - USER_AppExit( hTaskOrModule, hInstance, hQueue ); /* task */ - break; - - case USIG_DLL_LOAD: - break; - - case USIG_DLL_UNLOAD: - USER_ModuleUnload( hTaskOrModule ); /* module */ - break; - - default: - FIXME(msg,"Unimplemented USER signal: %i\n", (int)uCode ); - } + FIXME( win, "Win 3.1 USER signal %04x\n", uCode ); } +/*********************************************************************** + * UserSignalProc (USER.610) (USER32.559) + * + * For comments about the meaning of uCode and dwFlags + * see PROCESS_CallUserSignalProc. + * + */ +WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID, + DWORD dwFlags, HMODULE16 hModule ) +{ + HINSTANCE16 hInst; + + /* FIXME: Proper reaction to most signals still missing. */ + + switch ( uCode ) + { + case USIG_DLL_UNLOAD_WIN16: + case USIG_DLL_UNLOAD_WIN32: + USER_ModuleUnload( hModule ); + break; + + case USIG_DLL_UNLOAD_ORPHANS: + break; + + case USIG_FAULT_DIALOG_PUSH: + case USIG_FAULT_DIALOG_POP: + break; + + case USIG_THREAD_INIT: + break; + + case USIG_THREAD_EXIT: + USER_QueueCleanup( GetThreadQueue16( dwThreadOrProcessID ) ); + SetThreadQueue16( dwThreadOrProcessID, 0 ); + break; + + case USIG_PROCESS_CREATE: + case USIG_PROCESS_INIT: + case USIG_PROCESS_LOADED: + case USIG_PROCESS_RUNNING: + break; + + case USIG_PROCESS_EXIT: + break; + + case USIG_PROCESS_DESTROY: + hInst = GetProcessDword( dwThreadOrProcessID, GPD_HINSTANCE16 ); + USER_AppExit( hInst ); + break; + + default: + FIXME( win, "(%04x, %08lx, %04lx, %04x)\n", + uCode, dwThreadOrProcessID, dwFlags, hModule ); + break; + } + + /* FIXME: Should chain to GdiSignalProc now. */ + + return 0; +} + + /*********************************************************************** * ExitWindows16 (USER.7)