MCPcopy Create free account
hub / github.com/Windscribe/Desktop-App / getUpdatePath

Function getUpdatePath

src/helper/windows/utils.cpp:604–628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602}
603
604std::wstring getUpdatePath(bool create)
605{
606 // To prevent shenanigans with various TOCTOU exploits, the staged installer should be in Program Files,
607 // which is only writable by administrators
608 wchar_t* programFilesPath = NULL;
609 HRESULT hr = SHGetKnownFolderPath(FOLDERID_ProgramFiles, 0, NULL, &programFilesPath);
610 if (FAILED(hr)) {
611 spdlog::error("Failed to get Program Files dir");
612 return L"";
613 }
614
615 std::wstringstream filePath;
616 filePath << programFilesPath;
617 CoTaskMemFree(programFilesPath);
618 filePath << L"\\" WS_WIN_CONFIG_SUBDIR_W L"\\update";
619 if (create) {
620 int ret = SHCreateDirectoryEx(NULL, filePath.str().c_str(), NULL);
621 if (ret != ERROR_SUCCESS && ret != ERROR_ALREADY_EXISTS) {
622 spdlog::error("Failed to create update dir");
623 return L"";
624 }
625 }
626
627 return filePath.str();
628}
629
630std::wstring getSystemDir()
631{

Callers 2

installerStageAndVerifyFunction · 0.85
installerCleanupStagedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected