Commit graph

197 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto
d7c1d220b5
[SETUPLIB][REACTOS][USETUP] Turn setuplib into a DLL shared between TUI and GUI 1st-stage setups (#7523)
CORE-13525

Notes:
- Most of the exported functions have been turned from default cdecl to explicit stdcall / "NTAPI".
- The two InitializeSetup() phases have been collapsed to make the initialization simpler.

Average reductions (percentages; see PR #7523 for actual numbers):

x86 Debug builds:
reactos.exe: 35.1%
smss.exe   : 39.8%
Total (including setuplib.dll): 17.9%

x86 Release builds:
reactos.exe: 22.3%
smss.exe   : 25.0%
Total (including setuplib.dll): 10.6%

x64 Debug builds:
reactos.exe: 40.6%
smss.exe   : 41.6%
Total (including setuplib.dll): 20.0%

x64 Release builds:
reactos.exe: 22.8%
smss.exe   : 22.3%
Total (including setuplib.dll): 10.1%
2024-12-02 23:05:38 +01:00
Timo Kreuzer
53f498c968 [SDK][PSEH] Improve PSEH a bit
Add PSEH include dir globally, include pseh2.h from excpt.h and add compatibility macros to reduce hacks in 3rd-perty code.
2024-11-27 10:50:03 +02:00
Hermès Bélusca-Maïto
4aee0280f9
[SETUPLIB][REACTOS][USETUP] Finish unification of MBR extended and primary/logical partitions
Fixes previous attempt at commit 0ca4e6dcf, which was reverted by commit
bbdcc14b1 because the partitioning checks mistook unpartitioned disks as
GPT.

Addendum to commit 99f0937fd.

The partition-creation checks are unified for these partitions into one
single function. To prepare for GPT support, the specifics are put into
a separate MBRPartitionCreateChecks() helper, called for MBR disks by the
upper-level function. GPT disks will have a similar helper in the future.
2024-11-24 18:13:17 +01:00
Stanislav Motylkov
bbdcc14b1c [REACTOS] Temporarily revert 0ca4e6dcfa, as requested by Hermès
The setup mistakes the unpartitioned disk as GPT.
This reverts commit 0ca4e6dcfa.
2024-11-23 23:12:02 +01:00
Hermès Bélusca-Maïto
0ca4e6dcfa
[SETUPLIB][REACTOS][USETUP] Finish unification of MBR extended and primary/logical partitions
Addendum to commmit 99f0937fd.

The partition-creation checks are unified for these partitions into one
single function. To prepare for GPT support, the specifics are put into
a separate MBRPartitionCreateChecks() helper, called for MBR disks by the
upper-level function. GPT disks will have a similar helper in the future.
2024-11-23 21:41:32 +01:00
Timo Kreuzer
31334ebcfe [SETUPLIB] Use proper SEH instead of nasty hacks
Addendum to commit 2268b3d
2024-11-18 10:23:50 +02:00
Hermès Bélusca-Maïto
3ddb05d443
[SETUPLIB] GetSourcePaths(): Fix determination of the installation source path.
Refine the algorithm introduced in commit c560342f08 (r75667, r75676),
whereby the installation source path is based on the full image file path
of the installer program, and of the \SystemRoot symlink.

Also reverts commit 6f389a35db "Add a workaround for installing from USB drives"
CORE-17818

+ SAL2-annotate and add Doxygen comments.

----

In case the \SystemRoot full path prefixes the image file path,
use the resolved \SystemRoot as the installation source path.
Otherwise, use the image file path.

The \SystemRoot symlink target resolution needs full path reparsing,
because it can reference other symlinks. This is what happens, for
example when booting the installation from a removable hard-disk.
We can have:

         \SystemRoot ---> \Device\Harddisk1\Partition1\ReactOS
and:     \Device\Harddisk1\Partition1 ---> \Device\HarddiskVolume2
etc.
and we wish to resolve \SystemRoot to: \Device\HarddiskVolume2\ReactOS
instead of keeping the former version (using Harddisk1\Partition1).

We then verify whether it prefixes the image file path, which is
a fully reparsed path.
2024-10-23 23:19:58 +02:00
Hermès Bélusca-Maïto
b3cd576737
[SETUPLIB][USETUP] Introduce a bootloader installation helper (#7310)
CORE-13525

This is done so that the caller doesn't need to know details
about particular architecture specifics, like VBR, MBR etc.

Extra checks and specific handling is also performed for supporting
bootloader installation on removable media:
- verify whether the media is a floppy or some other removable media,
- depending on which, a suitable file system is chosen,
- and if the media is not a floppy, do the supplemental partition
  verifications to determine whether the media is a "super-floppy"
  (in the partitioning sense).
2024-10-20 16:51:25 +02:00
Hermès Bélusca-Maïto
636e2e9172
[SETUPLIB] Introduce a helper for copying bootloader files (#7310)
This function could be generalized later to copy other files necessary
for the bootloader; removing also the currently hardcoded placement in
the installation source directory, and instead, using a configurable
path (specified in txtsetup.sif); etc.

Adapted from a commit by Timo Kreuzer (see PR #7420)

Co-Authored-By: Timo Kreuzer <timo.kreuzer@reactos.org>
2024-10-20 16:51:24 +02:00
Hermès Bélusca-Maïto
d6d3d0eacd
[SETUPLIB] Add helpers to determine whether a disk is partitioned as a "super-floppy" (#7310) 2024-10-20 16:51:23 +02:00
Hermès Bélusca-Maïto
ad5d9aa28a
[SETUPLIB] Add UNICODE_STRING versions of the pOpenDevice helpers (#7310)
+ Use a FILE_SHARE_ALL define. Based on a suggestion from Whindmar Saksit.
2024-10-20 16:51:16 +02:00
Timo Kreuzer
e4930be4ff [REACTOS] Use the ISO C and C++ conformant names: _wcsicmp, _stricmp
Stop using non-conforming wcsicmp, stricmp, strcasecmp
2024-10-20 14:12:25 +03:00
Hermès Bélusca-Maïto
1573461cec
[SETUP:REACTOS] Add partitioning and formatting support (#7159)
CORE-13525

- Newly-created partitions and unpartitioned space ar reinserted
  or updated in correct order in the tree-list. Volume-creation
  information data associated with the tree items is persisted
  across operations.

- Reliably delete data associated to tree-list items via the
  TVN_DELETEITEM notification.
  This allows simplifying the cleanup function; keeping simple
  the code that deletes items when deleting partitions, etc.

- Make the PrintPartitionData() function call itself recursively on
  extended partitions to display the sub-list of logical partitions.

- Handle the new partition size in MB the same way as in USETUP.

- Allow existing partitions/volumes to be re-formatted, using
  common code with the partition creation dialog.

- Allow selecting unpartitioned space or non-formatted partitions
  for installing ReactOS: unused space will automatically be
  partitioned and non-formatted partitions formatted (the user
  is prompted for choosing the file system).

- Correctly zero the progress-bar position when starting file copy.
- Add missing file copy error handler in FileCopyCallback:
  just copying what USETUP does.
2024-08-27 23:18:12 +02:00
Hermès Bélusca-Maïto
6f15802af7
[SETUPLIB][REACTOS][USETUP] Split FS-volume-specific functionality from partitions (#7258)
CORE-13525

This greatly helps in reducing code complexity in some areas: code that
previously iterated over all partitions of a given disk, just to find
which ones were partitioned and contained a valid file system, now just
have to iterate over mounted volumes.
See in particular, `lib/utils/osdetect.c` and `lib/fsutil.c` .

- Remove FORMATSTATE "Preformatted" enum value;
- Cleanup osdetect code after introducing Volume support;
- Some simplifications for FormatState.

- Differentiate between 'new' partition and 'new' volume:

  * "New" partition: it has been created and added in the cached list,
    but not yet actually written into the disk.

  * "New" volume: newly-created volume (may be backed by a partition or
    not), not yet formatted. May exist on either new, or not new partition,
    or elsewhere.

- Cache partition and volume NT device names.

  These do not change across repartitioning operations, as long as the
  partition or the filesystem volume hasn't been deleted/recreated.
  This avoids doing \Device\Harddisk%u\Partition%u sprintf's everytime
  we need to retrieve the given partition or volume device name.

  When a partition/fileysystem volume is "virtually" created (i.e. in
  the partition list, but not yet committed to disk and exposed to the
  OS), no device partition number and device name are available yet.
  In particular, validate that no manipulation of \Device\HarddiskM\Partition0
  (i.e. the whole disk) is being made.
2024-08-26 16:42:47 +02:00
Hermès Bélusca-Maïto
0f8dc6b2df
[SETUPLIB] Add some device utility functions; to be used later (#7258) 2024-08-26 16:42:46 +02:00
Hermès Bélusca-Maïto
ea5728b5f3
[SETUPLIB] SetupCreateDirectory(): Don't assume the form of the directory prefix (#7257)
Addendum to commit 32e6eed760 (r63715)
CORE-5982

The function assumed that the directory path name to be created
always starts with a harddisk-partition root device name of the form:

  \Device\HarddiskX\PartitionY\

Indeed, it can be (when using the volume manager) of the form:

  \Device\HarddiskVolumeN\

and could even have a different format if trying to install ReactOS
on an external removable drive or other weird device.

Since the format of this prefix is not 100% always the same,
a different way to create the sub-directories is needed.
The nested-directory creation algorithm is changed as follows:

Suppose that the directory to be created is:

  \Device\HarddiskVolume1\ReactOS\system32\drivers

The function first loops backwards each path component in order
to find the deepest existing sub-directory: it will try to verify
whether each of the following sub-directories exist, successively:

  \Device\HarddiskVolume1\ReactOS\system32\drivers
  \Device\HarddiskVolume1\ReactOS\system32\
  \Device\HarddiskVolume1\ReactOS\
  \Device\HarddiskVolume1\

(Notice the trailing path separators kept in this step.)
In principle, this root device FS directory must exist (since the
volume has been formatted previously). Once found, the function will
then create each of the sub-directories in turn:

  \Device\HarddiskVolume1\ReactOS
  \Device\HarddiskVolume1\ReactOS\system32
  \Device\HarddiskVolume1\ReactOS\system32\drivers

----

An alternative to the fix could be to always specify the root device
name in a separate parameter, but this hasn't been pursued here so as
to not modify all the callers of this function.
2024-08-22 20:40:35 +02:00
Hermès Bélusca-Maïto
00ddae49d5
[SETUPLIB] SetupCreateSingleDirectory(): Remove '\.' trailing sequence handling hack
It was introduced in commit 703eb5e8c9 (r7756) in order to hack around
the "dot"-path added in the reactos.dff generator file by the earlier
commit 3bd689f185 (r7269).
Its aim was to describe the installation directory itself, instead of
one of its sub-directories.

That _invalid_ "dot"-path was removed later by commit 027e2bfa3a (r15423);
however the '\.' hack stayed for quite a while in our code.

The correct way to describe the installation directory itself is to use
instead "\", compatible with Windows' setup, as was originally done in
txtsetup.sif, and fixed in reactos.dff(.in) in commit 97bb83fcd9 (r66604).
2024-08-22 20:40:34 +02:00
Hermès Bélusca-Maïto
8056081c2f
[SETUPLIB] Store a machine architecture type
It will be used to determine how the bootloader has to be installed, etc.

Currently hardcoded for XBOX, or rnutime-determined for NEC PC-98 and BIOS-based PC-AT.
More thorough runtime determination will be added in the future.
2024-08-12 12:16:56 +02:00
Hermès Bélusca-Maïto
9b9065df52
[SETUPLIB] Move the initialization of other default values into InitializeSetup() 2024-08-12 12:04:39 +02:00
Hermès Bélusca-Maïto
c9c5fd1a18
[SETUPLIB][BOOTDATA] Rename "MBRInstallType" to "BootLoaderLocation"
Less hardcoded references to "MBR" for code that should be generic
is always better.
2024-08-12 12:04:38 +02:00
Hermès Bélusca-Maïto
259abe59dc
[SETUPLIB] Fix the class of characters valid for the installation directory
Commit 7c3f4c94a4 (r68307) mentions the valid characters:
these are:
ASCII alphanumericals (a-z, A-Z, 0-9)
(hence the iswalnum() -> isalnum() change),
and: '.', '\\', '-', '_' . Spaces are not accepted.

Addendum to commit 785cc21598.
2024-08-12 12:04:37 +02:00
Hermès Bélusca-Maïto
2d8c2cd8dc
[SETUPLIB][ROSTESTS] Move setuplib unittests to rostests directory.
Addendum to commit 6289183dcd ; fixes our MSVC_x64 builder.
2024-07-31 13:46:00 +02:00
Hermès Bélusca-Maïto
71197535a1
[SETUPLIB][USETUP] Improve IsValidInstallDirectory() behaviour (#7187)
CORE-6149, CORE-6179, CORE-9529

See also commits d329fbebf (r66995), 7c3f4c94a (r68307), and 16daf6700.

The function verifies that each path component of the directory is
a valid 8.3 name, not . or .. nor empty. This behaviour is compatible
with what can be observed from Windows XP/2003 installer.
(To reliably test this with the Windows installer, you need to modify
the TXTSETUP.SIF DefaultPath value in the [SetupData] section.)
2024-07-31 11:41:24 +02:00
Hermès Bélusca-Maïto
6289183dcd
[SETUPLIB_UNITTEST] Add unit-tests for the setuplib (#7187) 2024-07-31 11:41:23 +02:00
Hermès Bélusca-Maïto
785cc21598
[SETUPLIB][USETUP] Move IsValidPath() back into setuplib for reusability (#7186)
Reverts the IsValidPath() move done in commit 9c64b57dc.

- Turn IsValidPath() into a IsValidInstallDirectory() helper function
  available in the setuplib, so that it can also be used in the GUI setup.

- Introduce a IS_VALID_INSTALL_PATH_CHAR() macro.
2024-07-31 11:40:21 +02:00
Hermès Bélusca-Maïto
7639cb750a
[SETUPLIB][USETUP] Reduce duplicated code
- ScrollDownPartitionList() and ScrollUpPartitionList()
  --> ScrollUpDownPartitionList()

- GetPrimaryPartitionCount() and GetLogicalPartitionCount()
  --> generic GetPartitionCount() and macros.

- GetPrevUnpartitionedEntry() and GetNextUnpartitionedEntry()
  --> GetAdjUnpartitionedEntry() ("Adj" == Adjacent)
2024-07-04 17:14:32 +02:00
Hermès Bélusca-Maïto
97821f00d5
[SETUPLIB] Fix for GetPartition() 2024-07-04 17:14:31 +02:00
Hermès Bélusca-Maïto
f57601d14b
[SETUPLIB][USETUP] FS utilities: Use the ISO C and C++ conformant name: _wcsicmp
Stop using non-conforming wcsicmp.
See also PR #6925 by Timo Kreuzer.
2024-07-01 16:28:17 +02:00
Hermès Bélusca-Maïto
a7a7e6a09c
[SETUPLIB][USETUP] Isolate and decouple the filesystem operations code from the UI (#7049)
The idea is reminiscent of the SetupCommitFileQueue() function:
filesystem volume operations are "queued" and processed via a
"commit queue".

The commit queue uses a user-specified callback, that is used to
interact with the user whenever an operation (filesystem formatting,
checking) is started, ended, or fails, for example by displaying
appropriate UI screens and choices, etc.
2024-07-01 16:18:57 +02:00
Katayama Hirofumi MZ
0f9e889736
[NTGDI][FREETYPE][SETUP][INF] Support FontLink (#7009)
If East Asian people were unable
to see the Latin characters, it
becomes a barrier to mutual
understanding.
FontLink will break that barrier.
JIRA issue: CORE-9616
JIRA issue: CORE-15480
- Modify font substitutes.
- Unify the lock variables.
- Add FONTLINK and
  FONTLINK_CHAIN structures.
- Add FontLink_Create and
  FontLink_Destroy functions.
- Add FontLink_Chain_Init,
  FontLink_Chain_Free,
  FontLink_Chain_LoadReg,
  FontLink_Chain_Populate, and
  FontLink_Chain_FindGlyph
  functions.
- Implement FontLink.
- Add font file DroidSansFallback.ttf
  for LiveCD.
2024-06-30 22:15:34 +09:00
Hermès Bélusca-Maïto
a2777cd828
[SETUPLIB] Cleanup some partition getters and remove GetDiskOrPartition.
- osdetect.c: Replace usage of GetDiskOrPartition by SelectPartition.
2024-06-24 16:28:07 +02:00
Hermès Bélusca-Maïto
99f0937fd0
[SETUPLIB][USETUP] Finish unification of extended and primary/logical partitions
See commits ebcf3cf38 and c9c6902f0 (PR #5837)

In addition, correctly set the type of extended partition being used,
depending on whether it is contained below or above the 1024-cylinder
boundary (tested on NT).
2024-06-20 17:21:51 +02:00
Hermès Bélusca-Maïto
c752e8c0be
[SETUPLIB] FindSupportedSystemPartition(): Add missing NULL check
Addendum to commit 59acff79e.
2024-06-10 13:14:28 +02:00
Hermès Bélusca-Maïto
a7cbb60ebf
[SETUPLIB] Don't flag freeldr.ini as read-only during installation.
CORE-19575

For the time being, don't add read-only attribute for ease of testing
and modifying files, but it won't always stay this way.

For example, Windows sets its boot.ini (as well as NTLDR, NTDETECT.COM
etc.) as read-only (+ hidden and system) during its 1st-stage setup.
2nd-stage setup makes some adjustments in boot.ini but doesn't restore
its read-only attribute.
Windows tools that can modify boot.ini (i.e. msconfig.exe, bootcfg.exe,
and sysdm.cpl) **ALL** know how to remove the read-only attribute for
modifying boot.ini, before restoring it if needed.
2024-05-07 19:30:33 +02:00
Hermès Bélusca-Maïto
2b43390d04
[SETUPLIB] Use new BootPath value for BootSector boot entries (#6815)
The BootDrive and BootPartition values are deprecated, and support
for them will soon be removed from FreeLoader.

Add an helper function to migrate these values during ReactOS
(re)installation / update.
2024-05-07 12:33:14 +02:00
Hermès Bélusca-Maïto
c7295b2cdf
[SETUPLIB] Support different boot store file creation/opening and access modes
The support is so far enabled only for INI files (freeldr.ini, boot.ini).
May be subject to further improvements in the future.

Usage examples:

- When finding existing ReactOS or Windows installations, the boot store
  should exist and is opened in read-only mode. Closing the boot store
  doesn't store any temporary modifications made to it.

- When doing a clean installation, freeldr.ini is created in read-write
  access.

- When installing with an existing freeldr.ini or boot.ini, they are
  opened as existing files in read-write access.
2024-05-06 21:13:23 +02:00
Hermès Bélusca-Maïto
9b563d32d2
[SETUPLIB] Improve a bit the management of boot-store options
- QueryBootStoreOptions(): De-duplicate code.
- SetBootStoreOpt(): Respect the FieldsToChange flag.
- BOOT_STORE_OPTIONS: Remove unused Version field and distinguish
  between "Current" and "Next" BootEntryKey.
2024-05-06 17:05:03 +02:00
Hermès Bélusca-Maïto
68c2a28973
[SETUPLIB] Split OpenAndMapFile function and Doxygen-ize it 2024-05-06 17:00:01 +02:00
Hermès Bélusca-Maïto
e151ef9ae1
[SETUPLIB] Add support for removing sections and key values, and remove some hacks (#6815)
- Use LIST_ENTRY instead of custom list pointers;
- Fix key/section unlinking before freeing.
2024-05-05 18:15:31 +02:00
Hermès Bélusca-Maïto
b9ca9b0061
[SETUPLIB] Don't create new INI sections or key-values if they already exist (#6815)
- If a section already exists, return the existing one. This allows
  avoiding different section entries with the same name in the cache.
  If an INI file has separate sections with the same name, their
  contents (key-values) get merged into a unique section.

- If a key-value already exists, update its data value and return the
  existing one. (Note that this may be subject to behaviour change in
  the future.)
2024-05-05 18:15:31 +02:00
Hermès Bélusca-Maïto
817c27a54e
[SETUPLIB] Some INI support refactoring: function/struct names, duplicated code (#6815)
And convert ANSI strings to UNICODE in a better way instead of
zero-extending them.
2024-05-05 18:15:24 +02:00
Hermès Bélusca-Maïto
b7ad4a2298
[SETUPLIB][USETUP] Some cleanup for partition code.
- Make the Create*Partition helpers take a size in bytes, not in sectors.

  This allows them to be easier to use by the caller, alleviating the
  need for making the size conversion into sectors. Instead it is done
  internally by the helpers.

- Introduce helper macros to easily retrieve the size of a partition
  entry or a disk in bytes, from their internal representation in number
  of sectors.

- The 'AutoCreate' variable being USETUP-specific, remove it from the
  PARTENTRY structure and use instead a flag set into the 'New' member.

- Rename IsDiskSizeValid to IsPartitionLargeEnough, to better describe
  what the function is for.
2024-02-20 15:52:37 +01:00
Hermès Bélusca-Maïto
b02dd8eb22
[SETUPLIB] Make the settings' Process* functions take an actual value instead of a GENERIC_LIST
The reason is to avoid enforcing the usage of a specific list
container by the users of the setup library. This is a departure
of what I originally thought would be the best, in commits
92692eae3 (r74553), 8f2c4f7a6 (r75700)

This should actually make some parts of the GUI setup code simpler
(e.g. using the win32 comboboxes to store the list contents).
2024-02-18 16:30:46 +01:00
Hermès Bélusca-Maïto
88891d2ce7
[SETUPLIB][USETUP] Convert MUI_LANGUAGE GeoID values to numbers. 2024-02-09 22:33:30 +01:00
Hermès Bélusca-Maïto
c26a2e89eb
[SETUPLIB][USETUP] Convert MUI_LANGUAGE codepages to numbers. 2024-02-09 22:06:39 +01:00
Hermès Bélusca-Maïto
f0a1d766f1
[SETUPLIB][USETUP] Convert internal MUI_LAYOUTS data to numbers.
LangID is a LANGID and LayoutID is a KLID: keyboard layout ID.
See terminology at http://archives.miloush.net/michkap/archive/2004/11/27/270931.html

These tables of MUI_LAYOUTS for each language, correspond to the
intl.inf LCID map:
```
; List of locales.
; <LCID> = <Description>,<OEMCP>,<Language Group>,<langID:HKL pair>,<langID:HKL pair>,...
```
where:
- each MUI_LANGUAGE entry corresponds to one such locale description;
- each MUI_LAYOUTS entry corresponds to a <langID:HKL pair>.

See http://archives.miloush.net/michkap/archive/2006/10/14/825404.html
for some details.
2024-02-09 21:28:23 +01:00
Katayama Hirofumi MZ
e2b1ee9a53
[SETUP][BOOTDATA][INF] Add font substitute ('Segoe UI Symbol' to 'Arial') (#6155)
Based on CORE-19346 "segoe-ui-symbo.patch".
In order to display gender glyphs (U+2642 and
U+2640; ♂ and ♀), we add a font substitute from
"Segoe UI Symbol" to "Arial".

ReactOS Arial has many symbol glyphs, so I think
we can use it for "Segoe UI Symbol" font substitute.

The glyph size problem will be fixed in #6156.
CORE-19346
2023-12-11 20:51:04 +09:00
Hermès Bélusca-Maïto
5ee1dc6113
[USETUP] Don't error out in case one tries to "delete" empty partition space.
Just... don't delete it ¯\_(ツ)_/¯
2023-11-19 16:44:34 +01:00
Serge Gautherie
780c2a0375
[SERVICES][SETUPLIB][UMANDLG][USETUP] Add missing \n to DPRINT() calls (#5983)
And promote 1 DPRINT() to DPRINT1.
2023-11-16 22:22:12 +00:00
Dmitry Borisov
8d7153c8ba
[FREELDR] Implement NOSERIALMICE and FASTDETECT options (#5886)
Enable FASTDETECT by default, as done in NT 5+. This is because
the serial mouse is recognized by the serial stack since NT 5.x.
2023-11-13 19:49:41 +01:00