Giter Site home page Giter Site logo

lavagang / melonloader Goto Github PK

View Code? Open in Web Editor NEW
2.1K 2.1K 450.0 443.9 MB

The World's First Universal Mod Loader for Unity Games compatible with both Il2Cpp and Mono

Home Page: https://discord.gg/2Wn3N2P

License: Apache License 2.0

C# 75.00% ASP.NET 18.91% Rust 6.08%
dll game il2cpp melonloader mono unity

melonloader's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

melonloader's Issues

Remove ZIP Loading Functionality

It is hardly used and only causes more issues for the end user to have it load Plugins and Mods from ZIP Archives.
Should remove this and instead throw an error if the file type isn't in the compatible list of extensions.

Extension
.dll
.txt
.json
.xml
.mdb
.pdb
.md

Replace Native Hooking

Currently relies on custom icalls for MelonUtils.NativeHookAttach and MelonUtils.NativeHookDetach
They are exported to use MSDetours for Native Hooking.

This needs to be converted to an implementation that will help improve platform compatibility.

MelonLoader fails to locate mono if the game dir is the root of a drive

This setup is most common within wine/proton environments where the game dir is mapped to be the D drive, etc.

Mono::CheckLibName tries to check if base_path (which is, in this case, D:) exists, which it apparently doesn't (missing backslash? root of drive "doesn't exist" according to windows/wine/proton? who knows), and therefore fails, even though the rest of the method would succeed.

This results in an Internal Failure thrown from Mono::SetupPaths because CheckFolderName returns an empty string for every folder.

I suggest simply removing the check for base_path existing and just bailing out if new_path doesn't exist, because clearly base_path must exist in all callers to this method, even if explicitly checking that fact says it doesn't.

TLS Bridging Failure on Unity 2018.1.0 x64 Il2Cpp

I'm having an error while opening a game with melon loader 0.5.2 when it tries to initialize and contact the remote API. Seems to be a TLS connection problem, as said in the title I'm on Windows 7.
Following this page, I added the registry keys and have the KB update installed, but it still gives the same error.
Log: [REDACTED]

Resolving Issue with Plugins upon Clean Assembly Generation

When running a Plugin from a Clean Installation it seems to attempt to resolve it's dependencies too early.
Resulting in dependencies getting resolved to null before Assembly Generation completes for the first time.
Marking as Optional Dependency does not help.
Leveraging Late Dependency usage does not help.
Dependencies get resolved properly from there on out after restarting the game.

Add Unity Game Check to Proxy

If MelonLoader happens to get installed to something that isn't a Unity Game the Proxy still gets loaded.
This forces the loading of the Bootstrap causing errors and crashing as it fails to initialize.

A built-in check in the Proxy for if it is a Unity Game would solve this.
Possibly with a Warning Popup Message.

[RFC] MelonHandler Events

Events are a common pattern in F# and JavaScript.

I am pretty sure that none of the MelonMod overrides return a value so this system should work perfectly.

Delegate invocation (events) has the same speed as virtual invocation (interfaces), so there shouldn't be a performance hit, rather there would've been a performance increase, unfortunately this will not be gained due to backwards compatibility.

Additionally, multiple functions can subscribe to an event, which can result in cleaner looking code instead of a monolithic override function.

Another benefit is unsubscribing from events, instead of if (!enabled) return; being ran every single time the function is called, the function won't get called at all (faster).

Example:

public Mod() { // class constructor
  MelonHandler.OnUpdate += Update;
}

// this could be useful for a 0Reloader plugin if that ever happens
~Mod() { // finalizer/destructor
  MelonHandler.OnUpdate -= Update;
}

void Update() { ... }

Add dnSpy Debugger Usage Guide to README and Wiki

MelonLoader is already setup to handle dnSpy's Debugger and Environment Variables.
Should probably state its usage in the README and Wiki.
To use it currently just run MelonLoader in Debug Mode and follow the steps in this GUIDE after the part about replacing files.
It should work without replacing any files.

Image for Reference:

MelonLoader fails to read the Game Name and Development Company on Some Games

Originally reported by @bbepis

Some games don't ship with app.info.
Resulting in MelonLoader running things in Universal Fallback as if everything is Universal.
This also causes the MelonGame attribute to just not be checked or used at all.

Solution is some kind of signature scan of globalgamemanagers or data.unity3d to pull the Game Info from there instead.

TLS Bridging Failure on Unity 2021.2.8 x64 Il2Cpp

All of the following criteria must be met

  • All Requirements must be installed.
  • Full Latest.log file included. If no file exists then leave this unchecked and state so.

All of the following are optional to answer

  • Tried reinstalling the Game.
  • Tried reinstalling MelonLoader.
  • Tried restarting PC.
  • Was able to see the Start Screen.

Describe the issue.

Failing to download Unity dependencies.

[REDACTED]

