Skip to content

Fix automatic DLL discovery matching short filename aliases - #32

Open
DeathFishAtEase wants to merge 3 commits into
Phobos-developers:masterfrom
DeathFishAtEase:fixload
Open

DeathFishAtEase wants to merge 3 commits into
Phobos-developers:masterfrom
DeathFishAtEase:fixload

Conversation

@DeathFishAtEase

Copy link
Copy Markdown
Member

Renaming a DLL to .dlli can appear to disable it, then unexpectedly stop working after copying the game directory to another drive or machine.

Windows file searches match both long filenames and their 8.3 short aliases. On a volume that generates short names, PatcherLoader.dlli can receive an alias such as PATCHE~1.DLL, which still matches *.dll. Windows then returns the long filename, and Syringe accepts it for injection. Files without such aliases remain excluded, so even two .dlli files in the same directory can behave differently.

Automatic discovery now checks that the returned long filename ends in .dll, case insensitively. Explicit -i= selections continue to allow other extensions.

Verified with a test executable and hook DLL, including renamed files with .DLL short aliases, mixed-case extensions, and explicit selections. The existing test suite also passes.

@DeathFishAtEase DeathFishAtEase self-assigned this Nov 11, 2026
@DeathFishAtEase DeathFishAtEase added the bug Something isn't working label Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@DeathFishAtEase
DeathFishAtEase requested review from Coronia and ZivDero and removed request for Belonit and Coronia November 11, 2026 11:47
@Metadorius

Copy link
Copy Markdown
Member

it looks to me as a workaround rather than a proper solution. is there a way to exclude short filenames from the paths maybe? they're useless for modern apps anyway

@DeathFishAtEase

Copy link
Copy Markdown
Member Author

it looks to me as a workaround rather than a proper solution. is there a way to exclude short filenames from the paths maybe? they're useless for modern apps anyway

I looked into whether we could exclude short aliases through the enumeration API.

The Remarks section of Microsoft's FindFirstFileEx documentation explicitly states:

The search includes the long and short file names.

There is no documented option in FindFirstFile/Ex to disable short-name matching. FindExInfoBasic initially looked promising, but the FINDEX_INFO_LEVELS documentation describes its effect on the returned information:

the cAlternateFileName member is always a NULL string.

I verified this with compiled Syringe.exe variants: I removed the extension check and switched the enumeration to FindFirstFileEx with FindExInfoBasic, then tested another variant using absolute paths with the \\?\ prefix. Both still injected .dlli and .dll+ files with .DLL short aliases, and the hooks executed successfully.

The returned filename is already the long name. Windows matches an alias such as PATCHE~1.DLL but returns PatcherLoader.dlli, so converting the returned path to a long name would not address the mismatch.

The extension check therefore enforces the intended automatic discovery rule against the long filename. We could instead enumerate * and filter the long filenames ourselves, but that would still require the extension check.

Do you know of an API or approach that avoids short-alias matching directly, or have you handled something similar before? I'd appreciate any pointers or practical experience that could help improve this.

@DeathFishAtEase
DeathFishAtEase removed the request for review from ZivDero November 12, 2026 16:19
@Metadorius

Copy link
Copy Markdown
Member

what a stupid limitation from the API side...

I don't have much idea, but I think you have to filter everything to be matching that, not just default case.

does Windows expose some way to check whether the path matches the wildcard? maybe we could double-check every matched path to match the *.dll or whatever we specify to inject?

Use PathMatchSpecEx for every returned filename, including explicit -i patterns, so 8.3 aliases cannot select unintended extensions. Replace the default-scan-only suffix check with the same filter for all selections.
Use the native DOS wildcard matcher for the long-name recheck so existing -i patterns keep FindFirstFile behavior, including question marks, extensionless names, and trailing-dot normalization.
@DeathFishAtEase

Copy link
Copy Markdown
Member Author

I don't have much idea, but I think you have to filter everything to be matching that, not just default case.

does Windows expose some way to check whether the path matches the wildcard? maybe we could double-check every matched path to match the *.dll or whatever we specify to inject?

I’ve updated the default DLL discovery so every FindFirstFile result is rechecked against its long filename, preventing 8.3 aliases from making files such as .dlli or .dll+ match *.dll.

Commit e340029 additionally preserves FindFirstFile’s existing Win32 wildcard semantics for the second check. I’m not sure whether this extra compatibility layer is necessary given its added complexity. What do you think?

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants