Commit graph

353 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto
565a4b359a
[FREELDR] Don't popup about deprecated features in auto-boot scenario (#6803)
Addendum to commit 5f3554a40.
2024-05-04 16:19:22 +02:00
Hermès Bélusca-Maïto
7bee32d237
[FREELDR] The multiboot command-line and FREELOADER section options become global settings (#6803)
Dual-license settings.c: "old" code (CmdLineParse) stays BSD
and new code (mine) becomes MIT.
2024-05-04 16:19:07 +02:00
Hermès Bélusca-Maïto
2f4bb4084d
[FREELDR] Rename cmdline.c to settings.c: it will be used for managing global settings (#6803) 2024-05-04 15:46:06 +02:00
Hermès Bélusca-Maïto
5f3554a40c
[FREELDR] Merge boot-drive and partition functionalities together (#6760)
And deprecate corresponding boot types "Drive" and "Partition".
These are replaced by the more general "BootSector" boot type.

Finish the unification of the code, started in commit ff85aa0c3,
that loads and boots disk MBR, partition VBR or boot sector in file.

A "WarnDeprecated()" helper is added to warn the user about the
deprecated features, and to inform them to adjust their FREELDR.INI
file in accordance.

In addition, bump FreeLoader version to 3.2 (at last!): a lot of
features have been added or deprecated since its last release.
2024-04-19 21:45:41 +02:00
Mark Harmstone
dd6c1c8843 [FREELDR] Allow Freeloader to boot Vista revamp of PR #1905 (#6479)
[FREELDR] Add "WindowsVista" boot type
[FREELDR] Set GDT correctly for Vista
[FREELDR] Map first page of memory, this is an observed behavior, and
also increases stability boot Checked windows 2003 SP2 ntoskrnl with
freeloader.
[SDK] Don't assert on big keys in bootloader

Co-authored-by: Justin Miller <justin.miller@reactos.org>
2024-04-18 09:28:54 -07:00
Hermès Bélusca-Maïto
7b4f42470f
[FREELDR] Reformat the boot editor strings in the code. 2024-04-17 22:25:14 +02:00
Hermès Bélusca-Maïto
e5517176b8
[FREELDR] linuxboot: It doesn't need the BIOS boot drive number and partition.
Also document a little bit the RootDevice field in the boot sector;
add SAL2 annotations.
2024-04-17 22:25:13 +02:00
Hermès Bélusca-Maïto
c25a0e1919
[FREELDR:UI] Minor miscellaneous fixes.
- UiMessageBox(): Enlarge the default buffer used to printf msgbox strings.

- TuiUpdateDateTime(): When displaying the time, don't pad too much
  with spaces on the left.

- TuiDrawShadow():
  * Pre-calculate whether we need to show the right/bottom shadows,
    and whether the right-shadow has a double width.
  * Cap the right and bottom upper-bound coordinates before looping,
    in order to avoid buffer overflows if the given coordinates go
    beyond the screen.

- TuiDrawMsgBoxCommon(): Improve how the message box centering
  calculations are done:
  * When the "full-UI" is used (and center-menu is used), try to
    center the message box in the space between the header and
    the status bar.
  * Ensure the top-left box corner is inside the screen, in case
    the calculated message box borders go off-screen.

- TuiCalcMenuBoxSize():
  * Uniformize the way the menu box coordinates are calculated.
  * Reduce the space between menu box margins and the longest item.
  * Ensure the top-left menu corner is inside the screen, in case
    the calculated menu box borders go off-screen.
2024-04-17 22:19:43 +02:00
Hermès Bélusca-Maïto
c044201472
[FREELDR] Skip NULL-pointer entries in Argv when enumerating arguments.
A NULL pointer (not necessarily the terminating one) is a valid entry
in the Argv argument vector, according to the ARC specification
(Section 4.4 "Loaded-Program Conventions").
Thus, such pointer needs to be ignored when searching over the
argument vector.
2024-04-17 21:57:12 +02:00
Hermès Bélusca-Maïto
93245d385d
[FREELDR] arcsupp.c: Relicense my code to MIT and use SAL2 annotations. 2024-04-17 21:57:11 +02:00
Hermès Bélusca-Maïto
5b2dcdd03d
[FREELDR] BuildArgvForOsLoader: Add a terminating NULL pointer to the Argv vector.
Addendum to commits d05be0da3 and bd451f240.

This is required for POSIX compliance, which the ARC specification obeys.

See Section 2.1.2.2.1 (ANSI X3.159-1989) or 5.1.2.2.1 (ISO/IEC 9899:x)
"Program startup":
```
If they are declared, the parameters to the main function shall obey
the following constraints:
— The value of argc shall be nonnegative.
— argv[argc] shall be a null pointer.
[...]
```

See also https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html
2024-04-17 21:57:09 +02:00
Timo Kreuzer
43fc73207d [FREELDR/x64] Set up CR0/CR4 for SSE instructions
Newer GCC starts emitting SSE/SSE2 instructions, which would cause a triple fault, during early boot, if not enabled.
2024-03-29 19:39:01 +01:00
Adam Słaboń
fec827eeef
[FREELDR][NTOS:MM] Add security cookie generation to FreeLoader (#6270)
* [NTOS:MM] Misc improvements for cookie generation code

- Improve support for 64 bit images
- Improve LdrpFetchAddressOfSecurityCookie code

* [FREELDR] Add security cookie generation to FreeLoader

CORE-17808
2024-03-27 23:33:06 +02:00
Hermès Bélusca-Maïto
9ae73010c2
[FREELDR] Factor duplicated code into a GetOSLoadingMethod() helper
This removes duplicated code present in both LoadOperatingSystem()
and EditOperatingSystemEntry().

+ Add SAL annotations to the related functions.
2024-03-12 17:15:02 +01:00
Hermès Bélusca-Maïto
bbce6c3fdf
[FREELDR] Deduplicate common message-box creation code.
Also, make the (T)uiSave/RestoreScreen() helpers manage themselves the
temporary memory buffer used to store the temporary screen snapshot.
2024-03-11 22:37:39 +01:00
Hermès Bélusca-Maïto
64155019df
[FREELDR] Minor formatting for MsgBox functions + add SAL annotations 2024-03-11 22:37:38 +01:00
Hermès Bélusca-Maïto
dad056e06a
[FREELDR] Move the arch-specific intrin_i.h inclusions to where they are actually needed (NTLDR) 2024-03-11 22:37:37 +01:00
Hermès Bélusca-Maïto
50e5f76212
[FREELDR] FrLdrHeapCreate: Show the memory type in the ERR(). 2024-03-11 22:37:36 +01:00
Hermès Bélusca-Maïto
9a707af2e3
[FREELDR] Initialize CandidatePageCount to zero, needed if the while-loop is not run.
Granted, if the while-loop is not run, this means there is no memory
available at all on the computer where FreeLdr is running, which is
quite unexpected. But do the initialization anyways, in order to avoid
more obscure bugs down the line.

On the other hand, PageLookupTableMemAddress doesn't need to be
pre-initialized, since it gets initialized unconditionally afterwards.
2024-03-11 22:37:35 +01:00
Hermès Bélusca-Maïto
61c4b5f615
[FREELDR] pcat.cmake: minor cleanup 2024-03-11 22:37:34 +01:00
Hermès Bélusca-Maïto
b790cfcef1
[FREELDR] Pre-initialize the INI section list, improve loops over sections and items.
Avoids dereferencing list entries to sections/items when these lists are empty.

IniParseFile(): Emit an error to the debug log when a candidate setting
is outside a section and skip it, instead of popping up an error on the UI.
2024-03-11 22:37:33 +01:00
Hermès Bélusca-Maïto
c8c32db8c5
[FREELDR] ueficon.c: Add missing support for HOME and END keys.
And reserve INSERT, PAGE_UP and PAGE_DOWN for future handling.
2024-03-11 22:37:33 +01:00
Hermès Bélusca-Maïto
f4ff0aba2f
[FREELDR] Minor code cleanup in arch/uefi files 2024-03-11 22:37:32 +01:00
Hermès Bélusca-Maïto
1e409e6902
[FREELDR] i386/hwdisk.c: Use FIRST_BIOS_DISK and FIRST_PARTITION macros like what's done in UEFI code. 2024-03-11 22:37:30 +01:00
Hermès Bélusca-Maïto
e1d334794a
[FREELDR][ROSSYM(_NEW)] Remove last vestigial references to "NTOSAPI".
This was a MinGW-specific, non-MS-DDK/WDK-compatible define, that was
used to mark NTOS kernel/hal exports, instead of NTSYSAPI etc.

We have since fixed that, and changed the way Freeldr (and rossym)
manages these, see commits:
186c8b72d (r16028), 51f0dfd30 (r17651) and 526efd2ee (r24359)
2024-03-07 13:35:08 +01:00
Hervé Poussineau
922757e2e3 [FREELDR:UI] Update display after restoring screen contents
JIRA issue: CORE-18186
2024-01-14 19:12:11 +01:00
Justin Miller
516ccad340
[NTOS:KE][HALX86] Implement AP startup code (#5879)
Co-authored-by: Victor Perevertkin <victor.perevertkin@reactos.org>

Introduce the initial changes needed to get other processors up and into kernel mode. 
This only supports x86 as of now but is the first real step towards using other system processors.
2023-11-19 15:51:33 -08:00
George Bișoc
fa80176a62
[FREELDR][HACK] Temporarily disable registry recovery code for AMD64
The newly implemented code for registry recovery makes the FreeLdr binary to grow
in size, to the point that it would BSOD because the PE image is too big.

For now we have to temporarily disable any of the newly added code, until
either FreeLdr is split into a basic PE bootloader image itself and a
"FreeLdrlib" that is used by the PE image to access various bootloader APIs
or another proper solution is found.
2023-11-19 20:44:28 +01:00
George Bișoc
7983b65e10
[FREELDR] Implement SYSTEM hive recovery at bootloader level & use CmCheckRegistry for registry validation
Validate the SYSTEM hive with CmCheckRegistry and purge volatile data with the same function when initializing a hive descriptor for SYSTEM.
Also implement SYSTEM recovery code that takes use of SYSTEM log in case something is fishy with the hive. If hive repair doesn't have fully recovered the SYSTEM hive, FreeLdr will load the alternate variant of the SYSTEM hive, aka SYSTEM.ALT.

If FreeLdr repairs the hive with a LOG, it will mark it with HBOOT_BOOT_RECOVERED_BY_HIVE_LOG on BootRecover field of the header. All the recovered data that is present as dirty in memory will have to be flushed by the kernel once it is in charge of the system.
Otherwise if the system boot occurred by loading SYSTEM.ALT instead, FreeLdr will mark HBOOT_BOOT_RECOVERED_BY_ALTERNATE_HIVE, the kernel will start recovering the main hive as soon as it does any I/O activity into it.
2023-11-19 20:44:28 +01: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
Hermès Bélusca-Maïto
10e7643c80
[FREELDR:NTLDR] Pass boot-time detection options to HwDetect routines.
Will be used for supporting /NOSERIALMICE, /FASTDETECT (NT 5+) switches
(see PR #5886), as well as the undocumented /PCIENUM option.
2023-11-13 19:19:40 +01:00
Justin Miller
ff3dadf89d
[FREELDR] Enable UEFI boot for x86 and amd64 (#5267)
Co-authored-by: Stanislav Motylkov <x86corez@gmail.com>
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>

- Allow to boot NT kernel on UEFI systems with our 2 primary supported architectures
- Implement remaining code needed to pass execution to x86 and amd64 kernels

CORE-11954
2023-10-11 12:45:08 -07:00
Serge Gautherie
aa2d2139be [FREELDR] Convert ntfs.c to UTF-8 without BOM
Addendum to f0d73e0 (and ab3bd82).
2023-08-18 00:51:36 +02:00
Hermès Bélusca-Maïto
ab3bd82928
[FREELDR] Convert source files to UTF-8 without BOM 2023-08-17 15:36:54 +02:00
Sylvain Deverre
f0d73e0f7f
[BOOTSECT][FREELDR] Support booting from NTFS partitions (#3416)
Implement NTFS boot sector that loads FreeLdr from a NTFS partition.

CORE-17474

- Able to find/parse root directory;
- Handle fixups in FILE MFT record;
- Implement directory tree search;
- Implement loading found file from disk;
- Handle fixups in INDX records;
- Fail if compressed or sparse;
- Attempt to support 64-bit disks.

Some TO-DOs for later:
- Handle "weird" NTFS partition with uncommon sector sizes / sectors per cluster / sectors per index record;
- Better implementation for file loading;
- 64-bit LCN support.
2023-08-17 15:07:59 +02:00
Dmitry Borisov
ffbc81fdf2 [FREELDR] Implement bus mouse detection
This allows to automatically install the inport device driver
(it's now possible since 7d5e159131), which can be used on 86Box.

References:
- https://raw.githubusercontent.com/86Box/86Box/master/src/device/mouse_bus.c
- https://bochs.sourceforge.io/cgi-bin/lxr/source/iodev/busmouse.cc
2023-08-05 16:40:13 +03:00
Justin Miller
e505394466
[FREELDR] Add UEFI Console input support. CORE-11954 (#5426)
Co-authored-by: Stanislav Motylkov <x86corez@gmail.com>
2023-07-11 11:07:31 -07:00
Hermès Bélusca-Maïto
3bc71f9086
[FREELDR][SCSIPORT][STORPORT] Use existing defines for some hardcoded max values.
See https://www.osronline.com/article.cfm%5Earticle=538.htm

[SCSIPORT] Remove 'MaxBus' variable, deprecated since commit fc3d38d1c (r26220).
2023-06-19 21:10:51 +02:00
Hermès Bélusca-Maïto
0c16bcd4e8
[FREELDR] scsiport.c: Fix x64 compilation. 2023-06-19 21:09:01 +02:00
Hermès Bélusca-Maïto
af47866f76
[FREELDR:UEFI] Fix compilation warning LNK4006.
ntoskrnl.c.obj : warning LNK4006: _KeStallExecutionProcessor@4
already defined in stubs.c.obj; second definition ignored.
2023-06-19 21:09:00 +02:00
Hermès Bélusca-Maïto
095510bdac
[FREELDR:UEFI] Fix two MSVC build warnings C4553.
In both lines 451 and 474:
uefidisk.c: warning C4553: '==': result of expression not used; did you intend '='?

It's "funny" that GCC builds doesn't catch those...
2023-06-19 21:08:59 +02:00
Hermès Bélusca-Maïto
8061a6f6f4
[FREELDR] Cleanup some FldrCreateComponentKey() calls and archwsup.c 2023-06-05 22:39:47 +02:00
Hermès Bélusca-Maïto
7112815e23
[FREELDR] PeLdrLoadImage: FileName -> FilePath and make it const. 2023-05-07 22:14:30 +02:00
Justin Miller
f2a58733e8
[FREELDR][SDK] Build UEFI bootloader for ARM32 (#5196)
CORE-17604

- Disable some functions for ARM32;
- Remove some link options not used on ARM;
- Add get _controlfp() to LIBCNTPR to link properly on ARM;
- Unify Freeldr UI Drawing on ARM;
- Add qemu UART debugging for ARM32/ARM64.
2023-05-03 20:56:06 +02:00
Justin Miller
1fd9d11f16
[FREELDR] Add disk access handlers for UEFI (#5219)
CORE-11953
2023-04-30 14:57:10 +02:00
Justin Miller
ccef43f3b0
[FREELDR] Implement the memory managment functions for UEFI (#5174)
CORE-11954

- EFI binaries have a different subsystem in the PE header;
- ENVIRON: Make sure INTN and UINTN are 64bit for 64bit platforms;
- Handle UEFI Memory maps and translate it for freeldr;
- Add FAILED_TO_EXIT_BOOTSERVICES Freeldr BSoD code.
2023-04-03 17:33:20 +02:00
Justin Miller
150f721273
[FREELDR] Support compiling freeldr as a UEFI loader + Implement UI functions (#5171)
First batch of changes to implement a UEFI version of freeldr:
- Compile freeldr as EFI binary on top of the existing loader.
- Stub out various functions so we can create a UEFI machine-type in freeldr.
- Implement all of the video output functions so we can display a pretty freeldr BSoD :)
2023-03-19 20:13:16 +01:00
Hermès Bélusca-Maïto
995630ccec
[FREELDR] Fix missing exports and .edata section after commit 728694f6.
CORE-18880
2023-03-19 17:50:55 +01:00
Hermès Bélusca-Maïto
728694f60f
[FREELDR] Move platform-specific build targets into dedicated .cmake files. (#5141)
- Keep the common definitions and file lists in CMakeLists.txt
- Move PC-AT & compatibles (PC-98, XBOX) definitions in pcat.cmake
- Future UEFI-specific definitions will be in an uefi.cmake
2023-03-18 22:40:10 +01:00
Hermès Bélusca-Maïto
7a2aca423e
[FREELDR] Move common x64 runtime-specific ASM helpers to a misc file.
Co-authored-by: Justin Miller <justinmiller100@gmail.com>
2023-03-18 22:40:08 +01:00