[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.
This commit is contained in:
Hermès Bélusca-Maïto 2018-01-07 01:35:48 +01:00
parent 13998a15c9
commit 1b0c26e21c
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
4 changed files with 16 additions and 27 deletions

View 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;

View 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 */

View 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;
}

View 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)
{