3030#include < SharedUtil.h>
3131
3232#ifdef CEF_ENABLE_SANDBOX
33- #include < cef3/cef/include/cef_sandbox_win.h>
34- #pragma comment(lib, "cef_sandbox.lib")
33+ #include < cef3/cef/include/cef_sandbox_win.h>
34+ #pragma comment(lib, "cef_sandbox.lib")
3535#endif
3636
3737// Return codes
38- inline constexpr int CEF_INIT_SUCCESS = 0 ;
39- inline constexpr int CEF_INIT_ERROR_NO_BASE_DIR = -1 ;
40- inline constexpr int CEF_INIT_ERROR_DLL_LOAD_FAILED = -2 ;
38+ inline constexpr int CEF_INIT_SUCCESS = 0 ;
39+ inline constexpr int CEF_INIT_ERROR_NO_BASE_DIR = -1 ;
40+ inline constexpr int CEF_INIT_ERROR_DLL_LOAD_FAILED = -2 ;
4141
42- inline constexpr DWORD CEF_PARENT_CHECK_INTERVAL = 1000 ;
43- inline constexpr const char * CEF_DLL_NAME = " libcef.dll" ;
44- inline constexpr const char * CEF_MTA_SUBDIR = " MTA" ;
42+ inline constexpr DWORD CEF_PARENT_CHECK_INTERVAL = 1000 ;
43+ inline constexpr const char * CEF_DLL_NAME = " libcef.dll" ;
44+ inline constexpr const char * CEF_MTA_SUBDIR = " MTA" ;
4545
46- inline constexpr DWORD PARENT_CHECK_ERROR_NO_QUERY_FUNC = 1 ;
47- inline constexpr DWORD PARENT_CHECK_ERROR_QUERY_FAILED = 2 ;
48- inline constexpr DWORD PARENT_CHECK_ERROR_OPEN_FAILED = 3 ;
46+ inline constexpr DWORD PARENT_CHECK_ERROR_NO_QUERY_FUNC = 1 ;
47+ inline constexpr DWORD PARENT_CHECK_ERROR_QUERY_FAILED = 2 ;
48+ inline constexpr DWORD PARENT_CHECK_ERROR_OPEN_FAILED = 3 ;
4949
5050using NtQueryInformationProcessFunc = NTSTATUS(NTAPI*)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
5151
5252// Safe parent monitor thread shutdown
53- std::atomic<bool > g_bShouldTerminateMonitor{false };
53+ std::atomic<bool > g_bShouldTerminateMonitor{false };
5454std::atomic<HANDLE> g_hMonitorThread{nullptr };
5555
5656namespace
@@ -60,19 +60,19 @@ namespace
6060 const auto ntdll = GetModuleHandleW (L" ntdll.dll" );
6161 if (!ntdll)
6262 return nullptr ;
63-
63+
6464 const auto procAddr = GetProcAddress (ntdll, " NtQueryInformationProcess" );
6565 if (!procAddr)
6666 return nullptr ;
67-
67+
6868 return reinterpret_cast <NtQueryInformationProcessFunc>(procAddr);
6969 }
7070
7171 [[nodiscard]] auto GetParentProcessId (NtQueryInformationProcessFunc queryFunc) noexcept -> DWORD
7272 {
7373 PROCESS_BASIC_INFORMATION info{};
74- ULONG returnLength = 0 ;
75-
74+ ULONG returnLength = 0 ;
75+
7676 if (const auto status = queryFunc (GetCurrentProcess (), ProcessBasicInformation, &info, sizeof (info), &returnLength);
7777 !NT_SUCCESS (status) || returnLength < sizeof (PROCESS_BASIC_INFORMATION))
7878 {
@@ -87,7 +87,7 @@ namespace
8787 while (!g_bShouldTerminateMonitor.load (std::memory_order_acquire))
8888 {
8989 const DWORD result = WaitForSingleObject (parentProcess, CEF_PARENT_CHECK_INTERVAL);
90-
90+
9191 if (result == WAIT_OBJECT_0)
9292 {
9393 DWORD exitCode = 0 ;
@@ -120,7 +120,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, [[maybe_unused]] LPVOID l
120120 {
121121 g_bShouldTerminateMonitor.store (true , std::memory_order_release);
122122 }
123-
123+
124124 return TRUE ;
125125}
126126
@@ -130,30 +130,28 @@ extern "C" [[nodiscard]] __declspec(dllexport) auto InitCEF() noexcept -> int
130130 const std::wstring_view cmdLine{GetCommandLineW ()};
131131 if (const auto pos = cmdLine.find (L" --kgfiv8n=" ); pos != std::wstring_view::npos)
132132 {
133- const auto valueStart = pos + 11 ; // Skip "--kgfiv8n="
133+ const auto valueStart = pos + 11 ; // Skip "--kgfiv8n="
134134 const auto valueEnd = cmdLine.find_first_of (L" \t\" " , valueStart);
135- const auto authCodeW = cmdLine.substr (valueStart,
136- valueEnd == std::wstring_view::npos ? 30 : std::min<size_t >(30 , valueEnd - valueStart));
137-
135+ const auto authCodeW = cmdLine.substr (valueStart, valueEnd == std::wstring_view::npos ? 30 : std::min<size_t >(30 , valueEnd - valueStart));
136+
138137 std::string authCode;
139138 authCode.reserve (30 );
140- std::transform (authCodeW.begin (), authCodeW.end (), std::back_inserter (authCode),
141- [](const wchar_t wc) { return static_cast <char >(wc); });
142-
139+ std::transform (authCodeW.begin (), authCodeW.end (), std::back_inserter (authCode), [](const wchar_t wc) { return static_cast <char >(wc); });
140+
143141 CefAppAuth::AuthCodeStorage () = std::move (authCode);
144142 }
145143
146144 const auto baseDir = SharedUtil::GetMTAProcessBaseDir ();
147145 if (baseDir.empty ())
148146 return CEF_INIT_ERROR_NO_BASE_DIR;
149-
147+
150148 const auto mtaDir = SharedUtil::PathJoin (baseDir, CEF_MTA_SUBDIR);
151149 SetDllDirectoryW (SharedUtil::FromUTF8 (mtaDir));
152150
153151 if (FAILED (__HrLoadAllImportsForDll (CEF_DLL_NAME)))
154152 return CEF_INIT_ERROR_DLL_LOAD_FAILED;
155153
156- const CefMainArgs mainArgs (GetModuleHandleW (nullptr ));
154+ const CefMainArgs mainArgs (GetModuleHandleW (nullptr ));
157155 const CefRefPtr<CCefApp> app{new CCefApp};
158156
159157 void * sandboxInfo = nullptr ;
0 commit comments