Commit graph

705 commits

Author SHA1 Message Date
Hermès Bélusca-Maïto
3a7fe56a5d
[FREELDR] Change GEOMETRY "Sectors" to "SectorsPerTrack" and introduce a new "Sectors" field (#7379)
----
Thanks to the following testers!
- Dmitry Borisov (@disean) for testing on NEC PC-98 emulator;
- Justin Miller (@DarkFire01) for testing on UEFI platform;
- Stanislav Motylkov (@binarymaster) for testing on Xbox emulator
  (xemu), both livecd and bootcd.
----

"SectorsPerTrack" is for the legacy Cylinders/Heads/Sectors(PerTrack)
scheme.

- On BIOS-based PCs, INT 13h can return (for LBA-only drives) an invalid
  geometry, like: C/H/S = (-1)/(-1)/(-1). This is also what happens in
  our hwide.c driver (see IdentifyDevice() for ATAPI devices):
db419efbf2/boot/freeldr/freeldr/arch/drivers/hwide.c (L918-L928)

  as well as on VirtualBox for CD-ROMs:
https://www.virtualbox.org/browser/vbox/trunk/src/VBox/Devices/PC/BIOS/disk.c#L155

- Therefore, we cannot reliably calculate a valid total number of sectors
  by multiplying the Cylinders*Heads*SectorsPerTrack values. In addition,
  such a multiplication could overflow a 32-bit ULONG.
  Thus, a separate ULONGLONG Sectors member is required to hold such a
  value, that is retrieved differently. For example for ATAPI devices,
  our hwide.c driver does return a valid TotalSectors value, even though
  CHS values are invalid. Other platforms, like UEFI, just work using
  logical block addressing (LBA) values (see EFI_BLOCK_IO_MEDIA).

- uefidisk.c : Per the spec, EFI_BLOCK_IO_MEDIA::LastBlock contains
  "The last LBA on the device. [...] For ATA devices, this is reported
  in IDENTIFY DEVICE data words 60-61 (i.e., Total number of user
  addressable logical sectors) _minus one_.
  For SCSI devices, this is reported in the READ CAPACITY parameter
  data 'Returned Logical Block Address field' _minus one_."
  In other words, LastBlock is a zero-based LBA index quantity. The
  corresponding total number of valid "sectors"/blocks of the device
  is therefore, (LastBlock + 1).

- Cleanup some old disabled code.
2024-09-30 12:11:15 +02:00
Joachim Henze
dbda7ab66f
[FDEBUG] *.rc: Less outdated version-hardcodes (#7383)
We do have 22 rc files. Strip a hardcoded version in all of them.
Which hasn't been groomed by anyone for longer than the year 2005 already (SVN r18478).
What a waste of bytes!
2024-09-28 21:23:28 +02:00
Joachim Henze
4f4be5c498
[FREELDR] Print arch + buildnumber on crash-screen (#7382)
This commit tries to improve the quality of the screenshots that we do get posted in JIRA,
where we couldn't even see up to now which build and arch was run.
This is in the wider context of CORE6762
(I intentionally left out the minus in the CORE-ID to prevent auto-linkage to that ticket)
2024-09-26 00:49:29 +02:00
Hermès Bélusca-Maïto
840d39b9d0
[FREELDR] i386/pc/pcdisk.c: Fix LBA reads retry loop (#7367)
When the Int 13h AH=42h "Extended read" function fails, the disk address
packet's LBA block count is reset to the number of blocks that have been
successfully transferred. This is more or less fine, unless one wants to
ensure the exact number of sectors gets read.

If the function fails so that zero sectors were read, the retry loop is
restarted, but with the packet's LBA block count member reset, as per
the documentation. (In this example, it is reset to zero.) Then, at the
next retry attempt, zero sectors are requested to be read, and this time
of course, the call succeeds... Wrongly, of course, this is not what's
expected.

Therefore, for each retry, the LBA block count member should be set
again to the correct number of sectors to read. There are maximum 3
retries, so the retry loop will stop anyway, but the LBA read will now
correctly fail and return FALSE, as expected.

This problem doesn't exist in the retry loop for the Int 13h, AH=02h
"Read Disk Sectors" CHS function, because here, the call is made only
using registers, and we use a pair of RegsIn/RegsOut. RegsOut receives
the modified register values, but the input RegsIn stays unchanged.
2024-09-25 13:24:08 +02:00
Hermès Bélusca-Maïto
4190b48924
[FREELDR] Fix the seg:off values when dumping the extended drive parameters (#7367)
(By the way, it's "EDD": "Enhanced Disk Drive", not "EED"...)

The 13th and 14th USHORTs (at offsets 0x1A-0x1D) in the retrieved buffer
from the INT 13h, AH=48h "Get Extended Drive Parameters" function,
correspond respectively to the offset and the segment of the "EDD
configuration parameters", see http://www.ctyme.com/intr/rb-0715.htm

Fixes code introduced in commit b3f11cfb38 (r17484).

----

16 years ago, these values were wrongly stored in the returned buffer
by VirtualBox, see https://www.virtualbox.org/ticket/2848 .
This has been fixed since VBox 2.1.0 in commit 15712 (22 Dec. 2008):
https://www.virtualbox.org/changeset/15712/vbox
This problem was also noticed earlier (07 Mar. 2008) and fixed in Xen:
https://lists.xenproject.org/archives/html/xen-devel/2008-03/msg00229.html

This bug originated from Bochs, from which the two projects above
adapted their rombios.c code. It was fixed on 08-09 Oct. 2007 by
Myles Watson, see https://sourceforge.net/p/bochs/mailman/message/13777090/
and included in Bochs 1.15x and 1.185+
https://sourceforge.net/p/bochs/mailman/message/12953093/
https://sourceforge.net/p/bochs/mailman/message/12953094/
2024-09-25 13:05:07 +02:00
Hermès Bélusca-Maïto
e2d0c7de30
[FREELDR] iso.c: Perform extra validation before mounting the ISO filesystem (#7367)
Validate the primary volume descriptor version and its reported
logical block size.
2024-09-25 13:05:02 +02:00
Hermès Bélusca-Maïto
56eede6e38
[FREELDR] iso.h: Fix definition of the "Primary Volume Descriptor" PVD structure (#7367)
For reference, see the cdfs/cd.h RAW_ISO_VD structure.

Each of the old "VolumeSetSize", "VolumeSequenceNumber" and "LogicalBlockSize"
ULONG fields actually correspond to pairs of USHORT fields:
"VolumeSetSizeL" and "VolumeSetSizeM", etc., where the "L" one contains
the value in little-endian format, while the "M" one contains the same
value in big-endian format.

Additionally, use UCHARs for the character arrays.
2024-09-25 12:56:47 +02:00
Hermès Bélusca-Maïto
5d99a70597
[FREELDR] Minimally reformat include/fs/iso.h 2024-09-25 12:56:46 +02:00
Laura Konopinska
e2fc578f6d [FREELDR] Support drives with 4k sector size
PR was reviewed at pull/5784
2024-09-12 20:53:10 -07:00
Adam Słaboń
e168d60bc5
[FREELDR] Fix boot timeout regression on AMD64 (#7281)
Initialize the BootMgrInfo struct globally, so the TimeOut value is guaranteed to be negative when no Multiboot cmdline is provided. This could happen when BootMain is called with a NULL pointer:
https://git.reactos.org/?p=reactos.git;a=blob;f=boot/freeldr/freeldr/arch/amd64/entry.S;hb=163f3407c8fa93ce06773fdf9fc53064506bd05e#l73
so CmdLine == NULL and LoadSettings is called with NULL, thus the CmdLineParse isn't run.

Fixes boot timeout regression introduced in commit 7bee32d237 which occured only on AMD64 builds.
2024-09-01 11:54:28 +03:00
Adam Słaboń
03d41008d4
[BOOTDATA] Fix LiveCD autorun (#7282)
Use 'shellexecute' entry instead of 'open', because the latter
tries to execute a non-executable readme.txt file.

https://learn.microsoft.com/en-us/windows/win32/shell/autorun-cmds

Addendum to 4cc03bbf01 (r71342).
2024-08-30 10:16:31 +03:00
Serge Gautherie
44662eaf62 [CMAKE] Use COMPILE_OPTIONS instead of superseded COMPILE_FLAGS
for set_source_files_properties().
2024-08-21 11:34:48 +03: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
Václav Zouzalík
5e6b2daf15
[THEMEUI][INF] Update Czech (cs-CZ) translation (#7145) 2024-07-29 14:18:10 +02:00
Whindmar Saksit
a8b33400a2
[INF][BOOTDATA][SETUPAPI] Use Inf instead of Cmd.exe to register IExplore (#7171)
This moves the IExplore registration from cmd.exe (established in 4a4060ce3c (r52196) for CORE-1370) to syssetup.inf to avoid console popups on first boot.
2024-07-24 22:55:29 +02:00
Katayama Hirofumi MZ
070d353326
[BOOTDATA] Fix Internet Browser icon for LiveCD (#7153)
JIRA issue: CORE-19202
Add CLSID_Internet settings to
boot/bootdata/livecd.inf.
2024-07-19 22:10:29 +09:00
Andrei Miloiu
d8fb869de0
[INF] Update Romanian (ro-RO) translation (#6859) 2024-07-16 21:38:44 +02:00
Katayama Hirofumi MZ
22561d5046
[CMD][BOOTDATA] Populate 'Command Processor' registry data (#7114)
Improve compatibility.
JIRA issue: CORE-8002
- Fix the default values of AutoCompletionChar
  and PathCompletionChar in cmd.exe.
- Populate "SOFTWARE\Microsoft\Command
  Processor" registry key like Win2k3 does.
2024-07-09 22:40:22 +09: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
Katayama Hirofumi MZ
e8b88cf879
Revert "[BOOT] Don't create CSIDL_ADMINTOOLS folder in initial (#6551)" (#7017)
Reverts #6551
This caused the non-English programs menu
items to not be populated.
JIRA issue: CORE-12328 will have to be
reopened afterwards and approached
differently
JIRA issue: CORE-19652 will get resolved
2024-06-14 11:08:14 +09:00
Ratin Gao
67d5a53839
[TRANSLATION] Improve Simplified Chinese (zh-CN) translation (#6804)
- Add and improve translation
- Fix mistakes

Reviewed-by: Chilung Chan <eason066@gmail.com>
Reviewed-by: yangyangdaji <1504305527@qq.com>
Reviewed-by: He Yang <1160386205@qq.com>
2024-06-13 16:36:41 +03:00
Hermès Bélusca-Maïto
0b366ea122
[CMAKE][REACTOS] Introduce a utf16le_convert() cmake helper (#6904)
Used when we convert files to UTF16-LE during our build process.
Removes duplicated code.
2024-06-10 21:23:12 +02:00
Katayama Hirofumi MZ
7e2cd98688
[BOOTDATA][INF] Retry: Add Tahoma entry to Asian FontLink (#7001)
This is re-trial of #6985.
Forgot a comma and a backslash.
JIRA issue: CORE-9616
Modify boot/bootdata/hivesft.inf.
2024-06-07 21:21:03 +09:00
Katayama Hirofumi MZ
5a159ad1cc
Revert "[BOOTDATA][INF] Add Tahoma entry to Asian FontLink (#6985)" (#6996)
Reverts #6985
JIRA issue: CORE-9616
Forgot a comma and a backslash.
I will retry.
2024-06-07 01:48:22 +09:00
Katayama Hirofumi MZ
8079fa1a3d
[BOOTDATA][INF] Add Tahoma entry to Asian FontLink (#6985)
Follow-up to #6929.
Latin accented characters will be able to
be mixed in East Asian text by FontLink
framework in the future.
JIRA issue: CORE-9616
- Modify boot/bootdata/hivesft.inf.
- Add "tahoma.ttf,Tahoma" entry to
  Asian FontLink registry values.
2024-06-07 00:43:55 +09:00
Katayama Hirofumi MZ
817f89466d
[BOOTDATA][IMM32][NTUSER] Follow-up to #6961 (#6962)
JIRA issue: CORE-19320
- Delete "(brain-dead)".
- Fix "despite of" as "despite".
- Use "%S" instead of debugstr_w.
2024-05-29 01:14:52 +09:00
Katayama Hirofumi MZ
c8a3c919e5 [BOOTDATA][IMM32][NTUSER] Set "LoadIMM" to zero
We set "LoadIMM" to zero in order to disable Cicero.
The name of "LoadIMM" is a brain-dead name. This name
means Cicero despite of its name (brain-dead).
They use a human-confusing name intentionally.

JIRA issue: CORE-19320

- Set HKLM\SOFTWARE\Microsoft\Windows NT\
  CurrentVersion\IMM:LoadIMM to 0.
- Add warning comments to the brain-dead name "LoadIMM".
2024-05-28 23:17:22 +09:00
Katayama Hirofumi MZ
eb43a803bd
[BOOTDATA][INF] Add FontLink registry entries (#6929)
Prepare for font linking implementation.
JIRA issue: CORE-9616
Modify boot/bootdata/hivesft.inf.
2024-05-25 07:11:26 +09:00
Whindmar Saksit
108db8f007
[CSCRIPT][WSCRIPT][BOOTDATA] Basic .wsf support (#6140)
Support for .wsf files with a single script block
2024-05-19 13:57:47 +02:00
Carl J. Bialorucki
190b3da95d
[CMD][BOOTDATA] Minor improvements (#5745)
* Remove a hardcoded copyright string and move into localizable resources.
* Remove the PROMPT environment variable from clean installs of ReactOS. By default, the command prompt uses $P$G (path + '>') as its prompt settings and does not require this environment variable. Clean installs of Windows Server 2003 do not include this environment variable either. I documented this environment variable in our wiki if anyone would like to set it on their own ReactOS installs.
* Remove the new line above the copyright notice when the information line is turned off.

CORE-16193, CORE-17031
2024-05-09 10:03:43 -06:00
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
Mark Jansen
24a56f89ab
Rework apisets to use a table
This removes all fake apiset forwarders,
and handles apisets inside ntdll.
This is not 100% compatible with how windows does it, but it should be good enough for us.
2024-04-27 22:51:34 +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