Alexandre Julliard : ntdll: Add a helper to launch start.exe always as builtin.

Alexandre Julliard julliard at winehq.org
Thu Mar 25 16:49:21 CDT 2021


Module: wine
Branch: master
Commit: aef821ccbd9f2b7c8980c289316696eb4a3bca3c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=aef821ccbd9f2b7c8980c289316696eb4a3bca3c

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Mar 25 11:29:37 2021 +0100

ntdll: Add a helper to launch start.exe always as builtin.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/unix/env.c          | 12 +++---------
 dlls/ntdll/unix/loader.c       | 26 ++++++++++++++++++++++++++
 dlls/ntdll/unix/unix_private.h |  1 +
 3 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c
index 07b9f0fc384..f7ba8ce8ab5 100644
--- a/dlls/ntdll/unix/env.c
+++ b/dlls/ntdll/unix/env.c
@@ -1880,23 +1880,17 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params(void)
 
     if (status)  /* try launching it through start.exe */
     {
-        static const WCHAR startW[] = {'C',':','\\','w','i','n','d','o','w','s','\\',
-            's','y','s','t','e','m','3','2','\\','s','t','a','r','t','.','e','x','e',0};
         static const WCHAR slashwW[] = {'/','w',0};
         static const WCHAR slashbW[] = {'/','b',0};
-        const WCHAR *args[] = { startW, slashwW, slashbW };
+        const WCHAR *args[] = { NULL, slashwW, slashbW };
 
         free( image );
         prepend_main_wargv( args, 3 );
-        if ((status = load_main_exe( startW, NULL, curdir, &image, &module, &image_info )))
-        {
-            MESSAGE( "wine: failed to start %s\n", debugstr_w(main_wargv[2]) );
-            NtTerminateProcess( GetCurrentProcess(), status );
-        }
+        load_start_exe( &image, &module, &image_info );
     }
-    else main_wargv[0] = get_dos_path( image );
 
     NtCurrentTeb()->Peb->ImageBaseAddress = module;
+    main_wargv[0] = get_dos_path( image );
     cmdline = build_command_line( main_wargv );
 
     TRACE( "image %s cmdline %s dir %s\n",
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c
index 24cc546c300..2467b640a79 100644
--- a/dlls/ntdll/unix/loader.c
+++ b/dlls/ntdll/unix/loader.c
@@ -1544,6 +1544,32 @@ failed:
 }
 
 
+/***********************************************************************
+ *           load_start_exe
+ *
+ * Load start.exe as main image.
+ */
+NTSTATUS load_start_exe( WCHAR **image, void **module, SECTION_IMAGE_INFORMATION *image_info )
+{
+    static const WCHAR startW[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\',
+        's','y','s','t','e','m','3','2','\\','s','t','a','r','t','.','e','x','e',0};
+    UNICODE_STRING nt_name;
+    NTSTATUS status;
+    SIZE_T size;
+
+    init_unicode_string( &nt_name, startW );
+    status = find_builtin_dll( &nt_name, module, &size, image_info, current_machine, FALSE );
+    if (status)
+    {
+        MESSAGE( "wine: failed to load start.exe: %x\n", status );
+        NtTerminateProcess( GetCurrentProcess(), status );
+    }
+    *image = malloc( sizeof(startW) );
+    memcpy( *image, startW, sizeof(startW) );
+    return status;
+}
+
+
 #ifdef __FreeBSD__
 /* The PT_LOAD segments are sorted in increasing order, and the first
  * starts at the beginning of the ELF file. By parsing the file, we can
diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h
index a486a2ff0f4..3f84fa9c065 100644
--- a/dlls/ntdll/unix/unix_private.h
+++ b/dlls/ntdll/unix/unix_private.h
@@ -145,6 +145,7 @@ extern NTSTATUS load_builtin( const pe_image_info_t *image_info, const WCHAR *fi
                               void **addr_ptr, SIZE_T *size_ptr ) DECLSPEC_HIDDEN;
 extern NTSTATUS load_main_exe( const WCHAR *name, const char *unix_name, const WCHAR *curdir, WCHAR **image,
                                void **module, SECTION_IMAGE_INFORMATION *image_info ) DECLSPEC_HIDDEN;
+extern NTSTATUS load_start_exe( WCHAR **image, void **module, SECTION_IMAGE_INFORMATION *image_info ) DECLSPEC_HIDDEN;
 extern void start_server( BOOL debug ) DECLSPEC_HIDDEN;
 extern ULONG_PTR get_image_address(void) DECLSPEC_HIDDEN;
 




More information about the wine-cvs mailing list