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

Function getConfigPath

src/helper/windows/utils.cpp:580–602  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

578}
579
580std::wstring getConfigPath()
581{
582 // To prevent shenanigans with various TOCTOU exploits, the config file should be in Program Files,
583 // which is only writable by administrators
584 wchar_t* programFilesPath = NULL;
585 HRESULT hr = SHGetKnownFolderPath(FOLDERID_ProgramFiles, 0, NULL, &programFilesPath);
586 if (FAILED(hr)) {
587 spdlog::error("Failed to get Program Files dir");
588 return L"";
589 }
590
591 std::wstringstream filePath;
592 filePath << programFilesPath;
593 CoTaskMemFree(programFilesPath);
594 filePath << L"\\" WS_WIN_CONFIG_SUBDIR_W L"\\config";
595 int ret = SHCreateDirectoryEx(NULL, filePath.str().c_str(), NULL);
596 if (ret != ERROR_SUCCESS && ret != ERROR_ALREADY_EXISTS) {
597 spdlog::error("Failed to create config dir");
598 return L"";
599 }
600
601 return filePath.str();
602}
603
604std::wstring getUpdatePath(bool create)
605{

Callers 2

writeOVPNFileMethod · 0.85
configFileMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected