| 2417 | |
| 2418 | |
| 2419 | BOOL write_volume_name_if_changed(WCHAR dl, wstring& mes) { |
| 2420 | |
| 2421 | |
| 2422 | wstring fs_root; |
| 2423 | |
| 2424 | fs_root.push_back(dl); |
| 2425 | fs_root.push_back(':'); |
| 2426 | |
| 2427 | CryptThreadData *tdata = MountPointManager::getInstance().get(fs_root.c_str()); |
| 2428 | |
| 2429 | if (!tdata) { |
| 2430 | mes += LocUtils::GetStringFromResources(IDS_MPOINT_NOT_FOUND); |
| 2431 | return FALSE; |
| 2432 | } |
| 2433 | |
| 2434 | fs_root.push_back('\\'); |
| 2435 | |
| 2436 | CryptContext *con = &tdata->con; |
| 2437 | |
| 2438 | if (!con) { |
| 2439 | mes += LocUtils::GetStringFromResources(IDS_MPOINT_NULL); |
| 2440 | return FALSE; |
| 2441 | } |
| 2442 | |
| 2443 | KeyDecryptor kdc(&con->GetConfig()->m_keybuf_manager); |
| 2444 | |
| 2445 | WCHAR volbuf[256]; |
| 2446 | |
| 2447 | if (!GetVolumeInformationW(&fs_root[0], volbuf, |
| 2448 | sizeof(volbuf) / sizeof(volbuf[0]) - 1, NULL, NULL, |
| 2449 | NULL, NULL, 0)) { |
| 2450 | DWORD error = GetLastError(); |
| 2451 | DbgPrint(L"update volume name error = %u\n", error); |
| 2452 | CString strMsg; |
| 2453 | strMsg.Format(LocUtils::GetStringFromResources(IDS_UNABLE_GET_VOLUME_INFO).c_str(), GetWindowsErrorString(error)); |
| 2454 | mes += strMsg; |
| 2455 | return FALSE; |
| 2456 | } |
| 2457 | |
| 2458 | if (con->GetConfig()->m_VolumeName != volbuf) { |
| 2459 | con->GetConfig()->m_VolumeName = volbuf; |
| 2460 | bool res = con->GetConfig()->write_updated_config_file(nullptr, nullptr, 0); |
| 2461 | if (!res) { |
| 2462 | mes += LocUtils::GetStringFromResources(IDS_UNABLE_WRITE_NEW_VOL_NAME); |
| 2463 | return FALSE; |
| 2464 | } |
| 2465 | } |
| 2466 | |
| 2467 | return TRUE; |
| 2468 | } |
| 2469 | |
| 2470 | BOOL have_security_name_privilege() { |
| 2471 | static BOOL bHaveName = FALSE; |
no test coverage detected