mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-01-29 09:32:39 +00:00
Initial elevated windows work
This commit is contained in:
parent
415dec37ad
commit
83dd07469e
@ -332,6 +332,9 @@ int apply_flags(const char *line) {
|
|||||||
case '1':
|
case '1':
|
||||||
config::sunshine.flags[config::flag::FRESH_STATE].flip();
|
config::sunshine.flags[config::flag::FRESH_STATE].flip();
|
||||||
break;
|
break;
|
||||||
|
case 'p':
|
||||||
|
config::sunshine.flags[config::flag::CONST_PIN].flip();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
std::cout << "Warning: Unrecognized flag: ["sv << *line << ']' << std::endl;
|
std::cout << "Warning: Unrecognized flag: ["sv << *line << ']' << std::endl;
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
@ -71,7 +71,8 @@ namespace flag {
|
|||||||
enum flag_e : std::size_t {
|
enum flag_e : std::size_t {
|
||||||
PIN_STDIN = 0, // Read PIN from stdin instead of http
|
PIN_STDIN = 0, // Read PIN from stdin instead of http
|
||||||
FRESH_STATE, // Do not load or save state
|
FRESH_STATE, // Do not load or save state
|
||||||
FLAG_SIZE
|
FLAG_SIZE,
|
||||||
|
CONST_PIN= 4 // Use "universal" pin
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,7 +360,11 @@ void pair(std::shared_ptr<safe::queue_t<crypto::x509_t>> &add_cert, std::shared_
|
|||||||
|
|
||||||
ptr->second.async_insert_pin.salt = std::move(args.at("salt"s));
|
ptr->second.async_insert_pin.salt = std::move(args.at("salt"s));
|
||||||
|
|
||||||
if(config::sunshine.flags[config::flag::PIN_STDIN]) {
|
if(config::sunshine.flags[config::flag::CONST_PIN]) {
|
||||||
|
std::string pin("6174");
|
||||||
|
getservercert(ptr->second, tree, pin);
|
||||||
|
}
|
||||||
|
else if(config::sunshine.flags[config::flag::PIN_STDIN]) {
|
||||||
std::string pin;
|
std::string pin;
|
||||||
|
|
||||||
std::cout << "Please insert pin: "sv;
|
std::cout << "Please insert pin: "sv;
|
||||||
|
18
sunshine/platform/windows/desktop.h
Normal file
18
sunshine/platform/windows/desktop.h
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace platf {
|
||||||
|
using namespace std::literals;
|
||||||
|
inline auto 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;
|
||||||
|
};
|
||||||
|
};
|
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
|
|
||||||
|
#include "desktop.h"
|
||||||
|
|
||||||
namespace platf {
|
namespace platf {
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
}
|
}
|
||||||
@ -90,6 +92,8 @@ int display_base_t::init() {
|
|||||||
FreeLibrary(user32);
|
FreeLibrary(user32);
|
||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
|
pairInputDesktop();
|
||||||
|
|
||||||
dxgi::factory1_t::pointer factory_p {};
|
dxgi::factory1_t::pointer factory_p {};
|
||||||
dxgi::adapter_t::pointer adapter_p {};
|
dxgi::adapter_t::pointer adapter_p {};
|
||||||
dxgi::output_t::pointer output_p {};
|
dxgi::output_t::pointer output_p {};
|
||||||
@ -150,8 +154,8 @@ int display_base_t::init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
D3D_FEATURE_LEVEL featureLevels[] {
|
D3D_FEATURE_LEVEL featureLevels[] {
|
||||||
D3D_FEATURE_LEVEL_12_1,
|
//D3D_FEATURE_LEVEL_12_1,
|
||||||
D3D_FEATURE_LEVEL_12_0,
|
//D3D_FEATURE_LEVEL_12_0,
|
||||||
D3D_FEATURE_LEVEL_11_1,
|
D3D_FEATURE_LEVEL_11_1,
|
||||||
D3D_FEATURE_LEVEL_11_0,
|
D3D_FEATURE_LEVEL_11_0,
|
||||||
D3D_FEATURE_LEVEL_10_1,
|
D3D_FEATURE_LEVEL_10_1,
|
||||||
@ -164,7 +168,6 @@ int display_base_t::init() {
|
|||||||
status = adapter->QueryInterface(IID_IDXGIAdapter, (void**)&adapter_p);
|
status = adapter->QueryInterface(IID_IDXGIAdapter, (void**)&adapter_p);
|
||||||
if(FAILED(status)) {
|
if(FAILED(status)) {
|
||||||
BOOST_LOG(error) << "Failed to query IDXGIAdapter interface"sv;
|
BOOST_LOG(error) << "Failed to query IDXGIAdapter interface"sv;
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,11 +12,15 @@
|
|||||||
#include "sunshine/main.h"
|
#include "sunshine/main.h"
|
||||||
#include "sunshine/platform/common.h"
|
#include "sunshine/platform/common.h"
|
||||||
|
|
||||||
|
#include "desktop.h"
|
||||||
|
|
||||||
namespace platf {
|
namespace platf {
|
||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
|
|
||||||
using adapteraddrs_t = util::c_ptr<IP_ADAPTER_ADDRESSES>;
|
using adapteraddrs_t = util::c_ptr<IP_ADAPTER_ADDRESSES>;
|
||||||
|
|
||||||
|
volatile HDESK _lastKnownInputDesktop = NULL;
|
||||||
|
|
||||||
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>;
|
||||||
@ -171,9 +175,15 @@ void move_mouse(input_t &input, int deltaX, int deltaY) {
|
|||||||
mi.dwFlags = MOUSEEVENTF_MOVE;
|
mi.dwFlags = MOUSEEVENTF_MOVE;
|
||||||
mi.dx = deltaX;
|
mi.dx = deltaX;
|
||||||
mi.dy = deltaY;
|
mi.dy = deltaY;
|
||||||
|
|
||||||
|
retry:
|
||||||
auto send = SendInput(1, &i, sizeof(INPUT));
|
auto send = SendInput(1, &i, sizeof(INPUT));
|
||||||
if(send != 1) {
|
if(send != 1) {
|
||||||
|
auto hDesk = pairInputDesktop();
|
||||||
|
if (_lastKnownInputDesktop != hDesk) {
|
||||||
|
_lastKnownInputDesktop = hDesk;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
BOOST_LOG(warning) << "Couldn't send mouse movement input"sv;
|
BOOST_LOG(warning) << "Couldn't send mouse movement input"sv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,8 +228,14 @@ void button_mouse(input_t &input, int button, bool release) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retry:
|
||||||
auto send = SendInput(1, &i, sizeof(INPUT));
|
auto send = SendInput(1, &i, sizeof(INPUT));
|
||||||
if(send != 1) {
|
if(send != 1) {
|
||||||
|
auto hDesk = pairInputDesktop();
|
||||||
|
if (_lastKnownInputDesktop != hDesk) {
|
||||||
|
_lastKnownInputDesktop = hDesk;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
BOOST_LOG(warning) << "Couldn't send mouse button input"sv;
|
BOOST_LOG(warning) << "Couldn't send mouse button input"sv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -233,9 +249,15 @@ void scroll(input_t &input, int distance) {
|
|||||||
mi.dwFlags = MOUSEEVENTF_WHEEL;
|
mi.dwFlags = MOUSEEVENTF_WHEEL;
|
||||||
mi.mouseData = distance;
|
mi.mouseData = distance;
|
||||||
|
|
||||||
|
retry:
|
||||||
auto send = SendInput(1, &i, sizeof(INPUT));
|
auto send = SendInput(1, &i, sizeof(INPUT));
|
||||||
if(send != 1) {
|
if(send != 1) {
|
||||||
BOOST_LOG(warning) << "Couldn't send moue movement input"sv;
|
auto hDesk = pairInputDesktop();
|
||||||
|
if (_lastKnownInputDesktop != hDesk) {
|
||||||
|
_lastKnownInputDesktop = hDesk;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
BOOST_LOG(warning) << "Couldn't send mouse scroll input"sv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -282,9 +304,15 @@ void keyboard(input_t &input, uint16_t modcode, bool release) {
|
|||||||
ki.dwFlags |= KEYEVENTF_KEYUP;
|
ki.dwFlags |= KEYEVENTF_KEYUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retry:
|
||||||
auto send = SendInput(1, &i, sizeof(INPUT));
|
auto send = SendInput(1, &i, sizeof(INPUT));
|
||||||
if(send != 1) {
|
if(send != 1) {
|
||||||
BOOST_LOG(warning) << "Couldn't send moue movement input"sv;
|
auto hDesk = pairInputDesktop();
|
||||||
|
if (_lastKnownInputDesktop != hDesk) {
|
||||||
|
_lastKnownInputDesktop = hDesk;
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
BOOST_LOG(warning) << "Couldn't send keyboard input"sv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user