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>
This commit is contained in:
parent
75b1db42e5
commit
d47a711e98
|
@ -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_argc) *p___wine_main_argc = main_argc;
|
||||||
if (p___wine_main_argv) *p___wine_main_argv = main_argv;
|
if (p___wine_main_argv) *p___wine_main_argv = main_argv;
|
||||||
if (p___wine_main_wargv) *p___wine_main_wargv = main_wargv;
|
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 );
|
virtual_alloc_thread_stack( &stack, 0, 0, NULL );
|
||||||
teb->Tib.StackBase = stack.StackBase;
|
teb->Tib.StackBase = stack.StackBase;
|
||||||
teb->Tib.StackLimit = stack.StackLimit;
|
teb->Tib.StackLimit = stack.StackLimit;
|
||||||
|
|
|
@ -55,6 +55,8 @@ static struct
|
||||||
|
|
||||||
static const WCHAR separatorsW[] = {',',' ','\t',0};
|
static const WCHAR separatorsW[] = {',',' ','\t',0};
|
||||||
|
|
||||||
|
static HANDLE std_key;
|
||||||
|
static HANDLE app_key;
|
||||||
static BOOL init_done;
|
static BOOL init_done;
|
||||||
|
|
||||||
|
|
||||||
|
@ -221,6 +223,9 @@ static void init_load_order(void)
|
||||||
WCHAR *entry, *next, *order;
|
WCHAR *entry, *next, *order;
|
||||||
const char *overrides = getenv( "WINEDLLOVERRIDES" );
|
const char *overrides = getenv( "WINEDLLOVERRIDES" );
|
||||||
|
|
||||||
|
/* @@ Wine registry key: HKCU\Software\Wine\DllOverrides */
|
||||||
|
open_hkcu_key( "Software\\Wine\\DllOverrides", &std_key );
|
||||||
|
|
||||||
init_done = TRUE;
|
init_done = TRUE;
|
||||||
|
|
||||||
if (!overrides) return;
|
if (!overrides) return;
|
||||||
|
@ -264,37 +269,16 @@ static inline enum loadorder get_env_load_order( const WCHAR *module )
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* get_standard_key
|
* open_app_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
|
|
||||||
*
|
*
|
||||||
* Get the registry key for the app-specific DllOverrides list.
|
* 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};
|
static const WCHAR dlloverridesW[] = {'\\','D','l','l','O','v','e','r','r','i','d','e','s',0};
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
UNICODE_STRING nameW;
|
UNICODE_STRING nameW;
|
||||||
HANDLE root;
|
HANDLE root, app_key = 0;
|
||||||
static HANDLE app_key = (HANDLE)-1;
|
|
||||||
|
|
||||||
if (app_key != (HANDLE)-1) return app_key;
|
|
||||||
|
|
||||||
if (!open_hkcu_key( "Software\\Wine\\AppDefaults", &root ))
|
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 );
|
InitializeObjectAttributes( &attr, &nameW, 0, root, NULL );
|
||||||
|
|
||||||
/* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DllOverrides */
|
/* @@ 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 );
|
NtClose( root );
|
||||||
free( nameW.Buffer );
|
free( nameW.Buffer );
|
||||||
}
|
}
|
||||||
|
@ -372,6 +356,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)
|
* get_load_order (internal)
|
||||||
*
|
*
|
||||||
|
@ -382,21 +378,12 @@ enum loadorder get_load_order( const UNICODE_STRING *nt_name )
|
||||||
{
|
{
|
||||||
static const WCHAR prefixW[] = {'\\','?','?','\\'};
|
static const WCHAR prefixW[] = {'\\','?','?','\\'};
|
||||||
enum loadorder ret = LO_INVALID;
|
enum loadorder ret = LO_INVALID;
|
||||||
HANDLE std_key, app_key = 0;
|
|
||||||
const WCHAR *path = nt_name->Buffer;
|
const WCHAR *path = nt_name->Buffer;
|
||||||
const WCHAR *p, *app_name = NULL;
|
const WCHAR *p, *app_name = NULL;
|
||||||
WCHAR *module, *basename;
|
WCHAR *module, *basename;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (!init_done) init_load_order();
|
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;
|
if (!wcsncmp( path, prefixW, 4 )) path += 4;
|
||||||
|
|
||||||
|
|
|
@ -410,6 +410,7 @@ enum loadorder
|
||||||
LO_DEFAULT /* nothing specified, use default strategy */
|
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;
|
extern enum loadorder get_load_order( const UNICODE_STRING *nt_name ) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
static inline size_t ntdll_wcslen( const WCHAR *str )
|
static inline size_t ntdll_wcslen( const WCHAR *str )
|
||||||
|
|
Loading…
Reference in New Issue