Skip to content

Commit 04b7b94

Browse files
committed
Addendum #3 to a32fc5f
1 parent 46bb595 commit 04b7b94

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

Client/ceflauncher/Main.cpp

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

23-
#include <Windows.h>
23+
#include <cstdlib>
24+
#include <functional>
2425

25-
[[nodiscard]] int __declspec(dllimport) InitCEF();
26+
struct HINSTANCE__;
27+
using HINSTANCE = HINSTANCE__*;
28+
using LPSTR = char*;
2629

27-
int __stdcall WinMain(
28-
[[maybe_unused]] HINSTANCE hInstance,
29-
[[maybe_unused]] HINSTANCE hPrevInstance,
30-
[[maybe_unused]] LPSTR lpCmdLine,
31-
[[maybe_unused]] 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)
3235
{
33-
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();
3449
}

Client/ceflauncher/premake5.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ project "CEFLauncher"
3434

3535
filter {"system:windows", "configurations:Debug"}
3636
defines { "_DEBUG" }
37+
runtime "Debug"
3738

3839
filter {"system:windows", "configurations:Release"}
3940
optimize "Speed"

0 commit comments

Comments
 (0)