Skip to content

Commit accee96

Browse files
Merge branch 'master' into fix-dildo-vibrator-names
2 parents 93471cd + 45bb3d5 commit accee96

File tree

2,769 files changed

+654491
-97008
lines changed

Some content is hidden

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

2,769 files changed

+654491
-97008
lines changed

.github/workflows/codeql.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL Advanced"
13+
14+
on:
15+
push:
16+
branches: [ "master" ]
17+
pull_request:
18+
branches: [ "master" ]
19+
schedule:
20+
- cron: '19 17 * * 3'
21+
22+
jobs:
23+
analyze:
24+
name: Analyze (${{ matrix.language }})
25+
# Runner size impacts CodeQL analysis time. To learn more, please see:
26+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
27+
# - https://gh.io/supported-runners-and-hardware-resources
28+
# - https://gh.io/using-larger-runners (GitHub.com only)
29+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
30+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
31+
permissions:
32+
# required for all workflows
33+
security-events: write
34+
35+
# required to fetch internal or private CodeQL packs
36+
packages: read
37+
38+
# only required for workflows in private repositories
39+
actions: read
40+
contents: read
41+
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
include:
46+
- language: actions
47+
build-mode: none
48+
- language: c-cpp
49+
build-mode: autobuild
50+
- language: javascript-typescript
51+
build-mode: none
52+
- language: python
53+
build-mode: none
54+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
55+
# Use `c-cpp` to analyze code written in C, C++ or both
56+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
57+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
58+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
59+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
60+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
61+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v4
65+
66+
# Add any setup steps before running the `github/codeql-action/init` action.
67+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
68+
# or others). This is typically only required for manual builds.
69+
# - name: Setup runtime (example)
70+
# uses: actions/setup-example@v1
71+
72+
# Initializes the CodeQL tools for scanning.
73+
- name: Initialize CodeQL
74+
uses: github/codeql-action/init@v3
75+
with:
76+
languages: ${{ matrix.language }}
77+
build-mode: ${{ matrix.build-mode }}
78+
# If you wish to specify custom queries, you can do so here or in a config file.
79+
# By default, queries listed here will override any specified in a config file.
80+
# Prefix the list here with "+" to use these queries and those in the config file.
81+
82+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
83+
# queries: security-extended,security-and-quality
84+
85+
# If the analyze step fails for one of the languages you are analyzing with
86+
# "We were unable to automatically build your code", modify the matrix above
87+
# to set the build mode to "manual" for that language. Then modify this step
88+
# to build your code.
89+
# ℹ️ Command-line programs to run using the OS shell.
90+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
91+
- if: matrix.build-mode == 'manual'
92+
shell: bash
93+
run: |
94+
echo 'If you are using a "manual" build mode for one or more of the' \
95+
'languages you are analyzing, replace this with the commands to build' \
96+
'your code, for example:'
97+
echo ' make bootstrap'
98+
echo ' make release'
99+
exit 1
100+
101+
- name: Perform CodeQL Analysis
102+
uses: github/codeql-action/analyze@v3
103+
with:
104+
category: "/language:${{matrix.language}}"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2+
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:v3="urn:schemas-microsoft-com:asm.v3">
3+
<assemblyIdentity type="win32" version="1.0.0.0" processorArchitecture="*" name="CEFLauncher" />
4+
5+
<v3:application>
6+
<windowsSettings>
7+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>
8+
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
9+
</windowsSettings>
10+
</v3:application>
11+
12+
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
13+
<application>
14+
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> <!-- Windows 10 and Windows 11 -->
15+
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" /> <!-- Windows 8.1 -->
16+
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" /> <!-- Windows 8 -->
17+
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" /> <!-- Windows 7 -->
18+
</application>
19+
</compatibility>
20+
21+
<dependency optional="yes">
22+
<dependentAssembly>
23+
<!-- Automatically use ComCtl32.dll version 6 or later. -->
24+
<assemblyIdentity
25+
type="win32"
26+
name="Microsoft.Windows.Common-Controls"
27+
version="6.0.0.0"
28+
processorArchitecture="*"
29+
publicKeyToken="6595b64144ccf1df"
30+
language="*" />
31+
</dependentAssembly>
32+
</dependency>
33+
</assembly>

