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
ec5925a8
Commit
ec5925a8
authored
Mar 23, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Set the additional environment variables from the Unix side.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
5246f34a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
51 deletions
+79
-51
env.c
dlls/ntdll/env.c
+0
-51
env.c
dlls/ntdll/unix/env.c
+79
-0
No files found.
dlls/ntdll/env.c
View file @
ec5925a8
...
...
@@ -109,55 +109,6 @@ static WCHAR *get_registry_value( WCHAR *env, HKEY hkey, const WCHAR *name )
/***********************************************************************
* set_additional_environment
*
* Set some additional environment variables not specified in the registry.
*/
static
void
set_additional_environment
(
WCHAR
**
env
)
{
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
;
WCHAR
*
val
;
HANDLE
hkey
;
/* set the user profile variables */
InitializeObjectAttributes
(
&
attr
,
&
nameW
,
0
,
0
,
NULL
);
RtlInitUnicodeString
(
&
nameW
,
L"
\\
Registry
\\
Machine
\\
Software
\\
Microsoft
\\
Windows NT
\\
"
"CurrentVersion
\\
ProfileList"
);
if
(
!
NtOpenKey
(
&
hkey
,
KEY_READ
,
&
attr
))
{
if
((
val
=
get_registry_value
(
*
env
,
hkey
,
L"ProgramData"
)))
{
set_env_var
(
env
,
L"ALLUSERSPROFILE"
,
val
);
set_env_var
(
env
,
L"ProgramData"
,
val
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
val
);
}
if
((
val
=
get_registry_value
(
*
env
,
hkey
,
L"Public"
)))
{
set_env_var
(
env
,
L"PUBLIC"
,
val
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
val
);
}
NtClose
(
hkey
);
}
/* set the computer name */
RtlInitUnicodeString
(
&
nameW
,
L"
\\
Registry
\\
Machine
\\
System
\\
CurrentControlSet
\\
Control
\\
"
"ComputerName
\\
ActiveComputerName"
);
if
(
!
NtOpenKey
(
&
hkey
,
KEY_READ
,
&
attr
))
{
if
((
val
=
get_registry_value
(
*
env
,
hkey
,
L"ComputerName"
)))
{
set_env_var
(
env
,
L"COMPUTERNAME"
,
val
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
val
);
}
NtClose
(
hkey
);
}
}
/***********************************************************************
* set_wow64_environment
*
* Set the environment variables that change across 32/64/Wow64.
...
...
@@ -844,8 +795,6 @@ void init_user_process_params(void)
if
(
!
params
->
DllPath
.
MaximumLength
)
/* not inherited from parent process */
{
set_additional_environment
(
&
params
->
Environment
);
get_image_path
(
params
->
ImagePathName
.
Buffer
,
image
,
sizeof
(
image
)
);
RtlInitUnicodeString
(
&
params
->
ImagePathName
,
image
);
...
...
dlls/ntdll/unix/env.c
View file @
ec5925a8
...
...
@@ -1351,6 +1351,36 @@ static void add_registry_variables( WCHAR **env, SIZE_T *pos, SIZE_T *size, HAND
/***********************************************************************
* get_registry_value
*/
static
WCHAR
*
get_registry_value
(
WCHAR
*
env
,
SIZE_T
pos
,
HKEY
key
,
const
WCHAR
*
name
)
{
WCHAR
buffer
[
offsetof
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
[
1024
*
sizeof
(
WCHAR
)])];
KEY_VALUE_PARTIAL_INFORMATION
*
info
=
(
KEY_VALUE_PARTIAL_INFORMATION
*
)
buffer
;
DWORD
len
,
size
=
sizeof
(
buffer
)
-
sizeof
(
WCHAR
);
WCHAR
*
ret
=
NULL
;
UNICODE_STRING
nameW
;
init_unicode_string
(
&
nameW
,
name
);
if
(
NtQueryValueKey
(
key
,
&
nameW
,
KeyValuePartialInformation
,
buffer
,
size
,
&
size
))
return
NULL
;
if
(
size
<=
offsetof
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
))
return
NULL
;
len
=
size
-
offsetof
(
KEY_VALUE_PARTIAL_INFORMATION
,
Data
);
if
(
info
->
Type
==
REG_EXPAND_SZ
)
{
ret
=
expand_value
(
env
,
pos
,
(
WCHAR
*
)
info
->
Data
,
len
/
sizeof
(
WCHAR
)
);
}
else
{
ret
=
malloc
(
len
+
sizeof
(
WCHAR
)
);
memcpy
(
ret
,
info
->
Data
,
len
);
ret
[
len
/
sizeof
(
WCHAR
)]
=
0
;
}
return
ret
;
}
/***********************************************************************
* add_registry_environment
*
* Set the environment variables specified in the registry.
...
...
@@ -1364,8 +1394,27 @@ static void add_registry_environment( WCHAR **env, SIZE_T *pos, SIZE_T *size )
'\\'
,
'C'
,
'o'
,
'n'
,
't'
,
'r'
,
'o'
,
'l'
,
'\\'
,
'S'
,
'e'
,
's'
,
's'
,
'i'
,
'o'
,
'n'
,
' '
,
'M'
,
'a'
,
'n'
,
'a'
,
'g'
,
'e'
,
'r'
,
'\\'
,
'E'
,
'n'
,
'v'
,
'i'
,
'r'
,
'o'
,
'n'
,
'm'
,
'e'
,
'n'
,
't'
,
0
};
static
const
WCHAR
profileW
[]
=
{
'\\'
,
'R'
,
'e'
,
'g'
,
'i'
,
's'
,
't'
,
'r'
,
'y'
,
'\\'
,
'M'
,
'a'
,
'c'
,
'h'
,
'i'
,
'n'
,
'e'
,
'\\'
,
'S'
,
'o'
,
'f'
,
't'
,
'w'
,
'a'
,
'r'
,
'e'
,
'\\'
,
'M'
,
'i'
,
'c'
,
'r'
,
'o'
,
's'
,
'o'
,
'f'
,
't'
,
'\\'
,
'W'
,
'i'
,
'n'
,
'd'
,
'o'
,
'w'
,
's'
,
' '
,
'N'
,
'T'
,
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
,
'M'
,
'E'
,
0
};
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
;
WCHAR
*
value
;
HANDLE
key
;
InitializeObjectAttributes
(
&
attr
,
&
nameW
,
0
,
0
,
NULL
);
...
...
@@ -1385,6 +1434,36 @@ static void add_registry_environment( WCHAR **env, SIZE_T *pos, SIZE_T *size )
add_registry_variables
(
env
,
pos
,
size
,
key
);
NtClose
(
key
);
}
/* set the user profile variables */
init_unicode_string
(
&
nameW
,
profileW
);
if
(
!
NtOpenKey
(
&
key
,
KEY_READ
,
&
attr
))
{
if
((
value
=
get_registry_value
(
*
env
,
*
pos
,
key
,
progdataW
)))
{
set_env_var
(
env
,
pos
,
size
,
allusersW
,
wcslen
(
allusersW
),
value
);
set_env_var
(
env
,
pos
,
size
,
progdataW
,
wcslen
(
progdataW
),
value
);
free
(
value
);
}
if
((
value
=
get_registry_value
(
*
env
,
*
pos
,
key
,
publicW
)))
{
set_env_var
(
env
,
pos
,
size
,
publicW
,
wcslen
(
publicW
),
value
);
free
(
value
);
}
NtClose
(
key
);
}
/* set the computer name */
init_unicode_string
(
&
nameW
,
computerW
);
if
(
!
NtOpenKey
(
&
key
,
KEY_READ
,
&
attr
))
{
if
((
value
=
get_registry_value
(
*
env
,
*
pos
,
key
,
computernameW
)))
{
set_env_var
(
env
,
pos
,
size
,
computernameW
,
wcslen
(
computernameW
),
value
);
free
(
value
);
}
NtClose
(
key
);
}
}
...
...
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