Skip to content

Commit

Permalink
Merge Update to 3407 (mr-636)
Browse files Browse the repository at this point in the history
636b97b - feat(five): update to 3407
  • Loading branch information
prikolium-cfx committed Dec 24, 2024
2 parents 05bfe6e + 636b97b commit 2070731
Show file tree
Hide file tree
Showing 32 changed files with 156,610 additions and 1,228 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ dlldata.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
Expand Down
33 changes: 33 additions & 0 deletions code/client/launcher/ExecutableLoader.Snapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ inline uintptr_t GetTriggerEP()
return ep;
}

if (xbr::IsGameBuild<3407>())
{
return 0x14185CFAC;
}

if (xbr::IsGameBuild<3323>())
{
return 0x1418492F0;
Expand Down Expand Up @@ -193,6 +198,20 @@ static LONG CALLBACK SnapshotVEH(PEXCEPTION_POINTERS pointers)
IMAGE_NT_HEADERS* ntHeader = GetTargetRVA<IMAGE_NT_HEADERS>(header->e_lfanew);
IMAGE_SECTION_HEADER* section = IMAGE_FIRST_SECTION(ntHeader);

IMAGE_DATA_DIRECTORY* importDirectory = &ntHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];

auto descriptor = GetTargetRVA<IMAGE_IMPORT_DESCRIPTOR>(importDirectory->VirtualAddress);

int i = 0;
while (descriptor->Name)
{
char* name = GetTargetRVA<char>(descriptor->Name);
const char* realName = ExecutableLoader::m_moduleNames[i++].c_str();
memcpy(name, realName, strlen(realName) + 1);

descriptor++;
}

FILE* f = _wfopen(MakeRelativeCitPath(fmt::sprintf(L"data\\cache\\executable_snapshot_%x.bin", ntHeader->OptionalHeader.AddressOfEntryPoint)).c_str(), L"wb");

SHA256_CTX sha;
Expand Down Expand Up @@ -358,6 +377,20 @@ static LONG CALLBACK DumpVEH(PEXCEPTION_POINTERS pointers)
IMAGE_NT_HEADERS* ntHeader = GetTargetRVA<IMAGE_NT_HEADERS>(header->e_lfanew);
IMAGE_SECTION_HEADER* section = IMAGE_FIRST_SECTION(ntHeader);

IMAGE_DATA_DIRECTORY* importDirectory = &ntHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];

auto descriptor = GetTargetRVA<IMAGE_IMPORT_DESCRIPTOR>(importDirectory->VirtualAddress);

int i = 0;
while (descriptor->Name)
{
char* name = GetTargetRVA<char>(descriptor->Name);
const char* realName = ExecutableLoader::m_moduleNames[i++].c_str();
memcpy(name, realName, strlen(realName) + 1);

descriptor++;
}

FILE* f = _wfopen(g_dumpFileName.c_str(), L"wb");

auto zeroPad = [&](int64_t point)
Expand Down
2 changes: 2 additions & 0 deletions code/client/launcher/ExecutableLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ void ExecutableLoader::LoadImports(IMAGE_NT_HEADERS* ntHeader)
{
const char* name = GetTargetRVA<char>(descriptor->Name);

m_moduleNames.push_back(name);

HMODULE module = ResolveLibrary(name);

if (!module)
Expand Down
2 changes: 2 additions & 0 deletions code/client/launcher/ExecutableLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ class ExecutableLoader
void LoadIntoModule(HMODULE module);

bool LoadSnapshot(IMAGE_NT_HEADERS* ntHeader);

inline static std::vector<std::string> m_moduleNames;
};
1,057 changes: 562 additions & 495 deletions code/client/launcher/GameCache.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ inline bool Is3323()
return (!fx::GetReplaceExecutable() && xbr::GetDefaultGTA5Build() >= 3323) || fx::GetEnforcedGameBuildNumber() >= 3323;
})();

return value;
}

inline bool Is3407()
{
static bool value = ([]()
{
return (!fx::GetReplaceExecutable() && xbr::GetDefaultGTA5Build() >= 3407) || fx::GetEnforcedGameBuildNumber() >= 3407;
})();

return value;
}
#elif defined(STATE_RDR3)
Expand Down
Loading

0 comments on commit 2070731

Please sign in to comment.