Did you attach your log file?

  • Yes, I attached my log file to the text box above.
  • No, I could not find a log file at {Game_Directory}\MelonLoader\Latest.log

TLS Bridging Failure on Unity 2017.4.30 x64 Il2Cpp

Failed to download cpp2il and failed to download Unhollower

almost because of the same reason and I don't know why.

QQ截图20211228133223

 [ERROR] System.Net.WebException: Error: SecureChannelFailure (The authentication or decryption has failed.) ---> System.IO.IOException: The authentication or decryption has failed. ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.
  at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (System.IAsyncResult asyncResult) [0x00037] in <c7286d73afb545c3a75377349eeda263>:0
  at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (System.IAsyncResult ar, System.Boolean ignoreEmpty) [0x00000] in <c7286d73afb545c3a75377349eeda263>:0
  at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (System.IAsyncResult result) [0x00071] in <c7286d73afb545c3a75377349eeda263>:0
   --- End of inner exception stack trace ---
  at Mono.Security.Protocol.Tls.SslClientStream.EndNegotiateHandshake (System.IAsyncResult result) [0x00032] in <c7286d73afb545c3a75377349eeda263>:0
  at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (System.IAsyncResult asyncResult) [0x0000c] in <c7286d73afb545c3a75377349eeda263>:0
   --- End of inner exception stack trace ---
  at Mono.Security.Protocol.Tls.SslStreamBase.EndRead (System.IAsyncResult asyncResult) [0x0004b] in <c7286d73afb545c3a75377349eeda263>:0
  at Mono.Net.Security.Private.LegacySslStream.EndAuthenticateAsClient (System.IAsyncResult asyncResult) [0x0000e] in <d2957de1c3fd4781a43d89572183136c>:0
  at Mono.Net.Security.Private.LegacySslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x0000e] in <d2957de1c3fd4781a43d89572183136c>:0
  at Mono.Net.Security.MonoTlsStream.CreateStream (System.Byte[] buffer) [0x0007b] in <d2957de1c3fd4781a43d89572183136c>:0
  at System.Net.WebConnection.CreateStream (System.Net.HttpWebRequest request) [0x00073] in <d2957de1c3fd4781a43d89572183136c>:0
   --- End of inner exception stack trace ---
  at System.Net.WebClient.DownloadFile (System.Uri address, System.String fileName) [0x000ad] in <d2957de1c3fd4781a43d89572183136c>:0
  at System.Net.WebClient.DownloadFile (System.String address, System.String fileName) [0x00016] in <d2957de1c3fd4781a43d89572183136c>:0
  at (wrapper remoting-invoke-with-check) System.Net.WebClient.DownloadFile(string,string)
  at MelonLoader.Il2CppAssemblyGenerator.Packages.PackageBase.Download (System.Boolean directory_check) [0x00074] in <9bcfd816514243cb928753d2db66f6d7>:0
[13:31:53.501] [INTERNAL FAILURE] Failed to Download Il2CppAssemblyUnhollower!

Cleanup Managed Folder

After: #94

Mono Library included files can be moved from MelonLoader/Managed to its own Managed folder within the Mono Library Dependencies folder.
Keep all Il2Cpp Generated Assemblies within MelonLoader/Managed.

This will not only clean up the Managed folder but also prevent confusion from developers.
The library files are usually referenced and included from the .NET SDK by the IDE anyways instead of manually referencing from a Managed folder.

[Bug] [v0.5.3]: Failed to invoke PreStart method in UNO

All of the following criteria must be met

  • All Requirements must be installed.
  • Full Latest.log file included. If no file exists then leave this unchecked and state so.

All of the following are optional to answer

  • Tried reinstalling the Game.
  • Tried reinstalling MelonLoader.
  • Tried restarting PC.
  • Was able to see the Start Screen.

Describe the issue.

Issue is reproducible by multiple people. Latest.log attached.
Latest.log

Did you attach your log file?

  • Yes, I attached my log file to the text box above.
  • No, I could not find a log file at {Game_Directory}\MelonLoader\Latest.log

OnApplicationLateStart running too Early on some Mono Games

As the title suggests OnApplicationStart can run too Early on some Mono Games.
This causes unintended behavior for things like GameObjects when instantiated from OnApplicationStart.
Resulting in it ignoring DontDestroyOnLoad or hideFlags, hideFlags causing components not to run, the GameObject getting destroyed on first Scene Load, etc.

Add Wine/Proton Usage Guide to README and Wiki

The instructions for how to run a Game with MelonLoader under Wine or Steam Proton was posted on Discord.
They were written in the context of VRChat but they are the same no matter what Game it is.
Should probably state it in the README and Wiki.

Image for Reference:

Fix Issue with Bhaptics API and Steam Version of Bhaptics Player

