win32 fixes
All checks were successful
BlockStorage/repertory_mac/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
2025-09-07 11:57:26 -07:00
parent 7fd518a1e5
commit 68ca817fd7
7 changed files with 33 additions and 12 deletions

View File

@@ -16,9 +16,11 @@ boost_asio_has_std_string_view
bugprone bugprone
cflags cflags
chrono chrono
clsid
cmake_current_source_dir cmake_current_source_dir
coinit_apartmentthreaded coinit_apartmentthreaded
comdlg32 comdlg32
conin$
cppcoreguidelines cppcoreguidelines
cppdbg cppdbg
cppflags cppflags
@@ -110,6 +112,7 @@ filebase
flac_version flac_version
flag_nopath flag_nopath
flarge flarge
folderid
fontconfig_version fontconfig_version
foob foob
fooba fooba
@@ -125,11 +128,14 @@ gpath
gtest_version gtest_version
has_setxattr has_setxattr
hkey hkey
hresult
httpapi httpapi
httplib httplib
hwnd
icudata icudata
icui18n icui18n
icuuc icuuc
inproc
iostreams iostreams
iphlpapi iphlpapi
ipstream ipstream
@@ -208,13 +214,16 @@ renterd
richtext richtext
rocksdb_library rocksdb_library
rpcrt4 rpcrt4
runas
s_igid s_igid
s_isvtx s_isvtx
s_iuid s_iuid
sddl_revision_1 sddl_revision_1
secp256k1 secp256k1
secur32 secur32
see_mask_nocloseprocess
sfml_project sfml_project
shellexecuteinfoa
shlwapi shlwapi
sigchld sigchld
skynet skynet

View File

