Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
ee56be3f
Commit
ee56be3f
authored
Oct 22, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Move Unicode argv initialization to ntdll.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
075741b6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
52 deletions
+51
-52
process.c
dlls/kernel32/process.c
+9
-52
env.c
dlls/ntdll/env.c
+42
-0
No files found.
dlls/kernel32/process.c
View file @
ee56be3f
...
...
@@ -835,45 +835,28 @@ static void set_wow64_environment(void)
}
/***********************************************************************
* set_library_
w
argv
* set_library_argv
*
* Set the Wine library
Unicode
argv global variables.
* Set the Wine library argv global variables.
*/
static
void
set_library_
wargv
(
char
**
argv
)
static
void
set_library_
argv
(
WCHAR
**
w
argv
)
{
int
argc
;
char
*
q
;
WCHAR
*
p
;
WCHAR
**
wargv
;
char
*
p
,
**
argv
;
DWORD
total
=
0
;
for
(
argc
=
0
;
argv
[
argc
];
argc
++
)
total
+=
MultiByteToWideChar
(
CP_UNIXCP
,
0
,
argv
[
argc
],
-
1
,
NULL
,
0
);
wargv
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
total
*
sizeof
(
WCHAR
)
+
(
argc
+
1
)
*
sizeof
(
*
wargv
)
);
p
=
(
WCHAR
*
)(
wargv
+
argc
+
1
);
for
(
argc
=
0
;
argv
[
argc
];
argc
++
)
{
DWORD
reslen
=
MultiByteToWideChar
(
CP_UNIXCP
,
0
,
argv
[
argc
],
-
1
,
p
,
total
);
wargv
[
argc
]
=
p
;
p
+=
reslen
;
total
-=
reslen
;
}
wargv
[
argc
]
=
NULL
;
/* 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
)
);
q
=
(
char
*
)(
argv
+
argc
+
1
);
p
=
(
char
*
)(
argv
+
argc
+
1
);
for
(
argc
=
0
;
wargv
[
argc
];
argc
++
)
{
DWORD
reslen
=
WideCharToMultiByte
(
CP_ACP
,
0
,
wargv
[
argc
],
-
1
,
q
,
total
,
NULL
,
NULL
);
argv
[
argc
]
=
q
;
q
+=
reslen
;
DWORD
reslen
=
WideCharToMultiByte
(
CP_ACP
,
0
,
wargv
[
argc
],
-
1
,
p
,
total
,
NULL
,
NULL
);
argv
[
argc
]
=
p
;
p
+=
reslen
;
total
-=
reslen
;
}
argv
[
argc
]
=
NULL
;
...
...
@@ -885,30 +868,6 @@ static void set_library_wargv( char **argv )
/***********************************************************************
* update_library_argv0
*
* Update the argv[0] global variable with the binary we have found.
*/
static
void
update_library_argv0
(
const
WCHAR
*
argv0
)
{
DWORD
len
=
strlenW
(
argv0
);
if
(
len
>
strlenW
(
__wine_main_wargv
[
0
]
))
{
__wine_main_wargv
[
0
]
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
(
len
+
1
)
*
sizeof
(
WCHAR
)
);
}
strcpyW
(
__wine_main_wargv
[
0
],
argv0
);
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
argv0
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
(
len
>
strlen
(
__wine_main_argv
[
0
]
)
+
1
)
{
__wine_main_argv
[
0
]
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
len
);
}
WideCharToMultiByte
(
CP_ACP
,
0
,
argv0
,
-
1
,
__wine_main_argv
[
0
],
len
,
NULL
,
NULL
);
}
/***********************************************************************
* build_command_line
*
* Build the command line of a process from the argv array.
...
...
@@ -1232,13 +1191,10 @@ void * CDECL __wine_kernel_init(void)
}
init_windows_dirs
();
set_library_wargv
(
__wine_main_argv
);
boot_events
[
0
]
=
boot_events
[
1
]
=
0
;
if
(
!
peb
->
ProcessParameters
->
WindowTitle
.
Buffer
)
{
update_library_argv0
(
main_exe_name
);
if
(
!
build_command_line
(
__wine_main_wargv
))
goto
error
;
start_wineboot
(
boot_events
);
}
...
...
@@ -1269,6 +1225,7 @@ void * CDECL __wine_kernel_init(void)
set_additional_environment
();
}
set_wow64_environment
();
set_library_argv
(
__wine_main_wargv
);
if
(
!
(
peb
->
ImageBaseAddress
=
LoadLibraryExW
(
main_exe_name
,
0
,
DONT_RESOLVE_DLL_REFERENCES
)))
{
...
...
dlls/ntdll/env.c
View file @
ee56be3f
...
...
@@ -513,6 +513,45 @@ failed:
}
/***********************************************************************
* set_library_wargv
*
* Set the Wine library Unicode argv global variables.
*/
static
void
set_library_wargv
(
char
**
argv
,
const
UNICODE_STRING
*
image
)
{
int
argc
;
WCHAR
*
p
,
**
wargv
;
DWORD
total
=
0
;
if
(
image
)
total
+=
1
+
image
->
Length
/
sizeof
(
WCHAR
);
for
(
argc
=
(
image
!=
NULL
);
argv
[
argc
];
argc
++
)
total
+=
ntdll_umbstowcs
(
0
,
argv
[
argc
],
strlen
(
argv
[
argc
])
+
1
,
NULL
,
0
);
wargv
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
total
*
sizeof
(
WCHAR
)
+
(
argc
+
1
)
*
sizeof
(
*
wargv
)
);
p
=
(
WCHAR
*
)(
wargv
+
argc
+
1
);
if
(
image
)
{
strcpyW
(
p
,
image
->
Buffer
);
wargv
[
0
]
=
p
;
p
+=
1
+
image
->
Length
/
sizeof
(
WCHAR
);
total
-=
1
+
image
->
Length
/
sizeof
(
WCHAR
);
}
for
(
argc
=
(
image
!=
NULL
);
argv
[
argc
];
argc
++
)
{
DWORD
reslen
=
ntdll_umbstowcs
(
0
,
argv
[
argc
],
strlen
(
argv
[
argc
])
+
1
,
p
,
total
);
wargv
[
argc
]
=
p
;
p
+=
reslen
;
total
-=
reslen
;
}
wargv
[
argc
]
=
NULL
;
__wine_main_argc
=
argc
;
__wine_main_wargv
=
wargv
;
}
/******************************************************************************
* NtQuerySystemEnvironmentValue [NTDLL.@]
*/
...
...
@@ -1034,6 +1073,7 @@ void init_user_process_params( SIZE_T data_size )
params
->
Environment
=
build_initial_environment
(
__wine_get_main_environment
()
);
get_current_directory
(
&
params
->
CurrentDirectory
.
DosPath
);
get_image_path
(
__wine_main_argv
[
0
],
&
params
->
ImagePathName
);
set_library_wargv
(
__wine_main_argv
,
&
params
->
ImagePathName
);
if
(
isatty
(
0
)
||
isatty
(
1
)
||
isatty
(
2
))
params
->
ConsoleHandle
=
(
HANDLE
)
2
;
/* see kernel32/kernel_private.h */
...
...
@@ -1103,6 +1143,8 @@ void init_user_process_params( SIZE_T data_size )
else
params
->
Environment
[
0
]
=
0
;
}
set_library_wargv
(
__wine_main_argv
,
NULL
);
done:
RtlFreeHeap
(
GetProcessHeap
(),
0
,
info
);
if
(
RtlSetCurrentDirectory_U
(
&
params
->
CurrentDirectory
.
DosPath
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment