diff --git a/client/X11/cli/xfreerdp.c b/client/X11/cli/xfreerdp.c index a286c383a..a919c5360 100644 --- a/client/X11/cli/xfreerdp.c +++ b/client/X11/cli/xfreerdp.c @@ -34,6 +34,7 @@ int main(int argc, char* argv[]) { + HANDLE thread; xfContext* xfc; DWORD dwExitCode; rdpContext* context; @@ -69,9 +70,11 @@ int main(int argc, char* argv[]) freerdp_client_start(context); - WaitForSingleObject(xfc->thread, INFINITE); + thread = freerdp_client_get_thread(context); - GetExitCodeThread(xfc->thread, &dwExitCode); + WaitForSingleObject(thread, INFINITE); + + GetExitCodeThread(thread, &dwExitCode); freerdp_client_stop(context); diff --git a/client/X11/xf_interface.c b/client/X11/xf_interface.c index 86d3c1e03..67f49f250 100644 --- a/client/X11/xf_interface.c +++ b/client/X11/xf_interface.c @@ -1550,17 +1550,6 @@ int xfreerdp_client_stop(rdpContext* context) return 0; } -freerdp* freerdp_client_get_instance(rdpContext* context) -{ - return context->instance; -} - -HANDLE freerdp_client_get_thread(rdpContext* context) -{ - xfContext* xfc = (xfContext*) context; - return xfc->thread; -} - rdpClient* freerdp_client_get_interface(rdpContext* context) { return context->client; diff --git a/client/X11/xfreerdp.h b/client/X11/xfreerdp.h index 54bd5dbab..fc1563ec4 100644 --- a/client/X11/xfreerdp.h +++ b/client/X11/xfreerdp.h @@ -59,6 +59,7 @@ typedef struct xf_glyph xfGlyph; struct xf_context { rdpContext context; + DEFINE_RDP_CLIENT_COMMON(); freerdp* instance; rdpClient* client; @@ -95,7 +96,6 @@ struct xf_context BOOL disconnect; HCLRCONV clrconv; HANDLE mutex; - HANDLE thread; BOOL UseXThreads; HGDI_DC hdc; diff --git a/client/common/client.c b/client/common/client.c index 560cbb065..629c9c6f3 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -26,59 +26,6 @@ #include #include -freerdp* freerdp_client_get_instance(rdpContext* context) -{ - return context->instance; -} - -BOOL freerdp_client_get_param_bool(rdpContext* context, int id) -{ - rdpSettings* settings = context->settings; - return freerdp_get_param_bool(settings, id); -} - -int freerdp_client_set_param_bool(rdpContext* context, int id, BOOL param) -{ - rdpSettings* settings = context->settings; - return freerdp_set_param_bool(settings, id, param); -} - -UINT32 freerdp_client_get_param_uint32(rdpContext* context, int id) -{ - rdpSettings* settings = context->settings; - return freerdp_get_param_uint32(settings, id); -} - -int freerdp_client_set_param_uint32(rdpContext* context, int id, UINT32 param) -{ - rdpSettings* settings = context->settings; - return freerdp_set_param_uint32(settings, id, param); -} - -UINT64 freerdp_client_get_param_uint64(rdpContext* context, int id) -{ - rdpSettings* settings = context->settings; - return freerdp_get_param_uint64(settings, id); -} - -int freerdp_client_set_param_uint64(rdpContext* context, int id, UINT64 param) -{ - rdpSettings* settings = context->settings; - return freerdp_set_param_uint64(settings, id, param); -} - -char* freerdp_client_get_param_string(rdpContext* context, int id) -{ - rdpSettings* settings = context->settings; - return freerdp_get_param_string(settings, id); -} - -int freerdp_client_set_param_string(rdpContext* context, int id, char* param) -{ - rdpSettings* settings = context->settings; - return freerdp_set_param_string(settings, id, param); -} - /* Common API */ rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints) @@ -122,6 +69,16 @@ int freerdp_client_stop(rdpContext* context) return client->pEntryPoints->ClientStop(context); } +freerdp* freerdp_client_get_instance(rdpContext* context) +{ + return context->instance; +} + +HANDLE freerdp_client_get_thread(rdpContext* context) +{ + return ((rdpClientContext*) context)->thread; +} + int freerdp_client_parse_command_line(rdpContext* context, int argc, char** argv) { int status; diff --git a/include/freerdp/client.h b/include/freerdp/client.h index 270ea862a..fe62a5208 100644 --- a/include/freerdp/client.h +++ b/include/freerdp/client.h @@ -20,8 +20,6 @@ #ifndef FREERDP_CLIENT_H #define FREERDP_CLIENT_H -typedef struct rdp_client rdpClient; - #include #include @@ -88,6 +86,16 @@ struct rdp_client pOnParamChange OnParamChange; }; +#define DEFINE_RDP_CLIENT_COMMON() \ + HANDLE thread + +struct rdp_client_context +{ + rdpContext context; + DEFINE_RDP_CLIENT_COMMON(); +}; +typedef struct rdp_client_context rdpClientContext; + /* Common client functions */ FREERDP_API rdpContext* freerdp_client_context_new(RDP_CLIENT_ENTRY_POINTS* pEntryPoints); @@ -96,30 +104,13 @@ FREERDP_API void freerdp_client_context_free(rdpContext* context); FREERDP_API int freerdp_client_start(rdpContext* context); FREERDP_API int freerdp_client_stop(rdpContext* context); +FREERDP_API freerdp* freerdp_client_get_instance(rdpContext* context); +FREERDP_API HANDLE freerdp_client_get_thread(rdpContext* context); + FREERDP_API int freerdp_client_parse_command_line(rdpContext* context, int argc, char** argv); FREERDP_API int freerdp_client_parse_connection_file(rdpContext* context, char* filename); FREERDP_API int freerdp_client_parse_connection_file_buffer(rdpContext* context, BYTE* buffer, size_t size); -FREERDP_API freerdp* freerdp_client_get_instance(rdpContext* context); -FREERDP_API HANDLE freerdp_client_get_thread(rdpContext* context); -FREERDP_API rdpClient* freerdp_client_get_interface(rdpContext* context); -FREERDP_API double freerdp_client_get_scale(rdpContext* context); -FREERDP_API void freerdp_client_reset_scale(rdpContext* context); - -FREERDP_API BOOL freerdp_client_get_param_bool(rdpContext* context, int id); -FREERDP_API int freerdp_client_set_param_bool(rdpContext* context, int id, BOOL param); - -FREERDP_API UINT32 freerdp_client_get_param_uint32(rdpContext* context, int id); -FREERDP_API int freerdp_client_set_param_uint32(rdpContext* context, int id, UINT32 param); - -FREERDP_API UINT64 freerdp_client_get_param_uint64(rdpContext* context, int id); -FREERDP_API int freerdp_client_set_param_uint64(rdpContext* context, int id, UINT64 param); - -FREERDP_API char* freerdp_client_get_param_string(rdpContext* context, int id); -FREERDP_API int freerdp_client_set_param_string(rdpContext* context, int id, char* param); - -FREERDP_API void freerdp_client_mouse_event(rdpContext* context, DWORD flags, int x, int y); - #ifdef __cplusplus } #endif diff --git a/include/freerdp/freerdp.h b/include/freerdp/freerdp.h index 17a7240f4..c6438c5e6 100644 --- a/include/freerdp/freerdp.h +++ b/include/freerdp/freerdp.h @@ -26,10 +26,12 @@ typedef struct rdp_rail rdpRail; typedef struct rdp_cache rdpCache; typedef struct rdp_channels rdpChannels; typedef struct rdp_graphics rdpGraphics; +typedef struct rdp_client rdpClient; typedef struct rdp_freerdp freerdp; typedef struct rdp_context rdpContext; typedef struct rdp_freerdp_peer freerdp_peer; +typedef struct rdp_client_context rdpClientContext; #include #include @@ -39,8 +41,6 @@ typedef struct rdp_freerdp_peer freerdp_peer; #include -#include - #include #include #include @@ -73,46 +73,51 @@ typedef int (*pOnChannelDisconnected)(freerdp* instance, const char* name, void* */ struct rdp_context { - freerdp* instance; /**< (offset 0) + ALIGN64 freerdp* instance; /**< (offset 0) Pointer to a rdp_freerdp structure. This is a back-link to retrieve the freerdp instance from the context. It is set by the freerdp_context_new() function */ - freerdp_peer* peer; /**< (offset 1) + ALIGN64 freerdp_peer* peer; /**< (offset 1) Pointer to the client peer. This is set by a call to freerdp_peer_context_new() during peer initialization. This field is used only on the server side. */ - UINT32 paddingA[16 - 2]; /* 2 */ + UINT64 paddingA[16 - 2]; /* 2 */ - int argc; /**< (offset 16) + ALIGN64 int argc; /**< (offset 16) Number of arguments given to the program at launch time. Used to keep this data available and used later on, typically just before connection initialization. @see freerdp_parse_args() */ - char** argv; /**< (offset 17) + ALIGN64 char** argv; /**< (offset 17) List of arguments given to the program at launch time. Used to keep this data available and used later on, typically just before connection initialization. @see freerdp_parse_args() */ - UINT32 paddingB[32 - 18]; /* 18 */ + UINT64 paddingB[32 - 18]; /* 18 */ - rdpRdp* rdp; /**< (offset 32) + ALIGN64 rdpRdp* rdp; /**< (offset 32) Pointer to a rdp_rdp structure used to keep the connection's parameters. It is allocated by freerdp_context_new() and deallocated by freerdp_context_free(), at the same time that this rdp_context structure - there is no need to specifically allocate/deallocate this. */ - rdpGdi* gdi; /**< (offset 33) + ALIGN64 rdpGdi* gdi; /**< (offset 33) Pointer to a rdp_gdi structure used to keep the gdi settings. It is allocated by gdi_init() and deallocated by gdi_free(). It must be deallocated before deallocating this rdp_context structure. */ - rdpRail* rail; /* 34 */ - rdpCache* cache; /* 35 */ - rdpChannels* channels; /* 36 */ - rdpGraphics* graphics; /* 37 */ - rdpInput* input; /* 38 */ - rdpUpdate* update; /* 39 */ - rdpSettings* settings; /* 40 */ - rdpClient* client; /* 41 */ - UINT32 paddingC[64 - 42]; /* 42 */ + ALIGN64 rdpRail* rail; /* 34 */ + ALIGN64 rdpCache* cache; /* 35 */ + ALIGN64 rdpChannels* channels; /* 36 */ + ALIGN64 rdpGraphics* graphics; /* 37 */ + ALIGN64 rdpInput* input; /* 38 */ + ALIGN64 rdpUpdate* update; /* 39 */ + ALIGN64 rdpSettings* settings; /* 40 */ + ALIGN64 rdpClient* client; /* 41 */ + UINT64 paddingC[64 - 42]; /* 42 */ + + UINT64 paddingD[96 - 64]; /* 64 */ + UINT64 paddingE[128 - 96]; /* 96 */ }; +#include + /** Defines the options for a given instance of RDP connection. * This is built by the client and given to the FreeRDP library to create the connection * with the expected options. @@ -121,7 +126,7 @@ struct rdp_context */ struct rdp_freerdp { - rdpContext* context; /**< (offset 0) + ALIGN64 rdpContext* context; /**< (offset 0) Pointer to a rdpContext structure. Client applications can use the ContextSize field to register a context bigger than the rdpContext structure. This allow clients to use additional context information. @@ -130,20 +135,20 @@ struct rdp_freerdp Can be allocated by a call to freerdp_context_new(). Must be deallocated by a call to freerdp_context_free() before deallocating the current instance. */ - UINT32 paddingA[16 - 1]; /* 1 */ + UINT64 paddingA[16 - 1]; /* 1 */ - rdpInput* input; /* (offset 16) + ALIGN64 rdpInput* input; /* (offset 16) Input handle for the connection. Will be initialized by a call to freerdp_context_new() */ - rdpUpdate* update; /* (offset 17) + ALIGN64 rdpUpdate* update; /* (offset 17) Update display parameters. Used to register display events callbacks and settings. Will be initialized by a call to freerdp_context_new() */ - rdpSettings* settings; /**< (offset 18) + ALIGN64 rdpSettings* settings; /**< (offset 18) Pointer to a rdpSettings structure. Will be used to maintain the required RDP settings. Will be initialized by a call to freerdp_context_new() */ - UINT32 paddingB[32 - 19]; /* 19 */ + UINT64 paddingB[32 - 19]; /* 19 */ - size_t ContextSize; /* (offset 32) + ALIGN64 size_t ContextSize; /* (offset 32) Specifies the size of the 'context' field. freerdp_context_new() will use this size to allocate the context buffer. freerdp_new() sets it to sizeof(rdpContext). If modifying it, there should always be a minimum of sizeof(rdpContext), as the freerdp library will assume it can use the @@ -152,55 +157,55 @@ struct rdp_freerdp adding additional information after that. */ - pContextNew ContextNew; /**< (offset 33) + ALIGN64 pContextNew ContextNew; /**< (offset 33) Callback for context allocation Can be set before calling freerdp_context_new() to have it executed after allocation and initialization. Must be set to NULL if not needed. */ - pContextFree ContextFree; /**< (offset 34) + ALIGN64 pContextFree ContextFree; /**< (offset 34) Callback for context deallocation Can be set before calling freerdp_context_free() to have it executed before deallocation. Must be set to NULL if not needed. */ - UINT32 paddingC[48 - 35]; /* 35 */ + UINT64 paddingC[48 - 35]; /* 35 */ - pPreConnect PreConnect; /**< (offset 48) + ALIGN64 pPreConnect PreConnect; /**< (offset 48) Callback for pre-connect operations. Can be set before calling freerdp_connect() to have it executed before the actual connection happens. Must be set to NULL if not needed. */ - pPostConnect PostConnect; /**< (offset 49) + ALIGN64 pPostConnect PostConnect; /**< (offset 49) Callback for post-connect operations. Can be set before calling freerdp_connect() to have it executed after the actual connection has succeeded. Must be set to NULL if not needed. */ - pAuthenticate Authenticate; /**< (offset 50) + ALIGN64 pAuthenticate Authenticate; /**< (offset 50) Callback for authentication. It is used to get the username/password when it was not provided at connection time. */ - pVerifyCertificate VerifyCertificate; /**< (offset 51) + ALIGN64 pVerifyCertificate VerifyCertificate; /**< (offset 51) Callback for certificate validation. Used to verify that an unknown certificate is trusted. */ - pVerifyChangedCertificate VerifyChangedCertificate; /**< (offset 52) + ALIGN64 pVerifyChangedCertificate VerifyChangedCertificate; /**< (offset 52) Callback for changed certificate validation. Used when a certificate differs from stored fingerprint. If returns TRUE, the new fingerprint will be trusted and old thrown out. */ - pLogonErrorInfo LogonErrorInfo; /**< (offset 53) Callback for logon error info, important for logon system messages with RemoteApp */ + ALIGN64 pLogonErrorInfo LogonErrorInfo; /**< (offset 53) Callback for logon error info, important for logon system messages with RemoteApp */ - UINT32 paddingD[64 - 54]; /* 54 */ + UINT64 paddingD[64 - 54]; /* 54 */ - pSendChannelData SendChannelData; /* (offset 64) + ALIGN64 pSendChannelData SendChannelData; /* (offset 64) Callback for sending data to a channel. By default, it is set by freerdp_new() to freerdp_send_channel_data(), which eventually calls freerdp_channel_send() */ - pReceiveChannelData ReceiveChannelData; /* (offset 65) + ALIGN64 pReceiveChannelData ReceiveChannelData; /* (offset 65) Callback for receiving data from a channel. This is called by freerdp_channel_process() (if not NULL). Clients will typically use a function that calls freerdp_channels_data() to perform the needed tasks. */ - pOnChannelConnected OnChannelConnected; - pOnChannelDisconnected OnChannelDisconnected; + ALIGN64 pOnChannelConnected OnChannelConnected; + ALIGN64 pOnChannelDisconnected OnChannelDisconnected; - UINT32 paddingE[80 - 66]; /* 66 */ + UINT64 paddingE[80 - 66]; /* 66 */ }; FREERDP_API int freerdp_context_new(freerdp* instance); @@ -226,6 +231,7 @@ FREERDP_API freerdp* freerdp_new(void); FREERDP_API void freerdp_free(freerdp* instance); FREERDP_API BOOL freerdp_focus_required(freerdp* instance); + #ifdef __cplusplus } #endif