From c963e25c0e988c7031f6cd00430e6fb2fac98cdd Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 15 May 2003 23:11:00 +0000 Subject: [PATCH] Get rid of the 32-bit user signal proc since we always run builtin USER now. Moved USER module cleanups to the 16-bit signal proc. --- dlls/user/user.exe.spec | 2 +- dlls/user/user16.c | 18 ++++++ include/module.h | 25 +------ include/user.h | 3 - loader/ne/module.c | 5 +- loader/ne/segment.c | 27 +++++++- loader/task.c | 3 - scheduler/process.c | 125 ----------------------------------- scheduler/thread.c | 1 - windows/user.c | 140 +++++++++++++++++++++++++--------------- 10 files changed, 137 insertions(+), 212 deletions(-) diff --git a/dlls/user/user.exe.spec b/dlls/user/user.exe.spec index 70072c9fbb2..02c28a2cbcc 100644 --- a/dlls/user/user.exe.spec +++ b/dlls/user/user.exe.spec @@ -307,7 +307,7 @@ #311 CaretBlinkProc # W1.1 #312 SendMessage2 #313 PostMessage2 -314 pascal16 SignalProc(word word word word word) USER_SignalProc +314 pascal16 SignalProc(word word word word word) SignalProc16 #315 XCStoDS #316 CompUpdateRect #317 CompUpdateRgn diff --git a/dlls/user/user16.c b/dlls/user/user16.c index 26a22c64363..9a847280fa5 100644 --- a/dlls/user/user16.c +++ b/dlls/user/user16.c @@ -22,8 +22,11 @@ #include "wine/winuser16.h" #include "winbase.h" #include "wownt32.h" +#include "task.h" #include "user.h" #include "win.h" +#include "winproc.h" +#include "cursoricon.h" /* handle to handle 16 conversions */ #define HANDLE_16(h32) (LOWORD(h32)) @@ -455,6 +458,21 @@ UINT16 WINAPI RealizePalette16( HDC16 hdc ) } +/*********************************************************************** + * SignalProc (USER.314) + */ +void WINAPI SignalProc16( HANDLE16 hModule, UINT16 code, + UINT16 uExitFn, HINSTANCE16 hInstance, HQUEUE16 hQueue ) +{ + if (code == USIG16_DLL_UNLOAD) + { + /* HOOK_FreeModuleHooks( hModule ); */ + CLASS_FreeModuleClasses( hModule ); + CURSORICON_FreeModuleIcons( hModule ); + } +} + + /********************************************************************** * IsMenu (USER.358) */ diff --git a/include/module.h b/include/module.h index 0bea5928f31..6931cd0c2f4 100644 --- a/include/module.h +++ b/include/module.h @@ -214,6 +214,7 @@ extern BOOL NE_CreateAllSegments( NE_MODULE *pModule ); extern HINSTANCE16 NE_GetInstance( NE_MODULE *pModule ); extern void NE_InitializeDLLs( HMODULE16 hModule ); extern void NE_DllProcessAttach( HMODULE16 hModule ); +extern void NE_CallUserSignalProc( HMODULE16 hModule, UINT16 code ); /* loader/pe_resource.c */ extern HRSRC PE_FindResourceW(HMODULE,LPCWSTR,LPCWSTR); @@ -240,28 +241,4 @@ extern NTSTATUS BUILTIN32_dlopen( const char *name, void** handle ); extern HMODULE16 BUILTIN_LoadModule( LPCSTR name ); extern BOOL BUILTIN_IsPresent( LPCSTR name ); -/* USER signal proc flags and codes */ -/* See PROCESS_CallUserSignalProc for comments */ -#define USIG_FLAGS_WIN32 0x0001 -#define USIG_FLAGS_GUI 0x0002 -#define USIG_FLAGS_FEEDBACK 0x0004 -#define USIG_FLAGS_FAULT 0x0008 - -#define USIG_DLL_UNLOAD_WIN16 0x0001 -#define USIG_DLL_UNLOAD_WIN32 0x0002 -#define USIG_FAULT_DIALOG_PUSH 0x0003 -#define USIG_FAULT_DIALOG_POP 0x0004 -#define USIG_DLL_UNLOAD_ORPHANS 0x0005 -#define USIG_THREAD_INIT 0x0010 -#define USIG_THREAD_EXIT 0x0020 -#define USIG_PROCESS_CREATE 0x0100 -#define USIG_PROCESS_INIT 0x0200 -#define USIG_PROCESS_EXIT 0x0300 -#define USIG_PROCESS_DESTROY 0x0400 -#define USIG_PROCESS_RUNNING 0x0500 -#define USIG_PROCESS_LOADED 0x0600 - -/* scheduler/process.c */ -extern void PROCESS_CallUserSignalProc( UINT uCode, HMODULE16 hModule ); - #endif /* __WINE_MODULE_H */ diff --git a/include/user.h b/include/user.h index 752ecc16b05..1108e9aae20 100644 --- a/include/user.h +++ b/include/user.h @@ -116,9 +116,6 @@ typedef struct tagUSER_DRIVER { extern USER_DRIVER USER_Driver; -WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID, - DWORD dwFlags, HMODULE16 hModule ); - /* user lock */ extern void USER_Lock(void); extern void USER_Unlock(void); diff --git a/loader/ne/module.c b/loader/ne/module.c index f6469b202f5..9daded5b422 100644 --- a/loader/ne/module.c +++ b/loader/ne/module.c @@ -293,7 +293,7 @@ WORD NE_GetOrdinal( HMODULE16 hModule, const char *name ) NE_MODULE *pModule; if (!(pModule = NE_GetPtr( hModule ))) return 0; - assert( !(pModule->flags & NE_FFLAGS_WIN32) ); + if (pModule->flags & NE_FFLAGS_WIN32) return 0; TRACE("(%04x,'%s')\n", hModule, name ); @@ -1287,8 +1287,7 @@ static BOOL16 NE_FreeModule( HMODULE16 hModule, BOOL call_wep ) MODULE_CallWEP( hModule ); /* Free the objects owned by the DLL module */ - TASK_CallTaskSignalProc( USIG16_DLL_UNLOAD, hModule ); - PROCESS_CallUserSignalProc( USIG_DLL_UNLOAD_WIN16, hModule ); + NE_CallUserSignalProc( hModule, USIG16_DLL_UNLOAD ); } else call_wep = FALSE; /* We are freeing a task -> no more WEPs */ diff --git a/loader/ne/segment.c b/loader/ne/segment.c index 2f4e4499980..83fce736fd9 100644 --- a/loader/ne/segment.c +++ b/loader/ne/segment.c @@ -647,7 +647,7 @@ static BOOL NE_InitDLL( NE_MODULE *pModule ) (pModule->flags & NE_FFLAGS_WIN32)) return TRUE; /*not a library*/ /* Call USER signal handler for Win3.1 compatibility. */ - TASK_CallTaskSignalProc( USIG16_DLL_LOAD, pModule->self ); + NE_CallUserSignalProc( pModule->self, USIG16_DLL_LOAD ); if (!pModule->cs) return TRUE; /* no initialization code */ @@ -709,6 +709,31 @@ void NE_InitializeDLLs( HMODULE16 hModule ) } +/********************************************************************** + * NE_CallUserSignalProc + * + * According to "Undocumented Windows", the task signal proc is + * bypassed for module load/unload notifications, and the USER signal + * proc is called directly instead. This is what this function does. + */ +typedef DWORD (WINAPI *pSignalProc)( HANDLE16 module, UINT16 code, UINT16 exit, + HINSTANCE16 inst, HQUEUE16 queue ); + +void NE_CallUserSignalProc( HMODULE16 hModule, UINT16 code ) +{ + FARPROC16 proc; + HMODULE16 user = GetModuleHandle16("user.exe"); + + if (!user) return; + if ((proc = GetProcAddress16( user, "SignalProc" ))) + { + /* USER is always a builtin dll */ + pSignalProc sigproc = (pSignalProc)((ENTRYPOINT16 *)MapSL( (SEGPTR)proc ))->target; + sigproc( hModule, code, 0, 0, 0 ); + } +} + + /*********************************************************************** * NE_CallDllEntryPoint * diff --git a/loader/task.c b/loader/task.c index 992b5e131ae..e52ee0f8a13 100644 --- a/loader/task.c +++ b/loader/task.c @@ -490,9 +490,6 @@ void TASK_ExitTask(void) /* Perform USER cleanup */ TASK_CallTaskSignalProc( USIG16_TERMINATION, pTask->hSelf ); - PROCESS_CallUserSignalProc( USIG_PROCESS_EXIT, 0 ); - PROCESS_CallUserSignalProc( USIG_THREAD_EXIT, 0 ); - PROCESS_CallUserSignalProc( USIG_PROCESS_DESTROY, 0 ); /* Remove the task from the list to be sure we never switch back to it */ TASK_UnlinkTask( pTask->hSelf ); diff --git a/scheduler/process.c b/scheduler/process.c index ed4828b82b1..204e1a24d6d 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -137,116 +137,6 @@ extern void RELAY_InitDebugLists(void); extern BOOL MAIN_MainInit(void); extern void VERSION_Init( const char *appname ); -typedef WORD (WINAPI *pUserSignalProc)( UINT, DWORD, DWORD, HMODULE16 ); - -/*********************************************************************** - * PROCESS_CallUserSignalProc - * - * FIXME: Some of the signals aren't sent correctly! - * - * The exact meaning of the USER signals is undocumented, but this - * should cover the basic idea: - * - * USIG_DLL_UNLOAD_WIN16 - * This is sent when a 16-bit module is unloaded. - * - * USIG_DLL_UNLOAD_WIN32 - * This is sent when a 32-bit module is unloaded. - * - * USIG_DLL_UNLOAD_ORPHANS - * This is sent after the last Win3.1 module is unloaded, - * to allow removal of orphaned menus. - * - * USIG_FAULT_DIALOG_PUSH - * USIG_FAULT_DIALOG_POP - * These are called to allow USER to prepare for displaying a - * fault dialog, even though the fault might have happened while - * inside a USER critical section. - * - * USIG_THREAD_INIT - * This is called from the context of a new thread, as soon as it - * has started to run. - * - * USIG_THREAD_EXIT - * This is called, still in its context, just before a thread is - * about to terminate. - * - * USIG_PROCESS_CREATE - * This is called, in the parent process context, after a new process - * has been created. - * - * USIG_PROCESS_INIT - * This is called in the new process context, just after the main thread - * has started execution (after the main thread's USIG_THREAD_INIT has - * been sent). - * - * USIG_PROCESS_LOADED - * This is called after the executable file has been loaded into the - * new process context. - * - * USIG_PROCESS_RUNNING - * This is called immediately before the main entry point is called. - * - * USIG_PROCESS_EXIT - * This is called in the context of a process that is about to - * terminate (but before the last thread's USIG_THREAD_EXIT has - * been sent). - * - * USIG_PROCESS_DESTROY - * This is called after a process has terminated. - * - * - * The meaning of the dwFlags bits is as follows: - * - * USIG_FLAGS_WIN32 - * Current process is 32-bit. - * - * USIG_FLAGS_GUI - * Current process is a (Win32) GUI process. - * - * USIG_FLAGS_FEEDBACK - * Current process needs 'feedback' (determined from the STARTUPINFO - * flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK). - * - * USIG_FLAGS_FAULT - * The signal is being sent due to a fault. - */ -void PROCESS_CallUserSignalProc( UINT uCode, HMODULE16 hModule ) -{ - DWORD dwFlags = 0; - HMODULE user; - pUserSignalProc proc; - - if (!(user = GetModuleHandleA( "user32.dll" ))) return; - if (!(proc = (pUserSignalProc)GetProcAddress( user, "UserSignalProc" ))) return; - - /* Determine dwFlags */ - - if ( !(current_process.flags & PDB32_WIN16_PROC) ) dwFlags |= USIG_FLAGS_WIN32; - if ( !(current_process.flags & PDB32_CONSOLE_PROC) ) dwFlags |= USIG_FLAGS_GUI; - - if ( dwFlags & USIG_FLAGS_GUI ) - { - /* Feedback defaults to ON */ - if ( !(current_startupinfo.dwFlags & STARTF_FORCEOFFFEEDBACK) ) - dwFlags |= USIG_FLAGS_FEEDBACK; - } - else - { - /* Feedback defaults to OFF */ - if (current_startupinfo.dwFlags & STARTF_FORCEONFEEDBACK) - dwFlags |= USIG_FLAGS_FEEDBACK; - } - - /* Call USER signal proc */ - - if ( uCode == USIG_THREAD_INIT || uCode == USIG_THREAD_EXIT ) - proc( uCode, GetCurrentThreadId(), dwFlags, hModule ); - else - proc( uCode, GetCurrentProcessId(), dwFlags, hModule ); -} - - /*********************************************************************** * get_basename */ @@ -555,21 +445,6 @@ static void start_process(void) MODULE_DllProcessAttach( NULL, (LPVOID)1 ); - /* Note: The USIG_PROCESS_CREATE signal is supposed to be sent in the - * context of the parent process. Actually, the USER signal proc - * doesn't really care about that, but it *does* require that the - * startup parameters are correctly set up, so that GetProcessDword - * works. Furthermore, before calling the USER signal proc the - * 16-bit stack must be set up, which it is only after TASK_Create - * in the case of a 16-bit process. Thus, we send the signal here. - */ - PROCESS_CallUserSignalProc( USIG_PROCESS_CREATE, 0 ); - PROCESS_CallUserSignalProc( USIG_THREAD_INIT, 0 ); - PROCESS_CallUserSignalProc( USIG_PROCESS_INIT, 0 ); - PROCESS_CallUserSignalProc( USIG_PROCESS_LOADED, 0 ); - /* Call UserSignalProc ( USIG_PROCESS_RUNNING ... ) only for non-GUI win32 apps */ - if (console_app) PROCESS_CallUserSignalProc( USIG_PROCESS_RUNNING, 0 ); - if (TRACE_ON(relay)) DPRINTF( "%04lx:Starting process %s (entryproc=%p)\n", GetCurrentThreadId(), main_exe_name, entry ); diff --git a/scheduler/thread.c b/scheduler/thread.c index a485ce66850..f73830061e1 100644 --- a/scheduler/thread.c +++ b/scheduler/thread.c @@ -232,7 +232,6 @@ static void THREAD_Start(void) if (TRACE_ON(relay)) DPRINTF("%04lx:Starting thread (entryproc=%p)\n", GetCurrentThreadId(), func ); - PROCESS_CallUserSignalProc( USIG_THREAD_INIT, 0 ); MODULE_DllThreadAttach( NULL ); ExitThread( func( NtCurrentTeb()->entry_arg ) ); } diff --git a/windows/user.c b/windows/user.c index e8c60efb67e..194233e58ae 100644 --- a/windows/user.c +++ b/windows/user.c @@ -45,6 +45,28 @@ WINE_DECLARE_DEBUG_CHANNEL(win32); SYSLEVEL USER_SysLevel = { CRITICAL_SECTION_INIT("USER_SysLevel"), 2 }; +/* USER signal proc flags and codes */ +/* See UserSignalProc for comments */ +#define USIG_FLAGS_WIN32 0x0001 +#define USIG_FLAGS_GUI 0x0002 +#define USIG_FLAGS_FEEDBACK 0x0004 +#define USIG_FLAGS_FAULT 0x0008 + +#define USIG_DLL_UNLOAD_WIN16 0x0001 +#define USIG_DLL_UNLOAD_WIN32 0x0002 +#define USIG_FAULT_DIALOG_PUSH 0x0003 +#define USIG_FAULT_DIALOG_POP 0x0004 +#define USIG_DLL_UNLOAD_ORPHANS 0x0005 +#define USIG_THREAD_INIT 0x0010 +#define USIG_THREAD_EXIT 0x0020 +#define USIG_PROCESS_CREATE 0x0100 +#define USIG_PROCESS_INIT 0x0200 +#define USIG_PROCESS_EXIT 0x0300 +#define USIG_PROCESS_DESTROY 0x0400 +#define USIG_PROCESS_RUNNING 0x0500 +#define USIG_PROCESS_LOADED 0x0600 + + /*********************************************************************** * GetFreeSystemResources (USER.284) */ @@ -129,26 +151,6 @@ void USER_CheckNotLock(void) } -/********************************************************************** - * USER_ModuleUnload - */ -static void USER_ModuleUnload( HMODULE16 hModule ) -{ - /* HOOK_FreeModuleHooks( hModule ); */ - CLASS_FreeModuleClasses( hModule ); - CURSORICON_FreeModuleIcons( hModule ); -} - -/*********************************************************************** - * SignalProc (USER.314) - */ -void WINAPI USER_SignalProc( HANDLE16 hTaskOrModule, UINT16 uCode, - UINT16 uExitFn, HINSTANCE16 hInstance, - HQUEUE16 hQueue ) -{ - FIXME_(win)("Win 3.1 USER signal %04x\n", uCode ); -} - /*********************************************************************** * FinalUserInit (USER.400) */ @@ -161,43 +163,79 @@ void WINAPI FinalUserInit16( void ) * SignalProc32 (USER.391) * UserSignalProc (USER32.@) * - * For comments about the meaning of uCode and dwFlags - * see PROCESS_CallUserSignalProc. + * The exact meaning of the USER signals is undocumented, but this + * should cover the basic idea: * + * USIG_DLL_UNLOAD_WIN16 + * This is sent when a 16-bit module is unloaded. + * + * USIG_DLL_UNLOAD_WIN32 + * This is sent when a 32-bit module is unloaded. + * + * USIG_DLL_UNLOAD_ORPHANS + * This is sent after the last Win3.1 module is unloaded, + * to allow removal of orphaned menus. + * + * USIG_FAULT_DIALOG_PUSH + * USIG_FAULT_DIALOG_POP + * These are called to allow USER to prepare for displaying a + * fault dialog, even though the fault might have happened while + * inside a USER critical section. + * + * USIG_THREAD_INIT + * This is called from the context of a new thread, as soon as it + * has started to run. + * + * USIG_THREAD_EXIT + * This is called, still in its context, just before a thread is + * about to terminate. + * + * USIG_PROCESS_CREATE + * This is called, in the parent process context, after a new process + * has been created. + * + * USIG_PROCESS_INIT + * This is called in the new process context, just after the main thread + * has started execution (after the main thread's USIG_THREAD_INIT has + * been sent). + * + * USIG_PROCESS_LOADED + * This is called after the executable file has been loaded into the + * new process context. + * + * USIG_PROCESS_RUNNING + * This is called immediately before the main entry point is called. + * + * USIG_PROCESS_EXIT + * This is called in the context of a process that is about to + * terminate (but before the last thread's USIG_THREAD_EXIT has + * been sent). + * + * USIG_PROCESS_DESTROY + * This is called after a process has terminated. + * + * + * The meaning of the dwFlags bits is as follows: + * + * USIG_FLAGS_WIN32 + * Current process is 32-bit. + * + * USIG_FLAGS_GUI + * Current process is a (Win32) GUI process. + * + * USIG_FLAGS_FEEDBACK + * Current process needs 'feedback' (determined from the STARTUPINFO + * flags STARTF_FORCEONFEEDBACK / STARTF_FORCEOFFFEEDBACK). + * + * USIG_FLAGS_FAULT + * The signal is being sent due to a fault. */ WORD WINAPI UserSignalProc( UINT uCode, DWORD dwThreadOrProcessID, DWORD dwFlags, HMODULE16 hModule ) { - /* 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: - case USIG_FAULT_DIALOG_PUSH: - case USIG_FAULT_DIALOG_POP: - case USIG_THREAD_INIT: - case USIG_THREAD_EXIT: - case USIG_PROCESS_CREATE: - case USIG_PROCESS_INIT: - case USIG_PROCESS_LOADED: - case USIG_PROCESS_RUNNING: - case USIG_PROCESS_EXIT: - case USIG_PROCESS_DESTROY: - break; - - default: - FIXME_(win)("(%04x, %08lx, %04lx, %04x)\n", - uCode, dwThreadOrProcessID, dwFlags, hModule ); - break; - } - + FIXME_(win)("(%04x, %08lx, %04lx, %04x)\n", + uCode, dwThreadOrProcessID, dwFlags, hModule ); /* FIXME: Should chain to GdiSignalProc now. */ - return 0; }