Skip to content

Commit 1428ab4

Browse files
committed
feat(legitimacy): legitimacy check complete overhaul
# Conflicts: # code/components/ros-patches-five/src/AccountID.cpp
1 parent 94013de commit 1428ab4

817 files changed

Lines changed: 73717 additions & 307330 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ data/shared/citizen/scripting/lua/graph.lua linguist-vendored
1212
data/shared/citizen/scripting/lua/json.lua linguist-vendored
1313

1414
code/client/clrref/System.Drawing.cs linguist-vendored
15-
code/components/ros-patches-five/include/EntitlementTables_*.h linguist-vendored
1615
code/client/clrcore/External/* linguist-vendored
1716
code/tools/dbg/pe*/** linguist-vendored
1817

code/client/citicore/ComponentLoader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void ComponentLoader::InitializeWithString(std::string_view cacheBuf)
114114
if (wcsstr(moduleName, L"_ROS"))
115115
{
116116
neededComponentsList = {
117-
L"ros-patches-five",
117+
L"legitimacy",
118118
L"net-http-server",
119119
L"net-tcp-server",
120120
L"net-base",
@@ -282,7 +282,7 @@ static void LoadDependencies(ComponentLoader* loader, fwRefContainer<ComponentDa
282282
}
283283
}
284284

285-
if (!match && dependency.GetCategory() != "vendor")
285+
if (!match && dependency.GetCategory() != "vendor" && dependency.GetCategory() != "legitimacy")
286286
{
287287
FatalError("Unable to resolve dependency for %s.\n", dependency.GetString().c_str());
288288
}

code/client/citicore/DllGameComponent.Win32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Component* DllGameComponent::CreateComponent()
133133
// sanity check
134134
if (m_path == L"adhesive.dll" && errorCode == ERROR_PROC_NOT_FOUND)
135135
{
136-
HMODULE rosFive = GetModuleHandle(L"ros-patches-five.dll");
136+
HMODULE rosFive = GetModuleHandle(L"legitimacy.dll");
137137

138138
if (rosFive)
139139
{

code/client/citicore/EarlyMode.Win32.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ extern "C" DLL_EXPORT void EarlyMode_Init()
1919
std::vector<fwRefContainer<Component>> components;
2020

2121
for (auto compName : {
22-
#ifdef IS_RDR3
23-
"ros-patches:rdr3",
24-
#else
25-
"ros-patches:five",
26-
#endif
22+
"legitimacy",
2723
"adhesive" })
2824
{
2925
fwRefContainer<ComponentData> cliComponent = loader->LoadComponent(compName);

code/client/citicore/FileMapping.Win32.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ static std::wstring MapRedirectedFilename(const wchar_t* origFileName)
9999
{
100100
//trace("map %s\n", ToNarrow(origFileName));
101101

102+
if (wcsstr(origFileName, L"title.rgl") != nullptr)
103+
{
104+
return origFileName;
105+
}
106+
102107
for (const auto& fileName : g_socialClubDlls)
103108
{
104109
if (StrStrIW(origFileName, fileName.c_str()) != NULL)
@@ -263,6 +268,11 @@ static std::wstring MapRedirectedNtFilename(const wchar_t* origFileName)
263268

264269
static bool IsMappedFilename(const std::wstring& fileName)
265270
{
271+
if (fileName.find(L"title.rgl") != std::wstring::npos)
272+
{
273+
return false;
274+
}
275+
266276
if (fileName.find(L"Files\\Rockstar Games\\Social Club") != std::string::npos ||
267277
fileName.find(g_scFilesRoot) != std::string::npos ||
268278
// weird case: some users have SHGetFolderPathW fail only sometimes into returning "X:\\" with a double backslash

code/client/citicore/PatternCache.cpp

Lines changed: 0 additions & 116 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* This file is part of the CitizenFX project - http://citizen.re/
3+
*
4+
* See LICENSE and MENTIONS in the root of the source tree for information
5+
* regarding licensing.
6+
*/
7+
8+
#include "StdInc.h"
9+
10+
#if defined(GTA_FIVE) || defined(IS_RDR3)
11+
#include <Hooking.h>
12+
13+
static uintptr_t g_currentStub = hook::exe_end();
14+
15+
extern "C"
16+
{
17+
DLL_EXPORT void* AllocateStubMemoryImpl(size_t size)
18+
{
19+
// Try and pick a sensible alignment
20+
size_t alignMask = ((size > 64) ? 16 : 8) - 1;
21+
22+
g_currentStub = (g_currentStub + alignMask) & ~alignMask;
23+
24+
char* code = (char*)g_currentStub + hook::baseAddressDifference;
25+
26+
DWORD oldProtect;
27+
VirtualProtect(code, size, PAGE_EXECUTE_READWRITE, &oldProtect);
28+
29+
g_currentStub += size;
30+
31+
return code;
32+
}
33+
34+
DLL_EXPORT void* AllocateFunctionStubImpl(void* function, int type)
35+
{
36+
char* code = (char*) AllocateStubMemoryImpl(20);
37+
38+
DWORD oldProtect;
39+
VirtualProtect(code, 15, PAGE_EXECUTE_READWRITE, &oldProtect);
40+
41+
*(uint8_t*)code = 0x48;
42+
*(uint8_t*)(code + 1) = 0xb8 | type;
43+
44+
*(uint64_t*)(code + 2) = (uint64_t)function;
45+
46+
*(uint16_t*)(code + 10) = 0xE0FF | (type << 8);
47+
48+
*(uint64_t*)(code + 12) = 0xCCCCCCCCCCCCCCCC;
49+
50+
g_currentStub += 20;
51+
52+
return code;
53+
}
54+
55+
56+
}
57+
#endif

code/client/launcher/DisableNVSP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static std::optional<NvidiaConnectionInfo> GetNvidiaStateNew()
4242
std::optional<NvidiaConnectionInfo> rv;
4343
auto fileMapping = OpenFileMappingW(FILE_MAP_READ, FALSE, L"{8BA1E16C-FC54-4595-9782-E370A5FBE8DA}");
4444

45-
if (fileMapping != 0 && fileMapping != INVALID_HANDLE_VALUE)
45+
if (fileMapping)
4646
{
4747
const void* data = MapViewOfFile(fileMapping, FILE_MAP_READ, 0, 0, 0);
4848

code/client/launcher/DisableSteamInput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ bool IsSteamRunning()
2727
{
2828
HANDLE steamProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
2929

30-
if (steamProcess != INVALID_HANDLE_VALUE)
30+
if (steamProcess)
3131
{
3232
wchar_t imageName[512] = { 0 };
3333
GetProcessImageFileNameW(steamProcess, imageName, std::size(imageName));

code/client/launcher/ExecutableLoader.Snapshot.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ inline static uintptr_t GetLauncherTriggerEP()
1212
{
1313
if (getenv("CitizenFX_ToolMode"))
1414
{
15-
if (wcsstr(GetCommandLineW(), L"launcher.exe"))
15+
LPWSTR commandLine = GetCommandLineW();
16+
17+
// Case insensitive: name must match newCommandLine in LoopbackTcpServer
18+
if (wcsstr(commandLine, L"Launcher.exe") != nullptr && wcsstr(commandLine, L"ros:legit") == nullptr)
1619
{
17-
// launcher.exe with sha256 hash 0dbf58119cdd2d67e6ecee1e31be3f19827444df978f7df747064a870736bce4
20+
// Launcher.exe with
21+
// sha1 = f259de45c50f399d3e278fd39401ef51a3cc031a
22+
// sha256 = 0dbf58119cdd2d67e6ecee1e31be3f19827444df978f7df747064a870736bce4
1823
return 0x14020b70c;
1924
}
2025
}

0 commit comments

Comments
 (0)