| 578 | } |
| 579 | |
| 580 | std::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 | |
| 604 | std::wstring getUpdatePath(bool create) |
| 605 | { |
no outgoing calls
no test coverage detected