mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 22:40:52 +01:00
[PR #400] mfplat_offline: add offline Media Foundation source-resolver proxy and console path rewrite (RT-MF-OFFLINE) #452
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#452
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/400
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open
Base:
main← Head:feat/mfplat-offline-shim📝 Commits (5)
600511bmfplat_offline: add offline IMFSourceResolver proxy and console drive rewritef8ebf0bMerge remote-tracking branch 'ubiq/main' into feat/mfplat-offline-shimb99a982mfplat_offline: default-deny URL classifier, cache mfplat.dll, narrow docsb2c1920mfplat_offline: refuse mixed-slash and post-authority UNC forms as UNC (#400 review)54e65f8Merge remote-tracking branch 'ubiq/main' into feat/mfplat-offline-shim📊 Changes
9 files changed (+842 additions, -3 deletions)
View changed files
📝
docs/runtime_imports.md(+16 -1)📝
runtime/CMakeLists.txt(+17 -0)📝
runtime/shims/file_system.cpp(+12 -0)📝
runtime/shims/file_system.h(+7 -0)➕
runtime/shims/mfplat_offline.cpp(+425 -0)➕
runtime/shims/mfplat_offline.h(+37 -0)📝
runtime/shims/registry.cpp(+1 -1)➕
runtime/test/mfplat_offline_test.cpp(+326 -0)📝
scripts/build_runtime.ps1(+1 -1)📄 Description
Claimed in the coordination issue as:
RT-MF-OFFLINE(https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7121796272)What and why
Titles that play intro and UI videos through Media Foundation (
mfplat.dll!MFCreateSourceResolver) pass console drive paths (GAME:,G:,T:) orfile://URLs and could otherwise reach external hosts viahttp://,https://,rtsp://,mms://, or UNC shares.This PR adds a partial
mfplat.dllshim (runtime/shims/mfplat_offline.{h,cpp}) that wraps the hostIMFSourceResolverCOM object in a strict proxy:rt::fs::resolve_read_pathinruntime/shims/file_system.{h,cpp}so Media Foundation shares the exact overlay-first / package-fallback resolution and path-traversal refusal used by Win32 file I/O.http,https,rtsp,mms,\server\share,//server/share,\\?\UNC\..., remotefile://host/...) withMF_E_UNSUPPORTED_SCHEME(0xC00D36C3) before touching the host resolver.GAME:,G:,T:and percent-encoded localfile:////file://localhost/URLs to resolved host paths on bothCreateObjectFromURLandBeginCreateObjectFromURL, while forwarding byte-stream methods andCancelObjectCreationunchanged.QueryInterfaceIIDs on the proxy so callers cannot unwrap the raw host resolver and bypass the offline gate.mfplat.dllexports forwarded to the native Windows Media Foundation DLL so built-in H.264/AAC/Bink pipelines continue to work.mfplat_offline_testinruntime/CMakeLists.txt, updatesscripts/build_runtime.ps1fallback$files, and documentsmfplat.dllindocs/runtime_imports.md.Tested
runtime/test/mfplat_offline_test.cpplocally with Clang 23 (-std=c++20 -O2 -Wall -Wextra -Werror): 30 check(s), 0 failure(s).python -I scripts/check_no_game_data.pyon all touched files: exit 0.python -I tests/test_build_runtime_fallback.pyandpython -I tests/test_docs_links.py: all tests passed.GPUs tested: n/a (CPU-only Media Foundation COM proxy & URL classifier tests)
AI-assisted: yes
Update after review (merged with current
main)GAME:/G:/T:console paths, absolute drive paths (X:\orX:/) andfile:URLs with an empty orlocalhosthost that name one of those reach Media Foundation. Relative and drive-relative paths,\??\and\\.\device paths, whitespace before a scheme, and driveless or UNC-shapedfile:URLs (including percent-encoded%5C%5Chost) are refused withMF_E_UNSUPPORTED_SCHEME.DRIVE_REMOTEdrive is refused; console paths still resolve under the configured game/overlay folders.MFCreateSourceResolverloadsmfplat.dllonce (no per-callLoadLibraryExWreference leak) and returns the real load/export error.IMFSourceResolverURL methods are gated (not byte streams orMFCreateSourceReaderFromURL).mfplat_offline_test44 checks, 0 failures (clang 23 / mingw x64); docs tests 50 passed.Update after the second review
\\,//,/\,\/) are a UNC share, as Windows reads them, and are refused asunc. Afile:URL whose path starts with two or more separators after the authority and percent-decoding is refused as UNC too.file:////server/share/a.mp4,file://localhost//server/share,/\server\share,\/serverandfile:///%2F%2Fserver. The mixed-slash ones fail on the previous head.MFCreateSourceReaderFromURL,MFCreateFileand byte streams reach the host. The host'smfreadwrite.dlldelay-importsMFCreateSourceResolveritself (tools/pe_inspect.pyon Windows 10 22H2), so a source reader uses the unwrapped resolver.MFCreateSourceResolver: its import table (tools/import_call_sites.py) has one call toMFPlat.DLL!MFCreateSourceResolver(RVA0x33a4d25) and, 0x6a bytes later in the same function, the only call toMFReadWrite.dll!MFCreateSourceReaderFromMediaSource(0x33a4d8f). It imports neitherMFCreateSourceReaderFromURLnorMFCreateFile, andtools/pe_inspect.pylists no Media Foundation DLL among its run-time load candidates. So the title's one way to open media is resolver -> media source -> source reader, and the resolver is the wrapped one. Cited indocs/runtime_imports.md.mfplat_offline_test49 checks, 0 failures; docs tests 47 passed.Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a — runtime shim only)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.