Skip to content

Commit d6825c1

Browse files
committed
Fix Lego Builder's Journey Nvidia check for Turkish and similar locales (for now still needs spoofing)
1 parent d2b1232 commit d6825c1

4 files changed

Lines changed: 58 additions & 0 deletions

File tree

OptiPatcher/OptiPatcher.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
<PropertyGroup Label="UserMacros" />
7373
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
7474
<TargetExt>.asi</TargetExt>
75+
<OutDir>H:\LEGO Builder%27s Journey\plugins\</OutDir>
7576
</PropertyGroup>
7677
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
7778
<TargetExt>.asi</TargetExt>

OptiPatcher/Scanner.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,40 @@ uintptr_t FindPattern(uintptr_t startAddress, uintptr_t maxSize, const char* mas
6666
return std::distance(dataStart, sig) + startAddress;
6767
}
6868

69+
uintptr_t scanner::GetAddressFromWholeModule(HMODULE module, const std::string_view pattern, ptrdiff_t offset,
70+
uintptr_t startAddress)
71+
{
72+
const static uintptr_t moduleBase = reinterpret_cast<uintptr_t>(module);
73+
const static uintptr_t moduleEnd = [&]()
74+
{
75+
auto ntHeaders = reinterpret_cast<PIMAGE_NT_HEADERS64>(
76+
moduleBase + reinterpret_cast<PIMAGE_DOS_HEADER>(moduleBase)->e_lfanew);
77+
return static_cast<uintptr_t>(moduleBase + ntHeaders->OptionalHeader.SizeOfImage);
78+
}();
79+
80+
uintptr_t address = NULL;
81+
82+
if (startAddress != 0)
83+
{
84+
if (startAddress < moduleBase || startAddress > moduleEnd)
85+
return NULL;
86+
address = FindPattern(startAddress, moduleEnd - startAddress, pattern.data());
87+
}
88+
else
89+
{
90+
address = FindPattern(moduleBase, moduleEnd - moduleBase, pattern.data());
91+
}
92+
93+
if (address != NULL)
94+
{
95+
return (address + offset);
96+
}
97+
else
98+
{
99+
return NULL;
100+
}
101+
}
102+
69103
uintptr_t scanner::GetAddress(const std::wstring_view moduleName, const std::string_view pattern, ptrdiff_t offset,
70104
uintptr_t startAddress)
71105
{

OptiPatcher/Scanner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ namespace scanner
1212
uintptr_t GetAddress(const std::wstring_view moduleName, const std::string_view pattern, ptrdiff_t offset = 0,
1313
uintptr_t startAddress = 0);
1414
uintptr_t GetAddress(HMODULE module, const std::string_view pattern, ptrdiff_t offset = 0, uintptr_t startAddress = 0);
15+
uintptr_t GetAddressFromWholeModule(HMODULE module, const std::string_view pattern, ptrdiff_t offset,
16+
uintptr_t startAddress = 0);
1517
uintptr_t GetOffsetFromInstruction(HMODULE module, const std::string_view pattern, ptrdiff_t offset);
1618
} // namespace scanner

OptiPatcher/dllmain.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,27 @@ static void CheckForPatch()
13221322
}
13231323
}
13241324

1325+
// Lego Builder's Journey
1326+
// Patching Nvidia name to enable DLSS on Turkish locale
1327+
else if (exeName == "builder's journey.exe")
1328+
{
1329+
auto unityPlayerModule = GetModuleHandleA("UnityPlayer.dll");
1330+
if (unityPlayerModule != nullptr)
1331+
{
1332+
std::string_view pattern("41 54 49 00 4E 56 49 44 49 41");
1333+
auto patchAddress = (void*) scanner::GetAddressFromWholeModule(unityPlayerModule, pattern, 5);
1334+
if (patchAddress != nullptr)
1335+
{
1336+
std::vector<BYTE> patch = { 0x76, 0x69, 0x64, 0x69, 0x61 };
1337+
patcher::PatchAddress(patchAddress, &patch);
1338+
1339+
// Don't set patch result to true since this is only a workaround for Turkish locale
1340+
// not an actual DLSS check patch
1341+
_patchResult = false;
1342+
}
1343+
}
1344+
}
1345+
13251346
// Red Dead Redemption 2
13261347
// Thanks to 0x-FADED
13271348
// https://github.com/0x-FADED/RDR2-NVNGX-Loader

0 commit comments

Comments
 (0)