Skip to content

Commit 19967ad

Browse files
authored
Merge branch 'master' into startstop
2 parents 9d940d7 + 0772fcc commit 19967ad

File tree

307 files changed

+104400
-84680
lines changed

Some content is hidden

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

307 files changed

+104400
-84680
lines changed
Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,57 @@
11
<?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" />
2+
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
3+
xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"
4+
manifestVersion="1.0">
5+
<assemblyIdentity type="win32"
6+
name="CEFLauncher"
7+
version="1.0.0.0"
8+
processorArchitecture="x86" />
49

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>
10+
<description>MTA:SA CEF (Chromium Embedded Framework) Launcher</description>
1111

1212
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
1313
<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 -->
14+
<!-- Windows 11 and Windows 10 -->
15+
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
16+
<!-- Windows 8.1 -->
17+
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
18+
<!-- Windows 8 -->
19+
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
20+
<!-- Windows 7 -->
21+
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
1822
</application>
1923
</compatibility>
2024

25+
<asmv3:application>
26+
<asmv3:windowsSettings
27+
xmlns:ws2005="http://schemas.microsoft.com/SMI/2005/WindowsSettings"
28+
xmlns:ws2013="http://schemas.microsoft.com/SMI/2013/WindowsSettings"
29+
xmlns:ws2016="http://schemas.microsoft.com/SMI/2016/WindowsSettings"
30+
xmlns:ws2017="http://schemas.microsoft.com/SMI/2017/WindowsSettings"
31+
xmlns:ws2019="http://schemas.microsoft.com/SMI/2019/WindowsSettings"
32+
xmlns:ws2020="http://schemas.microsoft.com/SMI/2020/WindowsSettings"
33+
xmlns:ws2024="http://schemas.microsoft.com/SMI/2024/WindowsSettings">
34+
<ws2005:dpiAware>true/pm</ws2005:dpiAware>
35+
<ws2016:dpiAwareness>PerMonitorV2, PerMonitor</ws2016:dpiAwareness>
36+
<ws2013:ultraHighResolutionScrollingAware>true</ws2013:ultraHighResolutionScrollingAware>
37+
<ws2016:longPathAware>true</ws2016:longPathAware>
38+
<ws2019:activeCodePage>UTF-8</ws2019:activeCodePage>
39+
<ws2020:heapType>SegmentHeap</ws2020:heapType>
40+
<ws2024:supportedArchitectures>x86</ws2024:supportedArchitectures>
41+
</asmv3:windowsSettings>
42+
</asmv3:application>
43+
2144
<dependency optional="yes">
2245
<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="*" />
46+
<assemblyIdentity type="win32"
47+
name="Microsoft.Windows.Common-Controls"
48+
version="6.0.0.0"
49+
processorArchitecture="*"
50+
publicKeyToken="6595b64144ccf1df"
51+
language="*" />
3152
</dependentAssembly>
3253
</dependency>
54+
55+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
56+
</trustInfo>
3357
</assembly>

Client/ceflauncher/Main.cpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,30 @@
2020
(set flag.new_cef_exe on the build server to generate new exe)
2121
*/
2222

23-
int _declspec(dllimport) InitCEF();
23+
#include <cstdlib>
24+
#include <functional>
2425

25-
using HINSTANCE = struct HINSTANCE__*;
26+
struct HINSTANCE__;
27+
using HINSTANCE = HINSTANCE__*;
2628
using LPSTR = char*;
2729

28-
int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdShow, int nCmdShow)
30+
[[nodiscard("InitCEF return value must be used")]] __declspec(dllimport) auto InitCEF() -> int;
31+
32+
// Users are faced with vague crashes in CEFLauncher.exe, so rather than over-engineering all this is intended
33+
// Do note that CEFLauncher.exe ends up hosting any GPU rendering processes of CEF
34+
int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
2935
{
30-
return InitCEF();
36+
const auto init = std::function<int()>{InitCEF};
37+
const auto safe_invoke = [&]() noexcept -> int
38+
{
39+
try
40+
{
41+
return std::invoke_r<int>(init);
42+
}
43+
catch (...)
44+
{
45+
return EXIT_FAILURE;
46+
}
47+
};
48+
return safe_invoke();
3149
}

