https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1b0c26e21cbdb73998529…
commit 1b0c26e21cbdb739985290dc5b5135af6c313cb4
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jan 7 01:35:48 2018 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Nov 1 18:55:45 2018 +0100
[SETUPLIB][USETUP] Minor improvements.
- 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 | 25 +++++++++++--------------
base/setup/lib/setuplib.h | 4 ----
base/setup/lib/utils/arcname.c | 6 +++---
base/setup/usetup/usetup.c | 8 ++------
4 files changed, 16 insertions(+), 27 deletions(-)
diff --git a/base/setup/lib/setuplib.c b/base/setup/lib/setuplib.c
index 34eb2283bb..915acd5a36 100644
--- a/base/setup/lib/setuplib.c
+++ b/base/setup/lib/setuplib.c
@@ -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;
diff --git a/base/setup/lib/setuplib.h b/base/setup/lib/setuplib.h
index 0686b00d58..585808f6fa 100644
--- a/base/setup/lib/setuplib.h
+++ b/base/setup/lib/setuplib.h
@@ -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 */
diff --git a/base/setup/lib/utils/arcname.c b/base/setup/lib/utils/arcname.c
index 56f44cfef3..5d63dd02b3 100644
--- a/base/setup/lib/utils/arcname.c
+++ b/base/setup/lib/utils/arcname.c
@@ -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;
}
diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c
index 46da942935..d951a65a86 100644
--- a/base/setup/usetup/usetup.c
+++ b/base/setup/usetup/usetup.c
@@ -21,7 +21,7 @@
* PROJECT: ReactOS text-mode setup
* FILE: base/setup/usetup/usetup.c
* PURPOSE: Text-mode setup
- * PROGRAMMER: Casper S. Hornstrup (chorns(a)users.sourceforge.net)
+ * PROGRAMMERS: Casper S. Hornstrup (chorns(a)users.sourceforge.net)
* Herv� Poussineau (hpoussin(a)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)
{