Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
6b528d52
Commit
6b528d52
authored
Oct 22, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Move additional environment initialization to ntdll.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
628ca4aa
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
2 deletions
+119
-2
process.c
dlls/kernel32/process.c
+0
-2
env.c
dlls/ntdll/env.c
+119
-0
No files found.
dlls/kernel32/process.c
View file @
6b528d52
...
...
@@ -1228,9 +1228,7 @@ void * CDECL __wine_kernel_init(void)
{
/* convert old configuration to new format */
convert_old_config
();
got_environment
=
has_registry_environment
();
set_additional_environment
();
}
init_windows_dirs
();
...
...
dlls/ntdll/env.c
View file @
6b528d52
...
...
@@ -206,6 +206,124 @@ static void set_registry_environment( WCHAR **env )
/***********************************************************************
* get_registry_value
*/
static
WCHAR
*
get_registry_value
(
WCHAR
*
env
,
HKEY
hkey
,
const
WCHAR
*
name
)
{
char
buffer
[
1024
*
sizeof
(
WCHAR
)
+
sizeof
(
KEY_VALUE_PARTIAL_INFORMATION
)];
KEY_VALUE_PARTIAL_INFORMATION
*
info
=
(
KEY_VALUE_PARTIAL_INFORMATION
*
)
buffer
;
DWORD
len
,
size
=
sizeof
(
buffer
);
WCHAR
*
ret
=
NULL
;
UNICODE_STRING
nameW
;
RtlInitUnicodeString
(
&
nameW
,
name
);
if
(
NtQueryValueKey
(
hkey
,
&
nameW
,
KeyValuePartialInformation
,
buffer
,
size
,
&
size
))
return
NULL
;
if
(
size
<=
FIELD_OFFSET
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
))
return
NULL
;
len
=
(
size
-
FIELD_OFFSET
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
))
/
sizeof
(
WCHAR
);
if
(
info
->
Type
==
REG_EXPAND_SZ
)
{
UNICODE_STRING
value
,
expanded
;
value
.
MaximumLength
=
len
*
sizeof
(
WCHAR
);
value
.
Buffer
=
(
WCHAR
*
)
info
->
Data
;
if
(
!
value
.
Buffer
[
len
-
1
])
len
--
;
/* don't count terminating null if any */
value
.
Length
=
len
*
sizeof
(
WCHAR
);
expanded
.
Length
=
expanded
.
MaximumLength
=
1024
*
sizeof
(
WCHAR
);
if
(
!
(
expanded
.
Buffer
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
expanded
.
MaximumLength
)))
return
NULL
;
if
(
!
RtlExpandEnvironmentStrings_U
(
env
,
&
value
,
&
expanded
,
NULL
))
ret
=
expanded
.
Buffer
;
else
RtlFreeUnicodeString
(
&
expanded
);
}
else
if
(
info
->
Type
==
REG_SZ
)
{
if
((
ret
=
RtlAllocateHeap
(
GetProcessHeap
(),
0
,
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
memcpy
(
ret
,
info
->
Data
,
len
*
sizeof
(
WCHAR
)
);
ret
[
len
]
=
0
;
}
}
return
ret
;
}
/***********************************************************************
* set_additional_environment
*
* Set some additional environment variables not specified in the registry.
*/
static
void
set_additional_environment
(
WCHAR
**
env
)
{
static
const
WCHAR
profile_keyW
[]
=
{
'\\'
,
'R'
,
'e'
,
'g'
,
'i'
,
's'
,
't'
,
'r'
,
'y'
,
'\\'
,
'M'
,
'a'
,
'c'
,
'h'
,
'i'
,
'n'
,
'e'
,
'\\'
,
'S'
,
'o'
,
'f'
,
't'
,
'w'
,
'a'
,
'r'
,
'e'
,
'\\'
,
'M'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,
'N'
,
'A'
,
'M'
,
'E'
,
0
};
static
const
WCHAR
allusersW
[]
=
{
'A'
,
'L'
,
'L'
,
'U'
,
'S'
,
'E'
,
'R'
,
'S'
,
'P'
,
'R'
,
'O'
,
'F'
,
'I'
,
'L'
,
'E'
,
0
};
static
const
WCHAR
programdataW
[]
=
{
'P'
,
'r'
,
'o'
,
'g'
,
'r'
,
'a'
,
'm'
,
'D'
,
'a'
,
't'
,
'a'
,
0
};
static
const
WCHAR
publicW
[]
=
{
'P'
,
'U'
,
'B'
,
'L'
,
'I'
,
'C'
,
0
};
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
,
valW
;
WCHAR
*
val
;
HANDLE
hkey
;
/* set the user profile variables */
InitializeObjectAttributes
(
&
attr
,
&
nameW
,
0
,
0
,
NULL
);
RtlInitUnicodeString
(
&
nameW
,
profile_keyW
);
if
(
!
NtOpenKey
(
&
hkey
,
KEY_READ
,
&
attr
))
{
if
((
val
=
get_registry_value
(
*
env
,
hkey
,
programdataW
)))
{
RtlInitUnicodeString
(
&
valW
,
val
);
RtlInitUnicodeString
(
&
nameW
,
allusersW
);
RtlSetEnvironmentVariable
(
env
,
&
nameW
,
&
valW
);
RtlInitUnicodeString
(
&
nameW
,
programdataW
);
RtlSetEnvironmentVariable
(
env
,
&
nameW
,
&
valW
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
val
);
}
if
((
val
=
get_registry_value
(
*
env
,
hkey
,
public_valueW
)))
{
RtlInitUnicodeString
(
&
valW
,
val
);
RtlInitUnicodeString
(
&
nameW
,
publicW
);
RtlSetEnvironmentVariable
(
env
,
&
nameW
,
&
valW
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
val
);
}
NtClose
(
hkey
);
}
/* set the computer name */
RtlInitUnicodeString
(
&
nameW
,
computer_keyW
);
if
(
!
NtOpenKey
(
&
hkey
,
KEY_READ
,
&
attr
))
{
if
((
val
=
get_registry_value
(
*
env
,
hkey
,
computer_valueW
)))
{
RtlInitUnicodeString
(
&
valW
,
val
);
RtlInitUnicodeString
(
&
nameW
,
computernameW
);
RtlSetEnvironmentVariable
(
env
,
&
nameW
,
&
valW
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
val
);
}
NtClose
(
hkey
);
}
}
/***********************************************************************
* build_initial_environment
*
* Build the Win32 environment from the Unix environment
...
...
@@ -246,6 +364,7 @@ static WCHAR *build_initial_environment( char **env )
}
*
p
=
0
;
set_registry_environment
(
&
ptr
);
set_additional_environment
(
&
ptr
);
return
ptr
;
}
...
...
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