The Bhaptics API implementation in MelonLoader uses the TryGetExePath export to check if the Bhaptics Player is installed.
This causes a problem as TryGetExePath only checks and returns a registry value.
A registry value that only gets set by the installer for the Bhaptics Player when downloaded from their website and not from Steam.
If someone tries to use just the Steam version of the Bhaptics Player without the one from their website it will act as if the user doesn't have the Player installed.
Resulting in the API never initializing and anything using it to fail.

The fix would be to parse Steam Library files and check if the Bhaptics Player is installed from Steam as a fallback.

[Bug]: [0.5.3] Invalid Version '0.5.3.0' when using VerifyLoaderVersion

All of the following criteria must be met

  • All Requirements must be installed.
  • Full Latest.log file included. If no file exists then leave this unchecked and state so.

All of the following are optional to answer

  • Tried reinstalling the Game.
  • Tried reinstalling MelonLoader.
  • Tried restarting PC.
  • Was able to see the Start Screen.

Describe the issue.

I'm working on a mod for VRChat that triggered a bug in 0.5.2. So, to prevent users from using an earlier version, I moved to add the VerifyLoaderVersion attribute to the assembly. This resulted in the following log (I killed VRChat with CTRL+C after it failed to load the mod).

Code:

[assembly: VerifyLoaderVersion(0,5,3,true)] // Bug in ML 0.5.2 results in false obfuscation detection.

Log:
Latest.log

Did you attach your log file?

  • Yes, I attached my log file to the text box above.
  • No, I could not find a log file at {Game_Directory}\MelonLoader\Latest.log

Set Logging level? [Error Suppression]

For one of the games i am modding, i get a msg "Unable to connect to 127.0.0.1:15881"
I was wondering if there might be a way to suppress this msg.

Usually, if the msg comes from melon loader, it will have [00:00:00.000] before the msg.
or if it comes from a mod, it will have [Mod Name] before, but this error has nothing.

Add Optional ID Attribute for Melons

An attribute that lets the Developer of the Melon set an ID to be printed for the Melon.
Useful for things like CurseForge for example where its easier to lookup an ID for the Melon rather than just the Name itself.

Originally Suggested by @PyrrhaDevs

Whitelist `@` in symbol names

The F# compiler creates symbols with @ in the name. (Usually in static variables)
As a result, MelonLoader refuses to load any assemblies created in F# due to AssemblyVerifier not whitelisting it.

Add MelonLogger.Error overloads that also log a provided exception in a uniform way

At the moment, whenever mod authors have to log some kind of an exception, they either use 2 calls to MelonLogger.Error, or they manually concatenate the message they want to log and the exception, possibly including a new line.

As a quality-of-life improvement, I propose adding an overload MelonLogger.Error(string txt, Exception ex), which handles this somewhat common task in a uniform way. It would first print the message txt, then include a newline character, and then print the exception message as well as its stack trace on the following lines.

This might be a source-incompatible (but binary-compatible) change due to the existence of the overload MelonLogger.Error(string txt, params object[] args):
Error("foo", new Exception()) used to resolve to the varargs overload, but would now resolve to the exception-printing overload.

