Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

HunterPie with Mod Organizer 2 #160

Open
spaghetti-guy opened this issue May 8, 2021 · 4 comments
Open

HunterPie with Mod Organizer 2 #160

spaghetti-guy opened this issue May 8, 2021 · 4 comments
Labels
question Further information is requested

Comments

@spaghetti-guy
Copy link

spaghetti-guy commented May 8, 2021

Mod Organizer 2 released support for MHW a little over a month ago, and someone asked on the guide I wrote how to get HunterPie working with Mod Organizer 2. I did a quick test launching HunterPie first then running MHW through MO2 and was able to get some functions to work such as this overlay here. But due to how MO2 virtualizes the nativePC folder with usvfs, HunterPie kept warning me that Stacker's Loader and the CRC Bypass were needed for some functions of HunterPie Native (they were installed in MO2). This is because by default, the virtual file system created with MO2 is not visible to other applications.

I'd like to do some testing with MO2 to see if I can make those HunterPie Native functions work properly. That said, I'm not too familiar with HunterPie so I'm not sure what those functions actually are. So I have a couple questions:

  1. What would be a good way to test that the HunterPie Native functionality is working as intended? If there's a feature such as an overlay that I could try and load at the main menu or in game, I could use that to see if HunterPIe is actually able to use the virtual nativePC folder.
  2. Mod Organizer 2 allows the user to manually specify libraries to load when the game is launched. I believe these libraries would then be able to see the virtual nativePC folder created by MO2. Which library (or libraries) would be responsible for the detection of the nativePC folder and utilizing it?

If it helps to know what's working and what isn't, here's a log from starting the game in a "friends" session and walking around for 30 seconds in Astera with no libraries injected. Note that in game I received a message saying HunterPie Native was loaded, but the GUI of HunterPie.exe warned me that Stacker's Loader and the CRC Bypass were needed for some functionality and was pointing me to download them..
NoLibraries.log

Here's a log doing the same thing but with injecting "HunterPie.Core.dll, HunterPie.Native.dll, and HunterPie.UI.dll". Same messages appeared in game and in HunterPIe.exe. In both tests it looks like like HunterPie was able to connect with HunterPie.Native.dll
UINativeCoreInjected.log

@Haato3o
Copy link
Member

Haato3o commented May 8, 2021

HunterPie.Native is responsible to allow HunterPie to communicate with the game so it can call in-game functions and hook functions so it can track stuff what memory polling cannot. Before HunterPie injects the dll, it checks if loader.dll and CRCBypass.dll exists in Monster Hunter's root and NativePC folder respectively. Note that, the features that require Stracker's and CRCBypass are not core features, everything in the overlay would still work normally, just the function detours that wouldn't work (like input injection, which is something required by the Decoration Search Plugin)

Since Stracker injects DLLs using MemoryLoadLibraryEx instead of LoadLibrary it's really hard to detect if the user has Stracker installed or not (the difference is that MemoryLoadLibraryEx doesn't let me find Stracker's injected DLLs by iterating through the Monster Hunter's modules with EnumProcessModules, so the only way for me to detect it is by looking at the game's folder itself). When those two DLLs aren't found in MHW folder, HunterPie assumes the user doesn't have them and don't create some function hooks required by some features, that's a safety measure since creating function hook without CRCBypass will crash your game because of... well... CRC.

What would be a good way to test that the HunterPie Native functionality is working as intended? If there's a feature such as an overlay that I could try and load at the main menu or in game, I could use that to see if HunterPIe is actually able to use the virtual nativePC folder.

There's no overlay for that, but if HunterPie successfully injected Native and connected to it, it will display a message in your HunterPie console and also send a notification in-game saying HunterPie is connected to the game. And to check if the hooked functions were hooked properly, you'd need to see the assembly itself and look for the jmp instruction at the start of the detoured functions.

Mod Organizer 2 allows the user to manually specify libraries to load when the game is launched. I believe these libraries would then be able to see the virtual nativePC folder created by MO2. Which library (or libraries) would be responsible for the detection of the nativePC folder and utilizing it?

The one responsible for doing the detection is HunterPie.Core.dll, which is something HunterPie.exe uses as a dependency, so that wouldn't work because
1 - HunterPie.Core.dll is not something you load/inject into the game, it's an internal HunterPie.exe dependency.
2 - HunterPie.exe is the one that calls the function to check the nativePc, so HunterPie.exe is the one that handles everything.

Checking the NativePc was the only solution I could think of to check if the user has Stracker's and CRCBypass, since MO2 virtualizes that and makes it invisible to HunterPie, then I don't think I can fix that because it's out of my control. Let me know if you can think of any way to detect modules that were loaded through MemoryLoadLibraryEx though.

@Haato3o Haato3o added the question Further information is requested label May 8, 2021
@spaghetti-guy
Copy link
Author

I appreciate the insight, thank you! I will use your info and do some testing to see if there's some way I can expose the virtual nativePC folder to HunterPie. However, I'm leaning towards agreeing with you that since HunterPie.exe is the component that checks the nativePC folder, there probably isn't a great way to expose that to HunterPie.

That said, the path of least resistance might be for MO2 users to install Stacker's loader and the CRCBypass manually, directly to the actual MHW installation directory as this would allow HunterPie to see the the loader.dll and CRCBypass.dll. This would be similar to how Skyrim is usually setup with MO2, where users install the Skyrim Script Extender manually then the rest of their mods in MO2. A setup like this for MHW should work without issues, but I'll do some testing before making false assumptions.

Thanks again for your info!

@spaghetti-guy
Copy link
Author

Quick note, I had already theorized manually installing Stacker's Loader and the CRCBypass might work and had mentioned that to the user asking. Today, they replied to my suggestion and said everything is working as intended. Setting up the game in that way is a very easy workaround. I still plan to do some testing with Stacker's Loader and CRCBypass installed through MO2, but that will mostly be to satisfy my own curiosity. I'm going to add a quick note to the guide I wrote saying that users should install those plugins manually for now.

@DevilPepper
Copy link
Contributor

Maybe MO2 can have a Don't Virtualize setting, set by default for Stracker's & CRC since most mods (I imagine) require it anyway.

Or like how on NexusMods, each mod can have prerequisites and the download prompt will prompt you to make sure you've downloaded it. For those mods, you could probably group them together in the virtual fs?

I haven't used MO2, so sorry if these are already features.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants