Skip to content

Commit

Permalink
Windows 11 24H2 changed some low-level call hierarchies.
Browse files Browse the repository at this point in the history
This is a compatibility change, works on 23H2 and 24H2. Since in 24H2 GetModuleHandle no longer down-calls to LdrGetDllHandleEx, have to hook the GetModuleHandle() routines also.
  • Loading branch information
Richard Fortier committed Dec 1, 2024
1 parent e7d869b commit 51a6c62
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Code/immersive_launcher/stubs/FileMapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@ bool IsLocalModulePath(HMODULE aHmod)
// does the file exist in the ST dir?
return buf.find(s_OverridePath) != std::wstring::npos;
}
HMODULE WINAPI TP_GetModuleHandleW(LPCWSTR lpModuleName)
{
constexpr auto pTarget = TARGET_NAME L".exe";
auto targetSize = std::wcslen(pTarget);

if (lpModuleName && std::wcsncmp(pTarget, lpModuleName, targetSize) == 0)
lpModuleName = nullptr;
return RealGetModuleHandleW(lpModuleName);
}
HMODULE WINAPI TP_GetModuleHandleA(LPCSTR lpModuleName)
{
constexpr LPCSTR pTarget = "SkyrimSE.exe";
constexpr auto targetSize = sizeof("SkyrimSE.exe");

if (lpModuleName && std::strncmp(pTarget, lpModuleName, targetSize) == 0)
lpModuleName = nullptr;
return RealGetModuleHandleA(lpModuleName);
}

// some mods do GetModuleHandle("SkyrimSE.exe") for some reason instead of GetModuleHandle(nullptr)
HMODULE WINAPI TP_GetModuleHandleW(LPCWSTR lpModuleName)
Expand Down

0 comments on commit 51a6c62

Please sign in to comment.