ntdll: Avoid calling RtlInit(Ansi|Unicode)String on a static constant.

This commit is contained in:
Alex Henrie 2023-02-10 23:39:04 -07:00 committed by Alexandre Julliard
parent 94208fcee5
commit dfe047ee4c
2 changed files with 16 additions and 20 deletions

View file

@ -2195,10 +2195,9 @@ static NTSTATUS build_module( LPCWSTR load_path, const UNICODE_STRING *nt_name,
*/
static void build_ntdll_module( HMODULE module )
{
UNICODE_STRING nt_name;
UNICODE_STRING nt_name = RTL_CONSTANT_STRING( L"\\??\\C:\\windows\\system32\\ntdll.dll" );
WINE_MODREF *wm;
RtlInitUnicodeString( &nt_name, L"\\??\\C:\\windows\\system32\\ntdll.dll" );
wm = alloc_module( module, &nt_name, TRUE );
assert( wm );
wm->ldr.Flags &= ~LDR_DONT_RESOLVE_REFS;
@ -2370,7 +2369,7 @@ static inline WCHAR *append_path( WCHAR *p, const WCHAR *str, int len )
static NTSTATUS get_dll_load_path( LPCWSTR module, LPCWSTR dll_dir, ULONG safe_mode, WCHAR **path )
{
const WCHAR *mod_end = module;
UNICODE_STRING name, value;
UNICODE_STRING name = RTL_CONSTANT_STRING( L"PATH" ), value;
WCHAR *p, *ret;
int len = ARRAY_SIZE(system_path) + 1, path_len = 0;
@ -2380,7 +2379,6 @@ static NTSTATUS get_dll_load_path( LPCWSTR module, LPCWSTR dll_dir, ULONG safe_m
len += (mod_end - module) + 1;
}
RtlInitUnicodeString( &name, L"PATH" );
value.Length = 0;
value.MaximumLength = 0;
value.Buffer = NULL;
@ -3951,20 +3949,22 @@ static void process_breakpoint(void)
static void load_global_options(void)
{
OBJECT_ATTRIBUTES attr;
UNICODE_STRING name_str, val_str;
UNICODE_STRING bootstrap_mode_str = RTL_CONSTANT_STRING( L"WINEBOOTSTRAPMODE" );
UNICODE_STRING session_manager_str =
RTL_CONSTANT_STRING( L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager" );
UNICODE_STRING val_str;
HANDLE hkey;
RtlInitUnicodeString( &name_str, L"WINEBOOTSTRAPMODE" );
val_str.MaximumLength = 0;
is_prefix_bootstrap = RtlQueryEnvironmentVariable_U( NULL, &name_str, &val_str ) != STATUS_VARIABLE_NOT_FOUND;
is_prefix_bootstrap =
RtlQueryEnvironmentVariable_U( NULL, &bootstrap_mode_str, &val_str ) != STATUS_VARIABLE_NOT_FOUND;
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &name_str;
attr.ObjectName = &session_manager_str;
attr.Attributes = OBJ_CASE_INSENSITIVE;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &name_str, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager" );
if (!NtOpenKey( &hkey, KEY_QUERY_VALUE, &attr ))
{
@ -4019,12 +4019,11 @@ static void map_wow64cpu(void)
{
SIZE_T size = 0;
OBJECT_ATTRIBUTES attr;
UNICODE_STRING string;
UNICODE_STRING string = RTL_CONSTANT_STRING( L"\\??\\C:\\windows\\sysnative\\wow64cpu.dll" );
HANDLE file, section;
IO_STATUS_BLOCK io;
NTSTATUS status;
RtlInitUnicodeString( &string, L"\\??\\C:\\windows\\sysnative\\wow64cpu.dll" );
InitializeObjectAttributes( &attr, &string, 0, NULL, NULL );
if ((status = NtOpenFile( &file, GENERIC_READ | SYNCHRONIZE, &attr, &io, FILE_SHARE_READ,
FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE )))
@ -4114,7 +4113,8 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
if (!imports_fixup_done)
{
MEMORY_BASIC_INFORMATION meminfo;
ANSI_STRING func_name;
ANSI_STRING base_thread_init_thunk = RTL_CONSTANT_STRING( "BaseThreadInitThunk" );
ANSI_STRING ctrl_routine = RTL_CONSTANT_STRING( "CtrlRoutine" );
WINE_MODREF *kernel32;
PEB *peb = NtCurrentTeb()->Peb;
@ -4154,15 +4154,13 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
NtTerminateProcess( GetCurrentProcess(), status );
}
node_kernel32 = kernel32->ldr.DdagNode;
RtlInitAnsiString( &func_name, "BaseThreadInitThunk" );
if ((status = LdrGetProcedureAddress( kernel32->ldr.DllBase, &func_name,
if ((status = LdrGetProcedureAddress( kernel32->ldr.DllBase, &base_thread_init_thunk,
0, (void **)&pBaseThreadInitThunk )) != STATUS_SUCCESS)
{
MESSAGE( "wine: could not find BaseThreadInitThunk in kernel32.dll, status %lx\n", status );
NtTerminateProcess( GetCurrentProcess(), status );
}
RtlInitAnsiString( &func_name, "CtrlRoutine" );
LdrGetProcedureAddress( kernel32->ldr.DllBase, &func_name, 0, (void **)&pCtrlRoutine );
LdrGetProcedureAddress( kernel32->ldr.DllBase, &ctrl_routine, 0, (void **)&pCtrlRoutine );
actctx_init();
locale_init();
@ -4532,9 +4530,8 @@ NTSTATUS WINAPI RtlGetExePath( PCWSTR name, PWSTR *path )
/* same check as NeedCurrentDirectoryForExePathW */
if (!wcschr( name, '\\' ))
{
UNICODE_STRING name, value = { 0 };
UNICODE_STRING name = RTL_CONSTANT_STRING( L"NoDefaultCurrentDirectoryInExePath" ), value = { 0 };
RtlInitUnicodeString( &name, L"NoDefaultCurrentDirectoryInExePath" );
if (RtlQueryEnvironmentVariable_U( NULL, &name, &value ) != STATUS_VARIABLE_NOT_FOUND)
dlldir = L"";
}

View file

@ -165,7 +165,7 @@ static const WCHAR **load_list( HKEY hkey, const WCHAR *value )
static DWORD WINAPI init_debug_lists( RTL_RUN_ONCE *once, void *param, void **context )
{
OBJECT_ATTRIBUTES attr;
UNICODE_STRING name;
UNICODE_STRING name = RTL_CONSTANT_STRING( L"Software\\Wine\\Debug" );
HANDLE root, hkey;
RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
@ -175,7 +175,6 @@ static DWORD WINAPI init_debug_lists( RTL_RUN_ONCE *once, void *param, void **co
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &name, L"Software\\Wine\\Debug" );
/* @@ Wine registry key: HKCU\Software\Wine\Debug */
if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )) hkey = 0;