From: Sven Baars sbaars@codeweavers.com
--- dlls/kernelbase/registry.c | 55 ++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 29 deletions(-)
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index f96a18a9599..5c8b82423c1 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -261,32 +261,23 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES if (status == STATUS_OBJECT_NAME_NOT_FOUND) { WCHAR *buffer = attr->ObjectName->Buffer; - DWORD attrs, pos = 0, i = 0, len = attr->ObjectName->Length / sizeof(WCHAR); + DWORD attrs, i = 0, len = attr->ObjectName->Length / sizeof(WCHAR); UNICODE_STRING str;
- /* don't try to create registry root */ - if (!attr->RootDirectory && len > 10 && !wcsnicmp( buffer, L"\Registry\", 10 )) i += 10; - - while (i < len && buffer[i] != '\') i++; - if (i == len && !force_wow32) return status; - attrs = attr->Attributes; attr->ObjectName = &str;
- for (;;) + while (len) { - str.Buffer = buffer + pos; - str.Length = (i - pos) * sizeof(WCHAR); - if (force_wow32 && pos) - { - if (is_wow6432node( &str )) force_wow32 = FALSE; - else if ((subkey = open_wow6432node( attr->RootDirectory ))) - { - if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); - attr->RootDirectory = subkey; - force_wow32 = FALSE; - } - } + i = 0; + + /* don't try to create registry root */ + if (!attr->RootDirectory && len > 10 && !wcsnicmp( buffer, L"\Registry\", 10 )) i += 10; + while (i < len && buffer[i] != '\') i++; + + str.Buffer = buffer; + str.Length = i * sizeof(WCHAR); + if (i == len) { attr->Attributes = attrs; @@ -300,19 +291,25 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES } if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); if (!NT_SUCCESS(status)) return status; - if (i == len) break; attr->RootDirectory = subkey; while (i < len && buffer[i] == '\') i++; - pos = i; - while (i < len && buffer[i] != '\') i++; + buffer += i; + len -= i; + + if (force_wow32) + { + str.Buffer = buffer; + str.Length = len * sizeof(WCHAR); + if (is_wow6432node( &str )) force_wow32 = FALSE; + else if ((subkey = open_wow6432node( attr->RootDirectory ))) + { + NtClose( attr->RootDirectory ); + attr->RootDirectory = subkey; + force_wow32 = FALSE; + } + } } } - attr->RootDirectory = subkey; - if (force_wow32 && (subkey = open_wow6432node( attr->RootDirectory ))) - { - if (attr->RootDirectory != root) NtClose( attr->RootDirectory ); - attr->RootDirectory = subkey; - } if (status == STATUS_PREDEFINED_HANDLE) { attr->RootDirectory = get_perflib_key( attr->RootDirectory );