From 6d2758d3b7c789ca2dc2ca278eb745a455254f9e Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Thu, 29 May 2003 14:09:41 +0000 Subject: [PATCH] Converted the Registry to Unicode. Link default user hive to '\Registry\User\.Default' svn path=/trunk/; revision=4798 --- reactos/ntoskrnl/cm/cm.h | 19 +- reactos/ntoskrnl/cm/ntfunc.c | 437 ++++++++++++++++++--------------- reactos/ntoskrnl/cm/regfile.c | 63 ++++- reactos/ntoskrnl/cm/registry.c | 6 +- 4 files changed, 294 insertions(+), 231 deletions(-) diff --git a/reactos/ntoskrnl/cm/cm.h b/reactos/ntoskrnl/cm/cm.h index a79190ca666..71f54d2d57e 100644 --- a/reactos/ntoskrnl/cm/cm.h +++ b/reactos/ntoskrnl/cm/cm.h @@ -18,18 +18,20 @@ #define REG_SOFTWARE_KEY_NAME L"\\Registry\\Machine\\Software" #define REG_SAM_KEY_NAME L"\\Registry\\Machine\\Sam" #define REG_SEC_KEY_NAME L"\\Registry\\Machine\\Security" -#define REG_USERS_KEY_NAME L"\\Registry\\User" -#define REG_USER_KEY_NAME L"\\Registry\\User\\CurrentUser" +#define REG_USER_KEY_NAME L"\\Registry\\User" +#define REG_DEFAULT_USER_KEY_NAME L"\\Registry\\User\\.Default" +#define REG_CURRENT_USER_KEY_NAME L"\\Registry\\User\\CurrentUser" + #define SYSTEM_REG_FILE L"\\SystemRoot\\System32\\Config\\SYSTEM" #define SYSTEM_LOG_FILE L"\\SystemRoot\\System32\\Config\\SYSTEM.log" #define SOFTWARE_REG_FILE L"\\SystemRoot\\System32\\Config\\SOFTWARE" -#define USER_REG_FILE L"\\SystemRoot\\System32\\Config\\DEFAULT" +#define DEFAULT_USER_REG_FILE L"\\SystemRoot\\System32\\Config\\DEFAULT" #define SAM_REG_FILE L"\\SystemRoot\\System32\\Config\\SAM" #define SEC_REG_FILE L"\\SystemRoot\\System32\\Config\\SECURITY" #define REG_SYSTEM_FILE_NAME L"\\SYSTEM" #define REG_SOFTWARE_FILE_NAME L"\\SOFTWARE" -#define REG_USER_FILE_NAME L"\\DEFAULT" +#define REG_DEFAULT_USER_FILE_NAME L"\\DEFAULT" #define REG_SAM_FILE_NAME L"\\SAM" #define REG_SEC_FILE_NAME L"\\SECURITY" @@ -45,15 +47,6 @@ #define REG_VALUE_CELL_ID 0x6b76 #define REG_HIVE_ID 0x66676572 -#define REGISTRY_FILE_MAGIC "REGEDIT4" - -#define REG_MACHINE_STD_HANDLE_NAME "HKEY_LOCAL_MACHINE" -#define REG_CLASSES_STD_HANDLE_NAME "HKEY_CLASSES_ROOT" -#define REG_USERS_STD_HANDLE_NAME "HKEY_USERS" -#define REG_USER_STD_HANDLE_NAME "HKEY_CURRENT_USER" -#define REG_CONFIG_STD_HANDLE_NAME "HKEY_CURRENT_CONFIG" -#define REG_DYN_STD_HANDLE_NAME "HKEY_DYN_DATA" -#define MAX_REG_STD_HANDLE_NAME 19 // BLOCK_OFFSET = offset in file after header block typedef ULONG BLOCK_OFFSET; diff --git a/reactos/ntoskrnl/cm/ntfunc.c b/reactos/ntoskrnl/cm/ntfunc.c index dfa34e2a134..457817b353e 100644 --- a/reactos/ntoskrnl/cm/ntfunc.c +++ b/reactos/ntoskrnl/cm/ntfunc.c @@ -245,16 +245,13 @@ NtDeleteKey(IN HANDLE KeyHandle) NTSTATUS STDCALL -NtEnumerateKey( - IN HANDLE KeyHandle, - IN ULONG Index, - IN KEY_INFORMATION_CLASS KeyInformationClass, - OUT PVOID KeyInformation, - IN ULONG Length, - OUT PULONG ResultLength - ) +NtEnumerateKey(IN HANDLE KeyHandle, + IN ULONG Index, + IN KEY_INFORMATION_CLASS KeyInformationClass, + OUT PVOID KeyInformation, + IN ULONG Length, + OUT PULONG ResultLength) { - NTSTATUS Status; PKEY_OBJECT KeyObject; PREGISTRY_HIVE RegistryHive; PKEY_CELL KeyCell, SubKeyCell; @@ -262,7 +259,9 @@ NtEnumerateKey( PKEY_BASIC_INFORMATION BasicInformation; PKEY_NODE_INFORMATION NodeInformation; PKEY_FULL_INFORMATION FullInformation; - PDATA_CELL pClassData; + PDATA_CELL ClassData; + ULONG NameSize; + NTSTATUS Status; DPRINT("KH %x I %d KIC %x KI %x L %d RL %x\n", KeyHandle, @@ -362,102 +361,136 @@ NtEnumerateKey( Status = STATUS_SUCCESS; switch (KeyInformationClass) { - case KeyBasicInformation: - /* Check size of buffer */ - *ResultLength = sizeof(KEY_BASIC_INFORMATION) + - (SubKeyCell->NameSize ) * sizeof(WCHAR); - if (Length < *ResultLength) - { - Status = STATUS_BUFFER_OVERFLOW; - } - else - { - /* Fill buffer with requested info */ - BasicInformation = (PKEY_BASIC_INFORMATION) KeyInformation; - BasicInformation->LastWriteTime.u.LowPart = SubKeyCell->LastWriteTime.dwLowDateTime; - BasicInformation->LastWriteTime.u.HighPart = SubKeyCell->LastWriteTime.dwHighDateTime; - BasicInformation->TitleIndex = Index; - BasicInformation->NameLength = SubKeyCell->NameSize * sizeof(WCHAR); - mbstowcs(BasicInformation->Name, - SubKeyCell->Name, - SubKeyCell->NameSize * 2); - } - break; - - case KeyNodeInformation: - /* Check size of buffer */ - *ResultLength = sizeof(KEY_NODE_INFORMATION) + - SubKeyCell->NameSize * sizeof(WCHAR) + - SubKeyCell->ClassSize; - if (Length < *ResultLength) - { - Status = STATUS_BUFFER_OVERFLOW; - } - else - { - /* Fill buffer with requested info */ - NodeInformation = (PKEY_NODE_INFORMATION) KeyInformation; - NodeInformation->LastWriteTime.u.LowPart = SubKeyCell->LastWriteTime.dwLowDateTime; - NodeInformation->LastWriteTime.u.HighPart = SubKeyCell->LastWriteTime.dwHighDateTime; - NodeInformation->TitleIndex = Index; - NodeInformation->ClassOffset = sizeof(KEY_NODE_INFORMATION) + - SubKeyCell->NameSize * sizeof(WCHAR); - NodeInformation->ClassLength = SubKeyCell->ClassSize; - NodeInformation->NameLength = SubKeyCell->NameSize * sizeof(WCHAR); - mbstowcs(NodeInformation->Name, - SubKeyCell->Name, - SubKeyCell->NameSize * 2); - if (SubKeyCell->ClassSize != 0) - { - pClassData=CmiGetBlock(KeyObject->RegistryHive, - SubKeyCell->ClassNameOffset, - NULL); - wcsncpy(NodeInformation->Name + SubKeyCell->NameSize , - (PWCHAR) pClassData->Data, - SubKeyCell->ClassSize); - } - } - break; - - case KeyFullInformation: - /* check size of buffer */ - *ResultLength = sizeof(KEY_FULL_INFORMATION) + - SubKeyCell->ClassSize; - if (Length < *ResultLength) - { - Status = STATUS_BUFFER_OVERFLOW; - } - else - { - /* fill buffer with requested info */ - FullInformation = (PKEY_FULL_INFORMATION) KeyInformation; - FullInformation->LastWriteTime.u.LowPart = SubKeyCell->LastWriteTime.dwLowDateTime; - FullInformation->LastWriteTime.u.HighPart = SubKeyCell->LastWriteTime.dwHighDateTime; - FullInformation->TitleIndex = Index; - FullInformation->ClassOffset = sizeof(KEY_FULL_INFORMATION) - - sizeof(WCHAR); - FullInformation->ClassLength = SubKeyCell->ClassSize; - FullInformation->SubKeys = SubKeyCell->NumberOfSubKeys; - FullInformation->MaxNameLen = - CmiGetMaxNameLength(RegistryHive, SubKeyCell); - FullInformation->MaxClassLen = - CmiGetMaxClassLength(RegistryHive, SubKeyCell); - FullInformation->Values = SubKeyCell->NumberOfValues; - FullInformation->MaxValueNameLen = - CmiGetMaxValueNameLength(RegistryHive, SubKeyCell); - FullInformation->MaxValueDataLen = - CmiGetMaxValueDataLength(RegistryHive, SubKeyCell); - if (SubKeyCell->ClassSize != 0) - { - pClassData = CmiGetBlock(KeyObject->RegistryHive, - SubKeyCell->ClassNameOffset, - NULL); - wcsncpy(FullInformation->Class, - (PWCHAR) pClassData->Data, - SubKeyCell->ClassSize); - } - } - break; + case KeyBasicInformation: + /* Check size of buffer */ + NameSize = SubKeyCell->NameSize; + if (SubKeyCell->Flags & REG_KEY_NAME_PACKED) + { + NameSize *= sizeof(WCHAR); + } + *ResultLength = sizeof(KEY_BASIC_INFORMATION) + NameSize; + + if (Length < *ResultLength) + { + Status = STATUS_BUFFER_OVERFLOW; + } + else + { + /* Fill buffer with requested info */ + BasicInformation = (PKEY_BASIC_INFORMATION) KeyInformation; + BasicInformation->LastWriteTime.u.LowPart = SubKeyCell->LastWriteTime.dwLowDateTime; + BasicInformation->LastWriteTime.u.HighPart = SubKeyCell->LastWriteTime.dwHighDateTime; + BasicInformation->TitleIndex = Index; + BasicInformation->NameLength = NameSize; + + if (SubKeyCell->Flags & REG_KEY_NAME_PACKED) + { + CmiCopyPackedName(BasicInformation->Name, + SubKeyCell->Name, + SubKeyCell->NameSize); + } + else + { + RtlCopyMemory(BasicInformation->Name, + SubKeyCell->Name, + SubKeyCell->NameSize); + } + } + break; + + case KeyNodeInformation: + /* Check size of buffer */ + if (SubKeyCell->Flags & REG_KEY_NAME_PACKED) + { + NameSize = SubKeyCell->NameSize * sizeof(WCHAR); + } + else + { + NameSize = SubKeyCell->NameSize; + } + *ResultLength = sizeof(KEY_NODE_INFORMATION) + + NameSize + SubKeyCell->ClassSize; + + if (Length < *ResultLength) + { + Status = STATUS_BUFFER_OVERFLOW; + } + else + { + /* Fill buffer with requested info */ + NodeInformation = (PKEY_NODE_INFORMATION) KeyInformation; + NodeInformation->LastWriteTime.u.LowPart = SubKeyCell->LastWriteTime.dwLowDateTime; + NodeInformation->LastWriteTime.u.HighPart = SubKeyCell->LastWriteTime.dwHighDateTime; + NodeInformation->TitleIndex = Index; + NodeInformation->ClassOffset = sizeof(KEY_NODE_INFORMATION) + NameSize; + NodeInformation->ClassLength = SubKeyCell->ClassSize; + NodeInformation->NameLength = NameSize; + + if (SubKeyCell->Flags & REG_KEY_NAME_PACKED) + { + CmiCopyPackedName(BasicInformation->Name, + SubKeyCell->Name, + SubKeyCell->NameSize); + } + else + { + RtlCopyMemory(BasicInformation->Name, + SubKeyCell->Name, + SubKeyCell->NameSize); + } + + if (SubKeyCell->ClassSize != 0) + { + ClassData=CmiGetBlock(KeyObject->RegistryHive, + SubKeyCell->ClassNameOffset, + NULL); + wcsncpy(NodeInformation->Name + SubKeyCell->NameSize, + (PWCHAR)ClassData->Data, + SubKeyCell->ClassSize); + } + } + break; + + case KeyFullInformation: + /* Check size of buffer */ + *ResultLength = sizeof(KEY_FULL_INFORMATION) + + SubKeyCell->ClassSize; + + if (Length < *ResultLength) + { + Status = STATUS_BUFFER_OVERFLOW; + } + else + { + /* Fill buffer with requested info */ + FullInformation = (PKEY_FULL_INFORMATION) KeyInformation; + FullInformation->LastWriteTime.u.LowPart = SubKeyCell->LastWriteTime.dwLowDateTime; + FullInformation->LastWriteTime.u.HighPart = SubKeyCell->LastWriteTime.dwHighDateTime; + FullInformation->TitleIndex = Index; + FullInformation->ClassOffset = sizeof(KEY_FULL_INFORMATION) - + sizeof(WCHAR); + FullInformation->ClassLength = SubKeyCell->ClassSize; + FullInformation->SubKeys = SubKeyCell->NumberOfSubKeys; + FullInformation->MaxNameLen = + CmiGetMaxNameLength(RegistryHive, SubKeyCell); + FullInformation->MaxClassLen = + CmiGetMaxClassLength(RegistryHive, SubKeyCell); + FullInformation->Values = SubKeyCell->NumberOfValues; + FullInformation->MaxValueNameLen = + CmiGetMaxValueNameLength(RegistryHive, SubKeyCell); + FullInformation->MaxValueDataLen = + CmiGetMaxValueDataLength(RegistryHive, SubKeyCell); + if (SubKeyCell->ClassSize != 0) + { + ClassData = CmiGetBlock(KeyObject->RegistryHive, + SubKeyCell->ClassNameOffset, + NULL); + wcsncpy(FullInformation->Class, + (PWCHAR)ClassData->Data, + SubKeyCell->ClassSize); + } + } + break; } ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource); @@ -802,7 +835,7 @@ NtQueryKey(IN HANDLE KeyHandle, PKEY_NODE_INFORMATION NodeInformation; PKEY_FULL_INFORMATION FullInformation; PREGISTRY_HIVE RegistryHive; - PDATA_CELL pClassData; + PDATA_CELL ClassData; PKEY_OBJECT KeyObject; PKEY_CELL KeyCell; NTSTATUS Status; @@ -838,104 +871,104 @@ NtQueryKey(IN HANDLE KeyHandle, Status = STATUS_SUCCESS; switch (KeyInformationClass) { - case KeyBasicInformation: - /* Check size of buffer */ - if (Length < sizeof(KEY_BASIC_INFORMATION) + - KeyObject->Name.Length) - { - Status = STATUS_BUFFER_OVERFLOW; - } - else - { - /* Fill buffer with requested info */ - BasicInformation = (PKEY_BASIC_INFORMATION) KeyInformation; - BasicInformation->LastWriteTime.u.LowPart = KeyCell->LastWriteTime.dwLowDateTime; - BasicInformation->LastWriteTime.u.HighPart = KeyCell->LastWriteTime.dwHighDateTime; - BasicInformation->TitleIndex = 0; - BasicInformation->NameLength = KeyObject->Name.Length; - RtlCopyMemory(BasicInformation->Name, - KeyObject->Name.Buffer, - KeyObject->Name.Length); - *ResultLength = sizeof(KEY_BASIC_INFORMATION) + - KeyObject->Name.Length; - } - break; + case KeyBasicInformation: + /* Check size of buffer */ + *ResultLength = sizeof(KEY_BASIC_INFORMATION) + + KeyObject->Name.Length; - case KeyNodeInformation: - /* Check size of buffer */ - if (Length < sizeof(KEY_NODE_INFORMATION) - + KeyObject->Name.Length - + KeyCell->ClassSize) - { - Status = STATUS_BUFFER_OVERFLOW; - } - else - { - /* Fill buffer with requested info */ - NodeInformation = (PKEY_NODE_INFORMATION) KeyInformation; - NodeInformation->LastWriteTime.u.LowPart = KeyCell->LastWriteTime.dwLowDateTime; - NodeInformation->LastWriteTime.u.HighPart = KeyCell->LastWriteTime.dwHighDateTime; - NodeInformation->TitleIndex = 0; - NodeInformation->ClassOffset = sizeof(KEY_NODE_INFORMATION) + - KeyObject->Name.Length; - NodeInformation->ClassLength = KeyCell->ClassSize; - NodeInformation->NameLength = KeyObject->Name.Length; - RtlCopyMemory(NodeInformation->Name, - KeyObject->Name.Buffer, - KeyObject->Name.Length); + if (Length < *ResultLength) + { + Status = STATUS_BUFFER_OVERFLOW; + } + else + { + /* Fill buffer with requested info */ + BasicInformation = (PKEY_BASIC_INFORMATION) KeyInformation; + BasicInformation->LastWriteTime.u.LowPart = KeyCell->LastWriteTime.dwLowDateTime; + BasicInformation->LastWriteTime.u.HighPart = KeyCell->LastWriteTime.dwHighDateTime; + BasicInformation->TitleIndex = 0; + BasicInformation->NameLength = KeyObject->Name.Length; + RtlCopyMemory(BasicInformation->Name, + KeyObject->Name.Buffer, + KeyObject->Name.Length); + } + break; - if (KeyCell->ClassSize != 0) - { - pClassData = CmiGetBlock(KeyObject->RegistryHive, - KeyCell->ClassNameOffset, - NULL); - wcsncpy(NodeInformation->Name + KeyObject->Name.Length, - (PWCHAR)pClassData->Data, - KeyCell->ClassSize); - } - *ResultLength = sizeof(KEY_NODE_INFORMATION) - + KeyObject->Name.Length - + KeyCell->ClassSize; - } - break; + case KeyNodeInformation: + /* Check size of buffer */ + *ResultLength = sizeof(KEY_NODE_INFORMATION) + + KeyObject->Name.Length + KeyCell->ClassSize; - case KeyFullInformation: - /* Check size of buffer */ - if (Length < sizeof(KEY_FULL_INFORMATION) + KeyCell->ClassSize) - { - Status = STATUS_BUFFER_OVERFLOW; - } - else - { - /* Fill buffer with requested info */ - FullInformation = (PKEY_FULL_INFORMATION) KeyInformation; - FullInformation->LastWriteTime.u.LowPart = KeyCell->LastWriteTime.dwLowDateTime; - FullInformation->LastWriteTime.u.HighPart = KeyCell->LastWriteTime.dwHighDateTime; - FullInformation->TitleIndex = 0; - FullInformation->ClassOffset = sizeof(KEY_FULL_INFORMATION) - sizeof(WCHAR); - FullInformation->ClassLength = KeyCell->ClassSize; - FullInformation->SubKeys = KeyCell->NumberOfSubKeys; - FullInformation->MaxNameLen = - CmiGetMaxNameLength(RegistryHive, KeyCell); - FullInformation->MaxClassLen = - CmiGetMaxClassLength(RegistryHive, KeyCell); - FullInformation->Values = KeyCell->NumberOfValues; - FullInformation->MaxValueNameLen = - CmiGetMaxValueNameLength(RegistryHive, KeyCell); - FullInformation->MaxValueDataLen = - CmiGetMaxValueDataLength(RegistryHive, KeyCell); - if (KeyCell->ClassSize != 0) - { - pClassData=CmiGetBlock(KeyObject->RegistryHive, - KeyCell->ClassNameOffset, - NULL); - wcsncpy(FullInformation->Class, - (PWCHAR)pClassData->Data, - KeyCell->ClassSize); - } - *ResultLength = sizeof(KEY_FULL_INFORMATION) + KeyCell->ClassSize; - } - break; + if (Length < *ResultLength) + { + Status = STATUS_BUFFER_OVERFLOW; + } + else + { + /* Fill buffer with requested info */ + NodeInformation = (PKEY_NODE_INFORMATION) KeyInformation; + NodeInformation->LastWriteTime.u.LowPart = KeyCell->LastWriteTime.dwLowDateTime; + NodeInformation->LastWriteTime.u.HighPart = KeyCell->LastWriteTime.dwHighDateTime; + NodeInformation->TitleIndex = 0; + NodeInformation->ClassOffset = sizeof(KEY_NODE_INFORMATION) + + KeyObject->Name.Length; + NodeInformation->ClassLength = KeyCell->ClassSize; + NodeInformation->NameLength = KeyObject->Name.Length; + RtlCopyMemory(NodeInformation->Name, + KeyObject->Name.Buffer, + KeyObject->Name.Length); + + if (KeyCell->ClassSize != 0) + { + ClassData = CmiGetBlock(KeyObject->RegistryHive, + KeyCell->ClassNameOffset, + NULL); + wcsncpy(NodeInformation->Name + KeyObject->Name.Length, + (PWCHAR)ClassData->Data, + KeyCell->ClassSize); + } + } + break; + + case KeyFullInformation: + /* Check size of buffer */ + *ResultLength = sizeof(KEY_FULL_INFORMATION) + + KeyCell->ClassSize; + + if (Length < *ResultLength) + { + Status = STATUS_BUFFER_OVERFLOW; + } + else + { + /* Fill buffer with requested info */ + FullInformation = (PKEY_FULL_INFORMATION) KeyInformation; + FullInformation->LastWriteTime.u.LowPart = KeyCell->LastWriteTime.dwLowDateTime; + FullInformation->LastWriteTime.u.HighPart = KeyCell->LastWriteTime.dwHighDateTime; + FullInformation->TitleIndex = 0; + FullInformation->ClassOffset = sizeof(KEY_FULL_INFORMATION) - sizeof(WCHAR); + FullInformation->ClassLength = KeyCell->ClassSize; + FullInformation->SubKeys = KeyCell->NumberOfSubKeys; + FullInformation->MaxNameLen = + CmiGetMaxNameLength(RegistryHive, KeyCell); + FullInformation->MaxClassLen = + CmiGetMaxClassLength(RegistryHive, KeyCell); + FullInformation->Values = KeyCell->NumberOfValues; + FullInformation->MaxValueNameLen = + CmiGetMaxValueNameLength(RegistryHive, KeyCell); + FullInformation->MaxValueDataLen = + CmiGetMaxValueDataLength(RegistryHive, KeyCell); + if (KeyCell->ClassSize != 0) + { + ClassData=CmiGetBlock(KeyObject->RegistryHive, + KeyCell->ClassNameOffset, + NULL); + wcsncpy(FullInformation->Class, + (PWCHAR)ClassData->Data, + KeyCell->ClassSize); + } + } + break; } ExReleaseResourceLite(&KeyObject->RegistryHive->HiveResource); diff --git a/reactos/ntoskrnl/cm/regfile.c b/reactos/ntoskrnl/cm/regfile.c index 74408d40196..0984d568a5b 100644 --- a/reactos/ntoskrnl/cm/regfile.c +++ b/reactos/ntoskrnl/cm/regfile.c @@ -2099,22 +2099,44 @@ CmiAddSubKey(PREGISTRY_HIVE RegistryHive, NTSTATUS Status; USHORT NameSize; PWSTR NamePtr; + BOOLEAN Packable; + ULONG i; KeyCell = Parent->KeyCell; VERIFY_KEY_CELL(KeyCell); + /* Skip leading backslash */ if (SubKeyName->Buffer[0] == L'\\') { NamePtr = &SubKeyName->Buffer[1]; - NameSize = SubKeyName->Length / 2 - 1; + NameSize = SubKeyName->Length - sizeof(WCHAR); } else { NamePtr = SubKeyName->Buffer; - NameSize = SubKeyName->Length / 2; + NameSize = SubKeyName->Length; } + /* Check whether key name can be packed */ + Packable = TRUE; + for (i = 0; i < NameSize / sizeof(WCHAR); i++) + { + if (NamePtr[i] & 0xFF00) + { + Packable = FALSE; + break; + } + } + + /* Adjust name size */ + if (Packable) + { + NameSize = NameSize / sizeof(WCHAR); + } + + DPRINT("Key %S Length %lu %s\n", NamePtr, NameSize, (Packable)?"True":"False"); + Status = STATUS_SUCCESS; NewBlockSize = sizeof(KEY_CELL) + NameSize; @@ -2130,7 +2152,7 @@ CmiAddSubKey(PREGISTRY_HIVE RegistryHive, { NewKeyCell->Id = REG_KEY_CELL_ID; NewKeyCell->Flags = 0; - ZwQuerySystemTime((PTIME) &NewKeyCell->LastWriteTime); + NtQuerySystemTime((PTIME) &NewKeyCell->LastWriteTime); NewKeyCell->ParentKeyOffset = -1; NewKeyCell->NumberOfSubKeys = 0; NewKeyCell->HashTableOffset = -1; @@ -2139,9 +2161,22 @@ CmiAddSubKey(PREGISTRY_HIVE RegistryHive, NewKeyCell->SecurityKeyOffset = -1; NewKeyCell->ClassNameOffset = -1; - NewKeyCell->Flags |= REG_KEY_NAME_PACKED; + /* Pack the key name */ NewKeyCell->NameSize = NameSize; - wcstombs(NewKeyCell->Name, NamePtr, NameSize); + if (Packable) + { + NewKeyCell->Flags |= REG_KEY_NAME_PACKED; + for (i = 0; i < NameSize; i++) + { + NewKeyCell->Name[i] = (CHAR)(NamePtr[i] & 0x00FF); + } + } + else + { + RtlCopyMemory(NewKeyCell->Name, + NamePtr, + NameSize); + } VERIFY_KEY_CELL(NewKeyCell); @@ -2151,10 +2186,12 @@ CmiAddSubKey(PREGISTRY_HIVE RegistryHive, NewKeyCell->ClassSize = Class->Length + sizeof(WCHAR); Status = CmiAllocateBlock(RegistryHive, - (PVOID) &pClass, + (PVOID)&pClass, NewKeyCell->ClassSize, &NewKeyCell->ClassNameOffset); - wcsncpy((PWSTR) pClass->Data, Class->Buffer, Class->Length); + wcsncpy((PWSTR)pClass->Data, + Class->Buffer, + Class->Length); ((PWSTR) (pClass->Data))[Class->Length] = 0; } } @@ -3424,17 +3461,17 @@ CmiGetPackedNameLength(IN PUNICODE_STRING Name, if (Packable != NULL) *Packable = TRUE; - for (i = 0; i < Name->Length; i++) + for (i = 0; i < Name->Length / sizeof(WCHAR); i++) { - if (Name->Buffer[i] > 0xFF) + if (Name->Buffer[i] & 0xFF00) { if (Packable != NULL) *Packable = FALSE; - return(Name->Length); + return Name->Length; } } - return(Name->Length / sizeof(WCHAR)); + return (Name->Length / sizeof(WCHAR)); } @@ -3525,7 +3562,7 @@ CmiCompareKeyNames(PUNICODE_STRING KeyName, PWCHAR UnicodeName; USHORT i; - DPRINT1("Flags: %hx\n", KeyCell->Flags); + DPRINT("Flags: %hx\n", KeyCell->Flags); if (KeyCell->Flags & REG_KEY_NAME_PACKED) { @@ -3562,7 +3599,7 @@ CmiCompareKeyNamesI(PUNICODE_STRING KeyName, PWCHAR UnicodeName; USHORT i; - DPRINT1("Flags: %hx\n", KeyCell->Flags); + DPRINT("Flags: %hx\n", KeyCell->Flags); if (KeyCell->Flags & REG_KEY_NAME_PACKED) { diff --git a/reactos/ntoskrnl/cm/registry.c b/reactos/ntoskrnl/cm/registry.c index f7f5a2b8dde..a258132c17f 100644 --- a/reactos/ntoskrnl/cm/registry.c +++ b/reactos/ntoskrnl/cm/registry.c @@ -1,4 +1,4 @@ -/* $Id: registry.c,v 1.97 2003/05/28 16:09:51 ekohl Exp $ +/* $Id: registry.c,v 1.98 2003/05/29 14:09:41 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -874,11 +874,11 @@ CmiInitHives(BOOLEAN SetupBoot) } /* Connect the DEFAULT hive */ - wcscpy(EndPtr, REG_USER_FILE_NAME); + wcscpy(EndPtr, REG_DEFAULT_USER_FILE_NAME); DPRINT ("ConfigPath: %S\n", ConfigPath); RtlInitUnicodeString (&KeyName, - REG_USER_KEY_NAME); + REG_DEFAULT_USER_KEY_NAME); Status = CmiInitializeHive(ConfigPath, &KeyName, SetupBoot);