Client/ceflauncher/premake5.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,29 @@ project "CEFLauncher"
2020
"*.manifest",
2121
}
2222

23+
filter "system:windows"
24+
buildoptions {
25+
"/Zc:inline",
26+
"/Zc:throwingNew",
27+
"/diagnostics:caret",
28+
"/sdl",
29+
"/guard:cf"
30+
}
31+
editandcontinue "Off"
32+
linkoptions { "/guard:cf" }
33+
34+
filter {"system:windows", "configurations:Debug"}
35+
defines { "_DEBUG" }
36+
runtime "Debug"
37+
38+
filter {"system:windows", "configurations:Release"}
39+
optimize "Speed"
40+
defines { "NDEBUG" }
41+
42+
filter {"system:windows", "configurations:Nightly"}
43+
optimize "Speed"
44+
defines { "NDEBUG" }
45+
2346
filter "architecture:not x86"
2447
flags { "ExcludeFromBuild" }
2548

Client/cefweb/CAjaxResourceHandler.cpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ CAjaxResourceHandler::CAjaxResourceHandler(std::vector<SString>& vecGet, std::ve
1818
{
1919
}
2020

21+
CAjaxResourceHandler::~CAjaxResourceHandler()
22+
{
23+
// Ensure callback is released if handler is destroyed before completion
24+
if (m_callback)
25+
{
26+
m_callback = nullptr;
27+
}
28+
}
29+
2130
std::vector<SString>& CAjaxResourceHandler::GetGetData()
2231
{
2332
return m_vecGetData;
@@ -34,12 +43,18 @@ void CAjaxResourceHandler::SetResponse(const SString& data)
3443
m_bHasData = true;
3544

3645
if (m_callback)
46+
{
3747
m_callback->Continue();
48+
// Release callback to prevent memory leak
49+
m_callback = nullptr;
50+
}
3851
}
3952

4053
// CefResourceHandler implementation
4154
void CAjaxResourceHandler::Cancel()
4255
{
56+
// Release callback reference on cancellation to prevent memory leak
57+
m_callback = nullptr;
4358
}
4459

4560
void CAjaxResourceHandler::GetResponseHeaders(CefRefPtr<CefResponse> response, int64& response_length, CefString& redirectUrl)
@@ -69,13 +84,16 @@ bool CAjaxResourceHandler::ReadResponse(void* data_out, int bytes_to_read, int&
6984
}
7085

7186
// Are we done?
72-
if (m_strResponse.length() - m_DataOffset <= 0)
87+
if (m_strResponse.length() - m_DataOffset <= 0) [[unlikely]]
88+
return false;
89+
90+
if (bytes_to_read <= 0) [[unlikely]]
7391
return false;
7492

75-
int copyBytes = std::min((uint)bytes_to_read, m_strResponse.length() - m_DataOffset);
93+
const size_t copyBytes = std::min(static_cast<size_t>(bytes_to_read), m_strResponse.length() - m_DataOffset);
7694

7795
memcpy(data_out, m_strResponse.c_str() + m_DataOffset, copyBytes);
78-
bytes_read = copyBytes;
96+
bytes_read = static_cast<int>(copyBytes);
7997

8098
m_DataOffset += copyBytes;
8199

Client/cefweb/CAjaxResourceHandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class CAjaxResourceHandler : public CefResourceHandler, public CAjaxResourceHand
2020
{
2121
public:
2222
CAjaxResourceHandler(std::vector<SString>& vecGet, std::vector<SString>& vecPost, const CefString& mimeType);
23+
virtual ~CAjaxResourceHandler();
2324

2425
virtual std::vector<SString>& GetGetData() override;
2526
virtual std::vector<SString>& GetPostData() override;

0 commit comments

Comments
 (0)