Permalink
Browse files

Merge pull request #944 from awakecoding/master

TS Gateway Fix, Valgrind Cleanup, Asynchronous Mode (Experimental)
  • Loading branch information...
2 parents 2efb463 + 44bb105 commit 71de03c2e0847df56a8e1ae1dabb45f75cc44062 @awakecoding awakecoding committed Jan 31, 2013
Showing with 3,612 additions and 481 deletions.
  1. +2 −2 channels/client/CMakeLists.txt
  2. +2 −0 channels/client/channels.c
  3. +28 −0 client/X11/xfreerdp.c
  4. +10 −0 client/common/cmdline.c
  5. +3 −0 client/common/compatibility.c
  6. +2 −2 include/freerdp/altsec.h
  7. +13 −2 include/freerdp/freerdp.h
  8. +6 −0 include/freerdp/gdi/gdi.h
  9. +14 −0 include/freerdp/input.h
  10. +3 −3 include/freerdp/secondary.h
  11. +3 −1 include/freerdp/settings.h
  12. +7 −2 include/freerdp/update.h
  13. +9 −1 libfreerdp/cache/brush.c
  14. +2 −8 libfreerdp/cache/glyph.c
  15. +15 −2 libfreerdp/cache/pointer.c
  16. +10 −7 libfreerdp/codec/rfx_sse2.c
  17. +7 −3 libfreerdp/common/settings.c
  18. +4 −0 libfreerdp/core/CMakeLists.txt
  19. +10 −5 libfreerdp/core/capabilities.c
  20. +9 −7 libfreerdp/core/certificate.c
  21. +1 −1 libfreerdp/core/certificate.h
  22. +10 −10 libfreerdp/core/connection.h
  23. +212 −0 libfreerdp/core/event.c
  24. +60 −0 libfreerdp/core/event.h
  25. +38 −3 libfreerdp/core/freerdp.c
  26. +2 −1 libfreerdp/core/gateway/rpc_fault.c
  27. +6 −3 libfreerdp/core/gcc.c
  28. +18 −2 libfreerdp/core/input.c
  29. +2 −0 libfreerdp/core/input.h
  30. +7 −4 libfreerdp/core/license.c
  31. +1,723 −0 libfreerdp/core/message.c
  32. +233 −0 libfreerdp/core/message.h
  33. +17 −15 libfreerdp/core/orders.c
  34. +1 −1 libfreerdp/core/orders.h
  35. +12 −19 libfreerdp/core/transport.c
  36. +0 −2 libfreerdp/core/transport.h
  37. +69 −44 libfreerdp/core/update.c
  38. +5 −0 libfreerdp/core/update.h
  39. +1 −0 libfreerdp/crypto/CMakeLists.txt
  40. +141 −0 libfreerdp/crypto/base64.c
  41. +0 −44 libfreerdp/crypto/crypto.c
  42. +6 −0 libfreerdp/crypto/tls.c
  43. +1 −1 libfreerdp/gdi/32bpp.c
  44. +3 −1 libfreerdp/gdi/gdi.c
  45. +1 −1 libfreerdp/gdi/graphics.c
  46. +1 −1 libfreerdp/locale/CMakeLists.txt
  47. +270 −2 libfreerdp/locale/keyboard_x11.c
  48. +2 −2 server/Mac/mf_peer.c
  49. +1 −0 server/Windows/wf_peer.c
  50. +1 −0 server/X11/xf_peer.c
  51. +38 −0 winpr/include/winpr/collections.h
  52. +0 −4 winpr/include/winpr/pool.h
  53. +2 −2 winpr/include/winpr/sysinfo.h
  54. +2 −0 winpr/libwinpr/registry/registry.c
  55. +18 −1 winpr/libwinpr/sspi/NTLM/ntlm.c
  56. +4 −0 winpr/libwinpr/sspi/NTLM/ntlm.h
  57. +1 −1 winpr/libwinpr/sspi/NTLM/ntlm_av_pairs.c
  58. +5 −2 winpr/libwinpr/sspi/NTLM/ntlm_compute.c
  59. +250 −254 winpr/libwinpr/sspi/NTLM/ntlm_message.c
  60. +43 −12 winpr/libwinpr/sysinfo/sysinfo.c
  61. +2 −1 winpr/libwinpr/utils/CMakeLists.txt
  62. +193 −0 winpr/libwinpr/utils/collections/MessageQueue.c
  63. +3 −2 winpr/libwinpr/utils/test/CMakeLists.txt
  64. +48 −0 winpr/libwinpr/utils/test/TestMessageQueue.c
