Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mono search paths - multiple overrides and replace full mono search path #36

Closed
CptMoore opened this issue Sep 20, 2022 · 3 comments
Closed
Labels
enhancement New feature or request

Comments

@CptMoore
Copy link
Contributor

Allow multiple directories for mono_dll_search_path_override and allow to remove the target_path_folder and root_dir.

Maybe something like this (inspired by AssemblySearchPaths in csproj):

mono_dll_search_paths=Z:\MostImportant;{override};{target};{root};D:\Fallback
mono_dll_search_paths=A:\TheOneAndOnly
mono_dll_search_paths=

quick overview of what is happening currently:

    if (has_override) {
        strcat(mono_search_path, override_dir_full);
        strcat(mono_search_path, PATH_SEP);
    }
    strcat(mono_search_path, target_path_folder);
    strcat(mono_search_path, PATH_SEP);
    strcat(mono_search_path, root_dir);

The "fallback" case is there to avoid when future updates of the game suddenly introduce their own versions of the assemblies.
The "one and only" or "nothing" cases would allow using dynamic AppDomain.CurrentDomain.AssemblyResolve to programmatically resolve everything. (These are theoretical ideas that were not tested, so might not work well with Unity mono)

@ghorsington
Copy link
Member

Greetings!

The current override was implemented to allow overwriting DLLs in the game's Managed folder without having to modify the folder contents. The use case is primarily for unstripping games, as you cannot generally even launch your DLL with the stripped assemblies, see #10.

I am not really into allowing freely swapping the order however you want, as mono's DLL search paths have a very high priority. Therefore I made it specifically very simple, only allowing one folder.

If you need an assembly resolver that is earlier than the one in AppDomain, you can install mono's native assembly search hooks, see for example:

Yes, you can implement the same hooks on C# side with P/Invoke.

@ghorsington ghorsington added the enhancement New feature or request label Sep 20, 2022
@CptMoore
Copy link
Contributor Author

Cool, ill look into the pInvoke stuff

@CptMoore
Copy link
Contributor Author

So while playing around with search paths, i had cases where even an overridden search path wasn't adhered too. Im now force loading assemblies to make them first priority just to be sure in all cases. I wouldnt support this enhancements anymore either, due to the issues.

@CptMoore CptMoore closed this as completed Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants