Alexandre Julliard : kernel32: Initialize argv from the dll entry point.

Alexandre Julliard julliard at winehq.org
Wed Dec 4 16:13:04 CST 2019


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Dec  3 19:20:17 2019 +0100

kernel32: Initialize argv from the dll entry point.

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

---

 dlls/kernel32/kernel_main.c | 32 ++++++++++++++++++++++++++++++++
 dlls/kernel32/process.c     | 34 ----------------------------------
 2 files changed, 32 insertions(+), 34 deletions(-)

diff --git a/dlls/kernel32/kernel_main.c b/dlls/kernel32/kernel_main.c
index 954b08b523..1d61853d86 100644
--- a/dlls/kernel32/kernel_main.c
+++ b/dlls/kernel32/kernel_main.c
@@ -29,6 +29,7 @@
 
 #include "windef.h"
 #include "winbase.h"
+#include "winnls.h"
 #include "wincon.h"
 #include "winternl.h"
 
@@ -76,6 +77,36 @@ static void set_entry_point( HMODULE module, const char *name, DWORD rva )
 }
 
 
+/***********************************************************************
+ *              set_library_argv
+ *
+ * Set the Wine library argv global variable.
+ */
+static void set_library_argv( WCHAR **wargv )
+{
+    int argc;
+    char *p, **argv;
+    DWORD total = 0;
+
+    /* convert argv back from Unicode since it has to be in the Ansi codepage not the Unix one */
+
+    for (argc = 0; wargv[argc]; argc++)
+        total += WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, NULL, 0, NULL, NULL );
+
+    argv = RtlAllocateHeap( GetProcessHeap(), 0, total + (argc + 1) * sizeof(*argv) );
+    p = (char *)(argv + argc + 1);
+    for (argc = 0; wargv[argc]; argc++)
+    {
+        DWORD reslen = WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, p, total, NULL, NULL );
+        argv[argc] = p;
+        p += reslen;
+        total -= reslen;
+    }
+    argv[argc] = NULL;
+    __wine_main_argv = argv;
+}
+
+
 /***********************************************************************
  *           KERNEL process initialisation routine
  */
@@ -83,6 +114,7 @@ static BOOL process_attach( HMODULE module )
 {
     RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters;
 
+    set_library_argv( __wine_main_wargv );
     NtQuerySystemInformation( SystemBasicInformation, &system_info, sizeof(system_info), NULL );
 
     /* Setup registry timezone information */
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 09c6bab3ce..72a93a7fe7 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -86,39 +86,6 @@ const WCHAR DIR_System[] = {'C',':','\\','w','i','n','d','o','w','s',
 #define PDB32_WIN32S_PROC   0x8000  /* Win32s process */
 
 
-/***********************************************************************
- *              set_library_argv
- *
- * Set the Wine library argv global variables.
- */
-static void set_library_argv( WCHAR **wargv )
-{
-    int argc;
-    char *p, **argv;
-    DWORD total = 0;
-
-    /* convert argv back from Unicode since it has to be in the Ansi codepage not the Unix one */
-
-    for (argc = 0; wargv[argc]; argc++)
-        total += WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, NULL, 0, NULL, NULL );
-
-    argv = RtlAllocateHeap( GetProcessHeap(), 0, total + (argc + 1) * sizeof(*argv) );
-    p = (char *)(argv + argc + 1);
-    for (argc = 0; wargv[argc]; argc++)
-    {
-        DWORD reslen = WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, p, total, NULL, NULL );
-        argv[argc] = p;
-        p += reslen;
-        total -= reslen;
-    }
-    argv[argc] = NULL;
-
-    __wine_main_argc = argc;
-    __wine_main_argv = argv;
-    __wine_main_wargv = wargv;
-}
-
-
 #ifdef __i386__
 extern DWORD call_process_entry( PEB *peb, LPTHREAD_START_ROUTINE entry );
 __ASM_GLOBAL_FUNC( call_process_entry,
@@ -214,7 +181,6 @@ void * CDECL __wine_kernel_init(void)
     RtlSetUnhandledExceptionFilter( UnhandledExceptionFilter );
 
     LOCALE_Init();
-    set_library_argv( __wine_main_wargv );
 
     if (!params->CurrentDirectory.Handle) chdir("/"); /* avoid locking removable devices */
 




More information about the wine-cvs mailing list