Skip to content

runtime/shims: serve LoadPackagedLibrary and the DLL directory APIs (console paths resolved) - #8784

Closed
tedin7 wants to merge 5 commits into
ProjectLeonida:mainfrom
tedin7:c2-library-loader-packaged-dll-dirs
Closed

tedin7 wants to merge 5 commits into
ProjectLeonida:mainfrom
tedin7:c2-library-loader-packaged-dll-dirs

Conversation

@tedin7

@tedin7 tedin7 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

What

  • Route LoadPackagedLibrary and DLL directory APIs through the loader shim, registering both existing overlay and bundled directories for console paths.
  • Track host directory cookies and reject invalid packaged-load reserved arguments.

Why

Unpackaged processes cannot use the host package loader for owned shims, and console paths are not host directory names.

Known limits

  • The bundled loader accepts basenames only. Relative names containing a directory are rejected with ERROR_MOD_NOT_FOUND; absolute, drive and parent-traversal paths are rejected with ERROR_INVALID_PARAMETER.
  • Registered DLL directories are forwarded to the host loader; the guest mapper still searches its game root, not those directories. Supporting them requires extending the shim-to-mapper interface.

Tested

  • Review fixes: p2 Linux cross-build with clang-cl and Wine, loader_test: 106 checks, 0 failed; no GPU or driver used. Negative controls: previous loader implementation produced 2 failures; returning success without configuring defaults produced 1 failure.
  • Follow-up 2: Linux pod, clang-cl cross-build and Wine, loader_test: 102 checks, 0 failed. A synthetic bundled DLL loads successfully; version.dll is reachable through host search but is rejected by the packaged loader. No GPU or driver used.
  • Negative control: replaced only library_loader.cpp with revision 86a20c4 on the pod (equivalent to stashing that change), retaining the new path tests: 102 checks, 6 failed; restored the fix and forced recompilation: 102 passed. The host reachability assertion was added after the negative control.
  • AI-assisted change. Follow-up at 3b8a3b7 plus this change: remote Linux cross-build with clang-cl and Wine, loader_test, 95 checks, 0 failed; no GPU or driver used.
  • Follow-up negative control: substituted the previous library_loader.cpp on the pod (equivalent to stashing the follow-up .cpp change), retaining the new test: 95 checks, 1 failed because the host module was loaded. Restored the changed file and rebuilt: 95 passed.
  • Negative control: used the original library_loader.cpp on the remote copy with the new test (equivalent to stashing that change): 89 checks, 1 failed, missing shim exports. Restored the change and forced recompilation before the passing run.
  • Cross-built dll_thread_calls_test successfully. git diff --check and python -I scripts/check_no_game_data.py passed for the changed files.

@ItsNotRexed: an exe PR, as you asked.

Claim: #8683 (comment)

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Windows 11.

  • Correctly serves \LoadPackagedLibrary, \AddDllDirectory, \RemoveDllDirectory, and \SetDefaultDllDirectories\ in
    untime/shims/library_loader.cpp\ and
    untime/shims/file_system.cpp:
    • Rejects traversal/relative paths and reserved flags (\ERROR_INVALID_PARAMETER\ / \ERROR_MOD_NOT_FOUND).
    • Restricts packaged loading to bundled package modules and owned shims, refusing arbitrary host modules.
    • Resolves console paths (\GAME:...) through
      t::fs::resolve_read_path.
    • Proper tracking and lifecycle management for DLL directory cookies.
  • Unit tests in
    untime/test/loader_test.cpp\ verify all reject/accept paths and cookie round-trips.
  • \compileall, \git diff --check, and clean-room checks pass.

LGTM!

@smowlyy

smowlyy commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Verified head f9d6786f4 merged onto main (867d922f0) on native Windows 11 (10.0.26300.9974, MSVC 19.44, RelWithDebInfo):

  • python -I scripts/check_no_game_data.py on all 5 changed files: clean (exit 0)
  • cmake --build runtime/build --target loader_test file_system_test --parallel: built cleanly
  • ctest --test-dir runtime/build -R '^(loader|file_system)$' --output-on-failure -V: 2/2 passed (loader, file_system — 446 checks, 0 failures)

AI-assisted.

@lohant27-netizen

Copy link
Copy Markdown

Tested f9d6786f4 on Windows 11 (10.0.26300), NVIDIA GeForce RTX 5070 (driver 32.0.16.2101, subgroup 32), MSVC with SDK 10.0.26100, Release, merged onto main 867d922f0 together with #8815, #8814, #8809, #8784, #8783 and #8813 (no conflicts): pass.

@comtek21516

Copy link
Copy Markdown

Tested c9b1d63f9 on main at 867d922f0, in one tree with #8422, #8669, #8670, #8690, #8770 (six clean merges): pass.

For this change. loader (with the new LoadPackagedLibrary and DLL-directory cases in loader_test.cpp) and loader_tls pass natively and under Wine; run_tiny_bundled_load and run_tiny_gdk_load pass natively (the Wine runner skips those two, as on main).

Setup. Built with MSVC 14.52 (Visual Studio 18), Windows SDK 10.0.26100, Vulkan SDK 1.4.363.1, Ninja RelWithDebInfo on Windows Server 2025 (no Vulkan driver there), then the same binaries run through scripts/run_wine_tests.py under wine-11.0 (WineHQ stable, xvfb-run) on a Quadro RTX 4000 (Turing), NVIDIA 615.71.09, Ubuntu 22.04.5.

passed failed skipped
native Windows, this tree 147 4 124
Wine on the GPU machine, main 867d922f0 210 12 54
Wine on the GPU machine, this tree 210 12 54

Under Wine the tree is test by test the same as main. The four native failures are gameinput_host, d3d12_sparse_queue_family, vk_bindless_ps_tex and vk_bindless_ps_imgatomic, which fail the same way on main on that machine (#7452). The 12 under Wine are the same 12 as on main (host comparisons Wine cannot answer, and d3d12_xdxr_rt, d3d12_indirect_rt, d3d12_indirect_dispatch_count).

Because the six were built together, there is no per-PR negative control in this run: a regression would have shown as a difference from main, and there is none. No game files used. AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants