Author: ion Date: Thu May 10 05:48:54 2007 New Revision: 26670
URL: http://svn.reactos.org/svn/reactos?rev=26670&view=rev Log: - Move CmpSetSystemValues to cmsysini.c - Remove all NTLDR-style profile code from cmsysini.c, since ReactOS doesn't support it, and there's no use lugging that code around. - Rename CmpCreateCurrentControlSetLink to CmpCreateControlSet. - Get rid of CmiCreateCuttenControlSetLink and use the new version instead, which also supports setting the right current Hardware Profile ID.
Modified: trunk/reactos/ntoskrnl/cm/registry.c trunk/reactos/ntoskrnl/config/cmsysini.c
Modified: trunk/reactos/ntoskrnl/cm/registry.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/cm/registry.c?rev=... ============================================================================== --- trunk/reactos/ntoskrnl/cm/registry.c (original) +++ trunk/reactos/ntoskrnl/cm/registry.c Thu May 10 05:48:54 2007 @@ -66,8 +66,13 @@ ULONG ChunkSize, OUT PEREGISTRY_HIVE *RegistryHive);
-static NTSTATUS -CmiCreateCurrentControlSetLink(VOID); +NTSTATUS +NTAPI +CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock); + +NTSTATUS +NTAPI +CmpCreateControlSet(IN PLOADER_PARAMETER_BLOCK LoaderBlock);
static VOID STDCALL CmiHiveSyncDpcRoutine(PKDPC Dpc, @@ -78,8 +83,8 @@ extern LIST_ENTRY CmiCallbackHead; extern FAST_MUTEX CmiCallbackLock;
-UNICODE_STRING CmpSystemStartOptions; -UNICODE_STRING CmpLoadOptions; +extern UNICODE_STRING CmpSystemStartOptions; +extern UNICODE_STRING CmpLoadOptions; /* FUNCTIONS ****************************************************************/
VOID STDCALL @@ -206,63 +211,6 @@ return CmiConnectHive(&ObjectAttributes, RegistryHive); }
-NTSTATUS -NTAPI -CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING KeyName, ValueName; - HANDLE KeyHandle; - NTSTATUS Status; - ASSERT(LoaderBlock != NULL); - if (ExpInTextModeSetup) return STATUS_SUCCESS; - - /* Setup attributes for loader options */ - RtlInitUnicodeString(&KeyName, - L"\REGISTRY\MACHINE\SYSTEM\CurrentControlSet\" - L"Control"); - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - Status = NtOpenKey(&KeyHandle, KEY_WRITE, &ObjectAttributes); - if (!NT_SUCCESS(Status)) goto Quickie; - - /* Key opened, now write to the key */ - RtlInitUnicodeString(&KeyName, L"SystemStartOptions"); - Status = NtSetValueKey(KeyHandle, - &KeyName, - 0, - REG_SZ, - CmpSystemStartOptions.Buffer, - CmpSystemStartOptions.Length); - if (!NT_SUCCESS(Status)) goto Quickie; - - /* Free the options now */ - ExFreePool(CmpSystemStartOptions.Buffer); - - /* Setup value name for system boot device */ - RtlInitUnicodeString(&KeyName, L"SystemBootDevice"); - RtlCreateUnicodeStringFromAsciiz(&ValueName, LoaderBlock->NtBootPathName); - Status = NtSetValueKey(KeyHandle, - &KeyName, - 0, - REG_SZ, - ValueName.Buffer, - ValueName.Length); - -Quickie: - /* Free the buffers */ - RtlFreeUnicodeString(&ValueName); - - /* Close the key and return */ - NtClose(KeyHandle); - - /* Return the status */ - return Status; -} - BOOLEAN NTAPI CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock) @@ -538,7 +486,7 @@ }
/* Create the 'CurrentControlSet' link. */ - Status = CmiCreateCurrentControlSetLink(); + Status = CmpCreateControlSet(KeLoaderBlock); if (!NT_SUCCESS(Status)) { /* Bugcheck */ @@ -582,97 +530,6 @@
/* If we got here, all went well */ return TRUE; -} - -static NTSTATUS -CmiCreateCurrentControlSetLink(VOID) -{ - RTL_QUERY_REGISTRY_TABLE QueryTable[5]; - WCHAR TargetNameBuffer[80]; - ULONG TargetNameLength; - UNICODE_STRING LinkName = RTL_CONSTANT_STRING( - L"\Registry\Machine\SYSTEM\CurrentControlSet"); - UNICODE_STRING LinkValue = RTL_CONSTANT_STRING(L"SymbolicLinkValue"); - ULONG CurrentSet; - ULONG DefaultSet; - ULONG Failed; - ULONG LastKnownGood; - NTSTATUS Status; - OBJECT_ATTRIBUTES ObjectAttributes; - HANDLE KeyHandle; - if (ExpInTextModeSetup) return STATUS_SUCCESS; - - DPRINT("CmiCreateCurrentControlSetLink() called\n"); - - RtlZeroMemory(&QueryTable, sizeof(QueryTable)); - - QueryTable[0].Name = L"Current"; - QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; - QueryTable[0].EntryContext = &CurrentSet; - - QueryTable[1].Name = L"Default"; - QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT; - QueryTable[1].EntryContext = &DefaultSet; - - QueryTable[2].Name = L"Failed"; - QueryTable[2].Flags = RTL_QUERY_REGISTRY_DIRECT; - QueryTable[2].EntryContext = &Failed; - - QueryTable[3].Name = L"LastKnownGood"; - QueryTable[3].Flags = RTL_QUERY_REGISTRY_DIRECT; - QueryTable[3].EntryContext = &LastKnownGood; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE, - L"\Registry\Machine\SYSTEM\Select", - QueryTable, - NULL, - NULL); - if (!NT_SUCCESS(Status)) - { - return(Status); - } - - DPRINT("Current %ld Default %ld\n", CurrentSet, DefaultSet); - - swprintf(TargetNameBuffer, - L"\Registry\Machine\SYSTEM\ControlSet%03lu", - CurrentSet); - TargetNameLength = wcslen(TargetNameBuffer) * sizeof(WCHAR); - - DPRINT("Link target '%S'\n", TargetNameBuffer); - - InitializeObjectAttributes(&ObjectAttributes, - &LinkName, - OBJ_CASE_INSENSITIVE | OBJ_OPENIF | OBJ_OPENLINK, - NULL, - NULL); - Status = ZwCreateKey(&KeyHandle, - KEY_ALL_ACCESS | KEY_CREATE_LINK, - &ObjectAttributes, - 0, - NULL, - REG_OPTION_VOLATILE | REG_OPTION_CREATE_LINK, - NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT1("ZwCreateKey() failed (Status %lx)\n", Status); - return(Status); - } - - Status = ZwSetValueKey(KeyHandle, - &LinkValue, - 0, - REG_LINK, - (PVOID)TargetNameBuffer, - TargetNameLength); - if (!NT_SUCCESS(Status)) - { - DPRINT1("ZwSetValueKey() failed (Status %lx)\n", Status); - } - - ZwClose(KeyHandle); - - return Status; }
NTSTATUS
Modified: trunk/reactos/ntoskrnl/config/cmsysini.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/cmsysini.c?... ============================================================================== --- trunk/reactos/ntoskrnl/config/cmsysini.c (original) +++ trunk/reactos/ntoskrnl/config/cmsysini.c Thu May 10 05:48:54 2007 @@ -13,7 +13,6 @@ #define NDEBUG #include "debug.h"
-#if 0 /* GLOBALS *******************************************************************/
UNICODE_STRING CmSymbolicLinkValueName = @@ -21,6 +20,7 @@
UNICODE_STRING CmpSystemStartOptions; UNICODE_STRING CmpLoadOptions; +extern BOOLEAN ExpInTextModeSetup;
/* FUNCTIONS *****************************************************************/
@@ -33,6 +33,7 @@ HANDLE KeyHandle; NTSTATUS Status; ASSERT(LoaderBlock != NULL); + if (ExpInTextModeSetup) return STATUS_SUCCESS;
/* Setup attributes for loader options */ RtlInitUnicodeString(&KeyName, @@ -82,244 +83,9 @@
NTSTATUS NTAPI -CmpHwProfileDefaultSelect(IN PVOID ProfileList, - OUT PULONG ProfileIndexToUse, - IN PVOID Context) +CmpCreateControlSet(IN PLOADER_PARAMETER_BLOCK LoaderBlock) { - /* Clear the index and return success */ - *ProfileIndexToUse = 0; - return STATUS_SUCCESS; -} - -NTSTATUS -NTAPI -CmpAddDockingInfo(IN HANDLE Key, - IN PPROFILE_PARAMETER_BLOCK ProfileBlock) -{ - NTSTATUS Status = STATUS_SUCCESS; - UNICODE_STRING KeyName; - ULONG Value; - PAGED_CODE (); - - /* Get the Value from the profile block, create a Name for it and set it */ - Value = ProfileBlock->DockingState; - RtlInitUnicodeString(&KeyName, L"DockingState"); - Status = NtSetValueKey(Key, - &KeyName, - 0, - REG_DWORD, - &Value, - sizeof(Value)); - if (!NT_SUCCESS(Status)) return Status; - - /* Get the Value from the profile block, create a Name for it and set it */ - Value = ProfileBlock->Capabilities; - RtlInitUnicodeString(&KeyName, L"Capabilities"); - Status = NtSetValueKey(Key, - &KeyName, - 0, - REG_DWORD, - &Value, - sizeof(Value)); - if (!NT_SUCCESS(Status)) return Status; - - /* Get the Value from the profile block, create a Name for it and set it */ - Value = ProfileBlock->DockID; - RtlInitUnicodeString(&KeyName, L"DockID"); - Status = NtSetValueKey(Key, - &KeyName, - 0, - REG_DWORD, - &Value, - sizeof(Value)); - if (!NT_SUCCESS(Status)) return Status; - - /* Get the Value from the profile block, create a Name for it and set it */ - Value = ProfileBlock->SerialNumber; - RtlInitUnicodeString(&KeyName, L"SerialNumber"); - Status = NtSetValueKey(Key, - &KeyName, - 0, - REG_DWORD, - &Value, - sizeof(Value)); - - /* Return Status */ - return Status; -} - -NTSTATUS -NTAPI -CmpAddAliasEntry(IN HANDLE IDConfigDB, - IN PPROFILE_PARAMETER_BLOCK ProfileBlock, - IN ULONG ProfileNumber) -{ - UNICODE_STRING KeyName; - OBJECT_ATTRIBUTES ObjectAttributes; - NTSTATUS Status = STATUS_SUCCESS; - CHAR Buffer[128]; - WCHAR UnicodeBuffer[128]; - ANSI_STRING TempString; - HANDLE AliasHandle = NULL, AliasIdHandle = NULL; - ULONG Value; - ULONG Disposition; - ULONG AliasId = 0; - PAGED_CODE (); - - /* Open the alias key */ - RtlInitUnicodeString(&KeyName, L"Alias"); - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE, - IDConfigDB, - NULL); - Status = NtOpenKey(&AliasHandle, KEY_READ | KEY_WRITE, &ObjectAttributes); - - /* Check if we failed to open it */ - if (Status == STATUS_OBJECT_NAME_NOT_FOUND) - { - /* Create it instead */ - Status = NtCreateKey(&AliasHandle, - KEY_READ | KEY_WRITE, - &ObjectAttributes, - 0, - NULL, - 0, - &Disposition); - } - - /* Check if we failed */ - if (!NT_SUCCESS (Status)) - { - /* Cleanup and exit */ - AliasHandle = NULL; - goto Exit; - } - - /* Loop every alias ID */ - while (AliasId++ < 200) - { - /* Build the KeyName */ - sprintf(Buffer, "%04ld", AliasId); - RtlInitAnsiString(&TempString, Buffer); - - /* Convert it to Unicode */ - KeyName.MaximumLength = sizeof(UnicodeBuffer); - KeyName.Buffer = UnicodeBuffer; - Status = RtlAnsiStringToUnicodeString(&KeyName, - &TempString, - FALSE); - ASSERT (STATUS_SUCCESS == Status); - - /* Open the key */ - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE, - AliasHandle, - NULL); - Status = NtOpenKey(&AliasIdHandle, - KEY_READ | KEY_WRITE, - &ObjectAttributes); - if (NT_SUCCESS (Status)) - { - /* We opened it, close and keep looping */ - NtClose(AliasIdHandle); - } - else if (Status == STATUS_OBJECT_NAME_NOT_FOUND) - { - /* We couldn't find it, change Status and break out */ - Status = STATUS_SUCCESS; - break; - } - else - { - /* Any other error, break out */ - break; - } - } - - /* Check if we failed in the alias loop */ - if (!NT_SUCCESS(Status)) - { - /* Cleanup and exit */ - AliasIdHandle = 0; - goto Exit; - } - - /* Otherwise, create the alias key */ - Status = NtCreateKey(&AliasIdHandle, - KEY_READ | KEY_WRITE, - &ObjectAttributes, - 0, - NULL, - 0, - &Disposition); - if (!NT_SUCCESS(Status)) - { - /* Cleanup and exit */ - AliasIdHandle = 0; - goto Exit; - } - - /* Add docking information */ - CmpAddDockingInfo(AliasIdHandle, ProfileBlock); - - /* Set the profile number */ - Value = ProfileNumber; - RtlInitUnicodeString(&KeyName, L"ProfileNumber"); - Status = NtSetValueKey(AliasIdHandle, - &KeyName, - 0, - REG_DWORD, - &Value, - sizeof(Value)); - -Exit: - /* Close every opened key */ - if (AliasHandle) NtClose(AliasHandle); - if (AliasIdHandle) NtClose(AliasIdHandle); - - /* Return Status */ - return Status; -} - -NTSTATUS -NTAPI -CmSetAcpiHwProfile(IN PPROFILE_ACPI_DOCKING_STATE NewDockState, - IN PVOID Select, - IN PVOID Context, - OUT PHANDLE NewProfile, - OUT PBOOLEAN ProfileChanged) -{ - /* FIXME: TODO */ - *ProfileChanged = FALSE; - *NewProfile = NULL; - ASSERT(FALSE); - return STATUS_SUCCESS; -} - -NTSTATUS -NTAPI -CmpCloneHwProfile(IN HANDLE ConfigHandle, - IN HANDLE Parent, - IN HANDLE OldProfile, - IN ULONG OldProfileNumber, - IN USHORT DockingState, - OUT PHANDLE NewProfile, - OUT PULONG NewProfileNumber) -{ - /* FIXME: TODO */ - *NewProfileNumber = FALSE; - *NewProfile = NULL; - ASSERT(FALSE); - return STATUS_SUCCESS; -} - -NTSTATUS -NTAPI -CmpCreateCurrentControlSetLink(IN PLOADER_PARAMETER_BLOCK LoaderBlock) -{ - UNICODE_STRING ConfigName = RTL_CONSTANT_STRING(L"Control\ConfigHandle"); + UNICODE_STRING ConfigName = RTL_CONSTANT_STRING(L"Control\IDConfigDB"); UNICODE_STRING SelectName = RTL_CONSTANT_STRING(L"\Registry\Machine\System\Select"); UNICODE_STRING KeyName; @@ -329,16 +95,14 @@ CHAR Buffer[128]; WCHAR UnicodeBuffer[128]; HANDLE SelectHandle, KeyHandle, ConfigHandle = NULL, ProfileHandle = NULL; - HANDLE ParentHandle = NULL, AcpiHandle; + HANDLE ParentHandle = NULL; ULONG ControlSet, HwProfile; ANSI_STRING TempString; NTSTATUS Status; ULONG ResultLength, Disposition; - BOOLEAN AcpiProfile = FALSE; PLOADER_PARAMETER_EXTENSION LoaderExtension; - PROFILE_ACPI_DOCKING_STATE AcpiDockState; - BOOLEAN Active; PAGED_CODE(); + if (ExpInTextModeSetup) return STATUS_SUCCESS;
/* Open the select key */ InitializeObjectAttributes(&ObjectAttributes, @@ -347,7 +111,7 @@ NULL, NULL); Status = NtOpenKey(&SelectHandle, KEY_READ, &ObjectAttributes); - if (!NT_SUCCESS(Status))return(Status); + if (!NT_SUCCESS(Status)) return(Status);
/* Open the current value */ RtlInitUnicodeString(&KeyName, L"Current"); @@ -449,9 +213,7 @@ NULL, NULL); Status = NtOpenKey(&ParentHandle, KEY_READ, &ObjectAttributes); - - /* Check if there is no hardware profile key */ - if (!NT_SUCCESS (Status)) + if (!NT_SUCCESS(Status)) { /* Exit and clean up */ ParentHandle = 0; @@ -459,7 +221,7 @@ }
/* Build the profile name */ - sprintf(Buffer, "%04ld",HwProfile); + sprintf(Buffer, "%04ld", HwProfile); RtlInitAnsiString(&TempString, Buffer);
/* Convert it to Unicode */ @@ -479,8 +241,6 @@ Status = NtOpenKey(&ProfileHandle, KEY_READ | KEY_WRITE, &ObjectAttributes); - - /* Check if there's no such key */ if (!NT_SUCCESS (Status)) { /* Cleanup and exit */ @@ -492,80 +252,7 @@ LoaderExtension = LoaderBlock->Extension; if (LoaderExtension) { - /* Check the hardware profile status */ - switch (LoaderExtension->Profile.Status) - { - /* Cloned status */ - case 3: - - /* Clone it */ - Status = CmpCloneHwProfile(ConfigHandle, - ParentHandle, - ProfileHandle, - HwProfile, - LoaderExtension-> - Profile.DockingState, - &ProfileHandle, - &HwProfile); - if (!NT_SUCCESS(Status)) - { - /* Cloning failed, cleanup and exit */ - ProfileHandle = 0; - goto Cleanup; - } - - /* Set the current config key */ - RtlInitUnicodeString(&KeyName, L"CurrentConfig"); - Status = NtSetValueKey(ConfigHandle, - &KeyName, - 0, - REG_DWORD, - &HwProfile, - sizeof (HwProfile)); - if (!NT_SUCCESS (Status)) goto Cleanup; - - /* Alias status */ - case 1: - - /* Create an alias entry */ - Status = CmpAddAliasEntry(ConfigHandle, - &LoaderExtension->Profile, - HwProfile); - - /* Docking status */ - case 2: - - /* Create the current dock info key */ - RtlInitUnicodeString(&KeyName, - L"CurrentDockInfo"); - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE, - ConfigHandle, - NULL); - Status = NtCreateKey(&KeyHandle, - KEY_READ | KEY_WRITE, - &ObjectAttributes, - 0, - NULL, - REG_OPTION_VOLATILE, - &Disposition); - ASSERT (STATUS_SUCCESS == Status); - - /* Add the docking information */ - Status = CmpAddDockingInfo(KeyHandle, - &LoaderExtension->Profile); - break; - - /* Other cases */ - case 0: - case 0xC001: - break; - - /* Unknown status */ - default: - ASSERT(FALSE); - } + ASSERTMSG("ReactOS doesn't support NTLDR Profiles yet!\n", FALSE); }
/* Create the current hardware profile key */ @@ -602,7 +289,7 @@ Status = RtlAnsiStringToUnicodeString(&KeyName, &TempString, FALSE); - ASSERT (STATUS_SUCCESS == Status); + ASSERT(STATUS_SUCCESS == Status);
/* Set it */ Status = NtSetValueKey(KeyHandle, @@ -614,26 +301,6 @@ NtClose(KeyHandle); }
- /* Check if we have to set the ACPI Profile */ - if (AcpiProfile) - { - /* Setup the docking state to undocked */ - AcpiDockState.DockingState = 1; - AcpiDockState.SerialLength = 2; - AcpiDockState.SerialNumber[0] = L'\0'; - - /* Set the ACPI profile */ - Status = CmSetAcpiHwProfile(&AcpiDockState, - CmpHwProfileDefaultSelect, - NULL, - &AcpiHandle, - &Active); - ASSERT(NT_SUCCESS(Status)); - - /* Close the key */ - NtClose(AcpiHandle); - } - /* Close every opened handle */ Cleanup: if (ConfigHandle) NtClose(ConfigHandle); @@ -643,4 +310,3 @@ /* Return success */ return STATUS_SUCCESS; } -#endif