diff --git a/Dalamud.Boot/Dalamud.Boot.vcxproj b/Dalamud.Boot/Dalamud.Boot.vcxproj
index 2a0c6db83..298edbcbc 100644
--- a/Dalamud.Boot/Dalamud.Boot.vcxproj
+++ b/Dalamud.Boot/Dalamud.Boot.vcxproj
@@ -58,8 +58,8 @@
Windows
true
false
- Version.lib;Shlwapi.lib;nethost.lib;%(AdditionalDependencies)
- ..\lib\CoreCLR\nethost;%(AdditionalLibraryDirectories)
+ Version.lib;Shlwapi.lib;%(AdditionalDependencies)
+ ..\lib\CoreCLR;%(AdditionalLibraryDirectories)
diff --git a/Dalamud.Injector.Boot/Dalamud.Injector.Boot.vcxproj b/Dalamud.Injector.Boot/Dalamud.Injector.Boot.vcxproj
index 780f7c078..c293e258c 100644
--- a/Dalamud.Injector.Boot/Dalamud.Injector.Boot.vcxproj
+++ b/Dalamud.Injector.Boot/Dalamud.Injector.Boot.vcxproj
@@ -48,8 +48,7 @@
Console
true
false
- ..\lib\CoreCLR\nethost;%(AdditionalLibraryDirectories)
- nethost.lib;%(AdditionalDependencies)
+ ..\lib\CoreCLR;%(AdditionalLibraryDirectories)
$(OutDir)$(TargetName).Boot.pdb
@@ -108,4 +107,4 @@
-
+
\ No newline at end of file
diff --git a/lib/CoreCLR/CoreCLR.cpp b/lib/CoreCLR/CoreCLR.cpp
index e1d027f52..f0e5a65bb 100644
--- a/lib/CoreCLR/CoreCLR.cpp
+++ b/lib/CoreCLR/CoreCLR.cpp
@@ -18,8 +18,38 @@ int CoreCLR::load_hostfxr()
return CoreCLR::load_hostfxr(nullptr);
}
+// MS does not provide this typedef anymore in the header. They removed it since they want us to implicitly link nethost,
+// but we don't want to do that since we don't want to change the dll search path in ffxix_dx11.exe.
+// This is kind of a kludge but whatever. The static lib they ship is unusable. Fix it, goat.
+typedef int (NETHOST_CALLTYPE *get_hostfxr_path_type)(
+ char_t * buffer,
+ size_t * buffer_size,
+ const struct get_hostfxr_parameters *parameters);
+
int CoreCLR::load_hostfxr(const struct get_hostfxr_parameters* parameters)
{
+ // Get the path to CoreCLR's hostfxr
+ std::wstring calling_module_path(MAX_PATH, L'\0');
+
+ do
+ {
+ calling_module_path.resize(GetModuleFileNameW(static_cast(m_calling_module), &calling_module_path[0], static_cast(calling_module_path.size())));
+ }
+ while (!calling_module_path.empty() && GetLastError() == ERROR_INSUFFICIENT_BUFFER);
+ if (calling_module_path.empty())
+ return -1;
+
+ calling_module_path = (std::filesystem::path(calling_module_path).parent_path() / L"nethost.dll").wstring();
+
+ auto lib_nethost = reinterpret_cast(load_library(calling_module_path.c_str()));
+ if (!lib_nethost)
+ return -1;
+
+ auto get_hostfxr_path = reinterpret_cast(
+ get_export(lib_nethost, "get_hostfxr_path"));
+ if (!get_hostfxr_path)
+ return -1;
+
wchar_t buffer[MAX_PATH]{};
size_t buffer_size = sizeof buffer / sizeof(wchar_t);
if (int rc = get_hostfxr_path(buffer, &buffer_size, parameters); rc != 0)