Changeset 51912 in vbox for trunk/src/VBox/HostDrivers
- Timestamp:
- Jul 7, 2014 9:46:57 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/Support/SUPR3HardenedVerify.cpp
r51909 r51912 385 385 if (RT_SUCCESS(rc)) 386 386 { 387 #if defined(RT_OS_WINDOWS) /** @todo use CreateFileW */ 388 HANDLE hDir = CreateFile(szPath, 389 GENERIC_READ, 390 FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, 391 NULL, 392 OPEN_EXISTING, 393 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, 394 NULL); 395 if (hDir != INVALID_HANDLE_VALUE) 387 #if defined(RT_OS_WINDOWS) 388 PRTUTF16 pwszPath; 389 rc = RTStrToUtf16(szPath, &pwszPath); 390 if (RT_SUCCESS(rc)) 396 391 { 397 /** @todo check the type */ 398 /* That's all on windows, for now at least... */ 399 g_aSupVerifiedDirs[enmDir].hDir = (intptr_t)hDir; 400 g_aSupVerifiedDirs[enmDir].fValidated = true; 401 } 402 else if (enmDir == kSupID_Testcase) 403 { 404 g_aSupVerifiedDirs[enmDir].fValidated = true; 405 rc = VINF_SUCCESS; /* Optional directory, ignore if missing. */ 392 HANDLE hDir = CreateFileW(pwszPath, 393 GENERIC_READ, 394 FILE_SHARE_READ | FILE_SHARE_DELETE | FILE_SHARE_WRITE, 395 NULL, 396 OPEN_EXISTING, 397 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, 398 NULL); 399 if (hDir != INVALID_HANDLE_VALUE) 400 { 401 /** @todo check the type */ 402 /* That's all on windows, for now at least... */ 403 g_aSupVerifiedDirs[enmDir].hDir = (intptr_t)hDir; 404 g_aSupVerifiedDirs[enmDir].fValidated = true; 405 } 406 else if (enmDir == kSupID_Testcase) 407 { 408 g_aSupVerifiedDirs[enmDir].fValidated = true; 409 rc = VINF_SUCCESS; /* Optional directory, ignore if missing. */ 410 } 411 else 412 { 413 int err = GetLastError(); 414 rc = supR3HardenedError(VERR_PATH_NOT_FOUND, fFatal, 415 "supR3HardenedVerifyDir: Failed to open \"%s\": err=%d\n", 416 szPath, err); 417 } 418 RTUtf16Free(pwszPath); 406 419 } 407 420 else 408 { 409 int err = GetLastError(); 410 rc = supR3HardenedError(VERR_PATH_NOT_FOUND, fFatal, 411 "supR3HardenedVerifyDir: Failed to open \"%s\": err=%d\n", 412 szPath, err); 413 } 421 rc = supR3HardenedError(rc, fFatal, 422 "supR3HardenedVerifyDir: Failed to convert \"%s\" to UTF-16: err=%d\n", szPath, rc); 423 414 424 #else /* UNIXY */ 415 425 int fd = open(szPath, O_RDONLY, 0); … … 519 529 if (RT_SUCCESS(rc)) 520 530 { 521 #if defined(RT_OS_WINDOWS) /** @todo Need to use WCHAR on windows! */531 #if defined(RT_OS_WINDOWS) 522 532 PRTUTF16 pwszPath; 523 533 rc = RTStrToUtf16(szPath, &pwszPath); … … 1573 1583 * The files shall be signed on windows, verify that. 1574 1584 */ 1585 rc = VINF_SUCCESS; 1575 1586 HANDLE hVerify; 1576 if (hNativeFile == RTHCUINTPTR_MAX) /** @todo Need to use WCHAR on windows! */ 1577 hVerify = CreateFile(pszFilename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 1587 if (hNativeFile == RTHCUINTPTR_MAX) 1588 { 1589 PRTUTF16 pwszPath; 1590 rc = RTStrToUtf16(pszFilename, &pwszPath); 1591 if (RT_SUCCESS(rc)) 1592 { 1593 hVerify = CreateFileW(pwszPath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); 1594 RTUtf16Free(pwszPath); 1595 } 1596 else 1597 rc = RTErrInfoSetF(pErrInfo, rc, "Error converting '%s' to UTF-16: %Rrc", pszFilename, rc); 1598 } 1578 1599 else if (!DuplicateHandle(GetCurrentProcess(), (HANDLE)hNativeFile, GetCurrentProcess(), &hVerify, 1579 1600 GENERIC_READ, false /*bInheritHandle*/, 0 /*dwOptions*/)) … … 1599 1620 CloseHandle(hVerify); 1600 1621 } 1601 else 1622 else if (RT_SUCCESS(rc)) 1602 1623 rc = RTErrInfoSetF(pErrInfo, RTErrConvertFromWin32(GetLastError()), 1603 1624 "Error %u trying to open (or duplicate handle for) '%s'", GetLastError(), pszFilename);
Note:
See TracChangeset
for help on using the changeset viewer.