MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / write_volume_name_if_changed

Function write_volume_name_if_changed

cppcryptfs/dokan/cryptdokan.cpp:2419–2468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2417
2418
2419BOOL 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
2470BOOL have_security_name_privilege() {
2471 static BOOL bHaveName = FALSE;

Callers 3

CanCloseMethod · 0.85
DismountMethod · 0.85
DismountAllMethod · 0.85

Calls 5

DbgPrintFunction · 0.85
GetWindowsErrorStringFunction · 0.85
GetConfigMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected