Changeset 96803 in vbox for trunk/src/VBox/Main/src-global
- Timestamp:
- Sep 20, 2022 12:51:05 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-global/win/VirtualBoxSDSImpl.cpp
r96407 r96803 237 237 238 238 /* static */ 239 bool VirtualBoxSDS::i_isFeatureEnabled( com::Utf8Str const &a_rStrFeature)240 { 241 HKEY hKey;239 bool VirtualBoxSDS::i_isFeatureEnabled(wchar_t const *a_pwszFeature) 240 { 241 HKEY hKey; 242 242 LSTATUS lrc = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Oracle\\VirtualBox\\VBoxSDS", 0, KEY_READ, &hKey); 243 243 /* Treat any errors as the feature is off. Because the actual error value doesn't matter. */ … … 245 245 return false; 246 246 247 PRTUTF16 pwszFeature; 248 int rc = RTStrToUtf16(a_rStrFeature.c_str(), &pwszFeature); 249 AssertRCReturn(rc, false); 250 251 DWORD dwType = 0; 247 DWORD dwType = 0; 252 248 DWORD dwValue = 0; 253 249 DWORD cbValue = sizeof(DWORD); 254 lrc = RegQueryValueExW(hKey, pwszFeature, NULL, &dwType, (LPBYTE)&dwValue, &cbValue); 255 256 RTUtf16Free(pwszFeature); 257 258 bool const fEnabled = lrc == ERROR_SUCCESS 259 && dwType == REG_DWORD 260 /* A lot of people are used to putting 0xFF or similar to DWORDs for enabling stuff. */ 261 && dwValue >= 1; 250 lrc = RegQueryValueExW(hKey, a_pwszFeature, NULL, &dwType, (LPBYTE)&dwValue, &cbValue); 251 252 bool const fEnabled = lrc == ERROR_SUCCESS 253 && dwType == REG_DWORD 254 && dwValue != 0; 262 255 263 256 RegCloseKey(hKey); … … 296 289 { 297 290 *aExistingVirtualBox = NULL; 291 298 292 /* 299 293 * Get the client user SID and name. … … 344 338 #ifdef VBOX_WITH_VBOXSVC_SESSION_0 345 339 DWORD dwSessionId = 0; 346 if (VirtualBoxSDS::i_isFeatureEnabled( "ServerSession0"))340 if (VirtualBoxSDS::i_isFeatureEnabled(L"ServerSession0")) 347 341 { 348 342 /* Get user token. */ … … 360 354 HANDLE hNewToken; 361 355 if (DuplicateTokenEx(hThreadToken, MAXIMUM_ALLOWED, NULL /*SecurityAttribs*/, 362 356 SecurityIdentification, TokenPrimary, &hNewToken)) 363 357 { 364 358 CloseHandle(hThreadToken); … … 390 384 } 391 385 else 392 LogRel(("registerVBoxSVC: GetTokenInformation failed: % ld\n", GetLastError()));386 LogRel(("registerVBoxSVC: GetTokenInformation failed: %Rwc\n", GetLastError())); 393 387 } 388 394 389 /* Either the "VBoxSVC in windows session 0" feature is off or the request from VBoxSVC running 395 390 * in windows session 0. */ … … 397 392 { 398 393 /* if VBoxSVC in the Windows session 0 is not started or if it did not 399 394 * registered during a minute, start new one */ 400 395 if ( pUserData->m_pidTheChosenOne == NIL_RTPROCESS 401 396 || GetTickCount() - pUserData->m_tickTheChosenOne > 60 * 1000) … … 404 399 if (SetTokenInformation(hThreadToken, TokenSessionId, &uSessionId, sizeof(uint32_t))) 405 400 { 406 /* start VBoxSVC process */ 407 /* Get the path to the executable directory w/ trailing slash: */ 401 /* 402 * Start VBoxSVC process 403 */ 408 404 char szPath[RTPATH_MAX]; 409 405 int vrc = RTPathAppPrivateArch(szPath, sizeof(szPath)); 410 406 AssertRCReturn(vrc, vrc); 407 411 408 size_t cbBufLeft = RTPathEnsureTrailingSeparator(szPath, sizeof(szPath)); 412 409 AssertReturn(cbBufLeft > 0, VERR_FILENAME_TOO_LONG); 413 char *pszNamePart = &szPath[cbBufLeft]; NOREF(pszNamePart); 410 411 char *pszNamePart = &szPath[cbBufLeft]; 414 412 cbBufLeft = sizeof(szPath) - cbBufLeft; 413 415 414 static const char s_szVirtualBox_exe[] = "VBoxSVC.exe"; 416 415 vrc = RTStrCopy(pszNamePart, cbBufLeft, s_szVirtualBox_exe); 417 416 AssertRCReturn(vrc, vrc); 417 418 418 const char *apszArgs[] = 419 419 { … … 483 483 else 484 484 { 485 LogRel(("registerVBoxSVC: OpenProcess() failed: % ld\n", GetLastError()));485 LogRel(("registerVBoxSVC: OpenProcess() failed: %Rwc\n", GetLastError())); 486 486 hrc = E_ACCESSDENIED; 487 487 }
Note:
See TracChangeset
for help on using the changeset viewer.