Use ucrtbase.dll instead of msvcrt.dll for Proton 11.0 support#63
Use ucrtbase.dll instead of msvcrt.dll for Proton 11.0 support#63Pizzabelly wants to merge 3 commits intoFexty12573:masterfrom
Conversation
|
If I recall correctly, I switched this to use winmm instead of dinput8 to be able to implement the hooks/callbacks that happen before and after the CRT initializes in the game process (but prior to the game's main). It might be worth looking trying to figure out if anyone ever actually used those, or if they are just adding useless complexity / should be ripped out in favor of going back to a reliable dinput8 proxy. (Just throwing this out there, since you are looking at this all anyways). |
|
I know I've had to move patches out of Having to worry about load order from within the loader code also sounds limiting. Already I think using dinput8 specifically would break #60 based on the log order (dinput8 attached after D3D init). Although, it might be possible to work around by using a DirectX DLL as a proxy. There's an argument for picking the earliest loading non-KnownDLL and forgoing the CRT init hooks. The hooking in |
Fexty12573
left a comment
There was a problem hiding this comment.
Thanks for your work and for the detailed report! Looks good overall
| parser.add_argument("-h", "--help", action="help", help="Show this message") | ||
| parser.add_argument("-s", "--skip-build", help="Skip building the solution", action="store_true") | ||
| parser.add_argument("-c", "--config", help="The configuration to build", default="Release", choices=["Release", "Debug"], type=str.capitalize) | ||
| parser.add_argument("-m", "--msbuild-in-path", help="Set if msbuild is in the PATH environment variable", action="store_true") |
There was a problem hiding this comment.
Add this back please (or some other way to build with VS2026 instead of 2022).
There was a problem hiding this comment.
I kept the checking PATH by default but put it before searching the install directories. This should cover every case except wanting to use the VS 2026 MSBuild from a VS 2022 dev shell and vise versa, I can't think of any reason for doing that though.
(Continuing from #62)
I was finally able to test this on Windows and can confirm using
winmm.dllfor the loader still works the same after these changes.The situation with
ucrtbase.dllis interesting, though. Firstly, I've found a better source for the quirks of "Local deployment" ofucrtbase.dll1, which details that on Windows 10/11ucrtbase.dllwill not be loaded from the exe directory. Which is consistent with what I observed in testing on Windows 11. Vanilla Wine also follows this behavior and will not load a localucrtbase.dll. Therefore,ucrtbase.dllshould be treated effectively as a KnownDLL. Meaning: 1. "CW-Bug-Id: #22048" referenced in my original issue may have nothing to do with the differing registry entries like I theorized and is more likely related to Windows <10 compatability and 2. Usingucrtbase.dllfor the loader fully depends on the previously mention Wine patch to stay around in Proton.This had me wondering if I could get to the root of why trying to use
winmm.dllon Proton is different than Windows. It's been mentioned before2 thatMonsterHunterWorld.exehas all it's dependent DLLs, which includeswinmm.dll, marked as "delay load"3. This in theory means the game won't loadwinmm.dlluntil it's used4. Something that could plausibly end up different between Wine and Windows, but I don't think that's the case here.I'm fairly sure that the reason we're able to use
winmm.dllto hook the game so early on Windows is actually because of the Steam for Windows-specific behavior of injectingGameOverlayRenderer64.dll, which has a non-delayed dependency onwinmm.dll3. This can be verified on Windows by running the game without Steam, which will result in a very similar crash as trying to usewinmm.dllon Wine. Then, if you add thatMonsterHunterWorld.exeas a Non-Steam Game, causing Steam to injectGameOverlayRenderer64.dll, usingwinmm.dllnow loads as expected again.I think this is mostly fine to depend on because as far as I know the only other way we could get the loader loaded early enough would be a separate loader exe, which is definitely less user friendly.
Either way, I was curious how Steam would react to the loader exe approach, so I whipped up a little proof of concept. Surprisingly it actually works on both Windows and Linux. I was kinda expecting Steam to block it in some way. I guess it could be a last resort solution if Proton eventually stops allowing
ucrtbase.dll.Windows:
Linux:
I had to finagle the Linux launch command cause I'm not super good with bash, it may be possible to simplify.
For extra reference, this is a hacky Wine patch I made to force
winmm.dllto load early, which also lets usingwinmm.dllas the loader work on Proton. It's not a solution though, because it's unrealistic to require patching Wine.Footnotes
https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment?view=msvc-160#local-deployment ↩
https://github.com/Fexty12573/SharpPluginLoader/issues/44#issuecomment-2320324317 ↩
https://learn.microsoft.com/en-us/cpp/build/reference/linker-support-for-delay-loaded-dlls?view=msvc-170 ↩