Fix inabillity to display secure desktop even when runnig as system account
This commit is contained in:
@@ -51,6 +51,7 @@ if(WIN32)
|
|||||||
|
|
||||||
set(PLATFORM_TARGET_FILES
|
set(PLATFORM_TARGET_FILES
|
||||||
sunshine/platform/windows/publish.cpp
|
sunshine/platform/windows/publish.cpp
|
||||||
|
sunshine/platform/windows/misc.h
|
||||||
sunshine/platform/windows/misc.cpp
|
sunshine/platform/windows/misc.cpp
|
||||||
sunshine/platform/windows/input.cpp
|
sunshine/platform/windows/input.cpp
|
||||||
sunshine/platform/windows/display.h
|
sunshine/platform/windows/display.h
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
|
|
||||||
|
#include "display.h"
|
||||||
|
#include "misc.h"
|
||||||
#include "sunshine/config.h"
|
#include "sunshine/config.h"
|
||||||
#include "sunshine/main.h"
|
#include "sunshine/main.h"
|
||||||
#include "sunshine/platform/common.h"
|
#include "sunshine/platform/common.h"
|
||||||
|
|
||||||
#include "display.h"
|
|
||||||
|
|
||||||
namespace platf {
|
namespace platf {
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
}
|
}
|
||||||
@@ -91,6 +91,9 @@ int display_base_t::init() {
|
|||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Ensure we can duplicate the current display
|
||||||
|
syncThreadDesktop();
|
||||||
|
|
||||||
// Get rectangle of full desktop for absolute mouse coordinates
|
// Get rectangle of full desktop for absolute mouse coordinates
|
||||||
env_width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
env_width = GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
||||||
env_height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
env_height = GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
||||||
|
|||||||
@@ -4,20 +4,20 @@
|
|||||||
|
|
||||||
#include <ViGEm/Client.h>
|
#include <ViGEm/Client.h>
|
||||||
|
|
||||||
|
#include "misc.h"
|
||||||
#include "sunshine/main.h"
|
#include "sunshine/main.h"
|
||||||
#include "sunshine/platform/common.h"
|
#include "sunshine/platform/common.h"
|
||||||
|
|
||||||
namespace platf {
|
namespace platf {
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
volatile HDESK _lastKnownInputDesktop = NULL;
|
thread_local HDESK _lastKnownInputDesktop = nullptr;
|
||||||
|
|
||||||
constexpr touch_port_t target_touch_port {
|
constexpr touch_port_t target_touch_port {
|
||||||
0, 0,
|
0, 0,
|
||||||
65535, 65535
|
65535, 65535
|
||||||
};
|
};
|
||||||
|
|
||||||
HDESK pairInputDesktop();
|
|
||||||
|
|
||||||
class vigem_t {
|
class vigem_t {
|
||||||
public:
|
public:
|
||||||
using client_t = util::safe_ptr<_VIGEM_CLIENT_T, vigem_free>;
|
using client_t = util::safe_ptr<_VIGEM_CLIENT_T, vigem_free>;
|
||||||
@@ -102,12 +102,12 @@ void send_input(INPUT &i) {
|
|||||||
retry:
|
retry:
|
||||||
auto send = SendInput(1, &i, sizeof(INPUT));
|
auto send = SendInput(1, &i, sizeof(INPUT));
|
||||||
if(send != 1) {
|
if(send != 1) {
|
||||||
auto hDesk = pairInputDesktop();
|
auto hDesk = syncThreadDesktop();
|
||||||
if(_lastKnownInputDesktop != hDesk) {
|
if(_lastKnownInputDesktop != hDesk) {
|
||||||
_lastKnownInputDesktop = hDesk;
|
_lastKnownInputDesktop = hDesk;
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
BOOST_LOG(warning) << "Couldn't send input"sv;
|
BOOST_LOG(error) << "Couldn't send input"sv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) {
|
void abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y) {
|
||||||
@@ -281,29 +281,6 @@ void gamepad(input_t &input, int nr, const gamepad_state_t &gamepad_state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int thread_priority() {
|
|
||||||
return SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) ? 0 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
HDESK pairInputDesktop() {
|
|
||||||
auto hDesk = OpenInputDesktop(DF_ALLOWOTHERACCOUNTHOOK, FALSE, GENERIC_ALL);
|
|
||||||
if(NULL == hDesk) {
|
|
||||||
auto err = GetLastError();
|
|
||||||
BOOST_LOG(error) << "Failed to OpenInputDesktop [0x"sv << util::hex(err).to_string_view() << ']';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
BOOST_LOG(info) << std::endl
|
|
||||||
<< "Opened desktop [0x"sv << util::hex(hDesk).to_string_view() << ']';
|
|
||||||
if(!SetThreadDesktop(hDesk)) {
|
|
||||||
auto err = GetLastError();
|
|
||||||
BOOST_LOG(error) << "Failed to SetThreadDesktop [0x"sv << util::hex(err).to_string_view() << ']';
|
|
||||||
}
|
|
||||||
CloseDesktop(hDesk);
|
|
||||||
}
|
|
||||||
|
|
||||||
return hDesk;
|
|
||||||
}
|
|
||||||
|
|
||||||
void freeInput(void *p) {
|
void freeInput(void *p) {
|
||||||
auto vigem = (vigem_t *)p;
|
auto vigem = (vigem_t *)p;
|
||||||
|
|
||||||
|
|||||||
@@ -87,4 +87,37 @@ std::string get_mac_address(const std::string_view &address) {
|
|||||||
BOOST_LOG(warning) << "Unable to find MAC address for "sv << address;
|
BOOST_LOG(warning) << "Unable to find MAC address for "sv << address;
|
||||||
return "00:00:00:00:00:00"s;
|
return "00:00:00:00:00:00"s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HDESK syncThreadDesktop() {
|
||||||
|
auto hDesk = OpenInputDesktop(DF_ALLOWOTHERACCOUNTHOOK, FALSE, GENERIC_ALL);
|
||||||
|
if(!hDesk) {
|
||||||
|
auto err = GetLastError();
|
||||||
|
BOOST_LOG(error) << "Failed to Open Input Desktop [0x"sv << util::hex(err).to_string_view() << ']';
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!SetThreadDesktop(hDesk)) {
|
||||||
|
auto err = GetLastError();
|
||||||
|
BOOST_LOG(error) << "Failed to sync desktop to thread [0x"sv << util::hex(err).to_string_view() << ']';
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseDesktop(hDesk);
|
||||||
|
|
||||||
|
return hDesk;
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_status(const std::string_view &prefix, HRESULT status) {
|
||||||
|
char err_string[1024];
|
||||||
|
|
||||||
|
DWORD bytes = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
|
nullptr,
|
||||||
|
status,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||||
|
err_string,
|
||||||
|
sizeof(err_string),
|
||||||
|
nullptr);
|
||||||
|
|
||||||
|
BOOST_LOG(error) << prefix << ": "sv << std::string_view { err_string, bytes };
|
||||||
|
}
|
||||||
} // namespace platf
|
} // namespace platf
|
||||||
@@ -7,14 +7,14 @@
|
|||||||
|
|
||||||
#include <boost/asio/ip/host_name.hpp>
|
#include <boost/asio/ip/host_name.hpp>
|
||||||
|
|
||||||
|
#include "misc.h"
|
||||||
#include "sunshine/config.h"
|
#include "sunshine/config.h"
|
||||||
#include "sunshine/main.h"
|
#include "sunshine/main.h"
|
||||||
|
#include "sunshine/network.h"
|
||||||
#include "sunshine/nvhttp.h"
|
#include "sunshine/nvhttp.h"
|
||||||
#include "sunshine/platform/common.h"
|
#include "sunshine/platform/common.h"
|
||||||
#include "sunshine/thread_safe.h"
|
#include "sunshine/thread_safe.h"
|
||||||
|
|
||||||
#include "sunshine/network.h"
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
@@ -96,20 +96,6 @@ PDNS_SERVICE_INSTANCE DnsServiceConstructInstance(
|
|||||||
_In_reads_(dwPropertiesCount) PCWSTR *values);
|
_In_reads_(dwPropertiesCount) PCWSTR *values);
|
||||||
} /* extern "C" */
|
} /* extern "C" */
|
||||||
|
|
||||||
void print_status(const std::string_view &prefix, HRESULT status) {
|
|
||||||
char err_string[1024];
|
|
||||||
|
|
||||||
DWORD bytes = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
||||||
nullptr,
|
|
||||||
status,
|
|
||||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
||||||
err_string,
|
|
||||||
sizeof(err_string),
|
|
||||||
nullptr);
|
|
||||||
|
|
||||||
BOOST_LOG(error) << prefix << ": "sv << std::string_view { err_string, bytes };
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace platf::publish {
|
namespace platf::publish {
|
||||||
VOID WINAPI register_cb(DWORD status, PVOID pQueryContext, PDNS_SERVICE_INSTANCE pInstance) {
|
VOID WINAPI register_cb(DWORD status, PVOID pQueryContext, PDNS_SERVICE_INSTANCE pInstance) {
|
||||||
auto alarm = (safe::alarm_t<DNS_STATUS>::element_type *)pQueryContext;
|
auto alarm = (safe::alarm_t<DNS_STATUS>::element_type *)pQueryContext;
|
||||||
|
|||||||
Reference in New Issue
Block a user