Perhaps, even though it may be a bit uglier, MelonLogger.Error(Exception ex, string txt) would be the better argument order.
[Ugly and perhaps a bit confusing, since the message gets logged first, followed by the exception. Not sure what's best here.]
This would also allow adding MelonLogger.Error(Exception ex, string txt, params object[] args) as an analog to MelonLogger.Error(string txt, params object[] args).

[RFC] MelonInfo constructor with `(int, int, int)` versioning

MelonLoader's preferred versioning system is SemVer, which commonly uses 3 integers delimited by periods.
Some creators have accidentally put a v into their version number not expecting ML to add one.
Using an integer tuple would prevent this.

Since this would be an override, it shouldn't break old mods using the old constructor.

Additionally, this would allow in the future for MelonLoader to check if a dependency's version meets the minimum that a mod requires.

Example:

[assembly: MelonInfo(typeof(...), "Name", "1.2.3", "Author", "Link")]
could be converted to
[assembly: MelonInfo(typeof(...), "Name", (1, 2, 3), "Author", "Link")]

[Enhancement]: Load Native Libraries from the UserLibs Directory

Describe the new feature or enhancement

Some Melons may depend on native libraries and should have a directory where they can store those dependencies.
While I understand you can just tell the user to put the library into Unity's Plugins folder, I feel like Melons should still store all their dependencies in MelonLoader-generated directories.

Attempting to use a non-static harmony patch gives a cryptic error

Using a non static prefix with HarmonyInstance.Patch throws the following cryptic error

[ERROR] Exception in Harmony patch of method void VRC.UI.PageWorldInfo::Method_Public_Void_ApiWorld_ApiWorldInstance_Boolean_Boolean_Boolean_APIUser_0(VRC.Core.ApiWorld param_1, VRC.Core.ApiWorldInstance param_2, bool param_3, bool param_4, bool param_5, VRC.Core.APIUser param_6):
System.InvalidProgramException: Invalid IL code in (wrapper dynamic-method) VRC.UI.PageWorldInfo:DMD<VRC.UI.PageWorldInfo::Method_Public_Void_ApiWorld_ApiWorldInstance_Boolean_Boolean_Boolean_APIUser_0> (VRC.UI.PageWorldInfo,VRC.Core.ApiWorld,VRC.Core.ApiWorldInstance,bool,bool,bool,VRC.Core.APIUser): IL_0002: call      0x00000001

Needs to be investigated - if it's a fault in the harmony lib it needs to be reported upstream, if it's a fault in the il2cpp patching code, it needs to be fixed our side.

MelonLoader and Cpp2IL reading the wrong Unity Version from EXEs with Custom Info

Both MelonLoader and Cpp2IL prioritize reading the Unity Version from the EXE.
This results in an issue where some games that have Custom Information on the EXE have a different version.
The fix would be to prioritize a signature scan of an asset bundle like globalgamemanager or have it get from UnityPlayer.dll instead.

GC Issue with Start Screen

On some systems and games the Start Screen will induce a crash with the error: Collecting from unknown thread
This possibly means that an object is being mistakenly collected by the garbage collector.

The temporary workaround is to run the game with the --melonloader.disablestartscreen Launch Option.

Fix Assembly Conflict Issue by adding an Assembly Resolve and/or Redirection Manager

Currently MelonLoader just adds multiple custom Assembly Resolve events.
This can have conflict issues in certain use-cases.
The Fix would most likely be changing it to a single custom event or to a central Manager that will handle resolving and redirection.

Some examples of these conflicts are:
• Assembly being resolved to the wrong Assembly.
• Assembly being resolved to the wrong Version.
• Compatibility Layer System overriding File Loads when its not supposed to.
• Compatibility Layer System not overriding File Loads when its supposed to.

[Bug]: error when starting BONEWORK with MelonLoader latest version. thank you

All of the following criteria must be met

  • All Requirements must be installed.
  • Full Latest.log file included. If no file exists then leave this unchecked and state so.

All of the following are optional to answer

  • Tried reinstalling the Game.
  • Tried reinstalling MelonLoader.
  • Tried restarting PC.
  • Was able to see the Start Screen.

Describe the issue.

Latest.log

Did you attach your log file?

  • Yes, I attached my log file to the text box above.
  • No, I could not find a log file at {Game_Directory}\MelonLoader\Latest.log

[RFC] Higher level logging

MelonLoader only uses level 3 logging (Log, Warning, Error)

Other logging libraries such as slf4j use 5/6/7 level logging.

The common log levels are

  • Trace
  • Debug
  • Info
  • Notification (Level 7)
  • Warning
  • Error
  • Fatal (Level 6)

In my implementations, Trace and Debug are hidden by default and only should show up with a command line option or in the log file.

[Bug]: Background and Logo are not animated

All of the following criteria must be met

  • All Requirements must be installed.
  • Full Latest.log file included. If no file exists then leave this unchecked and state so.

All of the following are optional to answer

  • Tried reinstalling the Game.
  • Tried reinstalling MelonLoader.
  • Tried restarting PC.
  • Was able to see the Start Screen.

Describe the issue.

Latest.log

Both logo and background are not animated. The first frame is shown but doesn't continue like loading does.

Did you attach your log file?

  • Yes, I attached my log file to the text box above.
  • No, I could not find a log file at {Game_Directory}\MelonLoader\Latest.log

Add Mono Game Unstripping

Currently certain Mono based Games come with stripped DLLs in their Managed folder.
This can cause initialization failures with MelonLoader.

An automatic built-in preliminary pass of the Managed folder to unstrip these when a Mono game is detected would be ideal.
Similar to how there is already a preliminary pass to unstrip DLLs on Il2Cpp but for Mono Games.
Most likely needing to destroy the Mono Domain, replacing the files, then recreating the Mono Domain.

Temporary workaround is to manually replace the stripped files with unstripped ones.

[Bug]: Internal Failure when I try to install.

All of the following criteria must be met

  • All Requirements must be installed.
  • Full Latest.log file included. If no file exists then leave this unchecked and state so.

All of the following are optional to answer

  • Tried reinstalling the Game.
  • Tried reinstalling MelonLoader.
  • Tried restarting PC.
  • Was able to see the Start Screen.

Describe the issue.

Whenever I try to install MelonLoader on to BONEWORKS it just says internal failure and makes a .txt file in my downloads
MLInstaller_22-1-18_13-38-40.771.log

Did you attach your log file?

  • Yes, I attached my log file to the text box above.
  • No, I could not find a log file at {Game_Directory}\MelonLoader\Latest.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.