aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDedicatedTest/languagehooks.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDedicatedTest/languagehooks.cpp')
-rw-r--r--NorthstarDedicatedTest/languagehooks.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/NorthstarDedicatedTest/languagehooks.cpp b/NorthstarDedicatedTest/languagehooks.cpp
index ac421077..4e708517 100644
--- a/NorthstarDedicatedTest/languagehooks.cpp
+++ b/NorthstarDedicatedTest/languagehooks.cpp
@@ -4,15 +4,12 @@
#include <filesystem>
#include <regex>
-namespace fs = std::filesystem;
+AUTOHOOK_INIT()
-typedef char* (*GetGameLanguageType)();
-char* GetGameLanguage();
+namespace fs = std::filesystem;
typedef LANGID (*Tier0_DetectDefaultLanguageType)();
-GetGameLanguageType GetGameLanguageOriginal;
-
bool CheckLangAudioExists(char* lang)
{
std::string path {"r2\\sound\\general_"};
@@ -52,7 +49,8 @@ std::string GetAnyInstalledAudioLanguage()
return "NO LANGUAGE DETECTED";
}
-char* GetGameLanguageHook()
+AUTOHOOK(GetGameLanguage, tier0.dll + 0xF560,
+char*,, (),
{
auto tier0Handle = GetModuleHandleA("tier0.dll");
auto Tier0_DetectDefaultLanguageType = GetProcAddress(tier0Handle, "Tier0_DetectDefaultLanguage");
@@ -79,7 +77,7 @@ char* GetGameLanguageHook()
canOriginDictateLang = true; // let it try
{
- auto lang = GetGameLanguageOriginal();
+ auto lang = GetGameLanguage();
if (!CheckLangAudioExists(lang))
{
if (strcmp(lang, "russian") !=
@@ -97,7 +95,7 @@ char* GetGameLanguageHook()
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 = GetGameLanguageOriginal();
+ auto lang = GetGameLanguage();
spdlog::info("Detected system language: {}", lang);
if (!CheckLangAudioExists(lang))
{
@@ -110,10 +108,9 @@ char* GetGameLanguageHook()
}
return lang;
-}
+})
ON_DLL_LOAD_CLIENT("tier0.dll", LanguageHooks, [](HMODULE baseAddress)
{
- HookEnabler hook;
- ENABLER_CREATEHOOK(hook, (char*)baseAddress + 0xF560, &GetGameLanguageHook, reinterpret_cast<LPVOID*>(&GetGameLanguageOriginal));
+ AUTOHOOK_DISPATCH()
}) \ No newline at end of file