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
a511057f
Commit
a511057f
authored
Oct 22, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Move Unix environment initialization to ntdll.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
cac95992
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
57 deletions
+73
-57
process.c
dlls/kernel32/process.c
+1
-57
env.c
dlls/ntdll/env.c
+72
-0
No files found.
dlls/kernel32/process.c
View file @
a511057f
...
...
@@ -66,13 +66,6 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
process
);
WINE_DECLARE_DEBUG_CHANNEL
(
relay
);
#ifdef __APPLE__
extern
char
**
__wine_get_main_environment
(
void
);
#else
extern
char
**
__wine_main_environ
;
static
char
**
__wine_get_main_environment
(
void
)
{
return
__wine_main_environ
;
}
#endif
typedef
struct
{
LPSTR
lpEnvAddress
;
...
...
@@ -456,52 +449,6 @@ static BOOL find_exe_file( const WCHAR *name, WCHAR *buffer, int buflen, HANDLE
/***********************************************************************
* build_initial_environment
*
* Build the Win32 environment from the Unix environment
*/
static
BOOL
build_initial_environment
(
void
)
{
SIZE_T
size
=
1
;
char
**
e
;
WCHAR
*
p
,
*
endptr
;
void
*
ptr
;
char
**
env
=
__wine_get_main_environment
();
/* Compute the total size of the Unix environment */
for
(
e
=
env
;
*
e
;
e
++
)
{
if
(
is_special_env_var
(
*
e
))
continue
;
size
+=
MultiByteToWideChar
(
CP_UNIXCP
,
0
,
*
e
,
-
1
,
NULL
,
0
);
}
size
*=
sizeof
(
WCHAR
);
if
(
!
(
ptr
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
size
)))
return
FALSE
;
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
Environment
=
p
=
ptr
;
endptr
=
p
+
size
/
sizeof
(
WCHAR
);
/* And fill it with the Unix environment */
for
(
e
=
env
;
*
e
;
e
++
)
{
char
*
str
=
*
e
;
/* skip Unix special variables and use the Wine variants instead */
if
(
!
strncmp
(
str
,
"WINE"
,
4
))
{
if
(
is_special_env_var
(
str
+
4
))
str
+=
4
;
else
if
(
!
strncmp
(
str
,
"WINEPRELOADRESERVE="
,
19
))
continue
;
/* skip it */
}
else
if
(
is_special_env_var
(
str
))
continue
;
/* skip it */
MultiByteToWideChar
(
CP_UNIXCP
,
0
,
str
,
-
1
,
p
,
endptr
-
p
);
p
+=
strlenW
(
p
)
+
1
;
}
*
p
=
0
;
return
TRUE
;
}
/***********************************************************************
* set_registry_variables
*
* Set environment variables by enumerating the values of a key;
...
...
@@ -1255,11 +1202,8 @@ void * CDECL __wine_kernel_init(void)
LOCALE_Init
();
if
(
!
p
arams
->
Environment
)
if
(
!
p
eb
->
ProcessParameters
->
WindowTitle
.
Buffer
)
{
/* Copy the parent environment */
if
(
!
build_initial_environment
())
exit
(
1
);
/* convert old configuration to new format */
convert_old_config
();
...
...
dlls/ntdll/env.c
View file @
a511057f
...
...
@@ -35,6 +35,7 @@
#define WIN32_NO_STATUS
#include "windef.h"
#include "winternl.h"
#include "wine/library.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "ntdll_misc.h"
...
...
@@ -55,6 +56,76 @@ static inline SIZE_T get_env_length( const WCHAR *env )
return
end
+
1
-
env
;
}
#ifdef __APPLE__
extern
char
**
__wine_get_main_environment
(
void
);
#else
extern
char
**
__wine_main_environ
;
static
char
**
__wine_get_main_environment
(
void
)
{
return
__wine_main_environ
;
}
#endif
/***********************************************************************
* is_special_env_var
*
* Check if an environment variable needs to be handled specially when
* passed through the Unix environment (i.e. prefixed with "WINE").
*/
static
inline
BOOL
is_special_env_var
(
const
char
*
var
)
{
return
(
!
strncmp
(
var
,
"PATH="
,
sizeof
(
"PATH="
)
-
1
)
||
!
strncmp
(
var
,
"PWD="
,
sizeof
(
"PWD="
)
-
1
)
||
!
strncmp
(
var
,
"HOME="
,
sizeof
(
"HOME="
)
-
1
)
||
!
strncmp
(
var
,
"TEMP="
,
sizeof
(
"TEMP="
)
-
1
)
||
!
strncmp
(
var
,
"TMP="
,
sizeof
(
"TMP="
)
-
1
)
||
!
strncmp
(
var
,
"QT_"
,
sizeof
(
"QT_"
)
-
1
)
||
!
strncmp
(
var
,
"VK_"
,
sizeof
(
"VK_"
)
-
1
));
}
/***********************************************************************
* build_initial_environment
*
* Build the Win32 environment from the Unix environment
*/
static
WCHAR
*
build_initial_environment
(
char
**
env
)
{
SIZE_T
size
=
1
;
char
**
e
;
WCHAR
*
p
,
*
ptr
;
/* compute the total size of the Unix environment */
for
(
e
=
env
;
*
e
;
e
++
)
{
if
(
is_special_env_var
(
*
e
))
continue
;
size
+=
ntdll_umbstowcs
(
0
,
*
e
,
strlen
(
*
e
)
+
1
,
NULL
,
0
);
}
if
(
!
(
ptr
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
WCHAR
)
)))
return
NULL
;
p
=
ptr
;
/* and fill it with the Unix environment */
for
(
e
=
env
;
*
e
;
e
++
)
{
char
*
str
=
*
e
;
/* skip Unix special variables and use the Wine variants instead */
if
(
!
strncmp
(
str
,
"WINE"
,
4
))
{
if
(
is_special_env_var
(
str
+
4
))
str
+=
4
;
else
if
(
!
strncmp
(
str
,
"WINEPRELOADRESERVE="
,
19
))
continue
;
/* skip it */
}
else
if
(
is_special_env_var
(
str
))
continue
;
/* skip it */
ntdll_umbstowcs
(
0
,
str
,
strlen
(
str
)
+
1
,
p
,
size
-
(
p
-
ptr
)
);
p
+=
strlenW
(
p
)
+
1
;
}
*
p
=
0
;
return
ptr
;
}
/***********************************************************************
* get_current_directory
*
...
...
@@ -644,6 +715,7 @@ void init_user_process_params( SIZE_T data_size )
return
;
NtCurrentTeb
()
->
Peb
->
ProcessParameters
=
params
;
params
->
Environment
=
build_initial_environment
(
__wine_get_main_environment
()
);
get_current_directory
(
&
params
->
CurrentDirectory
.
DosPath
);
if
(
isatty
(
0
)
||
isatty
(
1
)
||
isatty
(
2
))
...
...
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