[SETUPLIB][USETUP] Minor improvements.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 7 Jan 2018 00:35:48 +0000 (01:35 +0100)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Thu, 1 Nov 2018 17:55:45 +0000 (18:55 +0100)
- Use adequate access flag when opening symbolic links.
- Simplify the prototype of UpdateRegistry() since now both Setup INF
  handle and settings lists are inside the USETUP_DATA structure.

base/setup/lib/setuplib.c
base/setup/lib/setuplib.h
base/setup/lib/utils/arcname.c
base/setup/usetup/usetup.c

index 34eb228..915acd5 100644 (file)
@@ -391,7 +391,7 @@ GetSourcePaths(
     OUT PUNICODE_STRING SourceRootDir)
 {
     NTSTATUS Status;
-    HANDLE Handle;
+    HANDLE LinkHandle;
     OBJECT_ATTRIBUTES ObjectAttributes;
     UCHAR ImageFileBuffer[sizeof(UNICODE_STRING) + MAX_PATH * sizeof(WCHAR)];
     PUNICODE_STRING InstallSourcePath = (PUNICODE_STRING)&ImageFileBuffer;
@@ -439,7 +439,7 @@ GetSourcePaths(
                                NULL,
                                NULL);
 
-    Status = NtOpenSymbolicLinkObject(&Handle,
+    Status = NtOpenSymbolicLinkObject(&LinkHandle,
                                       SYMBOLIC_LINK_QUERY,
                                       &ObjectAttributes);
     if (!NT_SUCCESS(Status))
@@ -458,10 +458,11 @@ GetSourcePaths(
                               SystemRootBuffer,
                               sizeof(SystemRootBuffer));
 
-    Status = NtQuerySymbolicLinkObject(Handle,
+    /* Resolve the link and close its handle */
+    Status = NtQuerySymbolicLinkObject(LinkHandle,
                                        &SystemRootPath,
                                        &BufferSize);
-    NtClose(Handle);
+    NtClose(LinkHandle);
 
     if (!NT_SUCCESS(Status))
         return Status; // Unexpected error
@@ -790,15 +791,11 @@ FinishSetup(
  */
 ERROR_NUMBER
 UpdateRegistry(
-    IN HINF SetupInf,
     IN OUT PUSETUP_DATA pSetupData,
     /**/IN BOOLEAN RepairUpdateFlag,     /* HACK HACK! */
     /**/IN PPARTLIST PartitionList,      /* HACK HACK! */
     /**/IN WCHAR DestinationDriveLetter, /* HACK HACK! */
     /**/IN PCWSTR SelectedLanguageId,    /* HACK HACK! */
-    IN PGENERIC_LIST DisplayList,
-    IN PGENERIC_LIST LayoutList,
-    IN PGENERIC_LIST LanguageList,
     IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL)
 {
     ERROR_NUMBER ErrorNumber;
@@ -860,9 +857,9 @@ DoUpdate:
          * "repair" (aka. recreate: ShouldRepairRegistry == TRUE).
          */
 
-        Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Fresh", NULL, &InfContext);       // Windows-compatible
+        Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Fresh", NULL, &InfContext);       // Windows-compatible
         if (!Success)
-            Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific
+            Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific
 
         if (!Success)
         {
@@ -879,7 +876,7 @@ DoUpdate:
          * we only update the hives.
          */
 
-        Success = SpInfFindFirstLine(SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext);
+        Success = SpInfFindFirstLine(pSetupData->SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext);
         if (!Success)
         {
             /* Nothing to do for update! */
@@ -939,7 +936,7 @@ DoUpdate:
 
         /* Update display registry settings */
         if (StatusRoutine) StatusRoutine(DisplaySettingsUpdate);
-        if (!ProcessDisplayRegistry(SetupInf, DisplayList))
+        if (!ProcessDisplayRegistry(pSetupData->SetupInf, pSetupData->DisplayList))
         {
             ErrorNumber = ERROR_UPDATE_DISPLAY_SETTINGS;
             goto Cleanup;
@@ -947,7 +944,7 @@ DoUpdate:
 
         /* Set the locale */
         if (StatusRoutine) StatusRoutine(LocaleSettingsUpdate);
-        if (!ProcessLocaleRegistry(LanguageList))
+        if (!ProcessLocaleRegistry(pSetupData->LanguageList))
         {
             ErrorNumber = ERROR_UPDATE_LOCALESETTINGS;
             goto Cleanup;
@@ -972,7 +969,7 @@ DoUpdate:
         {
             /* Update keyboard layout settings */
             if (StatusRoutine) StatusRoutine(KeybSettingsUpdate);
-            if (!ProcessKeyboardLayoutRegistry(LayoutList, SelectedLanguageId))
+            if (!ProcessKeyboardLayoutRegistry(pSetupData->LayoutList, SelectedLanguageId))
             {
                 ErrorNumber = ERROR_UPDATE_KBSETTINGS;
                 goto Cleanup;
index 0686b00..585808f 100644 (file)
@@ -176,15 +176,11 @@ typedef VOID
 
 ERROR_NUMBER
 UpdateRegistry(
-    IN HINF SetupInf,
     IN OUT PUSETUP_DATA pSetupData,
     /**/IN BOOLEAN RepairUpdateFlag,     /* HACK HACK! */
     /**/IN PPARTLIST PartitionList,      /* HACK HACK! */
     /**/IN WCHAR DestinationDriveLetter, /* HACK HACK! */
     /**/IN PCWSTR SelectedLanguageId,    /* HACK HACK! */
-    IN PGENERIC_LIST DisplayList,
-    IN PGENERIC_LIST LayoutList,
-    IN PGENERIC_LIST LanguageList,
     IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL);
 
 /* EOF */
index 56f44cf..5d63dd0 100644 (file)
@@ -616,7 +616,7 @@ ResolveArcNameNtSymLink(
                                DirectoryHandle,
                                NULL);
     Status = NtOpenSymbolicLinkObject(&LinkHandle,
-                                      SYMBOLIC_LINK_ALL_ACCESS,
+                                      SYMBOLIC_LINK_QUERY,
                                       &ObjectAttributes);
 
     /* Close the \ArcName object directory handle */
@@ -632,8 +632,9 @@ ResolveArcNameNtSymLink(
     /* Reserve one WCHAR for the NULL-termination */
     NtName->MaximumLength -= sizeof(UNICODE_NULL);
 
-    /* Resolve the link */
+    /* Resolve the link and close its handle */
     Status = NtQuerySymbolicLinkObject(LinkHandle, NtName, NULL);
+    NtClose(LinkHandle);
 
     /* Restore the NULL-termination */
     NtName->MaximumLength += sizeof(UNICODE_NULL);
@@ -650,7 +651,6 @@ ResolveArcNameNtSymLink(
         NtName->Buffer[NtName->Length / sizeof(WCHAR)] = UNICODE_NULL;
     }
 
-    NtClose(LinkHandle);
     return Status;
 }
 
index 46da942..d951a65 100644 (file)
@@ -21,7 +21,7 @@
  * PROJECT:         ReactOS text-mode setup
  * FILE:            base/setup/usetup/usetup.c
  * PURPOSE:         Text-mode setup
- * PROGRAMMER     Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * PROGRAMMERS:     Casper S. Hornstrup (chorns@users.sourceforge.net)
  *                  Hervé Poussineau (hpoussin@reactos.org)
  */
 
@@ -4300,15 +4300,11 @@ RegistryPage(PINPUT_RECORD Ir)
 
     MUIDisplayPage(REGISTRY_PAGE);
 
-    Error = UpdateRegistry(USetupData.SetupInf,
-                           &USetupData,
+    Error = UpdateRegistry(&USetupData,
                            RepairUpdateFlag,
                            PartitionList,
                            DestinationDriveLetter,
                            SelectedLanguageId,
-                           USetupData.DisplayList,
-                           USetupData.LayoutList,
-                           USetupData.LanguageList,
                            RegistryStatus);
     if (Error != ERROR_SUCCESS)
     {