Client/ceflauncher/premake5.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ project "CEFLauncher"
99
vpaths {
1010
["Headers/*"] = "**.h",
1111
["Sources/*"] = "**.cpp",
12+
["Resources/*"] = {"*.rc", "**.ico", "**.xml", "**.manifest"},
1213
["*"] = "premake5.lua"
1314
}
1415

1516
files {
1617
"premake5.lua",
1718
"*.h",
18-
"*.cpp"
19+
"*.cpp",
20+
"*.manifest",
1921
}
2022

2123
filter "architecture:not x86"

Client/ceflauncher_DLL/Main.cpp

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
*
1010
*****************************************************************************/
1111

12+
#define WIN32_NO_STATUS
1213
#define WIN32_LEAN_AND_MEAN
1314
#include <Windows.h>
15+
#undef WIN32_NO_STATUS
16+
#include <ntstatus.h>
17+
#include <winnt.h>
18+
#include <winternl.h>
1419
#include <delayimp.h>
1520
#include "CCefApp.h"
1621
#include <string>
@@ -21,6 +26,8 @@
2126
#pragma comment(lib, "cef_sandbox.lib")
2227
#endif
2328

29+
DWORD WINAPI CheckParentProcessAliveness(LPVOID);
30+
2431
int _declspec(dllexport) InitCEF()
2532
{
2633
// Get absolute CEFLauncher.exe path
@@ -46,20 +53,62 @@ int _declspec(dllexport) InitCEF()
4653
sandboxInfo = scopedSandbox.sandbox_info();
4754
#endif
4855

49-
if (HANDLE job = CreateJobObjectW(nullptr, nullptr); job != nullptr)
56+
const HANDLE parentCheckThread = CreateThread(nullptr, 0, CheckParentProcessAliveness, nullptr, 0, nullptr);
57+
58+
const int exitCode = CefExecuteProcess(mainArgs, app, sandboxInfo);
59+
60+
if (parentCheckThread != nullptr)
5061
{
51-
JOBOBJECT_EXTENDED_LIMIT_INFORMATION limits{};
52-
limits.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
62+
TerminateThread(parentCheckThread, 0);
63+
CloseHandle(parentCheckThread);
64+
}
5365

54-
if (SetInformationJobObject(job, JobObjectExtendedLimitInformation, &limits, sizeof(limits)))
55-
{
56-
AssignProcessToJobObject(job, GetCurrentProcess());
57-
}
58-
else
66+
return exitCode;
67+
}
68+
69+
static DWORD WINAPI CheckParentProcessAliveness(LPVOID)
70+
{
71+
NTSTATUS(NTAPI * queryInformation)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG) = nullptr;
72+
73+
if (HMODULE const ntdll = GetModuleHandleW(L"ntdll.dll"); ntdll != nullptr)
74+
{
75+
queryInformation = reinterpret_cast<decltype(queryInformation)>(GetProcAddress(ntdll, "NtQueryInformationProcess"));
76+
}
77+
78+
if (queryInformation == nullptr)
79+
return 1;
80+
81+
PROCESS_BASIC_INFORMATION info{};
82+
83+
ULONG returnLength = 0;
84+
NTSTATUS status = queryInformation(GetCurrentProcess(), ProcessBasicInformation, &info, sizeof(info), &returnLength);
85+
86+
if (!NT_SUCCESS(status) || returnLength < sizeof(PROCESS_BASIC_INFORMATION))
87+
return 2;
88+
89+
const auto parentProcessId = static_cast<DWORD>(reinterpret_cast<ULONG_PTR>(info.Reserved3));
90+
const HANDLE parentProcess = OpenProcess(SYNCHRONIZE | PROCESS_QUERY_LIMITED_INFORMATION, FALSE, parentProcessId);
91+
92+
if (parentProcess == nullptr)
93+
{
94+
if (GetLastError() == ERROR_INVALID_PARAMETER)
95+
ExitProcess(0);
96+
97+
return 3;
98+
}
99+
100+
while (true)
101+
{
102+
DWORD exitCode{};
103+
104+
if (!GetExitCodeProcess(parentProcess, &exitCode) || exitCode != STILL_ACTIVE)
59105
{
60-
CloseHandle(job);
106+
CloseHandle(parentProcess);
107+
ExitProcess(exitCode);
61108
}
109+
110+
Sleep(1000);
62111
}
63112

