25 #include <winpr/stream.h>
26 #include <winpr/sspi.h>
28 #include <freerdp/api.h>
29 #include <freerdp/types.h>
30 #include <freerdp/error.h>
31 #include <freerdp/event.h>
33 #include <freerdp/settings.h>
35 #include <freerdp/gdi/gdi.h>
36 #include <freerdp/codecs.h>
37 #include <freerdp/metrics.h>
38 #include <freerdp/extension.h>
39 #include <freerdp/heartbeat.h>
40 #include <freerdp/message.h>
41 #include <freerdp/autodetect.h>
42 #include <freerdp/streamdump.h>
50 typedef struct rdp_rail rdpRail;
55 typedef RDP_CLIENT_ENTRY_POINTS_V1 RDP_CLIENT_ENTRY_POINTS;
57 #include <freerdp/utils/smartcardlogon.h>
58 #include <freerdp/update.h>
59 #include <freerdp/input.h>
60 #include <freerdp/graphics.h>
62 #define MCS_BASE_CHANNEL_ID 1001
63 #define MCS_GLOBAL_CHANNEL_ID 1003
66 #define VERIFY_CERT_FLAG_NONE 0x00
67 #define VERIFY_CERT_FLAG_LEGACY 0x02
68 #define VERIFY_CERT_FLAG_REDIRECT 0x10
69 #define VERIFY_CERT_FLAG_GATEWAY 0x20
70 #define VERIFY_CERT_FLAG_CHANGED 0x40
71 #define VERIFY_CERT_FLAG_MISMATCH 0x80
72 #define VERIFY_CERT_FLAG_MATCH_LEGACY_SHA1 0x100
73 #define VERIFY_CERT_FLAG_FP_IS_PEM 0x200
76 #define GATEWAY_MESSAGE_CONSENT 1
77 #define GATEWAY_MESSAGE_SERVICE 2
90 typedef BOOL (*pContextNew)(freerdp* instance, rdpContext* context);
91 typedef void (*pContextFree)(freerdp* instance, rdpContext* context);
93 typedef BOOL (*pConnectCallback)(freerdp* instance);
94 typedef void (*pPostDisconnect)(freerdp* instance);
109 typedef BOOL (*pAuthenticate)(freerdp* instance,
char** username,
char** password,
126 typedef BOOL (*pAuthenticateEx)(freerdp* instance,
char** username,
char** password,
127 char** domain, rdp_auth_reason reason);
128 typedef BOOL (*pChooseSmartcard)(freerdp* instance,
SmartcardCertInfo** cert_list, DWORD count,
129 DWORD* choice, BOOL gateway);
133 ACCESS_TOKEN_TYPE_AAD,
134 ACCESS_TOKEN_TYPE_AVD
137 typedef BOOL (*pGetAccessToken)(freerdp* instance, AccessTokenType tokenType,
char** token,
151 typedef SSIZE_T (*pRetryDialog)(freerdp* instance,
const char* what,
size_t current,
169 #if defined(WITH_FREERDP_DEPRECATED)
170 typedef WINPR_DEPRECATED_VAR(
171 "Use pVerifyCertificateEx",
172 DWORD (*pVerifyCertificate)(freerdp* instance,
const char* common_name,
const char* subject,
173 const char* issuer,
const char* fingerprint,
174 BOOL host_mismatch));
192 typedef DWORD (*pVerifyCertificateEx)(freerdp* instance,
const char* host, UINT16 port,
193 const char* common_name,
const char* subject,
194 const char* issuer,
const char* fingerprint, DWORD flags);
211 #if defined(WITH_FREERDP_DEPRECATED)
212 typedef WINPR_DEPRECATED_VAR(
213 "Use pVerifyChangedCertificateEx",
214 DWORD (*pVerifyChangedCertificate)(freerdp* instance,
const char* common_name,
215 const char* subject,
const char* issuer,
216 const char* new_fingerprint,
const char* old_subject,
217 const char* old_issuer,
const char* old_fingerprint));
240 typedef DWORD (*pVerifyChangedCertificateEx)(freerdp* instance,
const char* host, UINT16 port,
241 const char* common_name,
const char* subject,
242 const char* issuer,
const char* new_fingerprint,
243 const char* old_subject,
const char* old_issuer,
244 const char* old_fingerprint, DWORD flags);
259 typedef int (*pVerifyX509Certificate)(freerdp* instance,
const BYTE* data,
size_t length,
260 const char* hostname, UINT16 port, DWORD flags);
262 typedef int (*pLogonErrorInfo)(freerdp* instance, UINT32 data, UINT32 type);
264 typedef BOOL (*pSendChannelData)(freerdp* instance, UINT16 channelId,
const BYTE* data,
266 typedef BOOL (*pSendChannelPacket)(freerdp* instance, UINT16 channelId,
size_t totalSize,
267 UINT32 flags,
const BYTE* data,
size_t chunkSize);
268 typedef BOOL (*pReceiveChannelData)(freerdp* instance, UINT16 channelId,
const BYTE* data,
269 size_t size, UINT32 flags,
size_t totalSize);
272 typedef BOOL (*pPresentGatewayMessage)(freerdp* instance, UINT32 type, BOOL isDisplayMandatory,
273 BOOL isConsentMandatory,
size_t length,
274 const WCHAR* message);
293 ALIGN64 UINT32 LastError;
295 UINT64 paddingA[16 - 4];
308 ALIGN64 wPubSub* pubSub;
310 ALIGN64 HANDLE channelErrorEvent;
311 ALIGN64 UINT channelErrorNum;
312 ALIGN64
char* errorDescription;
314 UINT64 paddingB[32 - 22];
326 ALIGN64 rdpRail* rail;
327 ALIGN64 rdpCache* cache;
328 ALIGN64 rdpChannels* channels;
329 ALIGN64 rdpGraphics* graphics;
330 ALIGN64 rdpInput* input;
331 ALIGN64 rdpUpdate* update;
332 ALIGN64 rdpSettings* settings;
333 ALIGN64 rdpMetrics* metrics;
334 ALIGN64 rdpCodecs* codecs;
335 ALIGN64 rdpAutoDetect* autodetect;
336 UINT64 paddingC1[45 - 44];
337 ALIGN64
int disconnectUltimatum;
338 UINT64 paddingC[64 - 46];
340 ALIGN64 rdpStreamDumpContext* dump;
343 UINT64 paddingD[96 - 66];
344 UINT64 paddingE[128 - 96];
352 enum Disconnect_Ultimatum
354 Disconnect_Ultimatum_domain_disconnected = 0,
355 Disconnect_Ultimatum_provider_initiated = 1,
356 Disconnect_Ultimatum_token_purged = 2,
357 Disconnect_Ultimatum_user_requested = 3,
358 Disconnect_Ultimatum_channel_purged = 4
361 #include <freerdp/client.h>
383 ALIGN64 RDP_CLIENT_ENTRY_POINTS* pClientEntryPoints;
385 UINT64 paddingA[16 - 2];
387 #if defined(WITH_FREERDP_DEPRECATED)
388 WINPR_DEPRECATED_VAR(
"use rdpContext::input instead", ALIGN64 rdpInput* input;)
391 WINPR_DEPRECATED_VAR(
"use rdpContext::update instead",
392 ALIGN64 rdpUpdate* update;)
395 WINPR_DEPRECATED_VAR(
"use rdpContext::settings instead",
396 ALIGN64 rdpSettings* settings;)
402 WINPR_DEPRECATED_VAR(
"use rdpContext::autodetect instead",
403 ALIGN64 rdpAutoDetect* autodetect;)
410 ALIGN64 rdpHeartbeat* heartbeat;
412 UINT64 paddingB[32 - 21];
436 UINT64 paddingC[47 - 35];
438 ALIGN64 UINT ConnectionCallbackState;
440 ALIGN64 pConnectCallback
446 ALIGN64 pConnectCallback
456 #if defined(WITH_FREERDP_DEPRECATED)
457 WINPR_DEPRECATED_VAR(
"Use VerifyCertificateEx or VerifyX509Certificate instead",
458 ALIGN64 pVerifyCertificate VerifyCertificate;)
459 WINPR_DEPRECATED_VAR(
"Use VerifyChangedCertificateEx or VerifyX509Certificate instead",
460 ALIGN64 pVerifyChangedCertificate
461 VerifyChangedCertificate;)
463 ALIGN64 UINT64 reserved[2];
465 ALIGN64 pVerifyX509Certificate
469 ALIGN64 pLogonErrorInfo
473 ALIGN64 pPostDisconnect
497 ALIGN64 pConnectCallback
502 ALIGN64 pPostDisconnect
511 ALIGN64 pSendChannelData
516 ALIGN64 pReceiveChannelData
523 ALIGN64 pVerifyCertificateEx
527 ALIGN64 pVerifyChangedCertificateEx
531 ALIGN64 pSendChannelPacket
541 ALIGN64 pChooseSmartcard
546 ALIGN64 pGetAccessToken GetAccessToken;
549 ALIGN64 pRetryDialog RetryDialog;
551 UINT64 paddingE[80 - 73];
556 wListDictionary* init;
557 wListDictionary* open;
561 FREERDP_API
void freerdp_context_free(freerdp* instance);
563 FREERDP_API BOOL freerdp_context_new(freerdp* instance);
564 FREERDP_API BOOL freerdp_context_new_ex(freerdp* instance, rdpSettings* settings);
566 FREERDP_API BOOL freerdp_context_reset(freerdp* instance);
568 FREERDP_API BOOL freerdp_connect(freerdp* instance);
570 WINPR_DEPRECATED_VAR(
"use freerdp_abort_connect_context instead",
571 FREERDP_API BOOL freerdp_abort_connect(freerdp* instance));
573 FREERDP_API BOOL freerdp_abort_connect_context(rdpContext* context);
574 FREERDP_API HANDLE freerdp_abort_event(rdpContext* context);
576 WINPR_DEPRECATED_VAR(
"use freerdp_shall_disconnect_context instead",
577 FREERDP_API BOOL freerdp_shall_disconnect(freerdp* instance));
579 FREERDP_API BOOL freerdp_shall_disconnect_context(
const rdpContext* context);
580 FREERDP_API BOOL freerdp_disconnect(freerdp* instance);
582 WINPR_DEPRECATED_VAR(
"use freerdp_disconnect_before_reconnect_context instead",
583 FREERDP_API BOOL freerdp_disconnect_before_reconnect(freerdp* instance));
584 FREERDP_API BOOL freerdp_disconnect_before_reconnect_context(rdpContext* context);
586 FREERDP_API BOOL freerdp_reconnect(freerdp* instance);
588 FREERDP_API UINT freerdp_channels_attach(freerdp* instance);
589 FREERDP_API UINT freerdp_channels_detach(freerdp* instance);
591 #if defined(WITH_FREERDP_DEPRECATED)
592 FREERDP_API WINPR_DEPRECATED_VAR(
"Use freerdp_get_event_handles",
593 BOOL freerdp_get_fds(freerdp* instance,
void** rfds,
594 int* rcount,
void** wfds,
int* wcount));
597 FREERDP_API BOOL freerdp_check_fds(freerdp* instance);
599 FREERDP_API DWORD freerdp_get_event_handles(rdpContext* context, HANDLE* events, DWORD count);
600 FREERDP_API BOOL freerdp_check_event_handles(rdpContext* context);
602 FREERDP_API wMessageQueue* freerdp_get_message_queue(freerdp* instance, DWORD
id);
603 FREERDP_API HANDLE freerdp_get_message_queue_event_handle(freerdp* instance, DWORD
id);
604 FREERDP_API
int freerdp_message_queue_process_message(freerdp* instance, DWORD
id,
606 FREERDP_API
int freerdp_message_queue_process_pending_messages(freerdp* instance, DWORD
id);
608 FREERDP_API UINT32 freerdp_error_info(freerdp* instance);
609 FREERDP_API
void freerdp_set_error_info(rdpRdp* rdp, UINT32 error);
610 FREERDP_API BOOL freerdp_send_error_info(rdpRdp* rdp);
611 FREERDP_API BOOL freerdp_get_stats(rdpRdp* rdp, UINT64* inBytes, UINT64* outBytes,
612 UINT64* inPackets, UINT64* outPackets);
614 FREERDP_API
void freerdp_get_version(
int* major,
int* minor,
int* revision);
615 FREERDP_API
const char* freerdp_get_version_string(
void);
616 FREERDP_API
const char* freerdp_get_build_revision(
void);
617 FREERDP_API
const char* freerdp_get_build_config(
void);
619 FREERDP_API
void freerdp_free(freerdp* instance);
621 WINPR_ATTR_MALLOC(freerdp_free, 1)
622 FREERDP_API freerdp* freerdp_new(
void);
624 FREERDP_API BOOL freerdp_focus_required(freerdp* instance);
625 FREERDP_API
void freerdp_set_focus(freerdp* instance);
627 FREERDP_API
int freerdp_get_disconnect_ultimatum(rdpContext* context);
629 FREERDP_API UINT32 freerdp_get_last_error(rdpContext* context);
630 FREERDP_API const
char* freerdp_get_last_error_name(UINT32 error);
631 FREERDP_API const
char* freerdp_get_last_error_string(UINT32 error);
632 FREERDP_API const
char* freerdp_get_last_error_category(UINT32 error);
634 #define freerdp_set_last_error(context, lastError) \
635 freerdp_set_last_error_ex((context), (lastError), __func__, __FILE__, __LINE__)
637 #define freerdp_set_last_error_if_not(context, lastError) \
640 if (freerdp_get_last_error(context) == FREERDP_ERROR_SUCCESS) \
641 freerdp_set_last_error_log(context, lastError); \
644 #define freerdp_set_last_error_log(context, lastError) \
645 freerdp_set_last_error_ex((context), (lastError), __func__, __FILE__, __LINE__)
646 FREERDP_API
void freerdp_set_last_error_ex(rdpContext* context, UINT32 lastError,
647 const char* fkt,
const char* file,
int line);
649 FREERDP_API
const char* freerdp_get_logon_error_info_type(UINT32 type);
650 FREERDP_API
const char* freerdp_get_logon_error_info_type_ex(UINT32 type,
char* buffer,
653 FREERDP_API
const char* freerdp_get_logon_error_info_data(UINT32 data);
654 FREERDP_API
const char* freerdp_get_logon_error_info_data_ex(UINT32 data,
char* buffer,
657 FREERDP_API ULONG freerdp_get_transport_sent(rdpContext* context, BOOL resetCount);
659 FREERDP_API BOOL freerdp_nla_impersonate(rdpContext* context);
660 FREERDP_API BOOL freerdp_nla_revert_to_self(rdpContext* context);
662 FREERDP_API UINT32 freerdp_get_nla_sspi_error(rdpContext* context);
672 FREERDP_API BOOL freerdp_nla_encrypt(rdpContext* context,
const SecBuffer* inBuffer,
683 FREERDP_API BOOL freerdp_nla_decrypt(rdpContext* context,
const SecBuffer* inBuffer,
695 FREERDP_API SECURITY_STATUS freerdp_nla_QueryContextAttributes(rdpContext* context,
696 DWORD ulAttr, PVOID pBuffer);
698 FREERDP_API
void clearChannelError(rdpContext* context);
699 FREERDP_API HANDLE getChannelErrorEventHandle(rdpContext* context);
700 FREERDP_API UINT getChannelError(rdpContext* context);
701 FREERDP_API
const char* getChannelErrorDescription(rdpContext* context);
702 FREERDP_API
void setChannelError(rdpContext* context, UINT errorNum,
const char* format, ...);
703 FREERDP_API BOOL checkChannelErrorEvent(rdpContext* context);
705 FREERDP_API
const char* freerdp_nego_get_routing_token(rdpContext* context, DWORD* length);
713 FREERDP_API CONNECTION_STATE freerdp_get_state(
const rdpContext* context);
721 FREERDP_API
const char* freerdp_state_string(CONNECTION_STATE state);
732 FREERDP_API BOOL freerdp_is_active_state(
const rdpContext* context);
734 FREERDP_API BOOL freerdp_channels_from_mcs(rdpSettings* settings,
const rdpContext* context);
736 FREERDP_API BOOL freerdp_is_valid_mcs_create_request(
const BYTE* data,
size_t size);
737 FREERDP_API BOOL freerdp_is_valid_mcs_create_response(
const BYTE* data,
size_t size);
ALIGN64 freerdp_peer * peer
ALIGN64 freerdp * instance
ALIGN64 pConnectCallback LoadChannels
ALIGN64 pVerifyChangedCertificateEx VerifyChangedCertificateEx
ALIGN64 pVerifyCertificateEx VerifyCertificateEx
ALIGN64 pConnectCallback Redirect
ALIGN64 pConnectCallback PostConnect
ALIGN64 pAuthenticateEx AuthenticateEx
ALIGN64 pPostDisconnect PostDisconnect
ALIGN64 pLogonErrorInfo LogonErrorInfo
ALIGN64 rdpContext * context
ALIGN64 pAuthenticate Authenticate
ALIGN64 pAuthenticate GatewayAuthenticate
ALIGN64 pContextFree ContextFree
ALIGN64 pVerifyX509Certificate VerifyX509Certificate
ALIGN64 pConnectCallback PreConnect
ALIGN64 pContextNew ContextNew
ALIGN64 pPresentGatewayMessage PresentGatewayMessage