A question about the chain of events #729
Unanswered
SolarVampire
asked this question in
Help and Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to better understand the chain of events that lead to a plugin being properly loaded.
Unity loads http*dll, which loads doorstop, which looks through the targeted dll in its config file for doorstop namespace which then in turn runs arbitrary code. What I'm having a hard time following after that point is the bepinex side of the process. We go to
UnityPreloaderRunner and run preloadermain and then the function names get REALLY fuzzy (silent criticism)
It looks like xterm patches a unity 4* issue. ok i can ignore that. I assume. Fringe case.
But ConsoleSetOutFix is absolutely arcane to me. I can't follow that. This is a C# limitation for me, so that's on me. But it's still rather rough to read.
Now we get to UnityPreloader.Run
This seems to be the meat and potatoes
I see harmonybackend fix. I'd like to ignore this. Please speak up if I should take the time to study it.
UnityInfo.Initialize is just some data collection
ConsoleManager.Initialize looks like it's just making a determination about whether or not we want a windows or linux terminal for the console
AllocateConsole creates it
Utility.TryDo we're using a homebrew try catcher which enacts harmony, in another library, which seems to be doing voodoo to patch in assemblies? So Harmony is what is actually loading the plugins ? and if it fails we get ourselves an exception for later
then we prep some logs for success or failure
we put together a hashset for the plugin search locations, the plugins to iterate over.
Ok so I understand how we got to this point. Now this is the part that is stumping me.
How are these assemblies getting patched? Where are they going? It's very difficult for me to follow.
For the context of what I'm trying to learn here, I'm trying to figure out how bepinex loads plugins to try to understand how I can do the same thing, but simpler. I'm attempting to make a doorstop unity explorer combo where essentially you'd only be loading unity explorer, and that's it. End of project. But getting to the point of understanding how mod loaders are working under the hood is getting rather complex and I need some help from the experts.
Is there a simple open source mod loader I should be investigating instead? Or am I just making things overly complicated?
Thanks for your time.
Beta Was this translation helpful? Give feedback.
All reactions