From c8908c8be68a559fb8d1f7c01448019a92abb8cd Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 12 Nov 2018 13:40:40 +0100 Subject: [PATCH] Updated windows shadow server assistance usage. --- client/common/client.c | 2 +- include/freerdp/assistance.h | 5 +- libfreerdp/common/assistance.c | 29 ++++- server/shadow/Win/win_wds.c | 273 +++++++++++++++++------------------------ 4 files changed, 143 insertions(+), 166 deletions(-) diff --git a/client/common/client.c b/client/common/client.c index 114d930..43f9e20 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -334,7 +334,7 @@ int freerdp_client_settings_parse_assistance_file(rdpSettings* settings, if (status < 0) goto out; - if (!freerdp_client_populate_settings_from_assistance_file(file, settings)) + if (!freerdp_assistance_populate_settings_from_assistance_file(file, settings)) goto out; ret = 0; diff --git a/include/freerdp/assistance.h b/include/freerdp/assistance.h index 1c3663b..c8f5e62 100644 --- a/include/freerdp/assistance.h +++ b/include/freerdp/assistance.h @@ -37,12 +37,15 @@ FREERDP_API char* freerdp_assistance_construct_expert_blob(const char* name, con FREERDP_API BYTE* freerdp_assistance_encrypt_pass_stub(const char* password, const char* passStub, size_t* pEncryptedSize); +FREERDP_API int freerdp_assistance_set_connection_string2(rdpAssistanceFile* file, + const char* string, const char* password); + FREERDP_API int freerdp_assistance_parse_file_buffer(rdpAssistanceFile* file, const char* buffer, size_t size, const char* password); FREERDP_API int freerdp_assistance_parse_file(rdpAssistanceFile* file, const char* name, const char* password); -FREERDP_API BOOL freerdp_client_populate_settings_from_assistance_file(rdpAssistanceFile* file, +FREERDP_API BOOL freerdp_assistance_populate_settings_from_assistance_file(rdpAssistanceFile* file, rdpSettings* settings); FREERDP_API BOOL freerdp_assistance_get_encrypted_pass_stub(rdpAssistanceFile* file, const char** pwd, size_t* size); diff --git a/libfreerdp/common/assistance.c b/libfreerdp/common/assistance.c index a6aee2a..1638b18 100644 --- a/libfreerdp/common/assistance.c +++ b/libfreerdp/common/assistance.c @@ -1045,7 +1045,7 @@ int freerdp_assistance_parse_file(rdpAssistanceFile* file, const char* name, con return status; } -BOOL freerdp_client_populate_settings_from_assistance_file(rdpAssistanceFile* file, +BOOL freerdp_assistance_populate_settings_from_assistance_file(rdpAssistanceFile* file, rdpSettings* settings) { UINT32 i; @@ -1057,9 +1057,17 @@ BOOL freerdp_client_populate_settings_from_assistance_file(rdpAssistanceFile* fi if (freerdp_set_param_string(settings, FreeRDP_RemoteAssistanceSessionId, file->RASessionId) != 0) return FALSE; - if (file->RCTicket && - (freerdp_set_param_string(settings, FreeRDP_RemoteAssistanceRCTicket, file->RCTicket) != 0)) - return FALSE; + if (file->RCTicket) + { + if (freerdp_set_param_string(settings, FreeRDP_RemoteAssistanceRCTicket, file->RCTicket) != 0) + return FALSE; + } + else + { + if (freerdp_set_param_string(settings, FreeRDP_RemoteAssistanceRCTicket, + file->ConnectionString2) != 0) + return FALSE; + } if (file->PassStub) { @@ -1171,3 +1179,16 @@ BOOL freerdp_assistance_get_encrypted_pass_stub(rdpAssistanceFile* file, const c *size = file->EncryptedPassStubLength; return TRUE; } + +int freerdp_assistance_set_connection_string2(rdpAssistanceFile* file, const char* string, + const char* password) +{ + if (!file || !string || !password) + return -1; + + free(file->ConnectionString2); + free(file->password); + file->ConnectionString2 = _strdup(string); + file->password = _strdup(password); + return freerdp_assistance_parse_connection_string2(file); +} diff --git a/server/shadow/Win/win_wds.c b/server/shadow/Win/win_wds.c index 2c3b80a..7f83b19 100644 --- a/server/shadow/Win/win_wds.c +++ b/server/shadow/Win/win_wds.c @@ -47,16 +47,26 @@ #include +#include + #define TAG SERVER_TAG("shadow.win") -DEFINE_GUID(CLSID_RDPSession,0x9B78F0E6,0x3E05,0x4A5B,0xB2,0xE8,0xE7,0x43,0xA8,0x95,0x6B,0x65); -DEFINE_GUID(DIID__IRDPSessionEvents,0x98a97042,0x6698,0x40e9,0x8e,0xfd,0xb3,0x20,0x09,0x90,0x00,0x4b); -DEFINE_GUID(IID_IRDPSRAPISharingSession,0xeeb20886,0xe470,0x4cf6,0x84,0x2b,0x27,0x39,0xc0,0xec,0x5c,0xfb); -DEFINE_GUID(IID_IRDPSRAPIAttendee,0xec0671b3,0x1b78,0x4b80,0xa4,0x64,0x91,0x32,0x24,0x75,0x43,0xe3); -DEFINE_GUID(IID_IRDPSRAPIAttendeeManager,0xba3a37e8,0x33da,0x4749,0x8d,0xa0,0x07,0xfa,0x34,0xda,0x79,0x44); -DEFINE_GUID(IID_IRDPSRAPISessionProperties,0x339b24f2,0x9bc0,0x4f16,0x9a,0xac,0xf1,0x65,0x43,0x3d,0x13,0xd4); -DEFINE_GUID(CLSID_RDPSRAPIApplicationFilter,0xe35ace89,0xc7e8,0x427e,0xa4,0xf9,0xb9,0xda,0x07,0x28,0x26,0xbd); -DEFINE_GUID(CLSID_RDPSRAPIInvitationManager,0x53d9c9db,0x75ab,0x4271,0x94,0x8a,0x4c,0x4e,0xb3,0x6a,0x8f,0x2b); +DEFINE_GUID(CLSID_RDPSession, 0x9B78F0E6, 0x3E05, 0x4A5B, 0xB2, 0xE8, 0xE7, 0x43, 0xA8, 0x95, 0x6B, + 0x65); +DEFINE_GUID(DIID__IRDPSessionEvents, 0x98a97042, 0x6698, 0x40e9, 0x8e, 0xfd, 0xb3, 0x20, 0x09, 0x90, + 0x00, 0x4b); +DEFINE_GUID(IID_IRDPSRAPISharingSession, 0xeeb20886, 0xe470, 0x4cf6, 0x84, 0x2b, 0x27, 0x39, 0xc0, + 0xec, 0x5c, 0xfb); +DEFINE_GUID(IID_IRDPSRAPIAttendee, 0xec0671b3, 0x1b78, 0x4b80, 0xa4, 0x64, 0x91, 0x32, 0x24, 0x75, + 0x43, 0xe3); +DEFINE_GUID(IID_IRDPSRAPIAttendeeManager, 0xba3a37e8, 0x33da, 0x4749, 0x8d, 0xa0, 0x07, 0xfa, 0x34, + 0xda, 0x79, 0x44); +DEFINE_GUID(IID_IRDPSRAPISessionProperties, 0x339b24f2, 0x9bc0, 0x4f16, 0x9a, 0xac, 0xf1, 0x65, + 0x43, 0x3d, 0x13, 0xd4); +DEFINE_GUID(CLSID_RDPSRAPIApplicationFilter, 0xe35ace89, 0xc7e8, 0x427e, 0xa4, 0xf9, 0xb9, 0xda, + 0x07, 0x28, 0x26, 0xbd); +DEFINE_GUID(CLSID_RDPSRAPIInvitationManager, 0x53d9c9db, 0x75ab, 0x4271, 0x94, 0x8a, 0x4c, 0x4e, + 0xb3, 0x6a, 0x8f, 0x2b); static ULONG Shadow_IRDPSessionEvents_RefCount = 0; @@ -172,16 +182,16 @@ const char* GetRDPSessionEventString(DISPID id) return "OnUnknown"; } -static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_QueryInterface( - __RPC__in _IRDPSessionEvents * This, - /* [in] */ __RPC__in REFIID riid, - /* [annotation][iid_is][out] */ - _COM_Outptr_ void **ppvObject) +static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_QueryInterface( + __RPC__in _IRDPSessionEvents* This, + /* [in] */ __RPC__in REFIID riid, + /* [annotation][iid_is][out] */ + _COM_Outptr_ void** ppvObject) { *ppvObject = NULL; if (IsEqualIID(riid, &DIID__IRDPSessionEvents) || - IsEqualIID(riid, &IID_IDispatch) || IsEqualIID(riid, &IID_IUnknown)) + IsEqualIID(riid, &IID_IDispatch) || IsEqualIID(riid, &IID_IUnknown)) { *ppvObject = This; } @@ -190,82 +200,79 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_QueryInterface( return E_NOINTERFACE; This->lpVtbl->AddRef(This); - return S_OK; } - -static ULONG STDMETHODCALLTYPE Shadow_IRDPSessionEvents_AddRef( - __RPC__in _IRDPSessionEvents * This) + +static ULONG STDMETHODCALLTYPE Shadow_IRDPSessionEvents_AddRef( + __RPC__in _IRDPSessionEvents* This) { Shadow_IRDPSessionEvents_RefCount++; return Shadow_IRDPSessionEvents_RefCount; } - -static ULONG STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Release( - __RPC__in _IRDPSessionEvents * This) + +static ULONG STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Release( + __RPC__in _IRDPSessionEvents* This) { if (!Shadow_IRDPSessionEvents_RefCount) return 0; Shadow_IRDPSessionEvents_RefCount--; - return Shadow_IRDPSessionEvents_RefCount; } - -static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_GetTypeInfoCount( - __RPC__in _IRDPSessionEvents * This, - /* [out] */ __RPC__out UINT *pctinfo) + +static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_GetTypeInfoCount( + __RPC__in _IRDPSessionEvents* This, + /* [out] */ __RPC__out UINT* pctinfo) { WLog_INFO(TAG, "Shadow_IRDPSessionEvents_GetTypeInfoCount"); *pctinfo = 1; return S_OK; } - -static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_GetTypeInfo( - __RPC__in _IRDPSessionEvents * This, - /* [in] */ UINT iTInfo, - /* [in] */ LCID lcid, - /* [out] */ __RPC__deref_out_opt ITypeInfo **ppTInfo) + +static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_GetTypeInfo( + __RPC__in _IRDPSessionEvents* This, + /* [in] */ UINT iTInfo, + /* [in] */ LCID lcid, + /* [out] */ __RPC__deref_out_opt ITypeInfo** ppTInfo) { WLog_INFO(TAG, "Shadow_IRDPSessionEvents_GetTypeInfo"); return E_NOTIMPL; } - -static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_GetIDsOfNames( - __RPC__in _IRDPSessionEvents * This, - /* [in] */ __RPC__in REFIID riid, - /* [size_is][in] */ __RPC__in_ecount_full(cNames) LPOLESTR *rgszNames, - /* [range][in] */ __RPC__in_range(0,16384) UINT cNames, - /* [in] */ LCID lcid, - /* [size_is][out] */ __RPC__out_ecount_full(cNames) DISPID *rgDispId) + +static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_GetIDsOfNames( + __RPC__in _IRDPSessionEvents* This, + /* [in] */ __RPC__in REFIID riid, + /* [size_is][in] */ __RPC__in_ecount_full(cNames) LPOLESTR* rgszNames, + /* [range][in] */ __RPC__in_range(0, 16384) UINT cNames, + /* [in] */ LCID lcid, + /* [size_is][out] */ __RPC__out_ecount_full(cNames) DISPID* rgDispId) { WLog_INFO(TAG, "Shadow_IRDPSessionEvents_GetIDsOfNames"); return E_NOTIMPL; } - -static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( - _IRDPSessionEvents * This, - /* [annotation][in] */ - _In_ DISPID dispIdMember, - /* [annotation][in] */ - _In_ REFIID riid, - /* [annotation][in] */ - _In_ LCID lcid, - /* [annotation][in] */ - _In_ WORD wFlags, - /* [annotation][out][in] */ - _In_ DISPPARAMS *pDispParams, - /* [annotation][out] */ - _Out_opt_ VARIANT *pVarResult, - /* [annotation][out] */ - _Out_opt_ EXCEPINFO *pExcepInfo, - /* [annotation][out] */ - _Out_opt_ UINT *puArgErr) + +static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( + _IRDPSessionEvents* This, + /* [annotation][in] */ + _In_ DISPID dispIdMember, + /* [annotation][in] */ + _In_ REFIID riid, + /* [annotation][in] */ + _In_ LCID lcid, + /* [annotation][in] */ + _In_ WORD wFlags, + /* [annotation][out][in] */ + _In_ DISPPARAMS* pDispParams, + /* [annotation][out] */ + _Out_opt_ VARIANT* pVarResult, + /* [annotation][out] */ + _Out_opt_ EXCEPINFO* pExcepInfo, + /* [annotation][out] */ + _Out_opt_ UINT* puArgErr) { HRESULT hr; VARIANT vr; UINT uArgErr; - WLog_INFO(TAG, "%s (%ld)", GetRDPSessionEventString(dispIdMember), dispIdMember); switch (dispIdMember) @@ -275,39 +282,35 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( int level; IDispatch* pDispatch; IRDPSRAPIAttendee* pAttendee; - vr.vt = VT_DISPATCH; vr.pdispVal = NULL; - hr = DispGetParam(pDispParams, 0, VT_DISPATCH, &vr, &uArgErr); if (FAILED(hr)) { WLog_ERR(TAG, "%s DispGetParam(0, VT_DISPATCH) failure: 0x%08lX", - GetRDPSessionEventString(dispIdMember), hr); + GetRDPSessionEventString(dispIdMember), hr); return hr; } - - pDispatch = vr.pdispVal; + pDispatch = vr.pdispVal; hr = pDispatch->lpVtbl->QueryInterface(pDispatch, &IID_IRDPSRAPIAttendee, (void**) &pAttendee); if (FAILED(hr)) { WLog_INFO(TAG, "%s IDispatch::QueryInterface(IRDPSRAPIAttendee) failure: 0x%08lX", - GetRDPSessionEventString(dispIdMember), hr); + GetRDPSessionEventString(dispIdMember), hr); return hr; } level = CTRL_LEVEL_VIEW; //level = CTRL_LEVEL_INTERACTIVE; - hr = pAttendee->lpVtbl->put_ControlLevel(pAttendee, level); if (FAILED(hr)) { WLog_INFO(TAG, "%s IRDPSRAPIAttendee::put_ControlLevel() failure: 0x%08lX", - GetRDPSessionEventString(dispIdMember), hr); + GetRDPSessionEventString(dispIdMember), hr); return hr; } @@ -341,41 +344,36 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( int level; IDispatch* pDispatch; IRDPSRAPIAttendee* pAttendee; - vr.vt = VT_INT; vr.pdispVal = NULL; - hr = DispGetParam(pDispParams, 1, VT_INT, &vr, &uArgErr); if (FAILED(hr)) { WLog_INFO(TAG, "%s DispGetParam(1, VT_INT) failure: 0x%08lX", - GetRDPSessionEventString(dispIdMember), hr); + GetRDPSessionEventString(dispIdMember), hr); return hr; } level = vr.intVal; - vr.vt = VT_DISPATCH; vr.pdispVal = NULL; - hr = DispGetParam(pDispParams, 0, VT_DISPATCH, &vr, &uArgErr); if (FAILED(hr)) { WLog_ERR(TAG, "%s DispGetParam(0, VT_DISPATCH) failure: 0x%08lX", - GetRDPSessionEventString(dispIdMember), hr); + GetRDPSessionEventString(dispIdMember), hr); return hr; } - - pDispatch = vr.pdispVal; + pDispatch = vr.pdispVal; hr = pDispatch->lpVtbl->QueryInterface(pDispatch, &IID_IRDPSRAPIAttendee, (void**) &pAttendee); if (FAILED(hr)) { WLog_INFO(TAG, "%s IDispatch::QueryInterface(IRDPSRAPIAttendee) failure: 0x%08lX", - GetRDPSessionEventString(dispIdMember), hr); + GetRDPSessionEventString(dispIdMember), hr); return hr; } @@ -384,7 +382,7 @@ static HRESULT STDMETHODCALLTYPE Shadow_IRDPSessionEvents_Invoke( if (FAILED(hr)) { WLog_INFO(TAG, "%s IRDPSRAPIAttendee::put_ControlLevel() failure: 0x%08lX", - GetRDPSessionEventString(dispIdMember), hr); + GetRDPSessionEventString(dispIdMember), hr); return hr; } @@ -491,9 +489,7 @@ int win_shadow_wds_wnd_init(winShadowSubsystem* subsystem) HMODULE hModule; HINSTANCE hInstance; WNDCLASSEX wndClassEx; - hModule = GetModuleHandle(NULL); - ZeroMemory(&wndClassEx, sizeof(WNDCLASSEX)); wndClassEx.cbSize = sizeof(WNDCLASSEX); wndClassEx.style = 0; @@ -515,9 +511,8 @@ int win_shadow_wds_wnd_init(winShadowSubsystem* subsystem) } hInstance = wndClassEx.hInstance; - subsystem->hWnd = CreateWindowEx(0, wndClassEx.lpszClassName, - 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hInstance, NULL); + 0, 0, 0, 0, 0, 0, HWND_MESSAGE, 0, hInstance, NULL); if (!subsystem->hWnd) { @@ -541,15 +536,12 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) BSTR bstrAuthString; BSTR bstrGroupName; BSTR bstrPassword; - BSTR bstrConnectionString; BSTR bstrPropertyName; VARIANT varPropertyValue; rdpAssistanceFile* file; IConnectionPoint* pCP; IConnectionPointContainer* pCPC; - win_shadow_wds_wnd_init(subsystem); - hr = OleInitialize(NULL); if (FAILED(hr)) @@ -567,7 +559,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) } hr = CoCreateInstance(&CLSID_RDPSession, NULL, CLSCTX_ALL, - &IID_IRDPSRAPISharingSession, (void**) &(subsystem->pSharingSession)); + &IID_IRDPSRAPISharingSession, (void**) & (subsystem->pSharingSession)); if (FAILED(hr)) { @@ -588,14 +580,14 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) if (FAILED(hr)) { - WLog_ERR(TAG, "IConnectionPointContainer::FindConnectionPoint(_IRDPSessionEvents) failure: 0x%08lX", hr); + WLog_ERR(TAG, "IConnectionPointContainer::FindConnectionPoint(_IRDPSessionEvents) failure: 0x%08lX", + hr); return -1; } dwCookie = 0; subsystem->pSessionEvents = &Shadow_IRDPSessionEvents; subsystem->pSessionEvents->lpVtbl->AddRef(subsystem->pSessionEvents); - hr = pCP->lpVtbl->Advise(pCP, (IUnknown*) subsystem->pSessionEvents, &dwCookie); if (FAILED(hr)) @@ -613,7 +605,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) } hr = subsystem->pSharingSession->lpVtbl->GetDesktopSharedRect(subsystem->pSharingSession, - &left, &top, &right, &bottom); + &left, &top, &right, &bottom); if (FAILED(hr)) { @@ -623,12 +615,11 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) width = right - left; height = bottom - top; - - WLog_INFO(TAG, "GetDesktopSharedRect(): left: %ld top: %ld right: %ld bottom: %ld width: %ld height: %ld", - left, top, right, bottom, width, height); - + WLog_INFO(TAG, + "GetDesktopSharedRect(): left: %ld top: %ld right: %ld bottom: %ld width: %ld height: %ld", + left, top, right, bottom, width, height); hr = subsystem->pSharingSession->lpVtbl->get_VirtualChannelManager(subsystem->pSharingSession, - &(subsystem->pVirtualChannelMgr)); + &(subsystem->pVirtualChannelMgr)); if (FAILED(hr)) { @@ -637,7 +628,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) } hr = subsystem->pSharingSession->lpVtbl->get_ApplicationFilter(subsystem->pSharingSession, - &(subsystem->pApplicationFilter)); + &(subsystem->pApplicationFilter)); if (FAILED(hr)) { @@ -646,7 +637,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) } hr = subsystem->pSharingSession->lpVtbl->get_Attendees(subsystem->pSharingSession, - &(subsystem->pAttendeeMgr)); + &(subsystem->pAttendeeMgr)); if (FAILED(hr)) { @@ -654,7 +645,8 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) return -1; } - hr = subsystem->pSharingSession->lpVtbl->get_Properties(subsystem->pSharingSession, &(subsystem->pSessionProperties)); + hr = subsystem->pSharingSession->lpVtbl->get_Properties(subsystem->pSharingSession, + &(subsystem->pSessionProperties)); if (FAILED(hr)) { @@ -665,10 +657,8 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) bstrPropertyName = SysAllocString(L"PortId"); varPropertyValue.vt = VT_I4; varPropertyValue.intVal = 40000; - hr = subsystem->pSessionProperties->lpVtbl->put_Property(subsystem->pSessionProperties, - bstrPropertyName, varPropertyValue); - + bstrPropertyName, varPropertyValue); SysFreeString(bstrPropertyName); if (FAILED(hr)) @@ -680,10 +670,8 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) bstrPropertyName = SysAllocString(L"DrvConAttach"); varPropertyValue.vt = VT_BOOL; varPropertyValue.boolVal = VARIANT_TRUE; - hr = subsystem->pSessionProperties->lpVtbl->put_Property(subsystem->pSessionProperties, - bstrPropertyName, varPropertyValue); - + bstrPropertyName, varPropertyValue); SysFreeString(bstrPropertyName); if (FAILED(hr)) @@ -694,14 +682,11 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) bstrPropertyName = SysAllocString(L"PortProtocol"); varPropertyValue.vt = VT_I4; - //varPropertyValue.intVal = 0; // AF_UNSPEC varPropertyValue.intVal = 2; // AF_INET //varPropertyValue.intVal = 23; // AF_INET6 - hr = subsystem->pSessionProperties->lpVtbl->put_Property(subsystem->pSessionProperties, - bstrPropertyName, varPropertyValue); - + bstrPropertyName, varPropertyValue); SysFreeString(bstrPropertyName); if (FAILED(hr)) @@ -719,7 +704,7 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) } hr = subsystem->pSharingSession->lpVtbl->get_Invitations(subsystem->pSharingSession, - &(subsystem->pInvitationMgr)); + &(subsystem->pInvitationMgr)); if (FAILED(hr)) { @@ -730,10 +715,8 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) bstrAuthString = SysAllocString(L"Shadow"); bstrGroupName = SysAllocString(L"ShadowGroup"); bstrPassword = SysAllocString(L"Shadow123!"); - hr = subsystem->pInvitationMgr->lpVtbl->CreateInvitation(subsystem->pInvitationMgr, bstrAuthString, - bstrGroupName, bstrPassword, 5, &(subsystem->pInvitation)); - + bstrGroupName, bstrPassword, 5, &(subsystem->pInvitation)); SysFreeString(bstrAuthString); SysFreeString(bstrGroupName); SysFreeString(bstrPassword); @@ -744,14 +727,6 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) return -1; } - hr = subsystem->pInvitation->lpVtbl->get_ConnectionString(subsystem->pInvitation, &bstrConnectionString); - - if (FAILED(hr)) - { - WLog_ERR(TAG, "IRDPSRAPIInvitation::get_ConnectionString() failure: 0x%08lX", hr); - return -1; - } - file = subsystem->pAssistanceFile = freerdp_assistance_file_new(); if (!file) @@ -760,43 +735,33 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) return -1; } - status = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) bstrConnectionString, - ((UINT32*) bstrConnectionString)[-1], &(file->ConnectionString2), 0, NULL, NULL); - - SysFreeString(bstrConnectionString); - - if (status < 1) { - WLog_ERR(TAG, "failed to convert connection string"); - return -1; - } - - status = freerdp_assistance_parse_connection_string2(file); + int status1 = -1, status2 = -1; + char* ConnectionString2; + BSTR bstrConnectionString; + hr = subsystem->pInvitation->lpVtbl->get_ConnectionString(subsystem->pInvitation, + &bstrConnectionString); - if (status < 0) - return -1; - - WLog_INFO(TAG, "ConnectionString: %s", file->ConnectionString2); - -#if 0 - FILE* fp; - size_t size; + if (FAILED(hr)) + { + WLog_ERR(TAG, "IRDPSRAPIInvitation::get_ConnectionString() failure: 0x%08lX", hr); + return -1; + } - fp = fopen("inv.xml", "w+b"); + status1 = ConvertFromUnicode(CP_UTF8, 0, (WCHAR*) bstrConnectionString, + ((UINT32*) bstrConnectionString)[-1], &(ConnectionString2), 0, NULL, NULL); + SysFreeString(bstrConnectionString); + status2 = freerdp_assistance_set_connection_string2(file, ConnectionString2, "Shadow123!"); + free(ConnectionString2); - if (fp) - { - size = strlen(file->ConnectionString2); - if (fwrite(file->ConnectionString2, size, 1, fp) != 1 || fwrite("\r\n", 2, 1, fp) != 1) + if ((status1 < 1) || (status < 0)) { - fclose(fp); - WLog_ERR(TAG, "Problem writing to inv.xml"); + WLog_ERR(TAG, "failed to convert connection string"); return -1; } - fclose(fp); } -#endif + freerdp_assistance_print_file(file, WLog_Get(TAG), WLOG_INFO); status = win_shadow_rdp_init(subsystem); if (status < 0) @@ -806,24 +771,12 @@ int win_shadow_wds_init(winShadowSubsystem* subsystem) } settings = subsystem->shw->settings; - - freerdp_set_param_bool(settings, FreeRDP_RemoteAssistanceMode, TRUE); - - freerdp_set_param_string(settings, FreeRDP_RemoteAssistanceSessionId, file->RASessionId); - - freerdp_set_param_string(settings, FreeRDP_RemoteAssistanceRCTicket, file->ConnectionString2); - + status = freerdp_assistance_populate_settings_from_assistance_file(file, settings); freerdp_set_param_string(settings, FreeRDP_Domain, "RDP"); freerdp_set_param_string(settings, FreeRDP_Username, "Shadow"); - freerdp_set_param_string(settings, FreeRDP_RemoteAssistancePassword, "Shadow123!"); freerdp_set_param_bool(settings, FreeRDP_AutoLogonEnabled, TRUE); - - freerdp_set_param_string(settings, FreeRDP_ServerHostname, file->MachineAddress); - freerdp_set_param_uint32(settings, FreeRDP_ServerPort, file->MachinePort); - freerdp_set_param_uint32(settings, FreeRDP_DesktopWidth, width); freerdp_set_param_uint32(settings, FreeRDP_DesktopHeight, height); - status = win_shadow_rdp_start(subsystem); if (status < 0) -- 2.7.4