Alexandre Julliard : ntdll: Avoid using RtlInitUnicodeString() in the Unix library.
Alexandre Julliard
julliard at winehq.org
Fri Jul 10 16:30:30 CDT 2020
Module: wine
Branch: master
Commit: 0357d2ca75be92e927bb785a786d3766c94f3c83
URL: https://source.winehq.org/git/wine.git/?a=commit;h=0357d2ca75be92e927bb785a786d3766c94f3c83
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Jul 10 07:57:59 2020 +0200
ntdll: Avoid using RtlInitUnicodeString() in the Unix library.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/unix/file.c | 3 ++-
dlls/ntdll/unix/system.c | 16 +++++++++-------
dlls/ntdll/unix/virtual.c | 10 ++++------
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c
index 070aac3083..af7c214984 100644
--- a/dlls/ntdll/unix/file.c
+++ b/dlls/ntdll/unix/file.c
@@ -1993,7 +1993,8 @@ static NTSTATUS get_mountmgr_fs_info( HANDLE handle, int fd, struct mountmgr_uni
else
drive->letter = 'a' + letter;
- RtlInitUnicodeString( &string, MOUNTMGR_DEVICE_NAME );
+ string.Buffer = (WCHAR *)MOUNTMGR_DEVICE_NAME;
+ string.Length = sizeof(MOUNTMGR_DEVICE_NAME) - sizeof(WCHAR);
InitializeObjectAttributes( &attr, &string, 0, NULL, NULL );
status = NtOpenFile( &mountmgr, GENERIC_READ | SYNCHRONIZE, &attr, &io,
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT );
diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c
index 33fb37ec33..07a3ad2154 100644
--- a/dlls/ntdll/unix/system.c
+++ b/dlls/ntdll/unix/system.c
@@ -1729,7 +1729,8 @@ static BOOL reg_query_value( HKEY key, LPCWSTR name, DWORD type, void *data, DWO
if (count > sizeof(buf) - sizeof(KEY_VALUE_PARTIAL_INFORMATION)) return FALSE;
- RtlInitUnicodeString( &nameW, name );
+ nameW.Buffer = (WCHAR *)name;
+ nameW.Length = wcslen( name ) * sizeof(WCHAR);
if (NtQueryValueKey( key, &nameW, KeyValuePartialInformation, buf, sizeof(buf), &count ))
return FALSE;
@@ -1756,7 +1757,7 @@ static void find_reg_tz_info(RTL_DYNAMIC_TIME_ZONE_INFORMATION *tzi, const char*
HANDLE key, subkey, subkey_dyn = 0;
ULONG idx, len;
OBJECT_ATTRIBUTES attr;
- UNICODE_STRING nameW, nameDynamicW;
+ UNICODE_STRING nameW;
WCHAR yearW[16];
char buffer[128];
KEY_BASIC_INFORMATION *info = (KEY_BASIC_INFORMATION *)buffer;
@@ -1764,9 +1765,8 @@ static void find_reg_tz_info(RTL_DYNAMIC_TIME_ZONE_INFORMATION *tzi, const char*
sprintf( buffer, "%u", year );
ascii_to_unicode( yearW, buffer, strlen(buffer) + 1 );
- RtlInitUnicodeString( &nameW, Time_ZonesW );
- RtlInitUnicodeString( &nameDynamicW, Dynamic_DstW );
-
+ nameW.Buffer = (WCHAR *)Time_ZonesW;
+ nameW.Length = sizeof(Time_ZonesW) - sizeof(WCHAR);
InitializeObjectAttributes( &attr, &nameW, 0, 0, NULL );
if (NtOpenKey( &key, KEY_READ, &attr )) return;
@@ -1785,7 +1785,7 @@ static void find_reg_tz_info(RTL_DYNAMIC_TIME_ZONE_INFORMATION *tzi, const char*
nameW.Buffer = info->Name;
nameW.Length = info->NameLength;
- InitializeObjectAttributes( &attr, &nameW, 0, key, NULL );
+ attr.RootDirectory = key;
if (NtOpenKey( &subkey, KEY_READ, &attr )) continue;
memset( ®_tzi, 0, sizeof(reg_tzi) );
@@ -1801,7 +1801,9 @@ static void find_reg_tz_info(RTL_DYNAMIC_TIME_ZONE_INFORMATION *tzi, const char*
goto next;
/* Check for Dynamic DST entry first */
- InitializeObjectAttributes( &attr, &nameDynamicW, 0, subkey, NULL );
+ nameW.Buffer = (WCHAR *)Dynamic_DstW;
+ nameW.Length = sizeof(Dynamic_DstW) - sizeof(WCHAR);
+ attr.RootDirectory = subkey;
if (!NtOpenKey( &subkey_dyn, KEY_READ, &attr ))
{
is_dynamic = reg_query_value( subkey_dyn, yearW, REG_BINARY, &tz_data, sizeof(tz_data) );
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c
index 7592234ccc..4e5b1acf0b 100644
--- a/dlls/ntdll/unix/virtual.c
+++ b/dlls/ntdll/unix/virtual.c
@@ -2804,16 +2804,14 @@ void virtual_clear_thread_stack( void *stack_end )
*/
void virtual_map_user_shared_data(void)
{
- static const WCHAR wine_usdW[] = {'\\','K','e','r','n','e','l','O','b','j','e','c','t','s',
- '\\','_','_','w','i','n','e','_','u','s','e','r','_','s','h','a','r','e','d','_','d','a','t','a',0};
- OBJECT_ATTRIBUTES attr = {sizeof(attr)};
- UNICODE_STRING wine_usd_str;
+ static const WCHAR nameW[] = {'\\','K','e','r','n','e','l','O','b','j','e','c','t','s',
+ '\\','_','_','w','i','n','e','_','u','s','e','r','_','s','h','a','r','e','d','_','d','a','t','a',0};
+ UNICODE_STRING name_str = { sizeof(nameW) - sizeof(WCHAR), sizeof(nameW), (WCHAR *)nameW };
+ OBJECT_ATTRIBUTES attr = { sizeof(attr), 0, &name_str };
NTSTATUS status;
HANDLE section;
int res, fd, needs_close;
- RtlInitUnicodeString( &wine_usd_str, wine_usdW );
- InitializeObjectAttributes( &attr, &wine_usd_str, OBJ_OPENIF, NULL, NULL );
if ((status = NtOpenSection( §ion, SECTION_ALL_ACCESS, &attr )))
{
ERR( "failed to open the USD section: %08x\n", status );
More information about the wine-cvs
mailing list