Commit Graph

8 Commits

Author SHA1 Message Date
7daa4a4a51 Merge pull request #664 from sodove/perf/pe-block-reads
runtime: read PE files in blocks (RT-PE-BLOCK-READ)
2026-11-28 18:59:07 +01:00
d8cfc01d51 tests: check whether the locked PE tail actually blocks CRT reads 2026-11-26 10:11:12 +05:00
2e8a92d72a runtime: guard base_reservation parsing and VirtualQuery loop overflow 2026-11-25 19:47:42 +01:00
291a96f7de runtime: read PE files in blocks (RT-PE-BLOCK-READ)
Based on the block-read proposal and Wine measurements from cobrabm12. Add a Windows regression for a read failure after a valid prefix.
2026-11-24 15:31:26 +05:00
74941a2411 base_reservation: read LEONIDA_BASE_RESERVED with swscanf_s (MSVC C4996)
swscanf at base_reservation.h:44 was the runtime build's only warning on
main 6a6704d, printed for five targets. swscanf_s takes no buffer sizes
for integer conversions, so the %llx:%llx parse is the same.

pe_loader_test now checks inherited(): a valid value, size 0, no size,
a non-hex base and no variable. Only arm64 Wine relaunches gta6rt, so a
Windows run never reached this parser before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 09:09:13 -06:00
27d1b11b64 Runtime: register each mapped image's x64 unwind table (.pdata) with RtlAddFunctionTable
Images the loader maps by hand are unknown to the system unwinder, so an exception raised in or passing through one couldn't be dispatched and killed the process. load() now validates the exception directory (entries in bounds, sorted, non-overlapping; zero-length entries allowed, as in System32's symcryptk.dll) and registers it; the loader removes it before freeing the image. Rules measured over 3,780 x64 System32 images (5,023,071 entries) and the 16 package DLLs.

Tests: loader_test covers registration, removal and six corrupt tables on hand-built images; pe_loader_test checks a fixture SEH fault is caught by the image's own handler (fails without registration) and, with LEONIDA_GAME_DIR, every package DLL's table.

AI-assisted.
2026-11-21 23:18:59 +01:00
da499ab911 Loader: initialise dependencies before their importers
map_image pushes a module into order_ before bind_imports maps the modules it
imports, so order_ lists an importer ahead of its DLLs, and initialise() ran
TLS callbacks and DllMain in that order. Keep a separate init_order_ filled
after a module's imports are loaded and initialise from it. modules() stays
mapping order. pe_loader_test checks tiny_dll comes before tiny_exe.
2026-11-21 21:07:23 +01:00
caa31b5fd2 Runtime: tests for the native PE loader (fixtures, imports, relocations) 2026-11-21 18:08:39 +00:00