win32 fixes
This commit is contained in:
@@ -16,9 +16,11 @@ boost_asio_has_std_string_view
|
||||
bugprone
|
||||
cflags
|
||||
chrono
|
||||
clsid
|
||||
cmake_current_source_dir
|
||||
coinit_apartmentthreaded
|
||||
comdlg32
|
||||
conin$
|
||||
cppcoreguidelines
|
||||
cppdbg
|
||||
cppflags
|
||||
@@ -110,6 +112,7 @@ filebase
|
||||
flac_version
|
||||
flag_nopath
|
||||
flarge
|
||||
folderid
|
||||
fontconfig_version
|
||||
foob
|
||||
fooba
|
||||
@@ -125,11 +128,14 @@ gpath
|
||||
gtest_version
|
||||
has_setxattr
|
||||
hkey
|
||||
hresult
|
||||
httpapi
|
||||
httplib
|
||||
hwnd
|
||||
icudata
|
||||
icui18n
|
||||
icuuc
|
||||
inproc
|
||||
iostreams
|
||||
iphlpapi
|
||||
ipstream
|
||||
@@ -208,13 +214,16 @@ renterd
|
||||
richtext
|
||||
rocksdb_library
|
||||
rpcrt4
|
||||
runas
|
||||
s_igid
|
||||
s_isvtx
|
||||
s_iuid
|
||||
sddl_revision_1
|
||||
secp256k1
|
||||
secur32
|
||||
see_mask_nocloseprocess
|
||||
sfml_project
|
||||
shellexecuteinfoa
|
||||
shlwapi
|
||||
sigchld
|
||||
skynet
|
||||
|
@@ -53,6 +53,10 @@
|
||||
#include <csignal>
|
||||
#endif // defined(__APPLE__)
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include "utils/com_init_wrapper.hpp"
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
namespace {
|
||||
#if defined(PROJECT_ENABLE_CURL)
|
||||
bool curl_initialized{false};
|
||||
@@ -65,6 +69,10 @@ bool spdlog_initialized{false};
|
||||
#if defined(PROJECT_ENABLE_SQLITE)
|
||||
bool sqlite3_initialized{false};
|
||||
#endif // defined(PROJECT_ENABLE_SQLITE)
|
||||
|
||||
#if defined(_WIN32)
|
||||
[[maybe_unused]] const repertory::utils::com_init_wrapper wrapper;
|
||||
#endif // defined(_WIN32)
|
||||
} // namespace
|
||||
|
||||
namespace repertory {
|
||||
|
@@ -40,7 +40,6 @@
|
||||
#include "drives/winfsp/remotewinfsp/remote_client.hpp"
|
||||
#include "drives/winfsp/remotewinfsp/remote_winfsp_drive.hpp"
|
||||
#include "drives/winfsp/winfsp_drive.hpp"
|
||||
#include "utils/com_init_wrapper.hpp"
|
||||
|
||||
using repertory_drive = repertory::winfsp_drive;
|
||||
using remote_client = repertory::remote_winfsp::remote_client;
|
||||
|
@@ -99,7 +99,6 @@ mount(std::vector<const char *> args, std::string data_directory,
|
||||
|
||||
#if defined(_WIN32)
|
||||
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)) {
|
||||
std::cerr << "failed to set mount state" << std::endl;
|
||||
}
|
||||
|
@@ -39,7 +39,7 @@ private:
|
||||
utils::atomic<std::string> api_password_{"repertory"};
|
||||
std::atomic<std::uint16_t> api_port_{default_ui_mgmt_port};
|
||||
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<std::string, std::string>>
|
||||
locations_;
|
||||
|
@@ -261,7 +261,7 @@ void mgmt_app_config::set_auto_start(bool auto_start) {
|
||||
#if defined(_WIN32)
|
||||
if (auto_start) {
|
||||
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.icon_path = utils::path::combine(L".", {L"icon.ico"});
|
||||
cfg.shortcut_name = L"repertory";
|
||||
|
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "utils/windows.hpp"
|
||||
|
||||
#include "utils/com_init_wrapper.hpp"
|
||||
#include "utils/error.hpp"
|
||||
#include "utils/file.hpp"
|
||||
#include "utils/path.hpp"
|
||||
@@ -91,10 +92,11 @@ auto is_process_elevated() -> bool {
|
||||
auto ret{false};
|
||||
HANDLE token{INVALID_HANDLE_VALUE};
|
||||
if (::OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
|
||||
TOKEN_ELEVATION te{};
|
||||
DWORD sz = sizeof(te);
|
||||
if (::GetTokenInformation(token, TokenElevation, &te, sizeof(te), &sz)) {
|
||||
ret = (te.TokenIsElevated != 0);
|
||||
TOKEN_ELEVATION token_elevation{};
|
||||
DWORD size = sizeof(token_elevation);
|
||||
if (::GetTokenInformation(token, TokenElevation, &token_elevation,
|
||||
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); }
|
||||
|
||||
auto get_startup_folder() -> std::wstring {
|
||||
utils::com_init_wrapper wrapper;
|
||||
|
||||
PWSTR raw{nullptr};
|
||||
auto result = ::SHGetKnownFolderPath(FOLDERID_Startup, 0, nullptr, &raw);
|
||||
if (FAILED(result)) {
|
||||
@@ -159,10 +163,12 @@ auto get_startup_folder() -> std::wstring {
|
||||
auto create_shortcut(const shortcut_cfg &cfg, bool overwrite_existing) -> bool {
|
||||
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;
|
||||
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();
|
||||
};
|
||||
|
||||
@@ -191,8 +197,8 @@ auto create_shortcut(const shortcut_cfg &cfg, bool overwrite_existing) -> bool {
|
||||
}
|
||||
|
||||
IShellLinkW *psl{nullptr};
|
||||
HRESULT result = ::CoCreateInstance(CLSID_ShellLink, nullptr,
|
||||
CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&psl));
|
||||
auto result = ::CoCreateInstance(CLSID_ShellLink, nullptr,
|
||||
CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&psl));
|
||||
if (FAILED(result)) {
|
||||
utils::error::handle_error(
|
||||
function_name,
|
||||
|
Reference in New Issue
Block a user