Commit Graph
14 Commits
Author SHA1 Message Date
Oliver Hamlet 5aa61abc10 Remove pelite dependency
The advantages of using the built-in implementation instead of pelite are:

- It's much faster on average: for Starfield.exe (~ 100 MB) it is 2.8x
  faster and 4% slower reading file and product versions respectively,
  and for sfse_1_15_222.dll it is 3.35x faster and < 1% slower
  respectively.
- It reduces the transitive dependency count by 8
- It uses ~ 700 lines of first-party code that only depends on the
  standard library, instead of 240715 lines of unaudited third-party code
- pelite hasn't had a release in 3 years, and my PR for replacing winapi
  hasn't had any response in the month and a half it's been open, so the
  built-in implementation is probably less of a maintenance risk.
2025-12-03 18:39:27 +00:00
Oliver Hamlet daf229c1e9 Implement PE executable version parsing
Using only the standard library (i.e. without pelite).

This commit keeps the pelite dependency and uses it to check that the
new parser gives the same result. The next commit will remove pelite.

I've verified that both parsers give the same result for the following
files that are referenced in the masterlists' version conditions:

Starfield.exe
sfse_1_15_222.dll
SkyrimSE.exe
skse64_loader.exe
skseVR_loader.exe
ENBHelperSE.dll
d3d11.dll
EngineFixes.dll
QuickLootEE.dll
FalloutNV.exe
nvse_1_4.dll
nvse_1_4ng.dll
nvse_1_1.dll
Fallout3.exe
fose_1_7.dll
fose_1_7ng.dll
nvac.dll
Fallout4.exe
f4se_loader.exe
f4sevr_loader.exe
place.dll
obse_1_2_416.dll
TESV.exe
skse_loader.exe

The only referenced files that I couldn't test against were SkyrimVR.exe
and Fallout4VR.exe, because I don't own those games.
2025-12-03 18:39:27 +00:00
Oliver Hamlet d70bbdd2c9 Fix new clippy lint error
Introduced in Rust 1.89.0 / clippy 0.1.89.
2025-08-20 17:26:17 +01:00
Oliver Hamlet 9c4f9dcb5e Deny a lot of extra lints and fix their errors 2025-04-26 10:10:48 +01:00
Oliver Hamlet a574a2c98b Fix compiling for platforms that don't have memory map support in pelite 2025-04-25 18:51:29 +01:00
Oliver Hamlet f7d9947fa4 Add Send, Sync and 'static bounds to Error variant 2025-02-26 19:45:59 +00:00
Oliver Hamlet f357fa48a3 Add is_executable() function
To guard against calling product_version() or version() on (non-plugin) files that unexpectedly aren't executables, e.g. Starfield.exe from the Microsoft Store.
2025-01-28 18:17:57 +00:00
Oliver Hamlet 3d9ac4cfc2 Address clippy warnings in test code 2025-01-14 18:12:31 +00:00
Oliver Hamlet 13600ba188 Apply clippy suggestion 2025-01-14 18:11:47 +00:00
Oliver Hamlet f7db75bfea Stop using 7z binaries in test cases
They're not reliably available and are now causing CI failures. Instead
use libloot for the test cases that used 7z, and update it because older
versions of libloot incorrectly use "ProductVERSION " instead of
"ProductVersion".
2022-11-09 00:04:38 +00:00
Oliver Hamlet d874dfcdbc Fix comparisons of versions with and without a pre-release ID
Semver says that 1.0.0-alpha < 1.0.0 but the comparison didn't account
for this case.
2022-02-04 16:22:55 +00:00
Oliver Hamlet aa3dabab8d Apply changes suggested by clippy lints 2022-01-23 22:17:35 +00:00
Oliver Hamlet d3fec5ee6a Improve the correctness of version comparison
This makes the comparison between a numeric and a non-numeric release ID
more granular, by trying to parse leading digits in a non-numeric
release ID as a number and comparing it against the numeric ID. If the
two differ, their ordering is used as the ID ordering. If they're equal,
the non-numeric ID is considered greater so long as it has a non-zero
length suffix after the numeric leading digits. This means that
the version
0.78b is correctly considered to be less than the version 0.86, which
was not previously the case.

Pre-release IDs are not affected to avoid not conforming to the Semver
spec, which states that numeric pre-release IDs are always less than
non-numeric pre-release IDs. As non-numeric release IDs are not allowed
in semver, this commit's changes don't change the behaviour for semver
version comparisons.
2021-04-25 18:07:16 +01:00
Oliver Hamlet 384b374d7d Move version module
It's only used inside the function module, so move it there.
2021-04-07 22:14:33 +01:00