From a37dec0c7ea5f39b609920649a01225ddfef0c41 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 8 Jun 2000 00:57:24 +0000 Subject: [PATCH] Pass the main exe name in the CREATE_PROCESS debug event. --- include/module.h | 2 +- include/server.h | 3 ++- relay32/builtin32.c | 4 +--- scheduler/process.c | 35 +++++++++++++++++++++++------------ server/debugger.c | 2 +- server/process.c | 1 + server/trace.c | 1 + 7 files changed, 30 insertions(+), 18 deletions(-) diff --git a/include/module.h b/include/module.h index 5844b0288af..e24e094f26a 100644 --- a/include/module.h +++ b/include/module.h @@ -228,7 +228,7 @@ HGLOBAL16 NE_LoadPEResource( NE_MODULE *pModule, WORD type, LPVOID bits, DWORD s /* relay32/builtin.c */ extern WINE_MODREF *BUILTIN32_LoadLibraryExA(LPCSTR name, DWORD flags); -extern HMODULE BUILTIN32_LoadExeModule( LPCSTR *filename ); +extern HMODULE BUILTIN32_LoadExeModule(void); extern void BUILTIN32_UnloadLibrary(WINE_MODREF *wm); extern void *BUILTIN32_dlopen( const char *name ); extern int BUILTIN32_dlclose( void *handle ); diff --git a/include/server.h b/include/server.h index eae797135ee..6eb4a0fe0ed 100644 --- a/include/server.h +++ b/include/server.h @@ -170,6 +170,7 @@ struct init_process_done_request { IN void* module; /* main module base address */ IN void* entry; /* process entry point */ + IN void* name; /* ptr to ptr to name (in process addr space) */ IN int gui; /* is it a GUI process? */ OUT int debugged; /* being debugged? */ }; @@ -1297,7 +1298,7 @@ enum request REQ_NB_REQUESTS }; -#define SERVER_PROTOCOL_VERSION 14 +#define SERVER_PROTOCOL_VERSION 15 /* ### make_requests end ### */ /* Everything above this line is generated automatically by tools/make_requests */ diff --git a/relay32/builtin32.c b/relay32/builtin32.c index c4744a77ac6..042bdbacf96 100644 --- a/relay32/builtin32.c +++ b/relay32/builtin32.c @@ -389,7 +389,7 @@ WINE_MODREF *BUILTIN32_LoadLibraryExA(LPCSTR path, DWORD flags) /*********************************************************************** * BUILTIN32_LoadExeModule */ -HMODULE BUILTIN32_LoadExeModule( LPCSTR *filename ) +HMODULE BUILTIN32_LoadExeModule(void) { int i, exe = -1; @@ -416,8 +416,6 @@ HMODULE BUILTIN32_LoadExeModule( LPCSTR *filename ) if ( !dll_modules[exe] ) if ( !(dll_modules[exe] = BUILTIN32_DoLoadImage( builtin_dlls[exe] )) ) return 0; - - *filename = builtin_dlls[exe]->filename; return dll_modules[exe]; } diff --git a/scheduler/process.c b/scheduler/process.c index 1c8205a78fb..0c4aedd1c12 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -338,6 +338,7 @@ static void start_process(void) /* Signal the parent process to continue */ req->module = (void *)module; req->entry = entry; + req->name = &pdb->exe_modref->filename; req->gui = !console_app; server_call( REQ_INIT_PROCESS_DONE ); debugged = req->debugged; @@ -386,25 +387,38 @@ static void start_process(void) * PROCESS_Start * * Startup routine of a new Win32 process once the main module has been loaded. + * The filename is free'd by this routine. */ -static void PROCESS_Start( HMODULE main_module, LPCSTR filename ) WINE_NORETURN; -static void PROCESS_Start( HMODULE main_module, LPCSTR filename ) +static void PROCESS_Start( HMODULE main_module, LPSTR filename ) WINE_NORETURN; +static void PROCESS_Start( HMODULE main_module, LPSTR filename ) { + if (!filename) + { + /* if no explicit filename, use argv[0] */ + if (!(filename = malloc( MAX_PATH ))) ExitProcess(1); + if (!GetFullPathNameA( argv0, MAX_PATH, filename, NULL )) + lstrcpynA( filename, argv0, MAX_PATH ); + } + /* load main module */ if (PE_HEADER(main_module)->FileHeader.Characteristics & IMAGE_FILE_DLL) ExitProcess( ERROR_BAD_EXE_FORMAT ); /* Create 32-bit MODREF */ if (!PE_CreateModule( main_module, filename, 0, FALSE )) - ExitProcess( GetLastError() ); + goto error; + free( filename ); /* allocate main thread stack */ if (!THREAD_InitStack( NtCurrentTeb(), PE_HEADER(main_module)->OptionalHeader.SizeOfStackReserve, TRUE )) - ExitProcess( GetLastError() ); + goto error; /* switch to the new stack */ SYSDEPS_SwitchToThreadStack( start_process ); + + error: + ExitProcess( GetLastError() ); } @@ -469,13 +483,12 @@ void PROCESS_InitWine( int argc, char *argv[] ) case SCS_WOW_BINARY: { HMODULE main_module; - LPCSTR filename; /* create 32-bit module for main exe */ - if (!(main_module = BUILTIN32_LoadExeModule( &filename ))) goto error; + if (!(main_module = BUILTIN32_LoadExeModule())) goto error; NtCurrentTeb()->tibflags &= ~TEBF_WIN32; PROCESS_Current()->flags |= PDB32_WIN16_PROC; SYSLEVEL_EnterWin16Lock(); - PROCESS_Start( main_module, filename ); + PROCESS_Start( main_module, NULL ); } break; @@ -505,16 +518,14 @@ void PROCESS_InitWine( int argc, char *argv[] ) void PROCESS_InitWinelib( int argc, char *argv[] ) { HMODULE main_module; - LPCSTR filename; if (!MAIN_MainInit( argv )) exit(1); - main_exe_argv = argv; - /* create 32-bit module for main exe */ - if (!(main_module = BUILTIN32_LoadExeModule( &filename ))) ExitProcess( GetLastError() ); + if (!(main_module = BUILTIN32_LoadExeModule())) ExitProcess( GetLastError() ); - PROCESS_Start( main_module, filename ); + main_exe_argv = argv; + PROCESS_Start( main_module, NULL ); } diff --git a/server/debugger.c b/server/debugger.c index 4c6539be570..436d1702f0e 100644 --- a/server/debugger.c +++ b/server/debugger.c @@ -140,7 +140,7 @@ static int fill_create_process_event( struct debug_event *event, void *arg ) event->data.info.create_process.start = arg; event->data.info.create_process.dbg_offset = process->exe.dbg_offset; event->data.info.create_process.dbg_size = process->exe.dbg_size; - event->data.info.create_process.name = 0; + event->data.info.create_process.name = process->exe.name; event->data.info.create_process.unicode = 0; return 1; } diff --git a/server/process.c b/server/process.c index e6fba62e80e..9af7637b10e 100644 --- a/server/process.c +++ b/server/process.c @@ -817,6 +817,7 @@ DECL_HANDLER(init_process_done) return; } process->exe.base = req->module; + process->exe.name = req->name; generate_startup_debug_events( current->process, req->entry ); set_event( process->init_event ); release_object( process->init_event ); diff --git a/server/trace.c b/server/trace.c index dc8dd0722d5..f4f9d155263 100644 --- a/server/trace.c +++ b/server/trace.c @@ -285,6 +285,7 @@ static void dump_init_process_done_request( const struct init_process_done_reque { fprintf( stderr, " module=%p,", req->module ); fprintf( stderr, " entry=%p,", req->entry ); + fprintf( stderr, " name=%p,", req->name ); fprintf( stderr, " gui=%d", req->gui ); }