Delay sending debug events until process initialization is complete.

This commit is contained in:
Ulrich Weigand 1999-12-08 03:28:14 +00:00 committed by Alexandre Julliard
parent 3393730f96
commit 0106f85e5f
3 changed files with 72 additions and 28 deletions

View file

@ -157,6 +157,7 @@ typedef struct _wine_modref
#define WINE_MODREF_PROCESS_ATTACHED 0x00000004
#define WINE_MODREF_LOAD_AS_DATAFILE 0x00000010
#define WINE_MODREF_DONT_RESOLVE_REFS 0x00000020
#define WINE_MODREF_DEBUG_EVENT_SENT 0x00000040
#define WINE_MODREF_MARKER 0x80000000
@ -181,6 +182,7 @@ extern BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved );
extern void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved );
extern void MODULE_DllThreadAttach( LPVOID lpReserved );
extern void MODULE_DllThreadDetach( LPVOID lpReserved );
extern void MODULE_SendLoadDLLEvents( void );
extern WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags );
extern BOOL MODULE_FreeLibrary( WINE_MODREF *wm );
extern WINE_MODREF *MODULE_FindModule( LPCSTR path );

View file

@ -327,6 +327,29 @@ BOOL WINAPI DisableThreadLibraryCalls( HMODULE hModule )
return retval;
}
/*************************************************************************
* MODULE_SendLoadDLLEvents
*
* Sends DEBUG_DLL_LOAD events for all outstanding modules.
*
* NOTE: Assumes that the process critical section is held!
*
*/
void MODULE_SendLoadDLLEvents( void )
{
WINE_MODREF *wm;
for ( wm = PROCESS_Current()->modref_list; wm; wm = wm->next )
{
if ( wm->type != MODULE32_PE ) continue;
if ( wm == PROCESS_Current()->exe_modref ) continue;
if ( wm->flags & WINE_MODREF_DEBUG_EVENT_SENT ) continue;
DEBUG_SendLoadDLLEvent( -1 /*FIXME*/, wm->module, &wm->modname );
wm->flags |= WINE_MODREF_DEBUG_EVENT_SENT;
}
}
/***********************************************************************
* MODULE_CreateDummyModule
@ -1321,14 +1344,19 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
EnterCriticalSection(&PROCESS_Current()->crit_section);
wm = MODULE_LoadLibraryExA( libname, hfile, flags );
if ( wm )
{
if ( PROCESS_Current()->flags & PDB32_DEBUGGED )
MODULE_SendLoadDLLEvents();
if(wm && !MODULE_DllProcessAttach(wm, NULL))
if ( !MODULE_DllProcessAttach( wm, NULL ) )
{
WARN_(module)("Attach failed for module '%s', \n", libname);
MODULE_FreeLibrary(wm);
SetLastError(ERROR_DLL_INIT_FAILED);
wm = NULL;
}
}
LeaveCriticalSection(&PROCESS_Current()->crit_section);
@ -1411,9 +1439,6 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
LeaveCriticalSection(&PROCESS_Current()->crit_section);
if (PROCESS_Current()->flags & PDB32_DEBUGGED)
DEBUG_SendLoadDLLEvent( -1 /*FIXME*/, pwm->module, &pwm->modname );
return pwm;
}

View file

@ -409,10 +409,33 @@ void PROCESS_Start(void)
if (!TASK_Create( pModule, cmdShow ))
goto error;
/* Perform Win16 specific process initialization */
if ( type == PROC_WIN16 )
/* Load all process modules */
switch ( type )
{
case PROC_WIN16:
if ( !NE_InitProcess( pModule ) )
goto error;
break;
case PROC_WIN32:
/* Create 32-bit MODREF */
if ( !PE_CreateModule( pModule->module32, filename, 0, FALSE ) )
goto error;
/* Increment EXE refcount */
assert( pdb->exe_modref );
pdb->exe_modref->refCount++;
/* Retrieve entry point address */
entry = (LPTHREAD_START_ROUTINE)RVA_PTR(pModule->module32,
OptionalHeader.AddressOfEntryPoint);
break;
case PROC_DOS:
/* FIXME: move DOS startup code here */
break;
}
/* Note: The USIG_PROCESS_CREATE signal is supposed to be sent in the
* context of the parent process. Actually, the USER signal proc
@ -426,39 +449,33 @@ void PROCESS_Start(void)
PROCESS_CallUserSignalProc( USIG_PROCESS_CREATE, 0, 0 );
PROCESS_CallUserSignalProc( USIG_THREAD_INIT, GetCurrentThreadId(), 0 );
PROCESS_CallUserSignalProc( USIG_PROCESS_INIT, 0, 0 );
PROCESS_CallUserSignalProc( USIG_PROCESS_LOADED, 0, 0 );
/* Signal the parent process to continue */
server_call( REQ_INIT_PROCESS_DONE );
/* Perform Win32 specific process initialization */
if ( type == PROC_WIN32 )
/* Send all required start-up debugger events */
if ( type == PROC_WIN32 && (pdb->flags & PDB32_DEBUGGED) )
{
/* Send the debug event to the debugger */
entry = (LPTHREAD_START_ROUTINE)RVA_PTR(pModule->module32,
OptionalHeader.AddressOfEntryPoint);
if (pdb->flags & PDB32_DEBUGGED)
EnterCriticalSection( &pdb->crit_section );
DEBUG_SendCreateProcessEvent( -1 /*FIXME*/, pModule->module32, entry );
MODULE_SendLoadDLLEvents();
/* Create 32-bit MODREF */
if (!PE_CreateModule( pModule->module32, filename, 0, FALSE )) goto error;
/* Increment EXE refcount */
assert( pdb->exe_modref );
pdb->exe_modref->refCount++;
/* Initialize thread-local storage */
PE_InitTls();
LeaveCriticalSection( &pdb->crit_section );
}
PROCESS_CallUserSignalProc( USIG_PROCESS_LOADED, 0, 0 ); /* FIXME: correct location? */
if ( (pdb->flags & PDB32_CONSOLE_PROC) || (pdb->flags & PDB32_DOS_PROC) )
AllocConsole();
/* Perform Win32 specific process initialization */
if ( type == PROC_WIN32 )
{
EnterCriticalSection( &pdb->crit_section );
PE_InitTls();
MODULE_DllProcessAttach( pdb->exe_modref, (LPVOID)1 );
LeaveCriticalSection( &pdb->crit_section );
}