64-
return CefExecuteProcess(mainArgs, app, sandboxInfo);
113+
return 0;
65114
}

Client/cefweb/CWebApp.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ void CWebApp::OnBeforeCommandLineProcessing(const CefString& process_type, CefRe
2626
if (!pWebCore->GetGPUEnabled())
2727
command_line->AppendSwitch("disable-gpu");
2828

29+
// Disable the AutoDeElevate feature to make launching CEF with Admin privileges work.
30+
// https://github.com/chromiumembedded/cef/issues/3960
31+
// https://chromium-review.googlesource.com/c/chromium/src/+/6515318
32+
command_line->AppendSwitch("do-not-de-elevate");
33+
2934
command_line->AppendSwitch("disable-gpu-compositing"); // always disable this, causes issues with official builds
3035

3136
// command_line->AppendSwitch("disable-d3d11");

Client/cefweb/CefWeb.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ extern "C" _declspec(dllexport) CWebCoreInterface* InitWebCoreInterface(CCoreInt
2222
// Ensure main thread identification is consistent
2323
IsMainThread();
2424

25+
SetMemoryAllocationFailureHandler();
26+
2527
CWebCore* pWebCore = new CWebCore;
2628
return pWebCore;
2729
}

Client/core/CClientVariables.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ void CClientVariables::LoadDefaults()
359359
DEFAULT("browser_enable_gpu", true); // Enable GPU in CEF? (allows stuff like WebGL to function)
360360
DEFAULT("process_cpu_affinity", true); // Set CPU 0 affinity to improve game performance and fix the known issue in single-threaded games
361361
DEFAULT("ask_before_disconnect", true); // Ask before disconnecting from a server
362+
DEFAULT("allow_steam_client", false); // Allow connecting with the local Steam client (to set GTA:SA ingame status)
362363

363364
if (!Exists("locale"))
364365
{

Client/core/CCommandFuncs.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,19 @@ void CCommandFuncs::Test(const char* szParameters)
427427
}
428428
}
429429
}
430+
#if defined(MTA_DEBUG) || MTASA_VERSION_TYPE == VERSION_TYPE_CUSTOM
431+
else if (SStringX(szParameters) == "bad_alloc")
432+
{
433+
if (FileExists(CalcMTASAPath("debug.txt")))
434+
{
435+
while (true)
436+
{
437+
new int[100 * 1024 * 1024]();
438+
g_pCore->GetConsole()->Print("Allocated 100 MiB");
439+
}
440+
}
441+
}
442+
#endif
430443
}
431444

432445
void CCommandFuncs::Serial(const char* szParameters)

Client/core/CCore.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <SharedUtil.Detours.h>
2727
#include <ServerBrowser/CServerCache.h>
2828
#include "CDiscordRichPresence.h"
29+
#include "CSteamClient.h"
2930

3031
using SharedUtil::CalcMTASAPath;
3132
using namespace std;
@@ -160,6 +161,7 @@ CCore::CCore()
160161

161162
// Create tray icon
162163
m_pTrayIcon = new CTrayIcon();
164+
m_steamClient = std::make_unique<CSteamClient>();
163165

