media: apply the local-file rule to the source reader, sink writer and MFCreateFile #663
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!663
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-663"
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?
@coderanonymus on GitHub · 2026-11-24 06:24 UTC · original
coderanonymus:media-foundation-url-guard→main· +169 −15 · 1 files · 1 commits · openWhat
media.rsproxies onlymfplat!MFCreateSourceResolver.HostPolicypasses the rest ofmfplat.dllandmfreadwrite.dllthrough. Four exports that take a URL or a path therefore bind straight to the host:mfreadwrite!MFCreateSourceReaderFromURLmfreadwrite!MFCreateSinkWriterFromURLmfplat!MFCreateFilemfplat!MFBeginCreateFileThe host's source reader calls
IMFSourceResolver::CreateObjectFromURLinternally. It gets that resolver from the real mfplat, not from our proxy. The host'sMFCreateFileopens the path with the host'sCreateFileW, not withfiles. Sochecked()andfiles::translatenever run:MFCreateSourceReaderFromURL(L"https://cdn.example.com/a.mp4", ...)fetches over the network, pastmodules::net.MFCreateFile(..., L"\\\\server\\share\\a.mp4", ...)opens a share.MFCreateFile(..., L"G:\\movies\\intro.mp4", ...)fails, because the host cannot see our virtual drives.This change adds
mfreadwrite.dllto the media module and registers the four exports. Each one runs the resolver's existingchecked()first. On a refusal it returns the same0xC00D36C3and clears the out pointer, ascreate_from_urlalready did. Otherwise it calls the host's export with the checked path, whichfiles::translatehas rewritten. The sink writer checks its URL only when it gets no byte stream. With a byte stream, the URL only names the container type, the same ascreate_from_stream. The out-pointer clearing moves into a smallchecked_outhelper, andcreate_from_urluses it too.GetProcAddresslookups by name are covered too:kernel::host_overridemaps any name the registry knows.Verification
every_media_foundation_url_entry_point_is_ours: assertsregistry::lookupfinds all four exports. On main none is registered, so it fails there.url_entry_points_refuse_what_is_not_a_local_file: calls each wrapper with an https URL or a share path and a stale out pointer. It expects0xC00D36C3and a null out pointer, and it never reaches the host.cargo clippy -p victory-hle --tests --target x86_64-pc-windows-msvc: clean. The only warning is the existing one inxmem.rs.--features victory-gpu/diagnostics: clean, with the same existing warning.rustfmt --edition 2024 --check crates/victory-hle/src/modules/media.rs: clean.Not run:
victory-hlebuilds only for Windows. Both tests type-check but were not executed (Linux machine, no Wine). Nothing was run against a real Media Foundation host or a game.No game data used.
🤖 Generated with Claude Code
@geiyiliyabumo on GitHub · 2026-11-24 12:41 UTC · original
Review: media local-file rule extended to the source reader / sink writer / file exports
Diff read:
crates/victory-hle/src/modules/media.rsonly, +169 / -15. Reviewed the full hunks, not the summary.What it does
checked/localrule:MFCreateSourceReaderFromURL,MFCreateSinkWriterFromURL,MFCreateFile,MFBeginCreateFile(media.rs:467-567), and registersmfreadwrite.dllalongsidemfplat.dllinmodule()(media.rs:569-581).checked_out(media.rs:152-160) that nulls the title's out pointer on a refusal, and refactorscreate_from_urlto use it (behaviour unchanged).MFCreateSinkWriterFromURLonly checks the URL whenstream.is_null()(media.rs:494-501); with a byte stream the URL is passed through raw as a container hint, matchingcreate_from_streamand MS semantics (the host does not open it).UNSUPPORTED_SCHEMEbefore the host is called and leaves a null out pointer.Findings
No correctness or memory-safety bugs found.
url.as_ptr()/path.as_ptr()are used only within the lifetime of their owningVec, so the transmuted host call never sees a dangling pointer.host::function(...)returnsNonethe export returnsUNSUPPORTED_SCHEMEwithout clearing the out param (e.g.media.rs:476-478), unlike the refusal path. A title that pre-seeds the out pointer to non-null could observe it unchanged. Low risk, andMFCreateSourceResolverhas the same shape.begin_from_urlstill usescheckedrather thanchecked_out(media.rs:335), so its cookie out param isn't cleared on refusal ? a now-more-visible inconsistency, out of this PR's scope.Commands actually run (proxy cleared,
--locked, CARGO_TARGET_DIR shared):cargo xtask policy?asset policy: 154 files ok(exit 0)cargo clippy -p victory-hle --all-targets --locked -- -D warnings? exit 0, no lint diagnostics. (Early runs showed per-crate "generated 1 warning" summaries; those were cargo's incremental lock-file-deletion noise on the shared target dir ? re-ran withCARGO_INCREMENTAL=0and it is completely clean, 0 warnings.)cargo clippy -p victory-hle --all-targets --features diagnostics --locked -- -D warnings? exit 0, clean.cargo test -p victory-hle --locked -- media?4 passed; 0 failed(only_local_files_reach_the_host,every_media_foundation_url_entry_point_is_ours,url_entry_points_refuse_what_is_not_a_local_file,interface_ids_are_the_resolvers).Verdict: approve-worthy. Only the two minor nits above; neither blocks.
AI-assisted; synthetic tests only, no game files.
@Marvisak on GitHub · 2026-11-25 00:33 UTC · original
Automated triage for the maintainers.
Needs rebase. This PR does not merge cleanly into current
main(ac2525d). Conflicting files:crates/victory-hle/src/modules/media.rs.The content has not been reviewed yet; it will be once the branch is rebased onto
main.Generated by Claude Code
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.