Files
reactos/base/setup/lib/utils/filesup.h
Whindmar Saksit 4c9a150083 [SETUPLIB] Search for unattend.inf on all drives (#9299)
This allows any ISO (nightly, etc.) to perform unattended installations
without having to manually rebuild the ISO with your modified unattend.inf
file. Instead, you simply need to place your custom unattend.inf file
at the root of any drive in the machine (and with a special value set
in this .inf to enable this feature).

Notes:
- It tries to use `QueryDosDeviceW` if kernel32.dll is loaded (GUI setup),
  so that the drive map matches the existing user logon session. If not
  available, it emulates a simplified version of `QueryDosDeviceW` which
  should be enough when booted directly into phase-1 setup.

- The unattend.inf file lookup algorithm goes as follows:

  Find first the default unattend.inf file on the installation media.
  If it specifies an unattended setup, we have found it.

  Otherwise, the default unattend.inf file does not exist, or does not
  enable an unattended setup. Check all DOS drives, removable first, then
  fixed, for an alternative unattend.inf that enables unattended setup.
  If we find one, use it; otherwise, return the default unattend.inf path.


Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
2026-09-24 23:28:38 +02:00

133 lines
2.9 KiB
C

/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: File support functions.
* COPYRIGHT: Casper S. Hornstrup (chorns@users.sourceforge.net)
* Copyright 2017-2018 Hermes Belusca-Maito
*/
#pragma once
NTSTATUS
SetupCreateDirectory(
_In_ PCWSTR PathName);
NTSTATUS
SetupDeleteFile(
IN PCWSTR FileName,
IN BOOLEAN ForceDelete); // ForceDelete can be used to delete read-only files
NTSTATUS
SetupCopyFile(
IN PCWSTR SourceFileName,
IN PCWSTR DestinationFileName,
IN BOOLEAN FailIfExists);
#ifndef _WINBASE_
#define MOVEFILE_REPLACE_EXISTING 1
#define MOVEFILE_COPY_ALLOWED 2
#define MOVEFILE_WRITE_THROUGH 8
#endif
NTSTATUS
SetupMoveFile(
IN PCWSTR ExistingFileName,
IN PCWSTR NewFileName,
IN ULONG Flags);
NTSTATUS
ConcatPathsV(
IN OUT PWSTR PathBuffer,
IN SIZE_T cchPathSize,
IN ULONG NumberOfPathComponents,
IN va_list PathComponentsList);
NTSTATUS
CombinePathsV(
OUT PWSTR PathBuffer,
IN SIZE_T cchPathSize,
IN ULONG NumberOfPathComponents,
IN va_list PathComponentsList);
NTSTATUS
ConcatPaths(
IN OUT PWSTR PathBuffer,
IN SIZE_T cchPathSize,
IN ULONG NumberOfPathComponents,
IN /* PCWSTR */ ...);
NTSTATUS
CombinePaths(
OUT PWSTR PathBuffer,
IN SIZE_T cchPathSize,
IN ULONG NumberOfPathComponents,
IN /* PCWSTR */ ...);
BOOLEAN
DoesPathExist_UStr(
_In_opt_ HANDLE RootDirectory,
_In_ PCUNICODE_STRING PathName,
_In_ BOOLEAN IsDirectory);
BOOLEAN
DoesPathExist(
_In_opt_ HANDLE RootDirectory,
_In_ PCWSTR PathName,
_In_ BOOLEAN IsDirectory);
#define DoesDirExist(RootDirectory, DirName) \
DoesPathExist((RootDirectory), (DirName), TRUE)
#define DoesFileExist(RootDirectory, FileName) \
DoesPathExist((RootDirectory), (FileName), FALSE)
// FIXME: DEPRECATED! HACKish function that needs to be deprecated!
BOOLEAN
DoesFileExist_2(
IN PCWSTR PathName OPTIONAL,
IN PCWSTR FileName);
BOOLEAN
NtPathToDiskPartComponents(
IN PCWSTR NtPath,
OUT PULONG pDiskNumber,
OUT PULONG pPartNumber,
OUT PCWSTR* PathComponent OPTIONAL);
NTSTATUS
OpenAndMapFile(
_In_opt_ HANDLE RootDirectory,
_In_ PCWSTR PathNameToFile,
_Out_opt_ PHANDLE FileHandle,
_Out_opt_ PULONG FileSize,
_Out_ PHANDLE SectionHandle,
_Out_ PVOID* BaseAddress,
_In_ BOOLEAN ReadWriteAccess);
NTSTATUS
MapFile(
_In_ HANDLE FileHandle,
_Out_ PHANDLE SectionHandle,
_Out_ PVOID* BaseAddress,
_In_ BOOLEAN ReadWriteAccess);
BOOLEAN
UnMapFile(
_In_ HANDLE SectionHandle,
_In_ PVOID BaseAddress);
#define UnMapAndCloseFile(FileHandle, SectionHandle, BaseAddress) \
do { \
UnMapFile((SectionHandle), (BaseAddress)); \
NtClose(FileHandle); \
} while (0)
UCHAR
GetNtDevicePathOfDriveNumber(
_In_ USHORT DriveNumber,
_Out_ PUNICODE_STRING DevicePath);
/* EOF */