BOOLEAN
NTAPI
CmpLinkKeyToHive(
- _In_z_ PWSTR LinkKeyName,
- _In_z_ PWSTR TargetKeyName)
+ _In_z_ PCWSTR LinkKeyName,
+ _In_z_ PCWSTR TargetKeyName)
{
+ NTSTATUS Status;
OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING LinkKeyName_U;
- HANDLE TargetKeyHandle;
+ UNICODE_STRING KeyName;
+ HANDLE LinkKeyHandle;
ULONG Disposition;
- NTSTATUS Status;
+
PAGED_CODE();
/* Initialize the object attributes */
- RtlInitUnicodeString(&LinkKeyName_U, LinkKeyName);
+ RtlInitUnicodeString(&KeyName, LinkKeyName);
InitializeObjectAttributes(&ObjectAttributes,
- &LinkKeyName_U,
+ &KeyName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL);
/* Create the link key */
- Status = ZwCreateKey(&TargetKeyHandle,
+ Status = ZwCreateKey(&LinkKeyHandle,
KEY_CREATE_LINK,
&ObjectAttributes,
0,
&Disposition);
if (!NT_SUCCESS(Status))
{
- DPRINT1("CM: CmpLinkKeyToHive: couldn't create %S Status = 0x%lx\n",
+ DPRINT1("CM: CmpLinkKeyToHive: couldn't create %S, Status = 0x%lx\n",
LinkKeyName, Status);
return FALSE;
}
if (Disposition != REG_CREATED_NEW_KEY)
{
DPRINT1("CM: CmpLinkKeyToHive: %S already exists!\n", LinkKeyName);
- ZwClose(TargetKeyHandle);
+ ZwClose(LinkKeyHandle);
return FALSE;
}
/* Set the target key name as link target */
- Status = ZwSetValueKey(TargetKeyHandle,
+ RtlInitUnicodeString(&KeyName, TargetKeyName);
+ Status = ZwSetValueKey(LinkKeyHandle,
&CmSymbolicLinkValueName,
0,
REG_LINK,
- TargetKeyName,
- wcslen(TargetKeyName) * sizeof(WCHAR));
+ KeyName.Buffer,
+ KeyName.Length);
/* Close the link key handle */
- ObCloseHandle(TargetKeyHandle, KernelMode);
+ ObCloseHandle(LinkKeyHandle, KernelMode);
if (!NT_SUCCESS(Status))
{
- DPRINT1("CM: CmpLinkKeyToHive: couldn't create symbolic link for %S\n",
- TargetKeyName);
+ DPRINT1("CM: CmpLinkKeyToHive: couldn't create symbolic link for %S, Status = 0x%lx\n",
+ TargetKeyName, Status);
return FALSE;
}
BytesToCopy);
/* Null terminate it */
- ObjectNameInfo->Name.Buffer[BytesToCopy / sizeof(WCHAR)] = 0;
+ ObjectNameInfo->Name.Buffer[BytesToCopy / sizeof(WCHAR)] = UNICODE_NULL;
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
}
/* Initialize the hive */
- Status = CmpInitializeHive((PCMHIVE*)&NewHive,
+ Status = CmpInitializeHive(&NewHive,
Operation,
HiveFlags,
FileType,
/* Success, return hive */
*Hive = NewHive;
- /* HACK: ROS: Init root key cell and prepare the hive */
- if (Operation == HINIT_CREATE) CmCreateRootNode(&NewHive->Hive, L"");
-
/* Duplicate the hive name */
NewHive->FileFullPath.Buffer = ExAllocatePoolWithTag(PagedPool,
HiveName->Length,
HiveName->Buffer,
HiveName->Length);
NewHive->FileFullPath.Length = HiveName->Length;
- NewHive->FileFullPath.MaximumLength = HiveName->MaximumLength;
+ NewHive->FileFullPath.MaximumLength = HiveName->Length;
}
/* Return success */
return (ExpInTextModeSetup ? STATUS_SUCCESS : Status);
}
+static
+NTSTATUS
+INIT_FUNCTION
+CmpCreateHardwareProfile(HANDLE ControlSetHandle)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING KeyName;
+ HANDLE ProfilesHandle = NULL;
+ HANDLE ProfileHandle = NULL;
+ ULONG Disposition;
+ NTSTATUS Status;
+
+ DPRINT("CmpCreateHardwareProfile()\n");
+
+ /* Create the Hardware Profiles key */
+ RtlInitUnicodeString(&KeyName, L"Hardware Profiles");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ControlSetHandle,
+ NULL);
+ Status = NtCreateKey(&ProfilesHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ 0,
+ &Disposition);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Creating the Hardware Profile key failed\n");
+ goto done;
+ }
+
+ /* Sanity check */
+ ASSERT(Disposition == REG_CREATED_NEW_KEY);
+
+ /* Create the 0000 key */
+ RtlInitUnicodeString(&KeyName, L"0000");
+ InitializeObjectAttributes(&ObjectAttributes,
+ &KeyName,
+ OBJ_CASE_INSENSITIVE,
+ ProfilesHandle,
+ NULL);
+ Status = NtCreateKey(&ProfileHandle,
+ KEY_ALL_ACCESS,
+ &ObjectAttributes,
+ 0,
+ NULL,
+ 0,
+ &Disposition);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Creating the Hardware Profile\\0000 key failed\n");
+ goto done;
+ }
+
+ /* Sanity check */
+ ASSERT(Disposition == REG_CREATED_NEW_KEY);
+
+done:
+ if (ProfilesHandle)
+ NtClose(ProfilesHandle);
+
+ if (ProfileHandle)
+ NtClose(ProfileHandle);
+
+ DPRINT("CmpCreateHardwareProfile() done\n");
+
+ return Status;
+}
+
NTSTATUS
NTAPI
INIT_FUNCTION
OBJECT_ATTRIBUTES ObjectAttributes;
CHAR ValueInfoBuffer[128];
PKEY_VALUE_FULL_INFORMATION ValueInfo;
- CHAR Buffer[128];
WCHAR UnicodeBuffer[128];
HANDLE SelectHandle, KeyHandle, ConfigHandle = NULL, ProfileHandle = NULL;
HANDLE ParentHandle = NULL;
ULONG ControlSet, HwProfile;
- ANSI_STRING TempString;
NTSTATUS Status;
ULONG ResultLength, Disposition;
PLOADER_PARAMETER_EXTENSION LoaderExtension;
&Disposition);
if (!NT_SUCCESS(Status)) return Status;
+ /* Create the Hardware Profile keys */
+ Status = CmpCreateHardwareProfile(KeyHandle);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
/* Don't need the handle */
ZwClose(KeyHandle);
/* Sanity check */
ASSERT(Disposition == REG_CREATED_NEW_KEY);
- /* Initialize the symbolic link name */
- sprintf(Buffer,
- "\\Registry\\Machine\\System\\ControlSet%03ld",
- ControlSet);
- RtlInitAnsiString(&TempString, Buffer);
-
- /* Create a Unicode string out of it */
- KeyName.MaximumLength = sizeof(UnicodeBuffer);
- KeyName.Buffer = UnicodeBuffer;
- Status = RtlAnsiStringToUnicodeString(&KeyName, &TempString, FALSE);
+ /* Initialize the target link name */
+ RtlStringCbPrintfW(UnicodeBuffer, sizeof(UnicodeBuffer),
+ L"\\Registry\\Machine\\System\\ControlSet%03ld",
+ ControlSet);
+ RtlInitUnicodeString(&KeyName, UnicodeBuffer);
/* Set the value */
Status = NtSetValueKey(KeyHandle,
if (!NT_SUCCESS(Status))
{
/* Cleanup and exit */
- ConfigHandle = 0;
+ ConfigHandle = NULL;
goto Cleanup;
}
- /* Now get the current config */
- RtlInitUnicodeString(&KeyName, L"CurrentConfig");
- Status = NtQueryValueKey(ConfigHandle,
- &KeyName,
- KeyValueFullInformation,
- ValueInfoBuffer,
- sizeof(ValueInfoBuffer),
- &ResultLength);
+ /* ReactOS Hack: Hard-code current to 001 for SetupLdr */
+ if (!LoaderBlock->RegistryBase)
+ {
+ HwProfile = 0;
+ }
+ else
+ {
+ /* Now get the current config */
+ RtlInitUnicodeString(&KeyName, L"CurrentConfig");
+ Status = NtQueryValueKey(ConfigHandle,
+ &KeyName,
+ KeyValueFullInformation,
+ ValueInfoBuffer,
+ sizeof(ValueInfoBuffer),
+ &ResultLength);
- /* Set pointer to buffer */
- ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer;
+ /* Set pointer to buffer */
+ ValueInfo = (PKEY_VALUE_FULL_INFORMATION)ValueInfoBuffer;
- /* Check if we failed or got a non DWORD-value */
- if (!(NT_SUCCESS(Status)) || (ValueInfo->Type != REG_DWORD)) goto Cleanup;
+ /* Check if we failed or got a non DWORD-value */
+ if (!(NT_SUCCESS(Status)) || (ValueInfo->Type != REG_DWORD)) goto Cleanup;
- /* Get the hadware profile */
- HwProfile = *(PULONG)((PUCHAR)ValueInfo + ValueInfo->DataOffset);
+ /* Get the hadware profile */
+ HwProfile = *(PULONG)((PUCHAR)ValueInfo + ValueInfo->DataOffset);
+ }
/* Open the hardware profile key */
RtlInitUnicodeString(&KeyName,
if (!NT_SUCCESS(Status))
{
/* Exit and clean up */
- ParentHandle = 0;
+ ParentHandle = NULL;
goto Cleanup;
}
/* Build the profile name */
- sprintf(Buffer, "%04ld", HwProfile);
- RtlInitAnsiString(&TempString, Buffer);
-
- /* Convert it to Unicode */
- KeyName.MaximumLength = sizeof(UnicodeBuffer);
- KeyName.Buffer = UnicodeBuffer;
- Status = RtlAnsiStringToUnicodeString(&KeyName,
- &TempString,
- FALSE);
- ASSERT(Status == STATUS_SUCCESS);
+ RtlStringCbPrintfW(UnicodeBuffer, sizeof(UnicodeBuffer),
+ L"%04ld", HwProfile);
+ RtlInitUnicodeString(&KeyName, UnicodeBuffer);
/* Open the associated key */
InitializeObjectAttributes(&ObjectAttributes,
ASSERT(Disposition == REG_CREATED_NEW_KEY);
/* Create the profile name */
- sprintf(Buffer,
- "\\Registry\\Machine\\System\\CurrentControlSet\\"
- "Hardware Profiles\\%04ld",
- HwProfile);
- RtlInitAnsiString(&TempString, Buffer);
-
- /* Convert it to Unicode */
- KeyName.MaximumLength = sizeof(UnicodeBuffer);
- KeyName.Buffer = UnicodeBuffer;
- Status = RtlAnsiStringToUnicodeString(&KeyName,
- &TempString,
- FALSE);
- ASSERT(STATUS_SUCCESS == Status);
+ RtlStringCbPrintfW(UnicodeBuffer, sizeof(UnicodeBuffer),
+ L"\\Registry\\Machine\\System\\CurrentControlSet\\"
+ L"Hardware Profiles\\%04ld",
+ HwProfile);
+ RtlInitUnicodeString(&KeyName, UnicodeBuffer);
/* Set it */
Status = NtSetValueKey(KeyHandle,
if (ProfileHandle) NtClose(ProfileHandle);
if (ParentHandle) NtClose(ParentHandle);
+ DPRINT("CmpCreateControlSet() done\n");
+
/* Return success */
return STATUS_SUCCESS;
}
if (HiveBase)
{
/* Import it */
- Status = CmpInitializeHive((PCMHIVE*)&SystemHive,
+ Status = CmpInitializeHive(&SystemHive,
HINIT_MEMORY,
HIVE_NOLAZYFLUSH,
HFILE_TYPE_LOG,
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\SYSTEM");
Status = CmpLinkHiveToMaster(&KeyName,
NULL,
- (PCMHIVE)SystemHive,
+ SystemHive,
Allocate,
SecurityDescriptor);
/* Free the security descriptor */
- ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
+ ExFreePoolWithTag(SecurityDescriptor, TAG_CMSD);
if (!NT_SUCCESS(Status)) return FALSE;
/* Add the hive to the hive list */
- CmpMachineHiveList[3].CmHive = (PCMHIVE)SystemHive;
+ CmpMachineHiveList[3].CmHive = SystemHive;
/* Success! */
return TRUE;
{
UNICODE_STRING KeyName;
PCM_KEY_NODE KeyCell;
- LARGE_INTEGER SystemTime;
PAGED_CODE();
/* Initialize the node name and allocate it */
if (!KeyCell) return FALSE;
/* Setup the cell */
- KeyCell->Signature = (USHORT)CM_KEY_NODE_SIGNATURE;
+ KeyCell->Signature = CM_KEY_NODE_SIGNATURE;
KeyCell->Flags = KEY_HIVE_ENTRY | KEY_NO_DELETE;
- KeQuerySystemTime(&SystemTime);
- KeyCell->LastWriteTime = SystemTime;
+ KeQuerySystemTime(&KeyCell->LastWriteTime);
KeyCell->Parent = HCELL_NIL;
KeyCell->SubKeyCounts[Stable] = 0;
KeyCell->SubKeyCounts[Volatile] = 0;
KeyCell->MaxValueDataLen = 0;
/* Copy the name (this will also set the length) */
- KeyCell->NameLength = CmpCopyName(Hive, (PWCHAR)KeyCell->Name, &KeyName);
+ KeyCell->NameLength = CmpCopyName(Hive, KeyCell->Name, &KeyName);
- /* Check if the name was compressed */
+ /* Check if the name was compressed and set the flag if so */
if (KeyCell->NameLength < KeyName.Length)
- {
- /* Set the flag */
KeyCell->Flags |= KEY_COMP_NAME;
- }
/* Return success */
HvReleaseCell(Hive, *Index);
&KeyName,
OBJ_CASE_INSENSITIVE,
NULL,
- NULL);
+ SecurityDescriptor);
Status = ObCreateObject(KernelMode,
CmpKeyObjectType,
&ObjectAttributes,
0,
0,
(PVOID*)&RootKey);
- ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
+ ExFreePoolWithTag(SecurityDescriptor, TAG_CMSD);
if (!NT_SUCCESS(Status)) return FALSE;
/* Sanity check, and get the key cell */
NTSTATUS
NTAPI
-CmpGetRegistryPath(IN PWCHAR ConfigPath)
+CmpGetRegistryPath(OUT PWCHAR ConfigPath)
{
OBJECT_ATTRIBUTES ObjectAttributes;
NTSTATUS Status;
/* Check if we are booted in setup */
if (ExpInTextModeSetup)
{
+ DPRINT1("CmpGetRegistryPath TextMode setup HACK!!\n");
+
/* Setup the object attributes */
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
- OBJ_CASE_INSENSITIVE,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL);
/* Open the key */
/* Add registry path */
wcscat(ConfigPath, L"\\System32\\Config\\");
+ DPRINT1("CmpGetRegistryPath: ConfigPath = '%S'\n", ConfigPath);
+
/* Done */
return STATUS_SUCCESS;
}
UNICODE_STRING TempName, FileName, RegName;
ULONG i, ErrorResponse, WorkerCount, Length;
USHORT FileStart;
- //ULONG RegStart;
ULONG PrimaryDisposition, SecondaryDisposition, ClusterSize;
PCMHIVE CmHive;
HANDLE PrimaryHandle = NULL, LogHandle = NULL;
CmpMachineHiveList[i].ThreadStarted = TRUE;
/* Build the file name and registry name strings */
- RtlInitEmptyUnicodeString(&FileName, FileBuffer, MAX_PATH);
- RtlInitEmptyUnicodeString(&RegName, RegBuffer, MAX_PATH);
+ RtlInitEmptyUnicodeString(&FileName, FileBuffer, sizeof(FileBuffer));
+ RtlInitEmptyUnicodeString(&RegName, RegBuffer, sizeof(RegBuffer));
/* Now build the system root path */
CmpGetRegistryPath(ConfigPath);
RtlInitUnicodeString(&TempName, ConfigPath);
- RtlAppendStringToString((PSTRING)&FileName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&FileName, &TempName);
FileStart = FileName.Length;
/* And build the registry root path */
RtlInitUnicodeString(&TempName, L"\\REGISTRY\\");
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
- //RegStart = RegName.Length;
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
/* Build the base name */
RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].BaseName);
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
/* Check if this is a child of the root */
- if (RegName.Buffer[RegName.Length / sizeof(WCHAR) - 1] == '\\')
+ if (RegName.Buffer[RegName.Length / sizeof(WCHAR) - 1] == OBJ_NAME_PATH_SEPARATOR)
{
/* Then setup the whole name */
RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].Name);
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
}
/* Now add the rest of the file name */
RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].Name);
FileName.Length = FileStart;
- RtlAppendStringToString((PSTRING)&FileName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&FileName, &TempName);
if (!CmpMachineHiveList[i].CmHive)
{
/* We need to allocate a new hive structure */
CmpNoWrite = FALSE;
/* Build the file name and registry name strings */
- RtlInitEmptyUnicodeString(&FileName, FileBuffer, MAX_PATH);
- RtlInitEmptyUnicodeString(&RegName, RegBuffer, MAX_PATH);
+ RtlInitEmptyUnicodeString(&FileName, FileBuffer, sizeof(FileBuffer));
+ RtlInitEmptyUnicodeString(&RegName, RegBuffer, sizeof(RegBuffer));
/* Now build the system root path */
CmpGetRegistryPath(ConfigPath);
RtlInitUnicodeString(&TempName, ConfigPath);
- RtlAppendStringToString((PSTRING)&FileName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&FileName, &TempName);
/* And build the registry root path */
RtlInitUnicodeString(&TempName, L"\\REGISTRY\\");
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
RegStart = RegName.Length;
/* Setup the event to synchronize workers */
/* Build the base name */
RegName.Length = RegStart;
RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].BaseName);
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
/* Check if this is a child of the root */
- if (RegName.Buffer[RegName.Length / sizeof(WCHAR) - 1] == '\\')
+ if (RegName.Buffer[RegName.Length / sizeof(WCHAR) - 1] == OBJ_NAME_PATH_SEPARATOR)
{
/* Then setup the whole name */
RtlInitUnicodeString(&TempName, CmpMachineHiveList[i].Name);
- RtlAppendStringToString((PSTRING)&RegName, (PSTRING)&TempName);
+ RtlAppendUnicodeStringToString(&RegName, &TempName);
}
/* Now link the hive to its master */
}
/* Get rid of the SD */
- ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
+ ExFreePoolWithTag(SecurityDescriptor, TAG_CMSD);
/* Link SECURITY to SAM */
CmpLinkKeyToHive(L"\\Registry\\Machine\\Security\\SAM",
/* Create the default security descriptor */
SecurityDescriptor = CmpHiveRootSecurityDescriptor();
- /* Create '\Registry\Machine' key. */
+ /* Create '\Registry\Machine' key */
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
/* Close the handle */
NtClose(KeyHandle);
- /* Create '\Registry\User' key. */
+ /* Create '\Registry\User' key */
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\USER");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 7, 0, 0);
}
- /* Create the 'CurrentControlSet' link. */
+ /* Create the 'CurrentControlSet' link */
Status = CmpCreateControlSet(KeLoaderBlock);
if (!NT_SUCCESS(Status))
{
}
/* Create the hardware hive */
- Status = CmpInitializeHive((PCMHIVE*)&HardwareHive,
+ Status = CmpInitializeHive(&HardwareHive,
HINIT_CREATE,
HIVE_VOLATILE,
HFILE_TYPE_PRIMARY,
}
/* Add the hive to the hive list */
- CmpMachineHiveList[0].CmHive = (PCMHIVE)HardwareHive;
+ CmpMachineHiveList[0].CmHive = HardwareHive;
/* Attach it to the machine key */
RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE");
Status = CmpLinkHiveToMaster(&KeyName,
NULL,
- (PCMHIVE)HardwareHive,
+ HardwareHive,
TRUE,
SecurityDescriptor);
if (!NT_SUCCESS(Status))
CmpAddToHiveFileList(HardwareHive);
/* Free the security descriptor */
- ExFreePoolWithTag(SecurityDescriptor, TAG_CM);
+ ExFreePoolWithTag(SecurityDescriptor, TAG_CMSD);
/* Fill out the Hardware key with the ARC Data from the Loader */
Status = CmpInitializeHardwareConfiguration(KeLoaderBlock);
/* Get hash indexes */
Index1 = GET_HASH_INDEX(ConvKey1);
Index2 = GET_HASH_INDEX(ConvKey2);
- ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey2).Owner == KeGetCurrentThread()) ||
+ ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey2)->Owner == KeGetCurrentThread()) ||
(CmpTestRegistryLockExclusive()));
/* See which one is highest */
if (Index1 < Index2)
{
/* Grab them in the proper order */
- ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey1).Owner == KeGetCurrentThread()) ||
+ ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey1)->Owner == KeGetCurrentThread()) ||
(CmpTestRegistryLockExclusive()));
CmpReleaseKcbLockByKey(ConvKey2);
CmpReleaseKcbLockByKey(ConvKey1);
/* Release the first one first, then the second */
if (Index1 != Index2)
{
- ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey1).Owner == KeGetCurrentThread()) ||
+ ASSERT((GET_HASH_ENTRY(CmpCacheTable, ConvKey1)->Owner == KeGetCurrentThread()) ||
(CmpTestRegistryLockExclusive()));
CmpReleaseKcbLockByKey(ConvKey1);
}
{
PLIST_ENTRY ListEntry;
PCMHIVE Hive;
- ULONG i;
/* Kill the workers */
if (!CmFirstTime) CmpShutdownWorkers();
{
Hive = CONTAINING_RECORD(ListEntry, CMHIVE, HiveList);
- for (i = 0; i < HFILE_TYPE_MAX; i++)
- {
- if (Hive->FileHandles[i] != NULL)
- {
- ZwClose(Hive->FileHandles[i]);
- Hive->FileHandles[i] = NULL;
- }
- }
+ CmpCloseHiveFiles(Hive);
ListEntry = ListEntry->Flink;
}
HANDLE MicrosoftKeyHandle = NULL;
HANDLE WindowsNtKeyHandle = NULL;
HANDLE CurrentVersionKeyHandle = NULL;
- WCHAR Buffer[128]; // Buffer large enough to contain a full ULONG in decimal representation,
- // and the full 'CurrentType' string.
+ WCHAR Buffer[128]; // Buffer large enough to contain a full ULONG in decimal
+ // representation, and the full 'CurrentType' string.
/*
* Open the 'HKLM\Software\Microsoft\Windows NT\CurrentVersion' key
RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE\\SOFTWARE");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
- OBJ_CASE_INSENSITIVE,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL,
NULL);
Status = NtCreateKey(&SoftwareKeyHandle,
RtlInitUnicodeString(&KeyName, L"Microsoft");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
- OBJ_CASE_INSENSITIVE,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
SoftwareKeyHandle,
NULL);
Status = NtCreateKey(&MicrosoftKeyHandle,
RtlInitUnicodeString(&KeyName, L"Windows NT");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
- OBJ_CASE_INSENSITIVE,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
MicrosoftKeyHandle,
NULL);
Status = NtCreateKey(&WindowsNtKeyHandle,
RtlInitUnicodeString(&KeyName, L"CurrentVersion");
InitializeObjectAttributes(&ObjectAttributes,
&KeyName,
- OBJ_CASE_INSENSITIVE,
+ OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
WindowsNtKeyHandle,
NULL);
Status = NtCreateKey(&CurrentVersionKeyHandle,
/* Set the 'CurrentType' value */
RtlInitUnicodeString(&ValueName, L"CurrentType");
-
- swprintf(Buffer, L"%s %s",
+ RtlStringCbPrintfW(Buffer, sizeof(Buffer),
+ L"%s %s",
#ifdef CONFIG_SMP
- L"Multiprocessor"
+ L"Multiprocessor"
#else
- L"Uniprocessor"
+ L"Uniprocessor"
#endif
- ,
+ ,
#if (DBG == 1)
- L"Checked"
+ L"Checked"
#else
- L"Free"
+ L"Free"
#endif
- );
+ );
RtlInitUnicodeString(&ValueData, Buffer);
NtSetValueKey(CurrentVersionKeyHandle,
&ValueName,