@@ -29,6 +29,34 @@ void CWebApp::OnBeforeCommandLineProcessing(const CefString& process_type, CefRe
2929 if (!command_line)
3030 return ;
3131
32+ // Add GTA path and MTA base path switches before g_pCore check
33+ // This callback runs in both browser process and subprocess
34+ // In subprocess, g_pCore is NULL, so switches must be added before that check
35+ // Read GTA path from registry
36+ const SString strGTAPath = GetCommonRegistryValue (" " , " GTA:SA Path" );
37+ if (!strGTAPath.empty ())
38+ {
39+ // Pass GTA directory path to CEFLauncher subprocess via command-line switch
40+ // CEF's AppendSwitchWithValue handles quoting automatically
41+ command_line->AppendSwitchWithValue (" mta-gta-path" , strGTAPath);
42+ // AddReportLog only available in browser process where g_pCore exists
43+ }
44+
45+ // Pass MTA base directory path to subprocess
46+ // MTA DLLs are in Bin/MTA but parent process may be elsewhere
47+ const SString strMTAPath = GetMTAProcessBaseDir ();
48+ if (!strMTAPath.empty ())
49+ {
50+ command_line->AppendSwitchWithValue (" mta-base-path" , strMTAPath);
51+ }
52+
53+ // Disable AutoDeElevate to allow CEF to run with elevated privileges
54+ // Must be added before g_pCore check to apply to both browser process and subprocess
55+ // https://github.com/chromiumembedded/cef/issues/3960
56+ // https://chromium-review.googlesource.com/c/chromium/src/+/6515318
57+ command_line->AppendSwitch (" do-not-de-elevate" );
58+
59+ // Browser-process-only settings
3260 if (!g_pCore) [[unlikely]]
3361 return ;
3462
@@ -39,11 +67,6 @@ void CWebApp::OnBeforeCommandLineProcessing(const CefString& process_type, CefRe
3967 if (!pWebCore->GetGPUEnabled ())
4068 command_line->AppendSwitch (" disable-gpu" );
4169
42- // Disable the AutoDeElevate feature to make launching CEF with Admin privileges work.
43- // https://github.com/chromiumembedded/cef/issues/3960
44- // https://chromium-review.googlesource.com/c/chromium/src/+/6515318
45- command_line->AppendSwitch (" do-not-de-elevate" );
46-
4770 command_line->AppendSwitch (" disable-gpu-compositing" ); // always disable this, causes issues with official builds
4871
4972 // command_line->AppendSwitch("disable-d3d11");
@@ -108,8 +131,8 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
108131 }
109132 else
110133 {
111- SString resourceName = path.substr (0 , slashPos);
112- SString resourcePath = path.substr (slashPos + 1 );
134+ const SString resourceName = path.substr (0 , slashPos);
135+ const SString resourcePath = path.substr (slashPos + 1 );
113136
114137 if (resourcePath.empty ())
115138 {
@@ -137,7 +160,7 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
137160
138161 if (urlParts.query .str )
139162 {
140- SString strGet = UTF16ToMbUTF8 (urlParts.query .str );
163+ const SString strGet = UTF16ToMbUTF8 (urlParts.query .str );
141164 std::vector<SString> vecTmp;
142165 vecTmp.reserve (8 ); // Reserve space for common query parameter count
143166 strGet.Split (" &" , vecTmp);
@@ -153,13 +176,13 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
153176 }
154177
155178 CefPostData::ElementVector vecPostElements;
156- if (auto postData = request->GetPostData (); postData)
179+ if (const auto postData = request->GetPostData (); postData)
157180 {
158181 postData->GetElements (vecPostElements);
159182
160183 SString key;
161184 SString value;
162- for (auto & & post : vecPostElements)
185+ for (const auto & post : vecPostElements)
163186 {
164187 // Limit to 5MiB and allow byte data only
165188 constexpr size_t MAX_POST_SIZE = 5 * 1024 * 1024 ;
@@ -168,12 +191,12 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
168191 continue ;
169192
170193 // Make string from buffer
171- auto buffer = std::make_unique<char []>(bytesCount);
194+ const auto buffer = std::make_unique<char []>(bytesCount);
172195 // Verify GetBytes succeeded before using buffer
173- size_t bytesRead = post ->GetBytes (bytesCount, buffer.get ());
196+ const size_t bytesRead = post ->GetBytes (bytesCount, buffer.get ());
174197 if (bytesRead != bytesCount)
175198 continue ;
176- SStringX postParam (buffer.get (), bytesCount);
199+ const SStringX postParam (buffer.get (), bytesCount);
177200
178201 // Parse POST data into vector
179202 std::vector<SString> vecTmp;
@@ -197,7 +220,7 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
197220 {
198221 // Calculate MTA resource path
199222 static constexpr auto LOCAL = " local" ;
200- path = (resourceName != LOCAL) ? " :" + resourceName + " /" + resourcePath : resourcePath;
223+ path = (resourceName != LOCAL) ? SString ( " :" + resourceName + " /" + resourcePath) : resourcePath;
201224
202225 // Calculate absolute path
203226 if (!pWebView->GetFullPathFromLocal (path))
0 commit comments