Alexandre Julliard : winecrt0: Create the Ansi argv from the Unicode one.
Alexandre Julliard
julliard at winehq.org
Mon Dec 9 16:57:35 CST 2019
Module: wine
Branch: master
Commit: 5a9c88d62e018049cc29369b0c463b0664ef6ef1
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5a9c88d62e018049cc29369b0c463b0664ef6ef1
Author: Alexandre Julliard <julliard at winehq.org>
Date: Sat Dec 7 14:45:24 2019 +0100
winecrt0: Create the Ansi argv from the Unicode one.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winecrt0/dll_entry.c | 2 +-
dlls/winecrt0/drv_entry.c | 2 +-
dlls/winecrt0/exe_entry.c | 28 ++++++++++++++++++++++++++--
dlls/winecrt0/exe_wentry.c | 2 +-
4 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/dlls/winecrt0/dll_entry.c b/dlls/winecrt0/dll_entry.c
index a002d87875..92bd069529 100644
--- a/dlls/winecrt0/dll_entry.c
+++ b/dlls/winecrt0/dll_entry.c
@@ -38,7 +38,7 @@ BOOL WINAPI DECLSPEC_HIDDEN __wine_spec_dll_entry( HINSTANCE inst, DWORD reason,
if (reason == DLL_PROCESS_ATTACH && __wine_spec_init_state != CONSTRUCTORS_DONE)
{
call_fini = TRUE;
- _init( __wine_main_argc, __wine_main_argv, NULL );
+ _init( 0, NULL, NULL );
}
ret = DllMain( inst, reason, reserved );
diff --git a/dlls/winecrt0/drv_entry.c b/dlls/winecrt0/drv_entry.c
index ee9f3b13a7..c7d39922e1 100644
--- a/dlls/winecrt0/drv_entry.c
+++ b/dlls/winecrt0/drv_entry.c
@@ -35,7 +35,7 @@ NTSTATUS DECLSPEC_HIDDEN WINAPI __wine_spec_drv_entry( struct _DRIVER_OBJECT *ob
{
BOOL needs_init = (__wine_spec_init_state != CONSTRUCTORS_DONE);
- if (needs_init) _init( __wine_main_argc, __wine_main_argv, NULL );
+ if (needs_init) _init( 0, NULL, NULL );
return DriverEntry( obj, path );
/* there is no detach routine so we can't call destructors */
}
diff --git a/dlls/winecrt0/exe_entry.c b/dlls/winecrt0/exe_entry.c
index 13a1d893c9..9ae45f9f04 100644
--- a/dlls/winecrt0/exe_entry.c
+++ b/dlls/winecrt0/exe_entry.c
@@ -25,19 +25,43 @@
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
+#include "winnls.h"
#include "winternl.h"
#include "wine/library.h"
#include "crt0_private.h"
extern int __cdecl main( int argc, char *argv[] );
+static char **build_argv( WCHAR **wargv )
+{
+ int argc;
+ char *p, **argv;
+ DWORD total = 0;
+
+ for (argc = 0; wargv[argc]; argc++)
+ total += WideCharToMultiByte( CP_ACP, 0, wargv[argc], -1, NULL, 0, NULL, NULL );
+
+ argv = HeapAlloc( 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;
+ return argv;
+}
+
DWORD WINAPI DECLSPEC_HIDDEN __wine_spec_exe_entry( PEB *peb )
{
BOOL needs_init = (__wine_spec_init_state != CONSTRUCTORS_DONE);
+ char **argv = build_argv( __wine_main_wargv );
DWORD ret;
- if (needs_init) _init( __wine_main_argc, __wine_main_argv, NULL );
- ret = main( __wine_main_argc, __wine_main_argv );
+ if (needs_init) _init( __wine_main_argc, argv, NULL );
+ ret = main( __wine_main_argc, argv );
if (needs_init) _fini();
ExitProcess( ret );
}
diff --git a/dlls/winecrt0/exe_wentry.c b/dlls/winecrt0/exe_wentry.c
index 9db135eed0..b889e5a102 100644
--- a/dlls/winecrt0/exe_wentry.c
+++ b/dlls/winecrt0/exe_wentry.c
@@ -36,7 +36,7 @@ DWORD WINAPI DECLSPEC_HIDDEN __wine_spec_exe_wentry( PEB *peb )
BOOL needs_init = (__wine_spec_init_state != CONSTRUCTORS_DONE);
DWORD ret;
- if (needs_init) _init( __wine_main_argc, __wine_main_argv, NULL );
+ if (needs_init) _init( 0, NULL, NULL );
ret = wmain( __wine_main_argc, __wine_main_wargv );
if (needs_init) _fini();
ExitProcess( ret );
More information about the wine-cvs
mailing list