aboutsummaryrefslogtreecommitdiff
path: root/primedev/client/languagehooks.cpp
diff options
context:
space:
mode:
authorJack <66967891+ASpoonPlaysGames@users.noreply.github.com>2024-08-31 10:42:55 +0100
committerGitHub <noreply@github.com>2024-08-31 11:42:55 +0200
commitcb62662816c1e1f38de3567f83140d2adf21eebb (patch)
tree711e576d97594787df91b9b0bf7ddd1b3630f499 /primedev/client/languagehooks.cpp
parent4d609a8d1cafae13b5ec14ad05f6e44e990cd403 (diff)
downloadNorthstarLauncher-1.27.6-rc2.tar.gz
NorthstarLauncher-1.27.6-rc2.zip
client: Remove uses of Autohook from `languagehooks.cpp` (#787)v1.27.6-rc2
Removes AUTOHOOK macro from `languagehooks.cpp`.
Diffstat (limited to 'primedev/client/languagehooks.cpp')
-rw-r--r--primedev/client/languagehooks.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/primedev/client/languagehooks.cpp b/primedev/client/languagehooks.cpp
index 36b5d5ae..80d3c31d 100644
--- a/primedev/client/languagehooks.cpp
+++ b/primedev/client/languagehooks.cpp
@@ -5,8 +5,6 @@
namespace fs = std::filesystem;
-AUTOHOOK_INIT()
-
typedef LANGID (*Tier0_DetectDefaultLanguageType)();
bool CheckLangAudioExists(char* lang)
@@ -48,10 +46,8 @@ std::string GetAnyInstalledAudioLanguage()
return "NO LANGUAGE DETECTED";
}
-// clang-format off
-AUTOHOOK(GetGameLanguage, tier0.dll + 0xF560,
-char*, __fastcall, ())
-// clang-format on
+static char*(__fastcall* o_pGetGameLanguage)() = nullptr;
+static char* __fastcall h_GetGameLanguage()
{
auto tier0Handle = GetModuleHandleA("tier0.dll");
auto Tier0_DetectDefaultLanguageType = GetProcAddress(tier0Handle, "Tier0_DetectDefaultLanguage");
@@ -78,7 +74,7 @@ char*, __fastcall, ())
canOriginDictateLang = true; // let it try
{
- auto lang = GetGameLanguage();
+ auto lang = o_pGetGameLanguage();
if (!CheckLangAudioExists(lang))
{
if (strcmp(lang, "russian") !=
@@ -96,7 +92,7 @@ char*, __fastcall, ())
Tier0_DetectDefaultLanguageType(); // force the global in tier0 to be populated with language inferred from user's system rather than
// defaulting to Russian
canOriginDictateLang = false; // Origin has no say anymore, we will fallback to user's system setup language
- auto lang = GetGameLanguage();
+ auto lang = o_pGetGameLanguage();
spdlog::info("Detected system language: {}", lang);
if (!CheckLangAudioExists(lang))
{
@@ -113,5 +109,6 @@ char*, __fastcall, ())
ON_DLL_LOAD_CLIENT("tier0.dll", LanguageHooks, (CModule module))
{
- AUTOHOOK_DISPATCH()
+ o_pGetGameLanguage = module.Offset(0xF560).RCast<decltype(o_pGetGameLanguage)>();
+ HookAttach(&(PVOID&)o_pGetGameLanguage, (PVOID)h_GetGameLanguage);
}