diff --git a/reactos/subsys/system/usetup/registry.c b/reactos/subsys/system/usetup/registry.c index 0d68a64ade7..06990f479e2 100644 --- a/reactos/subsys/system/usetup/registry.c +++ b/reactos/subsys/system/usetup/registry.c @@ -209,6 +209,7 @@ do_reg_operation(HANDLE KeyHandle, WCHAR EmptyStr = (WCHAR)0; ULONG Type; ULONG Size; + NTSTATUS Status; if (Flags & (FLG_ADDREG_DELREG_BIT | FLG_ADDREG_DELVAL)) /* deletion */ { @@ -331,37 +332,50 @@ do_reg_operation(HANDLE KeyHandle, if (Type == REG_DWORD) { - ULONG dw = Str ? wcstol (Str, NULL, 16) : 0; + ULONG dw = Str ? wcstol (Str, NULL, 0) : 0; - DPRINT1("setting dword %wZ to %lx\n", &ValueName, dw); + DPRINT1("setting dword %wZ to %lx\n", ValueName, dw); - NtSetValueKey (KeyHandle, - ValueName, - 0, - Type, - (PVOID)&dw, - (ULONG)sizeof(dw)); + Status = NtSetValueKey (KeyHandle, + ValueName, + 0, + Type, + (PVOID)&dw, + sizeof(ULONG)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status); + } } else { DPRINT1("setting value %wZ to %S\n", ValueName, Str); + if (Str) { - NtSetValueKey (KeyHandle, + Status = NtSetValueKey (KeyHandle, ValueName, 0, Type, (PVOID)Str, Size * sizeof(WCHAR)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status); + } } else { - NtSetValueKey (KeyHandle, + Status = NtSetValueKey (KeyHandle, ValueName, 0, Type, (PVOID)&EmptyStr, sizeof(WCHAR)); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status); + } } } RtlFreeHeap (ProcessHeap, 0, Str); @@ -383,16 +397,18 @@ do_reg_operation(HANDLE KeyHandle, InfGetBinaryField (Context, 5, Data, Size, NULL); } - NtSetValueKey (KeyHandle, - ValueName, - 0, - Type, - (PVOID)Data, - Size); + Status = NtSetValueKey (KeyHandle, + ValueName, + 0, + Type, + (PVOID)Data, + Size); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status); + } RtlFreeHeap (ProcessHeap, 0, Data); - - return TRUE; } return TRUE; @@ -651,6 +667,7 @@ ImportRegistryData(PWSTR Filename) NTSTATUS SetupUpdateRegistry(VOID) { +#if 0 OBJECT_ATTRIBUTES ObjectAttributes; UNICODE_STRING KeyName; UNICODE_STRING ValueName; @@ -679,7 +696,6 @@ SetupUpdateRegistry(VOID) NtClose(KeyHandle); -#if 0 /* Create '\Registry\Machine\System\Setup' key */ RtlInitUnicodeStringFromLiteral(&KeyName, L"\\Registry\\Machine\\SYSTEM\\Setup"); @@ -708,6 +724,7 @@ SetupUpdateRegistry(VOID) NtClose(KeyHandle); #endif + SetStatusText(" Importing hivesys.inf..."); if (!ImportRegistryData (L"hivesys.inf")) @@ -720,4 +737,49 @@ SetupUpdateRegistry(VOID) return STATUS_SUCCESS; } + +BOOLEAN +SetInstallPathValue(PUNICODE_STRING InstallPath) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING KeyName; + UNICODE_STRING ValueName; + HANDLE KeyHandle; + NTSTATUS Status; + + /* Create the 'secret' InstallPath key */ + RtlInitUnicodeStringFromLiteral (&KeyName, + L"\\Registry\\Machine\\HARDWARE"); + InitializeObjectAttributes (&ObjectAttributes, + &KeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtOpenKey (&KeyHandle, + KEY_ALL_ACCESS, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtOpenKey() failed (Status %lx)\n", Status); + return FALSE; + } + + RtlInitUnicodeStringFromLiteral (&ValueName, + L"InstallPath"); + Status = NtSetValueKey (KeyHandle, + &ValueName, + 0, + REG_SZ, + (PVOID)InstallPath->Buffer, + InstallPath->Length); + NtClose(KeyHandle); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status); + return FALSE; + } + + return TRUE; +} + /* EOF */ diff --git a/reactos/subsys/system/usetup/registry.h b/reactos/subsys/system/usetup/registry.h index be853eb4ce6..1ae50d39d7e 100644 --- a/reactos/subsys/system/usetup/registry.h +++ b/reactos/subsys/system/usetup/registry.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: registry.h,v 1.2 2003/03/18 20:39:49 ekohl Exp $ +/* $Id: registry.h,v 1.3 2003/03/19 20:12:44 ekohl Exp $ * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS text-mode setup * FILE: subsys/system/usetup/registry.h @@ -27,12 +27,16 @@ #ifndef __REGISTRY_H__ #define __REGISTRY_H__ + NTSTATUS SetupUpdateRegistry(VOID); BOOLEAN ImportRegistryData(PWSTR Filename); +BOOLEAN +SetInstallPathValue(PUNICODE_STRING InstallPath); + #endif /* __REGISTRY_H__ */ /* EOF */ diff --git a/reactos/subsys/system/usetup/usetup.c b/reactos/subsys/system/usetup/usetup.c index 64e038cd503..40a277edf31 100644 --- a/reactos/subsys/system/usetup/usetup.c +++ b/reactos/subsys/system/usetup/usetup.c @@ -1264,58 +1264,21 @@ FileCopyPage(PINPUT_RECORD Ir) static ULONG RegistryPage(PINPUT_RECORD Ir) { - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING KeyName; - UNICODE_STRING ValueName; - HANDLE KeyHandle; + INFCONTEXT InfContext; NTSTATUS Status; - SetTextXY(6, 8, "Setup updated the system configuration"); + PWSTR Action; + PWSTR File; + PWSTR Section; + + + SetTextXY(6, 8, "Setup is updating the system configuration"); SetStatusText(" Creating registry hives..."); - /* Create the 'secret' InstallPath key */ - RtlInitUnicodeStringFromLiteral(&KeyName, - L"\\Registry\\Machine\\HARDWARE"); - InitializeObjectAttributes(&ObjectAttributes, - &KeyName, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - Status = NtOpenKey(&KeyHandle, - KEY_ALL_ACCESS, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) + if (!SetInstallPathValue(&DestinationPath)) { - DPRINT1("NtOpenKey() failed (Status %lx)\n", Status); - PopupError("Setup failed to open the HARDWARE registry key.", - "ENTER = Reboot computer"); - - while(TRUE) - { - ConInKey(Ir); - - if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */ - { - return(QUIT_PAGE); - } - } - } - - RtlInitUnicodeStringFromLiteral(&ValueName, - L"InstallPath"); - - Status = NtSetValueKey(KeyHandle, - &ValueName, - 0, - REG_SZ, - (PVOID)DestinationPath.Buffer, - DestinationPath.Length); - NtClose(KeyHandle); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtSetValueKey() failed (Status %lx)\n", Status); - PopupError("Setup failed to set the \'InstallPath\' registry value.", + PopupError("Setup failed to set the initialize the registry.", "ENTER = Reboot computer"); while(TRUE) @@ -1334,7 +1297,7 @@ RegistryPage(PINPUT_RECORD Ir) if (!NT_SUCCESS(Status)) { DPRINT1("NtInitializeRegistry() failed (Status %lx)\n", Status); - PopupError("Setup failed to initialize the registry.", + PopupError("Setup failed to create the registry hives.", "ENTER = Reboot computer"); while(TRUE) @@ -1351,6 +1314,38 @@ RegistryPage(PINPUT_RECORD Ir) /* Update registry */ SetStatusText(" Updating registry hives..."); +#if 0 + if (!InfFindFirstLine(SetupInf, L"HiveInfs.Install", NULL, &InfContext)) + { + DPRINT1("InfFindFirstLine() failed\n"); + PopupError("Setup failed to find the registry hive inf-files.", + "ENTER = Reboot computer"); + + while(TRUE) + { + ConInKey(Ir); + + if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */ + { + return(QUIT_PAGE); + } + } + } + + do + { + + InfGetDataField (&InfContext, 0, &Action); + InfGetDataField (&InfContext, 1, &File); + InfGetDataField (&InfContext, 2, &Section); + + DPRINT1("Action: %S File: %S Section %S\n", Action, File, Section); + + } + while (InfFindNextLine (&InfContext, &InfContext)); +#endif + + Status = SetupUpdateRegistry(); if (!NT_SUCCESS(Status)) {