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
d47a711e
Commit
d47a711e
authored
May 05, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Open the per-application key for load order at startup.
It avoids accessing process parameters after startup. Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
75b1db42
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
34 deletions
+23
-34
loader.c
dlls/ntdll/unix/loader.c
+1
-0
loadorder.c
dlls/ntdll/unix/loadorder.c
+21
-34
unix_private.h
dlls/ntdll/unix/unix_private.h
+1
-0
No files found.
dlls/ntdll/unix/loader.c
View file @
d47a711e
...
...
@@ -1870,6 +1870,7 @@ static void start_main_thread(void)
if
(
p___wine_main_argc
)
*
p___wine_main_argc
=
main_argc
;
if
(
p___wine_main_argv
)
*
p___wine_main_argv
=
main_argv
;
if
(
p___wine_main_wargv
)
*
p___wine_main_wargv
=
main_wargv
;
set_load_order_app_name
(
main_wargv
[
0
]
);
virtual_alloc_thread_stack
(
&
stack
,
0
,
0
,
NULL
);
teb
->
Tib
.
StackBase
=
stack
.
StackBase
;
teb
->
Tib
.
StackLimit
=
stack
.
StackLimit
;
...
...
dlls/ntdll/unix/loadorder.c
View file @
d47a711e
...
...
@@ -55,6 +55,8 @@ static struct
static
const
WCHAR
separatorsW
[]
=
{
','
,
' '
,
'\t'
,
0
};
static
HANDLE
std_key
;
static
HANDLE
app_key
;
static
BOOL
init_done
;
...
...
@@ -221,6 +223,9 @@ static void init_load_order(void)
WCHAR
*
entry
,
*
next
,
*
order
;
const
char
*
overrides
=
getenv
(
"WINEDLLOVERRIDES"
);
/* @@ Wine registry key: HKCU\Software\Wine\DllOverrides */
open_hkcu_key
(
"Software
\\
Wine
\\
DllOverrides"
,
&
std_key
);
init_done
=
TRUE
;
if
(
!
overrides
)
return
;
...
...
@@ -264,37 +269,16 @@ static inline enum loadorder get_env_load_order( const WCHAR *module )
/***************************************************************************
* get_standard_key
*
* Return a handle to the standard DllOverrides registry section.
*/
static
HANDLE
get_standard_key
(
void
)
{
static
HANDLE
std_key
=
(
HANDLE
)
-
1
;
if
(
std_key
==
(
HANDLE
)
-
1
)
{
/* @@ Wine registry key: HKCU\Software\Wine\DllOverrides */
if
(
open_hkcu_key
(
"Software
\\
Wine
\\
DllOverrides"
,
&
std_key
))
std_key
=
0
;
}
return
std_key
;
}
/***************************************************************************
* get_app_key
* open_app_key
*
* Get the registry key for the app-specific DllOverrides list.
*/
static
HANDLE
get
_app_key
(
const
WCHAR
*
app_name
)
static
HANDLE
open
_app_key
(
const
WCHAR
*
app_name
)
{
static
const
WCHAR
dlloverridesW
[]
=
{
'\\'
,
'D'
,
'l'
,
'l'
,
'O'
,
'v'
,
'e'
,
'r'
,
'r'
,
'i'
,
'd'
,
'e'
,
's'
,
0
};
OBJECT_ATTRIBUTES
attr
;
UNICODE_STRING
nameW
;
HANDLE
root
;
static
HANDLE
app_key
=
(
HANDLE
)
-
1
;
if
(
app_key
!=
(
HANDLE
)
-
1
)
return
app_key
;
HANDLE
root
,
app_key
=
0
;
if
(
!
open_hkcu_key
(
"Software
\\
Wine
\\
AppDefaults"
,
&
root
))
{
...
...
@@ -306,7 +290,7 @@ static HANDLE get_app_key( const WCHAR *app_name )
InitializeObjectAttributes
(
&
attr
,
&
nameW
,
0
,
root
,
NULL
);
/* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DllOverrides */
if
(
NtOpenKey
(
&
app_key
,
KEY_ALL_ACCESS
,
&
attr
))
app_key
=
0
;
NtOpenKey
(
&
app_key
,
KEY_ALL_ACCESS
,
&
attr
)
;
NtClose
(
root
);
free
(
nameW
.
Buffer
);
}
...
...
@@ -373,6 +357,18 @@ static enum loadorder get_load_order_value( HANDLE std_key, HANDLE app_key, WCHA
/***************************************************************************
* set_load_order_app_name
*/
void
set_load_order_app_name
(
const
WCHAR
*
app_name
)
{
const
WCHAR
*
p
;
if
((
p
=
wcsrchr
(
app_name
,
'\\'
)))
app_name
=
p
+
1
;
app_key
=
open_app_key
(
app_name
);
}
/***************************************************************************
* get_load_order (internal)
*
* Return the loadorder of a module.
...
...
@@ -382,21 +378,12 @@ enum loadorder get_load_order( const UNICODE_STRING *nt_name )
{
static
const
WCHAR
prefixW
[]
=
{
'\\'
,
'?'
,
'?'
,
'\\'
};
enum
loadorder
ret
=
LO_INVALID
;
HANDLE
std_key
,
app_key
=
0
;
const
WCHAR
*
path
=
nt_name
->
Buffer
;
const
WCHAR
*
p
,
*
app_name
=
NULL
;
WCHAR
*
module
,
*
basename
;
int
len
;
if
(
!
init_done
)
init_load_order
();
std_key
=
get_standard_key
();
if
(
NtCurrentTeb
()
->
Peb
->
ImageBaseAddress
)
{
app_name
=
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
ImagePathName
.
Buffer
;
if
((
p
=
wcsrchr
(
app_name
,
'\\'
)))
app_name
=
p
+
1
;
app_key
=
get_app_key
(
app_name
);
}
if
(
!
wcsncmp
(
path
,
prefixW
,
4
))
path
+=
4
;
...
...
dlls/ntdll/unix/unix_private.h
View file @
d47a711e
...
...
@@ -410,6 +410,7 @@ enum loadorder
LO_DEFAULT
/* nothing specified, use default strategy */
};
extern
void
set_load_order_app_name
(
const
WCHAR
*
app_name
)
DECLSPEC_HIDDEN
;
extern
enum
loadorder
get_load_order
(
const
UNICODE_STRING
*
nt_name
)
DECLSPEC_HIDDEN
;
static
inline
size_t
ntdll_wcslen
(
const
WCHAR
*
str
)
...
...
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