@@ -46,11 +46,11 @@ foreach(STATIC_ENTRY ${CHANNEL_STATIC_CLIENT_ENTRIES})
set(CLIENT_STATIC_ENTRY_IMPORTS "${CLIENT_STATIC_ENTRY_IMPORTS}\n${${STATIC_ENTRY}_IMPORTS}")
set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\nconst STATIC_ENTRY CLIENT_${STATIC_ENTRY}_TABLE[] =\n{")
set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\n${${STATIC_ENTRY}_TABLE}")
- set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\n\t{ \"\", NULL }\n};")
+ set(CLIENT_STATIC_ENTRY_TABLES "${CLIENT_STATIC_ENTRY_TABLES}\n\t{ NULL, NULL }\n};")
set(CLIENT_STATIC_ENTRY_TABLES_LIST "${CLIENT_STATIC_ENTRY_TABLES_LIST}\n\t{ \"${STATIC_ENTRY}\", CLIENT_${STATIC_ENTRY}_TABLE },")
endforeach()
-set(CLIENT_STATIC_ENTRY_TABLES_LIST "${CLIENT_STATIC_ENTRY_TABLES_LIST}\n\t{ \"\", NULL }\n};")
+set(CLIENT_STATIC_ENTRY_TABLES_LIST "${CLIENT_STATIC_ENTRY_TABLES_LIST}\n\t{ NULL, NULL }\n};")
set(CLIENT_STATIC_ADDIN_TABLE "const STATIC_ADDIN_TABLE CLIENT_STATIC_ADDIN_TABLE[] =\n{")
foreach(STATIC_MODULE ${CHANNEL_STATIC_CLIENT_MODULES})
@@ -358,7 +358,9 @@ void* freerdp_channels_load_static_addin_entry(LPCSTR pszName, LPSTR pszSubsyste
}
}
else
+ {
return (void*) CLIENT_STATIC_ADDIN_TABLE[i].entry;
+ }
}
}
View
@@ -1025,6 +1025,10 @@ int xfreerdp_run(freerdp* instance)
void* wfds[32];
fd_set rfds_set;
fd_set wfds_set;
+ int fd_msg_event;
+ HANDLE msg_event;
+ int fd_evt_event;
+ HANDLE evt_event;
int select_status;
rdpChannels* channels;
struct timeval timeout;
@@ -1051,6 +1055,18 @@ int xfreerdp_run(freerdp* instance)
xfi = ((xfContext*) instance->context)->xfi;
channels = instance->context->channels;
+ fd_msg_event = -1;
+ msg_event = freerdp_get_message_queue_event_handle(instance);
+
+ if (msg_event)
+ fd_msg_event = GetEventFileDescriptor(msg_event);
+
+ fd_evt_event = -1;
+ evt_event = freerdp_get_input_queue_event_handle(instance);
+
+ if (evt_event)
+ fd_evt_event = GetEventFileDescriptor(evt_event);
+
while (!xfi->disconnect && !freerdp_shall_disconnect(instance))
{
rcount = 0;
@@ -1075,6 +1091,12 @@ int xfreerdp_run(freerdp* instance)
break;
}
+ if (fd_msg_event > 0)
+ rfds[rcount++] = (void*) (long) fd_msg_event;
+
+ if (fd_evt_event > 0)
+ rfds[rcount++] = (void*) (long) fd_evt_event;
+
max_fds = 0;
FD_ZERO(&rfds_set);
FD_ZERO(&wfds_set);
@@ -1130,6 +1152,12 @@ int xfreerdp_run(freerdp* instance)
break;
}
xf_process_channel_event(channels, instance);
+
+ if (fd_msg_event > 0)
+ freerdp_process_messages(instance);
+
+ if (fd_evt_event > 0)
+ freerdp_process_input(instance);
}
FILE *fin = fopen("/tmp/tsmf.tid", "rt");
View
@@ -109,6 +109,8 @@ COMMAND_LINE_ARGUMENT_A args[] =
{ "glyph-cache", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "glyph cache" },
{ "codec-cache", COMMAND_LINE_VALUE_REQUIRED, "<rfx|nsc|jpeg>", NULL, NULL, -1, NULL, "bitmap codec cache" },
{ "fast-path", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueTrue, NULL, -1, NULL, "fast-path input/output" },
+ { "async-input", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "asynchronous input" },
+ { "async-update", COMMAND_LINE_VALUE_BOOL, NULL, BoolValueFalse, NULL, -1, NULL, "asynchronous update" },
{ "version", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_VERSION, NULL, NULL, NULL, -1, NULL, "print version" },
{ "help", COMMAND_LINE_VALUE_FLAG | COMMAND_LINE_PRINT_HELP, NULL, NULL, NULL, -1, "?", "print help" },
{ NULL, 0, NULL, NULL, NULL, -1, NULL, NULL }
@@ -1305,6 +1307,14 @@ int freerdp_client_parse_command_line_arguments(int argc, char** argv, rdpSettin
settings->FastPathInput = arg->Value ? TRUE : FALSE;
settings->FastPathOutput = arg->Value ? TRUE : FALSE;
}
+ CommandLineSwitchCase(arg, "async-input")
+ {
+ settings->AsyncInput = arg->Value ? TRUE : FALSE;
+ }
+ CommandLineSwitchCase(arg, "async-update")
+ {
+ settings->AsyncUpdate = arg->Value ? TRUE : FALSE;
+ }
CommandLineSwitchDefault(arg)
{
@@ -341,6 +341,9 @@ int freerdp_detect_old_command_line_syntax(int argc, char** argv, int* count)
detect_status = 1;
}
+ if (settings->ServerHostname)
+ free(settings->ServerHostname);
+
free(settings);
return detect_status;
View
@@ -170,7 +170,7 @@ typedef void (*pSwitchSurface)(rdpContext* context, SWITCH_SURFACE_ORDER* switch
typedef void (*pCreateNineGridBitmap)(rdpContext* context, CREATE_NINE_GRID_BITMAP_ORDER* create_nine_grid_bitmap);
typedef void (*pFrameMarker)(rdpContext* context, FRAME_MARKER_ORDER* frame_marker);
typedef void (*pStreamBitmapFirst)(rdpContext* context, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_first);
-typedef void (*pStreamBitmapNext)(rdpContext* context, STREAM_BITMAP_FIRST_ORDER* stream_bitmap_next);
+typedef void (*pStreamBitmapNext)(rdpContext* context, STREAM_BITMAP_NEXT_ORDER* stream_bitmap_next);
typedef void (*pDrawGdiPlusFirst)(rdpContext* context, DRAW_GDIPLUS_FIRST_ORDER* draw_gdiplus_first);
typedef void (*pDrawGdiPlusNext)(rdpContext* context, DRAW_GDIPLUS_NEXT_ORDER* draw_gdiplus_next);
typedef void (*pDrawGdiPlusEnd)(rdpContext* context, DRAW_GDIPLUS_END_ORDER* draw_gdiplus_end);
@@ -204,7 +204,7 @@ struct rdp_altsec_update
CREATE_NINE_GRID_BITMAP_ORDER create_nine_grid_bitmap;
FRAME_MARKER_ORDER frame_marker;
STREAM_BITMAP_FIRST_ORDER stream_bitmap_first;
- STREAM_BITMAP_FIRST_ORDER stream_bitmap_next;
+ STREAM_BITMAP_NEXT_ORDER stream_bitmap_next;
DRAW_GDIPLUS_CACHE_FIRST_ORDER draw_gdiplus_cache_first;
DRAW_GDIPLUS_CACHE_NEXT_ORDER draw_gdiplus_cache_next;
DRAW_GDIPLUS_CACHE_END_ORDER draw_gdiplus_cache_end;
View
@@ -82,6 +82,7 @@ struct rdp_context
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 */
rdpRdp* rdp; /**< (offset 32)
@@ -96,7 +97,10 @@ struct rdp_context
rdpCache* cache; /* 35 */
rdpChannels* channels; /* 36 */
rdpGraphics* graphics; /* 37 */
- UINT32 paddingC[64 - 38]; /* 38 */
+ rdpInput* input; /* 38 */
+ rdpUpdate* update; /* 39 */
+ rdpSettings* settings; /* 40 */
+ UINT32 paddingC[64 - 41]; /* 41 */
};
/** Defines the options for a given instance of RDP connection.
@@ -114,7 +118,8 @@ struct rdp_freerdp
When using this capability, client application should ALWAYS declare their structure with the
rdpContext field first, and any additional content following it.
Can be allocated by a call to freerdp_context_new().
- Must be dealocated by a call to freerdp_context_free() before deallocating the current instance. */
+ Must be deallocated by a call to freerdp_context_free() before deallocating the current instance. */
+
UINT32 paddingA[16 - 1]; /* 1 */
rdpInput* input; /* (offset 16)
@@ -191,6 +196,12 @@ FREERDP_API BOOL freerdp_disconnect(freerdp* instance);
FREERDP_API BOOL freerdp_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, int* wcount);
FREERDP_API BOOL freerdp_check_fds(freerdp* instance);
+FREERDP_API int freerdp_process_messages(freerdp* instance);
+FREERDP_API HANDLE freerdp_get_message_queue_event_handle(freerdp* instance);
+
+FREERDP_API HANDLE freerdp_get_input_queue_event_handle(freerdp* instance);
+FREERDP_API int freerdp_process_input(freerdp* instance);
+
FREERDP_API UINT32 freerdp_error_info(freerdp* instance);
FREERDP_API void freerdp_get_version(int* major, int* minor, int* revision);
@@ -69,6 +69,12 @@
#define GDI_DPa 0x00A000C9 /* D = D & P */
#define GDI_PDxn 0x00A50065 /* D = D ^ ~P */
+#define GDI_DSxn 0x00990066
+#define GDI_PSDnox 0x002D060A
+#define GDI_PDSona 0x00100C85
+#define GDI_DSPDxox 0x00740646
+#define GDI_DPSDonox 0x005B18A9
+
#define GDI_DPon 0x000500A9
#define GDI_DPna 0x000A0329
#define GDI_Pn 0x000F0001
View
@@ -26,6 +26,9 @@ typedef struct rdp_input rdpInput;
#include <freerdp/freerdp.h>
#include <freerdp/scancode.h>
+#include <winpr/crt.h>
+#include <winpr/collections.h>
+
/* keyboard Flags */
#define KBD_FLAGS_EXTENDED 0x0100
#define KBD_FLAGS_DOWN 0x4000
@@ -54,6 +57,11 @@ typedef struct rdp_input rdpInput;
#define RDP_CLIENT_INPUT_PDU_HEADER_LENGTH 4
+/* defined inside libfreerdp-core */
+typedef struct rdp_event rdpEvent;
+
+/* Input Interface */
+
typedef void (*pSynchronizeEvent)(rdpInput* input, UINT32 flags);
typedef void (*pKeyboardEvent)(rdpInput* input, UINT16 flags, UINT16 code);
typedef void (*pUnicodeKeyboardEvent)(rdpInput* input, UINT16 flags, UINT16 code);
@@ -72,6 +80,12 @@ struct rdp_input
pMouseEvent MouseEvent; /* 19 */
pExtendedMouseEvent ExtendedMouseEvent; /* 20 */
UINT32 paddingB[32 - 21]; /* 21 */
+
+ /* Internal */
+
+ BOOL asynchronous;
+ rdpEvent* event;
+ wMessageQueue* queue;
};
#ifdef __cplusplus
@@ -147,7 +147,7 @@ struct _CACHE_GLYPH_ORDER
{
UINT32 cacheId;
UINT32 cGlyphs;
- GLYPH_DATA* glyphData[255];
+ GLYPH_DATA glyphData[255];
BYTE* unicodeCharacters;
};
typedef struct _CACHE_GLYPH_ORDER CACHE_GLYPH_ORDER;
@@ -169,7 +169,7 @@ struct _CACHE_GLYPH_V2_ORDER
UINT32 cacheId;
UINT32 flags;
UINT32 cGlyphs;
- GLYPH_DATA_V2* glyphData[255];
+ GLYPH_DATA_V2 glyphData[255];
BYTE* unicodeCharacters;
};
typedef struct _CACHE_GLYPH_V2_ORDER CACHE_GLYPH_V2_ORDER;
@@ -182,7 +182,7 @@ struct _CACHE_BRUSH_ORDER
UINT32 cy;
UINT32 style;
UINT32 length;
- BYTE* data;
+ BYTE data[256];
};
typedef struct _CACHE_BRUSH_ORDER CACHE_BRUSH_ORDER;
@@ -676,7 +676,9 @@ struct rdp_settings
ALIGN64 BOOL MouseMotion; /* 1541 */
ALIGN64 char* WindowTitle; /* 1542 */
ALIGN64 UINT64 ParentWindowId; /* 1543 */
- UINT64 padding1600[1600 - 1544]; /* 1544 */
+ ALIGN64 BOOL AsyncInput; /* 1544 */
+ ALIGN64 BOOL AsyncUpdate; /* 1545 */
+ UINT64 padding1600[1600 - 1546]; /* 1546 */
/* Miscellaneous */
ALIGN64 BOOL SoftwareGdi; /* 1601 */
View
@@ -134,6 +134,9 @@ enum SURFCMD_FRAMEACTION
SURFACECMD_FRAMEACTION_END = 0x0001
};
+/* defined inside libfreerdp-core */
+typedef struct rdp_message rdpMessage;
+
/* Update Interface */
typedef void (*pBeginPaint)(rdpContext* context);
@@ -191,6 +194,7 @@ struct rdp_update
BOOL dump_rfx;
BOOL play_rfx;
rdpPcap* pcap_rfx;
+ BOOL initialState;
BITMAP_UPDATE bitmap_update;
PALETTE_UPDATE palette_update;
@@ -199,8 +203,9 @@ struct rdp_update
SURFACE_BITS_COMMAND surface_bits_command;
SURFACE_FRAME_MARKER surface_frame_marker;
- HANDLE thread;
- wQueue* queue;
+ BOOL asynchronous;
+ rdpMessage* message;
+ wMessageQueue* queue;
};
#endif /* FREERDP_UPDATE_H */
View
@@ -75,8 +75,16 @@ void update_gdi_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb)
void update_gdi_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush)
{
+ int length;
+ void* data = NULL;
rdpCache* cache = context->cache;
- brush_cache_put(cache->brush, cache_brush->index, cache_brush->data, cache_brush->bpp);
+
+ length = cache_brush->bpp * 64 / 8;
+
+ data = malloc(length);
+ CopyMemory(data, cache_brush->data, length);
+
+ brush_cache_put(cache->brush, cache_brush->index, data, cache_brush->bpp);
}
void* brush_cache_get(rdpBrushCache* brush, UINT32 index, UINT32* bpp)
View
@@ -312,7 +312,7 @@ void update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph)
for (i = 0; i < (int) cache_glyph->cGlyphs; i++)
{
- glyph_data = cache_glyph->glyphData[i];
+ glyph_data = &cache_glyph->glyphData[i];
glyph = Glyph_Alloc(context);
@@ -325,9 +325,6 @@ void update_gdi_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph)
Glyph_New(context, glyph);
glyph_cache_put(cache->glyph, cache_glyph->cacheId, glyph_data->cacheIndex, glyph);
-
- cache_glyph->glyphData[i] = NULL;
- free(glyph_data);
}
}
@@ -340,7 +337,7 @@ void update_gdi_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_
for (i = 0; i < (int) cache_glyph_v2->cGlyphs; i++)
{
- glyph_data = cache_glyph_v2->glyphData[i];
+ glyph_data = &cache_glyph_v2->glyphData[i];
glyph = Glyph_Alloc(context);
@@ -353,9 +350,6 @@ void update_gdi_cache_glyph_v2(rdpContext* context, CACHE_GLYPH_V2_ORDER* cache_
Glyph_New(context, glyph);
glyph_cache_put(cache->glyph, cache_glyph_v2->cacheId, glyph_data->cacheIndex, glyph);
-
- cache_glyph_v2->glyphData[i] = NULL;
- free(glyph_data);
}
}
View
@@ -48,6 +48,7 @@ void update_pointer_system(rdpContext* context, POINTER_SYSTEM_UPDATE* pointer_s
default:
printf("Unknown system pointer type (0x%08X)\n", pointer_system->type);
+ break;
}
}
@@ -92,8 +93,20 @@ void update_pointer_new(rdpContext* context, POINTER_NEW_UPDATE* pointer_new)
pointer->height = pointer_new->colorPtrAttr.height;
pointer->lengthAndMask = pointer_new->colorPtrAttr.lengthAndMask;
pointer->lengthXorMask = pointer_new->colorPtrAttr.lengthXorMask;
- pointer->xorMaskData = pointer_new->colorPtrAttr.xorMaskData;
- pointer->andMaskData = pointer_new->colorPtrAttr.andMaskData;
+
+ pointer->andMaskData = pointer->xorMaskData = NULL;
+
+ if (pointer->lengthAndMask)
+ {
+ pointer->andMaskData = (BYTE*) malloc(pointer->lengthAndMask);
+ CopyMemory(pointer->andMaskData, pointer_new->colorPtrAttr.andMaskData, pointer->lengthAndMask);
+ }
+
+ if (pointer->lengthXorMask)
+ {
+ pointer->xorMaskData = (BYTE*) malloc(pointer->lengthXorMask);
+ CopyMemory(pointer->xorMaskData, pointer_new->colorPtrAttr.xorMaskData, pointer->lengthXorMask);
+ }
pointer->New(context, pointer);
pointer_cache_put(cache->pointer, pointer_new->colorPtrAttr.cacheIndex, pointer);
Oops, something went wrong.

0 comments on commit 71de03c

Please sign in to comment.