diff --git a/repertory/librepertory/src/utils/windows/windows_utils.cpp b/repertory/librepertory/src/utils/windows/windows_utils.cpp index be1a09dc..367f4e6c 100644 --- a/repertory/librepertory/src/utils/windows/windows_utils.cpp +++ b/repertory/librepertory/src/utils/windows/windows_utils.cpp @@ -87,8 +87,6 @@ auto from_api_error(const api_error &e) -> NTSTATUS { } } -auto get_last_error_code() -> DWORD { return ::GetLastError(); } - auto get_accessed_time_from_meta(const api_meta_map &meta) -> std::uint64_t { return utils::string::to_uint64(meta.at(META_ACCESSED)); } @@ -105,60 +103,6 @@ auto get_written_time_from_meta(const api_meta_map &meta) -> std::uint64_t { return utils::string::to_uint64(meta.at(META_WRITTEN)); } -auto get_thread_id() -> std::uint64_t { - return static_cast(::GetCurrentThreadId()); -} - -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); - } - } - - if (token != INVALID_HANDLE_VALUE) { - ::CloseHandle(token); - } - - return ret; -} - -auto run_process_elevated(std::vector args) -> int { - std::cout << "Elevating Process" << std::endl; - std::string parameters = "-hidden"; - for (std::size_t i = 1U; i < args.size(); i++) { - parameters += - (parameters.empty() ? args.at(i) : " " + std::string(args.at(i))); - } - - char full_path[MAX_PATH] = {0}; - if (::GetModuleFileName(nullptr, full_path, MAX_PATH)) { - SHELLEXECUTEINFO sei{}; - sei.fMask = SEE_MASK_NOCLOSEPROCESS; - sei.cbSize = sizeof(sei); - sei.lpVerb = "runas"; - sei.lpFile = &full_path[0]; - sei.lpParameters = ¶meters[0]; - sei.hwnd = nullptr; - sei.nShow = SW_NORMAL; - if (::ShellExecuteEx(&sei)) { - ::WaitForSingleObject(sei.hProcess, INFINITE); - DWORD exit_code{}; - ::GetExitCodeProcess(sei.hProcess, &exit_code); - ::CloseHandle(sei.hProcess); - return static_cast(exit_code); - } - } - - return static_cast(::GetLastError()); -} - -void set_last_error_code(DWORD error_code) { ::SetLastError(error_code); } - auto unix_access_mask_to_windows(std::int32_t mask) -> int { if (mask & 1) { mask -= 1;