164166
// Create discord rich presence
165167
m_pDiscordRichPresence = std::shared_ptr<CDiscordRichPresence>(new CDiscordRichPresence());
@@ -173,6 +175,8 @@ CCore::~CCore()
173175
if (m_pDiscordRichPresence)
174176
m_pDiscordRichPresence.reset();
175177

178+
m_steamClient.reset();
179+
176180
// Destroy tray icon
177181
delete m_pTrayIcon;
178182

@@ -1228,6 +1232,12 @@ void CCore::DoPostFramePulse()
12281232
ApplyConsoleSettings();
12291233
ApplyGameSettings();
12301234

1235+
// Allow connecting with the local Steam client
1236+
bool allowSteamClient = false;
1237+
CVARS_GET("allow_steam_client", allowSteamClient);
1238+
if (allowSteamClient)
1239+
m_steamClient->Connect();
1240+
12311241
m_pGUI->SelectInputHandlers(INPUT_CORE);
12321242
}
12331243

@@ -1273,7 +1283,8 @@ void CCore::DoPostFramePulse()
12731283
}
12741284
}
12751285

1276-
if (m_menuFrame >= 75 && m_requestNewNickname && GetLocalGUI()->GetMainMenu()->IsVisible() && !GetLocalGUI()->GetMainMenu()->IsFading())
1286+
if (m_menuFrame >= 75 && m_requestNewNickname && GetLocalGUI()->GetMainMenu()->IsVisible() && !GetLocalGUI()->GetMainMenu()->IsFading() &&
1287+
!GetLocalGUI()->GetMainMenu()->GetQuestionWindow()->IsVisible())
12771288
{
12781289
// Request a new nickname if we're waiting for one
12791290
GetLocalGUI()->GetMainMenu()->GetSettingsWindow()->RequestNewNickname();
@@ -1452,6 +1463,10 @@ void CCore::Quit(bool bInstantly)
14521463

14531464
WatchDogBeginSection("Q0"); // Allow loader to detect freeze on exit
14541465

1466+
// Hide game window to make quit look instant
1467+
PostQuitMessage(0);
1468+
ShowWindow(GetHookedWindow(), SW_HIDE);
1469+
14551470
// Destroy the client
14561471
CModManager::GetSingleton().Unload();
14571472

@@ -1462,7 +1477,6 @@ void CCore::Quit(bool bInstantly)
14621477

14631478
// Use TerminateProcess for now as exiting the normal way crashes
14641479
TerminateProcess(GetCurrentProcess(), 0);
1465-
// PostQuitMessage ( 0 );
14661480
}
14671481
else
14681482
{

Client/core/CCore.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ class CDiscordInterface;
7070
#define CONFIG_HISTORY_LIST_TAG "connected_server"
7171
#define IDT_TIMER1 1234
7272

73+
class CSteamClient;
74+
7375
extern class CCore* g_pCore;
7476
extern class CGraphics* g_pGraphics;
7577
extern class CLocalization* g_pLocalization;
@@ -104,6 +106,7 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
104106
CWebCoreInterface* GetWebCore();
105107
CTrayIconInterface* GetTrayIcon() { return m_pTrayIcon; };
106108
std::shared_ptr<CDiscordInterface> GetDiscord();
109+
CSteamClient* GetSteamClient() { return m_steamClient.get(); }
107110

108111
void SaveConfig(bool bWaitUntilFinished = false);
109112

@@ -311,6 +314,7 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
311314
CClientVariables m_ClientVariables;
312315
CWebCoreInterface* m_pWebCore = nullptr;
313316
CTrayIcon* m_pTrayIcon;
317+
std::unique_ptr<CSteamClient> m_steamClient;
314318
std::shared_ptr<CDiscordRichPresence> m_pDiscordRichPresence;
315319

316320
// Hook interfaces.

0 commit comments

Comments
 (0)