reactos/base/setup/lib/setuplib.h

237 lines
6 KiB
C
Raw Normal View History

/*
* PROJECT: ReactOS Setup Library
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Public header
* COPYRIGHT: Copyright 2017-2018 Hermes Belusca-Maito
*/
#pragma once
/* INCLUDES *****************************************************************/
/* Needed PSDK headers when using this library */
#if 0
#define WIN32_NO_STATUS
#define _INC_WINDOWS
#define COM_NO_WINDOWS_H
#include <winxxx.h>
#endif
/* NOTE: Please keep the header inclusion order! */
extern HANDLE ProcessHeap;
#include "errorcode.h"
#include "spapisup/fileqsup.h"
#include "spapisup/infsupp.h"
#include "utils/linklist.h"
#include "utils/ntverrsrc.h"
// #include "utils/arcname.h"
#include "utils/bldrsup.h"
#include "utils/filesup.h"
#include "utils/fsrec.h"
#include "utils/genlist.h"
#include "utils/inicache.h"
#include "utils/partinfo.h"
#include "utils/partlist.h"
#include "utils/arcname.h"
#include "utils/osdetect.h"
#include "utils/regutil.h"
#include "bootcode.h"
#include "fsutil.h"
#include "bootsup.h"
[USETUP][SETUPLIB] Split the registry helper code. Split the registry helper code into registry utility functions (create/mount/unmount/verify hives) and registry creation code (the rest: initializing the system hives) and move it in the setup library. svn path=/branches/setup_improvements/; revision=75247 [USETUP][SETUPLIB] Improve how the Setup* INF APIs are interfaced in the code. Define prototypes compatible (including their calling convention) with the ones defined by setupapi (.h/.dll) so that it can be possible to either use an internal implementation of these functions (via the INFLIB library) as currently being done, or using imported setupapi functions, as would be done by the future 1st-stage GUI installer. [SETUPLIB] Cleanup the registry.c file and use the infsupp.h header. svn path=/branches/setup_improvements/; revision=75345 svn path=/branches/setup_improvements/; revision=75346 [USETUP][SETUPLIB] Move some INF-related code from usetup to the setuplib. - Move the generic INF_GetDataField() and INF_GetData() helpers to setuplib, and rework them a bit so that they explicitly call setupapi functions (or implementations thereof when being used in usetup); - Rework the headers in accordance; - Fix compilation in lib/registry.c . - Fix compilation when these headers are used withing usetup (who doesn't use setupapi.dll) and "reactos" (the 1st-stage GUI installer that uses setupapi.dll). svn path=/branches/setup_improvements/; revision=75515 svn path=/branches/setup_improvements/; revision=75537 svn path=/branches/setup_improvements/; revision=75538
2017-06-30 19:07:02 +00:00
#include "registry.h"
[SETUPLIB][USETUP][INPUT.CPL] MUI integration with setuplib. [SETUPLIB] Copy the mui* files from usetup into the setuplib for later usage, and add mui.c to build. svn path=/branches/setup_improvements/; revision=75711 [SETUPLIB][USETUP] Start massaging the MUI files and split up what concerns only the usetup "resources", and what concerns general language parameters (in the setuplib). It may be interesting to retrieve the language parameters from INF file (e.g. intl.inf) (suggested by Giannis). svn path=/branches/setup_improvements/; revision=75715 [SETUPLIB] Add the necessary headers to mui.c to be able to compile. [USETUP] Comment out the languages that don't have any resources. svn path=/branches/setup_improvements/; revision=75716 [SETUPLIB][USETUP] Adjust MUI and settings code. - Re-enable settings code concerning language, keyboards & layout in the setuplib, and remove the old code in usetup. - Remove useless code in setuplib's mui.c. - Rename usetup's MUI "LanguageList" into "ResourceList" so as to avoid colliding with the "LanguageList" of setuplib. - Add the magic CMakeLists line "add_definitions(${I18N_DEFS})" that I forgot previously, that caused the "LanguageList" of setuplib to be empty! The code compiles and works during my tests. svn path=/branches/setup_improvements/; revision=75717 [SETUPLIB] Change some string pointer types & function prototypes so that the usetup-specific "SelectedLanguageId" variable is not used in the library. svn path=/branches/setup_improvements/; revision=75719 [SETUPLIB] Change some function prototypes so that the usetup-specific "SelectedLanguageId" variable is not used in the library. Also, make AddEntriesFromInfSection(), DefaultProcessEntry() and the typedef PPROCESS_ENTRY_ROUTINE private again. svn path=/branches/setup_improvements/; revision=75720 svn path=/branches/setup_improvements/; revision=75724 [USETUP] Code adaptations. - Transform some do{}while() loops into while(){} ones, since the lists on which we work may only contain one single {NULL} element. - Modify MUIGetOEMCodePage() call after r75719. - Use PCWSTR where needed. svn path=/branches/setup_improvements/; revision=75722 [USETUP] Adjust some MUI & settings calls, following the commits r75719, r75720 and r75721. svn path=/branches/setup_improvements/; revision=75723 [INPUT.CPL] Adjust inclusion of "muifonts.h" (commit 3dbd44f) due to changes introduced in r75711 and r75715.
2017-08-30 11:28:52 +00:00
#include "mui.h"
#include "settings.h"
// #include "install.h" // See at the end...
/* DEFINES ******************************************************************/
#define KB ((ULONGLONG)1024)
#define MB (KB*KB)
#define GB (KB*KB*KB)
// #define TB (KB*KB*KB*KB)
// #define PB (KB*KB*KB*KB*KB)
/* TYPEDEFS *****************************************************************/
struct _USETUP_DATA;
typedef VOID
(__cdecl *PSETUP_ERROR_ROUTINE)(IN struct _USETUP_DATA*, ...);
typedef struct _USETUP_DATA
{
/* Error handling *****/
ERROR_NUMBER LastErrorNumber;
PSETUP_ERROR_ROUTINE ErrorRoutine;
/* Setup INFs *****/
HINF SetupInf;
/* Installation *****/
PVOID SetupFileQueue; // HSPFILEQ
/* SOURCE Paths *****/
UNICODE_STRING SourceRootPath;
UNICODE_STRING SourceRootDir;
UNICODE_STRING SourcePath;
/* DESTINATION Paths *****/
/*
* Path to the system partition, where the boot manager resides.
* On x86 PCs, this is usually the active partition.
* On ARC, (u)EFI, ... platforms, this is a dedicated partition.
*
* For more information, see:
* https://en.wikipedia.org/wiki/System_partition_and_boot_partition
* http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/boot-and-system-volumes.html
* http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/arc-boot-process.html
* http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/efi-boot-process.html
* http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-system-volume.html
* http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/determining-boot-volume.html
*/
UNICODE_STRING SystemRootPath;
/* Path to the installation directory inside the ReactOS boot partition */
UNICODE_STRING DestinationArcPath; /** Equivalent of 'NTOS_INSTALLATION::SystemArcPath' **/
UNICODE_STRING DestinationPath; /** Equivalent of 'NTOS_INSTALLATION::SystemNtPath' **/
UNICODE_STRING DestinationRootPath;
// FIXME: This is only temporary!! Must be removed later!
UNICODE_STRING InstallPath;
LONG DestinationDiskNumber;
LONG DestinationPartitionNumber;
LONG MBRInstallType;
LONG FormatPartition;
LONG AutoPartition;
LONG FsType;
/* Settings lists *****/
PGENERIC_LIST ComputerList;
PGENERIC_LIST DisplayList;
PGENERIC_LIST KeyboardList;
PGENERIC_LIST LayoutList;
PGENERIC_LIST LanguageList;
/* Settings *****/
PCWSTR ComputerType;
PCWSTR DisplayType;
// PCWSTR KeyboardDriver;
// PCWSTR MouseDriver;
PCWSTR LayoutId; // DefaultKBLayout
/* Other stuff *****/
WCHAR LocaleID[9];
LANGID LanguageId;
ULONG RequiredPartitionDiskSpace;
WCHAR InstallationDirectory[MAX_PATH];
} USETUP_DATA, *PUSETUP_DATA;
#include "install.h"
// HACK!!
extern BOOLEAN IsUnattendedSetup;
/* FUNCTIONS ****************************************************************/
#include "substset.h"
VOID
CheckUnattendedSetup(
IN OUT PUSETUP_DATA pSetupData);
VOID
InstallSetupInfFile(
IN OUT PUSETUP_DATA pSetupData);
NTSTATUS
GetSourcePaths(
OUT PUNICODE_STRING SourcePath,
OUT PUNICODE_STRING SourceRootPath,
OUT PUNICODE_STRING SourceRootDir);
ERROR_NUMBER
LoadSetupInf(
IN OUT PUSETUP_DATA pSetupData);
#define ERROR_SYSTEM_PARTITION_NOT_FOUND (ERROR_LAST_ERROR_CODE + 1)
BOOLEAN
InitSystemPartition(
/**/_In_ PPARTLIST PartitionList, /* HACK HACK! */
/**/_In_ PPARTENTRY InstallPartition, /* HACK HACK! */
/**/_Out_ PPARTENTRY* pSystemPartition, /* HACK HACK! */
_In_opt_ PFSVOL_CALLBACK FsVolCallback,
_In_opt_ PVOID Context);
/**
* @brief
* Defines the class of characters valid for the installation directory.
*
* The valid characters are: ASCII alphanumericals (a-z, A-Z, 0-9),
* and: '.', '\\', '-', '_' . Spaces are not allowed.
**/
#define IS_VALID_INSTALL_PATH_CHAR(c) \
(isalnum(c) || (c) == L'.' || (c) == L'\\' || (c) == L'-' || (c) == L'_')
BOOLEAN
IsValidInstallDirectory(
_In_ PCWSTR InstallDir);
NTSTATUS
InitDestinationPaths(
IN OUT PUSETUP_DATA pSetupData,
IN PCWSTR InstallationDir,
IN PPARTENTRY PartEntry); // FIXME: HACK!
// NTSTATUS
ERROR_NUMBER
InitializeSetup(
IN OUT PUSETUP_DATA pSetupData,
IN ULONG InitPhase);
VOID
FinishSetup(
IN OUT PUSETUP_DATA pSetupData);
typedef enum _REGISTRY_STATUS
{
Success = 0,
RegHiveUpdate,
ImportRegHive,
DisplaySettingsUpdate,
LocaleSettingsUpdate,
KeybLayouts,
KeybSettingsUpdate,
CodePageInfoUpdate,
} REGISTRY_STATUS;
typedef VOID
(__cdecl *PREGISTRY_STATUS_ROUTINE)(IN REGISTRY_STATUS, ...);
ERROR_NUMBER
UpdateRegistry(
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 PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL,
IN PFONTSUBSTSETTINGS SubstSettings OPTIONAL);
/* EOF */