Commit 9cbbcb40 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

kernelbase: Avoid calling RtlInitUnicodeString on a static constant.

parent 1798bcd5
...@@ -205,12 +205,11 @@ static COORD get_console_font_size( HANDLE handle, DWORD index ) ...@@ -205,12 +205,11 @@ static COORD get_console_font_size( HANDLE handle, DWORD index )
static HANDLE create_console_server( void ) static HANDLE create_console_server( void )
{ {
OBJECT_ATTRIBUTES attr = {sizeof(attr)}; OBJECT_ATTRIBUTES attr = {sizeof(attr)};
UNICODE_STRING string; UNICODE_STRING string = RTL_CONSTANT_STRING( L"\\Device\\ConDrv\\Server" );
IO_STATUS_BLOCK iosb; IO_STATUS_BLOCK iosb;
HANDLE handle; HANDLE handle;
NTSTATUS status; NTSTATUS status;
RtlInitUnicodeString( &string, L"\\Device\\ConDrv\\Server" );
attr.ObjectName = &string; attr.ObjectName = &string;
attr.Attributes = OBJ_INHERIT; attr.Attributes = OBJ_INHERIT;
status = NtCreateFile( &handle, FILE_WRITE_PROPERTIES | FILE_READ_PROPERTIES | SYNCHRONIZE, status = NtCreateFile( &handle, FILE_WRITE_PROPERTIES | FILE_READ_PROPERTIES | SYNCHRONIZE,
...@@ -222,12 +221,11 @@ static HANDLE create_console_server( void ) ...@@ -222,12 +221,11 @@ static HANDLE create_console_server( void )
static HANDLE create_console_reference( HANDLE root ) static HANDLE create_console_reference( HANDLE root )
{ {
OBJECT_ATTRIBUTES attr = {sizeof(attr)}; OBJECT_ATTRIBUTES attr = {sizeof(attr)};
UNICODE_STRING string; UNICODE_STRING string = RTL_CONSTANT_STRING( L"Reference" );
IO_STATUS_BLOCK iosb; IO_STATUS_BLOCK iosb;
HANDLE handle; HANDLE handle;
NTSTATUS status; NTSTATUS status;
RtlInitUnicodeString( &string, L"Reference" );
attr.RootDirectory = root; attr.RootDirectory = root;
attr.ObjectName = &string; attr.ObjectName = &string;
status = NtCreateFile( &handle, FILE_READ_DATA | FILE_WRITE_DATA | FILE_WRITE_PROPERTIES | status = NtCreateFile( &handle, FILE_READ_DATA | FILE_WRITE_DATA | FILE_WRITE_PROPERTIES |
...@@ -466,7 +464,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateConsoleScreenBuffer( DWORD access, DWORD s ...@@ -466,7 +464,7 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateConsoleScreenBuffer( DWORD access, DWORD s
{ {
OBJECT_ATTRIBUTES attr = {sizeof(attr)}; OBJECT_ATTRIBUTES attr = {sizeof(attr)};
IO_STATUS_BLOCK iosb; IO_STATUS_BLOCK iosb;
UNICODE_STRING name; UNICODE_STRING name = RTL_CONSTANT_STRING( L"\\Device\\ConDrv\\ScreenBuffer" );
HANDLE handle; HANDLE handle;
NTSTATUS status; NTSTATUS status;
...@@ -478,7 +476,6 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateConsoleScreenBuffer( DWORD access, DWORD s ...@@ -478,7 +476,6 @@ HANDLE WINAPI DECLSPEC_HOTPATCH CreateConsoleScreenBuffer( DWORD access, DWORD s
return INVALID_HANDLE_VALUE; return INVALID_HANDLE_VALUE;
} }
RtlInitUnicodeString( &name, L"\\Device\\ConDrv\\ScreenBuffer" );
attr.ObjectName = &name; attr.ObjectName = &name;
attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL; attr.SecurityDescriptor = sa ? sa->lpSecurityDescriptor : NULL;
if (sa && sa->bInheritHandle) attr.Attributes |= OBJ_INHERIT; if (sa && sa->bInheritHandle) attr.Attributes |= OBJ_INHERIT;
......
...@@ -398,7 +398,7 @@ static void format_exception_msg( const EXCEPTION_POINTERS *ptr, char *buffer, i ...@@ -398,7 +398,7 @@ static void format_exception_msg( const EXCEPTION_POINTERS *ptr, char *buffer, i
static BOOL start_debugger( EXCEPTION_POINTERS *epointers, HANDLE event ) static BOOL start_debugger( EXCEPTION_POINTERS *epointers, HANDLE event )
{ {
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW; UNICODE_STRING nameW = RTL_CONSTANT_STRING( L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug" );
WCHAR *cmdline, *env, *p, *format = NULL; WCHAR *cmdline, *env, *p, *format = NULL;
HANDLE dbg_key; HANDLE dbg_key;
DWORD autostart = TRUE; DWORD autostart = TRUE;
...@@ -416,7 +416,6 @@ static BOOL start_debugger( EXCEPTION_POINTERS *epointers, HANDLE event ) ...@@ -416,7 +416,6 @@ static BOOL start_debugger( EXCEPTION_POINTERS *epointers, HANDLE event )
attr.Attributes = 0; attr.Attributes = 0;
attr.SecurityDescriptor = NULL; attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, L"\\Registry\\Machine\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug" );
if (!NtOpenKey( &dbg_key, KEY_READ, &attr )) if (!NtOpenKey( &dbg_key, KEY_READ, &attr ))
{ {
......
...@@ -148,7 +148,9 @@ static BOOL add_boot_rename_entry( LPCWSTR source, LPCWSTR dest, DWORD flags ) ...@@ -148,7 +148,9 @@ static BOOL add_boot_rename_entry( LPCWSTR source, LPCWSTR dest, DWORD flags )
static const int info_size = FIELD_OFFSET( KEY_VALUE_PARTIAL_INFORMATION, Data ); static const int info_size = FIELD_OFFSET( KEY_VALUE_PARTIAL_INFORMATION, Data );
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW, source_name, dest_name; UNICODE_STRING session_manager = RTL_CONSTANT_STRING( L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager" );
UNICODE_STRING pending_file_rename_operations = RTL_CONSTANT_STRING( L"PendingFileRenameOperations" );
UNICODE_STRING source_name, dest_name;
KEY_VALUE_PARTIAL_INFORMATION *info; KEY_VALUE_PARTIAL_INFORMATION *info;
BOOL rc = FALSE; BOOL rc = FALSE;
HANDLE key = 0; HANDLE key = 0;
...@@ -172,11 +174,10 @@ static BOOL add_boot_rename_entry( LPCWSTR source, LPCWSTR dest, DWORD flags ) ...@@ -172,11 +174,10 @@ static BOOL add_boot_rename_entry( LPCWSTR source, LPCWSTR dest, DWORD flags )
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = 0; attr.RootDirectory = 0;
attr.ObjectName = &nameW; attr.ObjectName = &session_manager;
attr.Attributes = 0; attr.Attributes = 0;
attr.SecurityDescriptor = NULL; attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager" );
if (NtCreateKey( &key, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ) != STATUS_SUCCESS) if (NtCreateKey( &key, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ) != STATUS_SUCCESS)
{ {
...@@ -194,14 +195,12 @@ static BOOL add_boot_rename_entry( LPCWSTR source, LPCWSTR dest, DWORD flags ) ...@@ -194,14 +195,12 @@ static BOOL add_boot_rename_entry( LPCWSTR source, LPCWSTR dest, DWORD flags )
} }
else len2 = sizeof(WCHAR); /* minimum is the 0 characters for the empty second string */ else len2 = sizeof(WCHAR); /* minimum is the 0 characters for the empty second string */
RtlInitUnicodeString( &nameW, L"PendingFileRenameOperations" );
/* First we check if the key exists and if so how many bytes it already contains. */ /* First we check if the key exists and if so how many bytes it already contains. */
if (NtQueryValueKey( key, &nameW, KeyValuePartialInformation, if (NtQueryValueKey( key, &pending_file_rename_operations, KeyValuePartialInformation,
NULL, 0, &size ) == STATUS_BUFFER_TOO_SMALL) NULL, 0, &size ) == STATUS_BUFFER_TOO_SMALL)
{ {
if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size + len1 + len2 + sizeof(WCHAR) ))) goto done; if (!(buffer = HeapAlloc( GetProcessHeap(), 0, size + len1 + len2 + sizeof(WCHAR) ))) goto done;
if (NtQueryValueKey( key, &nameW, KeyValuePartialInformation, buffer, size, &size )) goto done; if (NtQueryValueKey( key, &pending_file_rename_operations, KeyValuePartialInformation, buffer, size, &size )) goto done;
info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer; info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
if (info->Type != REG_MULTI_SZ) goto done; if (info->Type != REG_MULTI_SZ) goto done;
if (size > sizeof(info)) size -= sizeof(WCHAR); /* remove terminating null (will be added back later) */ if (size > sizeof(info)) size -= sizeof(WCHAR); /* remove terminating null (will be added back later) */
...@@ -231,7 +230,7 @@ static BOOL add_boot_rename_entry( LPCWSTR source, LPCWSTR dest, DWORD flags ) ...@@ -231,7 +230,7 @@ static BOOL add_boot_rename_entry( LPCWSTR source, LPCWSTR dest, DWORD flags )
p = (WCHAR *)(buffer + size); p = (WCHAR *)(buffer + size);
*p = 0; *p = 0;
size += sizeof(WCHAR); size += sizeof(WCHAR);
rc = !NtSetValueKey( key, &nameW, 0, REG_MULTI_SZ, buffer + info_size, size - info_size ); rc = !NtSetValueKey( key, &pending_file_rename_operations, 0, REG_MULTI_SZ, buffer + info_size, size - info_size );
done: done:
RtlFreeUnicodeString( &source_name ); RtlFreeUnicodeString( &source_name );
......
...@@ -107,7 +107,7 @@ static BOOL is_wow6432node( const UNICODE_STRING *name ) ...@@ -107,7 +107,7 @@ static BOOL is_wow6432node( const UNICODE_STRING *name )
static HANDLE open_wow6432node( HANDLE key ) static HANDLE open_wow6432node( HANDLE key )
{ {
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW; UNICODE_STRING nameW = RTL_CONSTANT_STRING( L"Wow6432Node" );
HANDLE ret; HANDLE ret;
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
...@@ -116,7 +116,6 @@ static HANDLE open_wow6432node( HANDLE key ) ...@@ -116,7 +116,6 @@ static HANDLE open_wow6432node( HANDLE key )
attr.Attributes = 0; attr.Attributes = 0;
attr.SecurityDescriptor = NULL; attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL; attr.SecurityQualityOfService = NULL;
RtlInitUnicodeString( &nameW, L"Wow6432Node" );
if (NtOpenKeyEx( &ret, MAXIMUM_ALLOWED, &attr, 0 )) ret = 0; if (NtOpenKeyEx( &ret, MAXIMUM_ALLOWED, &attr, 0 )) ret = 0;
return ret; return ret;
} }
...@@ -2312,7 +2311,7 @@ LSTATUS WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename ) ...@@ -2312,7 +2311,7 @@ LSTATUS WINAPI RegLoadKeyW( HKEY hkey, LPCWSTR subkey, LPCWSTR filename )
*/ */
LSTATUS WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename ) LSTATUS WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename )
{ {
UNICODE_STRING subkeyW, filenameW; UNICODE_STRING subkeyW = { 0, 0, NULL }, filenameW = { 0, 0, NULL };
STRING subkeyA, filenameA; STRING subkeyA, filenameA;
NTSTATUS status; NTSTATUS status;
LONG ret; LONG ret;
...@@ -2320,8 +2319,6 @@ LSTATUS WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename ) ...@@ -2320,8 +2319,6 @@ LSTATUS WINAPI RegLoadKeyA( HKEY hkey, LPCSTR subkey, LPCSTR filename )
RtlInitAnsiString(&subkeyA, subkey); RtlInitAnsiString(&subkeyA, subkey);
RtlInitAnsiString(&filenameA, filename); RtlInitAnsiString(&filenameA, filename);
RtlInitUnicodeString(&subkeyW, NULL);
RtlInitUnicodeString(&filenameW, NULL);
if (!(status = RtlAnsiStringToUnicodeString(&subkeyW, &subkeyA, TRUE)) && if (!(status = RtlAnsiStringToUnicodeString(&subkeyW, &subkeyA, TRUE)) &&
!(status = RtlAnsiStringToUnicodeString(&filenameW, &filenameA, TRUE))) !(status = RtlAnsiStringToUnicodeString(&filenameW, &filenameA, TRUE)))
{ {
......
...@@ -433,7 +433,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH DefineDosDeviceW( DWORD flags, const WCHAR *device ...@@ -433,7 +433,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH DefineDosDeviceW( DWORD flags, const WCHAR *device
*/ */
DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize ) DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize )
{ {
UNICODE_STRING nt_name;
NTSTATUS status; NTSTATUS status;
if (!bufsize) if (!bufsize)
...@@ -471,12 +470,11 @@ DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize ) ...@@ -471,12 +470,11 @@ DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize )
} }
else /* return a list of all devices */ else /* return a list of all devices */
{ {
UNICODE_STRING nt_name = RTL_CONSTANT_STRING( L"\\DosDevices" );
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
HANDLE handle; HANDLE handle;
WCHAR *p = target; WCHAR *p = target;
RtlInitUnicodeString( &nt_name, L"\\DosDevices\\" );
nt_name.Length -= sizeof(WCHAR); /* without trailing slash */
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = 0; attr.RootDirectory = 0;
attr.ObjectName = &nt_name; attr.ObjectName = &nt_name;
...@@ -517,12 +515,11 @@ DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize ) ...@@ -517,12 +515,11 @@ DWORD WINAPI QueryDosDeviceW( LPCWSTR devname, LPWSTR target, DWORD bufsize )
DWORD WINAPI DECLSPEC_HOTPATCH GetLogicalDrives(void) DWORD WINAPI DECLSPEC_HOTPATCH GetLogicalDrives(void)
{ {
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
UNICODE_STRING nt_name; UNICODE_STRING nt_name = RTL_CONSTANT_STRING( L"\\DosDevices\\" );
DWORD bitmask = 0; DWORD bitmask = 0;
NTSTATUS status; NTSTATUS status;
HANDLE handle; HANDLE handle;
RtlInitUnicodeString( &nt_name, L"\\DosDevices\\" );
nt_name.Length -= sizeof(WCHAR); /* without trailing slash */ nt_name.Length -= sizeof(WCHAR); /* without trailing slash */
attr.Length = sizeof(attr); attr.Length = sizeof(attr);
attr.RootDirectory = 0; attr.RootDirectory = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment