Skip to content

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

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

tedin7 wants to merge 5 commits into
ItsNotRexed: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.

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.

4 participants