Pass the main exe name in the CREATE_PROCESS debug event.

diff --git a/include/module.h b/include/module.h
index 5844b02..e24e094 100644
--- a/include/module.h
+++ b/include/module.h
@@ -228,7 +228,7 @@
 
 /* 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 eae7971..6eb4a0f 100644
--- a/include/server.h
+++ b/include/server.h
@@ -170,6 +170,7 @@
 {
     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 @@
     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 c4744a7..042bdba 100644
--- a/relay32/builtin32.c
+++ b/relay32/builtin32.c
@@ -389,7 +389,7 @@
 /***********************************************************************
  *           BUILTIN32_LoadExeModule
  */
-HMODULE BUILTIN32_LoadExeModule( LPCSTR *filename )
+HMODULE BUILTIN32_LoadExeModule(void)
 {
     int i, exe = -1;
 
@@ -416,8 +416,6 @@
     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 1c8205a..0c4aedd 100644
--- a/scheduler/process.c
+++ b/scheduler/process.c
@@ -338,6 +338,7 @@
     /* 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 @@
  *           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 @@
     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_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 4c6539b..436d170 100644
--- a/server/debugger.c
+++ b/server/debugger.c
@@ -140,7 +140,7 @@
     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 e6fba62..9af7637 100644
--- a/server/process.c
+++ b/server/process.c
@@ -817,6 +817,7 @@
         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 dc8dd07..f4f9d15 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -285,6 +285,7 @@
 {
     fprintf( stderr, " module=%p,", req->module );
     fprintf( stderr, " entry=%p,", req->entry );
+    fprintf( stderr, " name=%p,", req->name );
     fprintf( stderr, " gui=%d", req->gui );
 }