Dewera / Lunar

A lightweight native DLL mapping library that supports mapping directly from memory
MIT License
584 stars 102 forks source link

Inconsistent Directory Names Crash #33

Closed Alexflamer11 closed 3 years ago

Alexflamer11 commented 3 years ago

While messing around with how well the injector handled different files, I ran into an issue on my desktop where some of the files were not named how the program was expecting and getting an out-of-bounds index error.

In the function GetManifestDirectories in the file ActivationContext.cs around line 108 is where the function is defined.

When it iterates the directories and parses the names, it expects the names to be ...Version_Language_Hash But in the case a file is not named in that convention (such as "Backup", "Temp", anything not conforming to this style) will cause the out-of-bounds error.

https://github.com/Dewera/Lunar/blob/11e117d85994d34b9bfdbb4d930df683c8ab9bf4/Lunar/FileResolution/ActivationContext.cs#L108

Dewera commented 3 years ago

Thanks for reporting, actually already came across this the other day myself (seems Windows added a bunch of extra directories into the SxS directory.) Already have a fix in my dev version and am hoping to release soon alongside a new feature I've been working on for a while

If you need a quick fix for it now, you just need to filter the directories based on the architecture

var directoryPrefix = architecture == Architecture.X86 ? "x86" : "amd64";

foreach (var directory in sxsDirectory.EnumerateDirectories().Where(directory => directory.Name.StartsWith(directoryPrefix)))
Alexflamer11 commented 3 years ago

Thank you that fixed the issue with those files failing to load.