ntdll: Add a global constant for the system directory.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-03-19 11:24:46 +01:00
parent 1d66a108b9
commit 74390cead3
4 changed files with 12 additions and 14 deletions

View File

@ -76,6 +76,10 @@ static LANGID user_ui_language, system_ui_language;
static char system_locale[LOCALE_NAME_MAX_LENGTH];
static char user_locale[LOCALE_NAME_MAX_LENGTH];
/* system directory with trailing backslash */
const WCHAR system_dir[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','t','e','m','3','2','\\',0};
static struct
{
USHORT *data;
@ -149,8 +153,6 @@ static void *read_nls_file( ULONG type, ULONG id )
static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file )
{
static const WCHAR systemdirW[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','t','e','m','3','2','\\',0};
static const WCHAR sortdirW[] = {'\\','?','?','\\','C',':','\\','w','i','n','d','o','w','s','\\',
'g','l','o','b','a','l','i','z','a','t','i','o','n','\\',
's','o','r','t','i','n','g','\\',0};
@ -165,7 +167,7 @@ static NTSTATUS open_nls_data_file( ULONG type, ULONG id, HANDLE *file )
if (!path) return STATUS_OBJECT_NAME_NOT_FOUND;
/* try to open file in system dir */
wcscpy( buffer, type == NLS_SECTION_SORTKEYS ? sortdirW : systemdirW );
wcscpy( buffer, type == NLS_SECTION_SORTKEYS ? sortdirW : system_dir );
p = strrchr( path, '/' ) + 1;
ascii_to_unicode( buffer + wcslen(buffer), p, strlen(p) + 1 );
init_unicode_string( &valueW, buffer );
@ -1609,8 +1611,6 @@ static void run_wineboot( WCHAR *env, SIZE_T size )
static const WCHAR cmdlineW[] = {'"','C',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','t','e','m','3','2','\\','w','i','n','e','b','o','o','t','.','e','x','e','"',
' ','-','-','i','n','i','t',0};
static const WCHAR sysdirW[] = {'C',':','\\','w','i','n','d','o','w','s',
'\\','s','y','s','t','e','m','3','2',0};
RTL_USER_PROCESS_PARAMETERS params = { sizeof(params), sizeof(params) };
PS_ATTRIBUTE_LIST ps_attr;
PS_CREATE_INFO create_info;
@ -1635,8 +1635,8 @@ static void run_wineboot( WCHAR *env, SIZE_T size )
params.Flags = PROCESS_PARAMS_FLAG_NORMALIZED;
params.Environment = env;
params.EnvironmentSize = size;
init_unicode_string( &params.CurrentDirectory.DosPath, sysdirW );
init_unicode_string( &params.DllPath, sysdirW );
init_unicode_string( &params.CurrentDirectory.DosPath, system_dir + 4 );
init_unicode_string( &params.DllPath, system_dir + 4 );
init_unicode_string( &params.ImagePathName, appnameW + 4 );
init_unicode_string( &params.CommandLine, cmdlineW );
init_unicode_string( &params.WindowTitle, appnameW + 4 );

View File

@ -381,8 +381,6 @@ static enum loadorder get_load_order_value( HANDLE std_key, HANDLE app_key, WCHA
enum loadorder CDECL get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_name )
{
static const WCHAR prefixW[] = {'\\','?','?','\\'};
static const WCHAR system_dir[] = {'C',':','\\','w','i','n','d','o','w','s',
'\\','s','y','s','t','e','m','3','2'};
enum loadorder ret = LO_INVALID;
HANDLE std_key, app_key = 0;
const WCHAR *path = nt_name->Buffer;
@ -398,9 +396,9 @@ enum loadorder CDECL get_load_order( const WCHAR *app_name, const UNICODE_STRING
/* Strip path information if the module resides in the system directory
*/
if (!wcsnicmp( system_dir, path, ARRAY_SIZE( system_dir )))
if (!wcsnicmp( system_dir + 4, path, wcslen(system_dir) - 4 ))
{
const WCHAR *p = path + ARRAY_SIZE( system_dir );
const WCHAR *p = path + wcslen( system_dir ) - 4;
while (*p == '\\' || *p == '/') p++;
if (!wcschr( p, '\\' ) && !wcschr( p, '/' )) path = p;
}

View File

@ -281,13 +281,12 @@ static startup_info_t *create_startup_info( const RTL_USER_PROCESS_PARAMETERS *p
*/
static BOOL is_builtin_path( UNICODE_STRING *path, BOOL *is_64bit )
{
static const WCHAR systemW[] = {'\\','?','?','\\','c',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','t','e','m','3','2','\\'};
static const WCHAR wow64W[] = {'\\','?','?','\\','c',':','\\','w','i','n','d','o','w','s','\\',
's','y','s','w','o','w','6','4'};
*is_64bit = is_win64;
if (path->Length > sizeof(systemW) && !wcsnicmp( path->Buffer, systemW, ARRAY_SIZE(systemW) ))
if (path->Length > wcslen(system_dir) * sizeof(WCHAR) &&
!wcsnicmp( path->Buffer, system_dir, wcslen(system_dir) ))
{
#ifndef _WIN64
if (NtCurrentTeb64() && NtCurrentTeb64()->TlsSlots[WOW64_TLS_FILESYSREDIR]) *is_64bit = TRUE;

View File

@ -122,6 +122,7 @@ extern int main_argc DECLSPEC_HIDDEN;
extern char **main_argv DECLSPEC_HIDDEN;
extern char **main_envp DECLSPEC_HIDDEN;
extern WCHAR **main_wargv DECLSPEC_HIDDEN;
extern const WCHAR system_dir[] DECLSPEC_HIDDEN;
extern unsigned int server_cpus DECLSPEC_HIDDEN;
extern BOOL is_wow64 DECLSPEC_HIDDEN;
extern BOOL process_exiting DECLSPEC_HIDDEN;