@@ -29,6 +29,35 @@ 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+ int iResult = 0 ;
37+ const SString strGTAPath = GetCommonRegistryValue (" " , " GTA:SA Path" , &iResult);
38+ if (!strGTAPath.empty ())
39+ {
40+ // Pass GTA directory path to CEFLauncher subprocess via command-line switch
41+ // CEF's AppendSwitchWithValue handles quoting automatically
42+ command_line->AppendSwitchWithValue (" mta-gta-path" , strGTAPath);
43+ // AddReportLog only available in browser process where g_pCore exists
44+ }
45+
46+ // Pass MTA base directory path to subprocess
47+ // MTA DLLs are in Bin/MTA but parent process may be elsewhere
48+ const SString strMTAPath = GetMTAProcessBaseDir ();
49+ if (!strMTAPath.empty ())
50+ {
51+ command_line->AppendSwitchWithValue (" mta-base-path" , strMTAPath);
52+ }
53+
54+ // Disable AutoDeElevate to allow CEF to run with elevated privileges
55+ // Must be added before g_pCore check to apply to both browser process and subprocess
56+ // https://github.com/chromiumembedded/cef/issues/3960
57+ // https://chromium-review.googlesource.com/c/chromium/src/+/6515318
58+ command_line->AppendSwitch (" do-not-de-elevate" );
59+
60+ // Browser-process-only settings
3261 if (!g_pCore) [[unlikely]]
3362 return ;
3463
@@ -39,11 +68,6 @@ void CWebApp::OnBeforeCommandLineProcessing(const CefString& process_type, CefRe
3968 if (!pWebCore->GetGPUEnabled ())
4069 command_line->AppendSwitch (" disable-gpu" );
4170
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-
4771 command_line->AppendSwitch (" disable-gpu-compositing" ); // always disable this, causes issues with official builds
4872
4973 // command_line->AppendSwitch("disable-d3d11");
@@ -108,8 +132,8 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
108132 }
109133 else
110134 {
111- SString resourceName = path.substr (0 , slashPos);
112- SString resourcePath = path.substr (slashPos + 1 );
135+ const SString resourceName = path.substr (0 , slashPos);
136+ const SString resourcePath = path.substr (slashPos + 1 );
113137
114138 if (resourcePath.empty ())
115139 {
@@ -137,7 +161,7 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
137161
138162 if (urlParts.query .str )
139163 {
140- SString strGet = UTF16ToMbUTF8 (urlParts.query .str );
164+ const SString strGet = UTF16ToMbUTF8 (urlParts.query .str );
141165 std::vector<SString> vecTmp;
142166 vecTmp.reserve (8 ); // Reserve space for common query parameter count
143167 strGet.Split (" &" , vecTmp);
@@ -153,13 +177,13 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
153177 }
154178
155179 CefPostData::ElementVector vecPostElements;
156- if (auto postData = request->GetPostData (); postData)
180+ if (const auto postData = request->GetPostData (); postData)
157181 {
158182 postData->GetElements (vecPostElements);
159183
160184 SString key;
161185 SString value;
162- for (auto & & post : vecPostElements)
186+ for (const auto & post : vecPostElements)
163187 {
164188 // Limit to 5MiB and allow byte data only
165189 constexpr size_t MAX_POST_SIZE = 5 * 1024 * 1024 ;
@@ -168,12 +192,12 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
168192 continue ;
169193
170194 // Make string from buffer
171- auto buffer = std::make_unique<char []>(bytesCount);
195+ const auto buffer = std::make_unique<char []>(bytesCount);
172196 // Verify GetBytes succeeded before using buffer
173- size_t bytesRead = post ->GetBytes (bytesCount, buffer.get ());
197+ const size_t bytesRead = post ->GetBytes (bytesCount, buffer.get ());
174198 if (bytesRead != bytesCount)
175199 continue ;
176- SStringX postParam (buffer.get (), bytesCount);
200+ const SStringX postParam (buffer.get (), bytesCount);
177201
178202 // Parse POST data into vector
179203 std::vector<SString> vecTmp;
@@ -197,7 +221,7 @@ CefRefPtr<CefResourceHandler> CWebApp::Create(CefRefPtr<CefBrowser> browser, Cef
197221 {
198222 // Calculate MTA resource path
199223 static constexpr auto LOCAL = " local" ;
200- path = (resourceName != LOCAL) ? " :" + resourceName + " /" + resourcePath : resourcePath;
224+ path = (resourceName != LOCAL) ? SString ( " :" + resourceName + " /" + resourcePath) : resourcePath;
201225
202226 // Calculate absolute path
203227 if (!pWebView->GetFullPathFromLocal (path))
0 commit comments