@@ -53,6 +53,10 @@
#include <csignal> #include <csignal>
#endif // defined(__APPLE__) #endif // defined(__APPLE__)
#if defined(_WIN32)
#include "utils/com_init_wrapper.hpp"
#endif // defined(_WIN32)
namespace { namespace {
#if defined(PROJECT_ENABLE_CURL) #if defined(PROJECT_ENABLE_CURL)
bool curl_initialized{false}; bool curl_initialized{false};
@@ -65,6 +69,10 @@ bool spdlog_initialized{false};
#if defined(PROJECT_ENABLE_SQLITE) #if defined(PROJECT_ENABLE_SQLITE)
bool sqlite3_initialized{false}; bool sqlite3_initialized{false};
#endif // defined(PROJECT_ENABLE_SQLITE) #endif // defined(PROJECT_ENABLE_SQLITE)
#if defined(_WIN32)
[[maybe_unused]] const repertory::utils::com_init_wrapper wrapper;
#endif // defined(_WIN32)
} // namespace } // namespace
namespace repertory { namespace repertory {

View File

@@ -40,7 +40,6 @@
#include "drives/winfsp/remotewinfsp/remote_client.hpp" #include "drives/winfsp/remotewinfsp/remote_client.hpp"
#include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp" #include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp"
#include "drives/winfsp/winfsp_drive.hpp" #include "drives/winfsp/winfsp_drive.hpp"
#include "utils/com_init_wrapper.hpp"
using repertory_drive = repertory::winfsp_drive; using repertory_drive = repertory::winfsp_drive;
using remote_client = repertory::remote_winfsp::remote_client; using remote_client = repertory::remote_winfsp::remote_client;

View File

@@ -99,7 +99,6 @@ mount(std::vector<const char *> args, std::string data_directory,
#if defined(_WIN32) #if defined(_WIN32)
if (config.get_enable_mount_manager() && not utils::is_process_elevated()) { if (config.get_enable_mount_manager() && not utils::is_process_elevated()) {
utils::com_init_wrapper wrapper;
if (not lock.set_mount_state(true, "elevating", -1)) { if (not lock.set_mount_state(true, "elevating", -1)) {
std::cerr << "failed to set mount state" << std::endl; std::cerr << "failed to set mount state" << std::endl;
} }

View File

@@ -39,7 +39,7 @@ private:
utils::atomic<std::string> api_password_{"repertory"}; utils::atomic<std::string> api_password_{"repertory"};
std::atomic<std::uint16_t> api_port_{default_ui_mgmt_port}; std::atomic<std::uint16_t> api_port_{default_ui_mgmt_port};
utils::atomic<std::string> api_user_{"repertory"}; utils::atomic<std::string> api_user_{"repertory"};
std::atomic<bool> auto_start_{false}; std::atomic<bool> auto_start_{true};
std::unordered_map<provider_type, std::unordered_map<provider_type,
std::unordered_map<std::string, std::string>> std::unordered_map<std::string, std::string>>
locations_; locations_;

View File

@@ -261,7 +261,7 @@ void mgmt_app_config::set_auto_start(bool auto_start) {
#if defined(_WIN32) #if defined(_WIN32)
if (auto_start) { if (auto_start) {
utils::shortcut_cfg cfg{}; utils::shortcut_cfg cfg{};
cfg.arguments = {L"-ui", L"-lo"}; cfg.arguments = L"-ui -lo";
cfg.exe_path = utils::path::combine(L".", {L"repertory"}); cfg.exe_path = utils::path::combine(L".", {L"repertory"});
cfg.icon_path = utils::path::combine(L".", {L"icon.ico"}); cfg.icon_path = utils::path::combine(L".", {L"icon.ico"});
cfg.shortcut_name = L"repertory"; cfg.shortcut_name = L"repertory";

View File

@@ -23,6 +23,7 @@
#include "utils/windows.hpp" #include "utils/windows.hpp"
#include "utils/com_init_wrapper.hpp"
#include "utils/error.hpp" #include "utils/error.hpp"
#include "utils/file.hpp" #include "utils/file.hpp"
#include "utils/path.hpp" #include "utils/path.hpp"
@@ -91,10 +92,11 @@ auto is_process_elevated() -> bool {
auto ret{false}; auto ret{false};
HANDLE token{INVALID_HANDLE_VALUE}; HANDLE token{INVALID_HANDLE_VALUE};
if (::OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) { if (::OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
TOKEN_ELEVATION te{}; TOKEN_ELEVATION token_elevation{};
DWORD sz = sizeof(te); DWORD size = sizeof(token_elevation);
if (::GetTokenInformation(token, TokenElevation, &te, sizeof(te), &sz)) { if (::GetTokenInformation(token, TokenElevation, &token_elevation,
ret = (te.TokenIsElevated != 0); sizeof(token_elevation), &size)) {
ret = (token_elevation.TokenIsElevated != 0);
} }
} }
@@ -141,6 +143,8 @@ auto run_process_elevated(std::vector<const char *> args) -> int {
void set_last_error_code(DWORD error_code) { ::SetLastError(error_code); } void set_last_error_code(DWORD error_code) { ::SetLastError(error_code); }
auto get_startup_folder() -> std::wstring { auto get_startup_folder() -> std::wstring {
utils::com_init_wrapper wrapper;
PWSTR raw{nullptr}; PWSTR raw{nullptr};
auto result = ::SHGetKnownFolderPath(FOLDERID_Startup, 0, nullptr, &raw); auto result = ::SHGetKnownFolderPath(FOLDERID_Startup, 0, nullptr, &raw);
if (FAILED(result)) { if (FAILED(result)) {
@@ -159,10 +163,12 @@ auto get_startup_folder() -> std::wstring {
auto create_shortcut(const shortcut_cfg &cfg, bool overwrite_existing) -> bool { auto create_shortcut(const shortcut_cfg &cfg, bool overwrite_existing) -> bool {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto hr_hex = [](HRESULT hr) -> std::string { utils::com_init_wrapper wrapper;
const auto hr_hex = [](HRESULT result) -> std::string {
std::ostringstream oss; std::ostringstream oss;
oss << "0x" << std::uppercase << std::hex << std::setw(8) oss << "0x" << std::uppercase << std::hex << std::setw(8)
<< std::setfill('0') << static_cast<std::uint32_t>(hr); << std::setfill('0') << static_cast<std::uint32_t>(result);
return oss.str(); return oss.str();
}; };
@@ -191,8 +197,8 @@ auto create_shortcut(const shortcut_cfg &cfg, bool overwrite_existing) -> bool {
} }
IShellLinkW *psl{nullptr}; IShellLinkW *psl{nullptr};
HRESULT result = ::CoCreateInstance(CLSID_ShellLink, nullptr, auto result = ::CoCreateInstance(CLSID_ShellLink, nullptr,
CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&psl)); CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&psl));
if (FAILED(result)) { if (FAILED(result)) {
utils::error::handle_error( utils::error::handle_error(
function_name, function_name,