diff --git a/include/freerdp/update.h b/include/freerdp/update.h index ec5336a26..997cf33b0 100644 --- a/include/freerdp/update.h +++ b/include/freerdp/update.h @@ -238,32 +238,6 @@ struct rdp_update pSaveSessionInfo SaveSessionInfo; /* 69 */ pServerStatusInfo ServerStatusInfo; /* 70 */ UINT32 paddingE[80 - 71]; /* 71 */ - - /* internal */ - - wLog* log; - - BOOL dump_rfx; - BOOL play_rfx; - rdpPcap* pcap_rfx; - BOOL initialState; - - BOOL asynchronous; - rdpUpdateProxy* proxy; - wMessageQueue* queue; - - wStream* us; - UINT16 numberOrders; - size_t offsetOrders; /* the offset to patch numberOrders in the stream */ - BOOL combineUpdates; - rdpBounds currentBounds; - rdpBounds previousBounds; - CRITICAL_SECTION mux; - - /* if autoCalculateBitmapData is set to TRUE, the server automatically - * fills BITMAP_DATA struct members: flags, cbCompMainBodySize and cbCompFirstRowSize. - */ - BOOL autoCalculateBitmapData; }; #endif /* FREERDP_UPDATE_H */ diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index f450148a9..7c1cd00b2 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -125,6 +125,8 @@ BOOL freerdp_connect(freerdp* instance) /* Pointers might have changed inbetween */ if (rdp && rdp->settings) { + rdp_update_internal* up = update_cast(rdp->update); + /* --authonly tests the connection without a UI */ if (rdp->settings->AuthenticationOnly) { @@ -134,10 +136,10 @@ BOOL freerdp_connect(freerdp* instance) if (rdp->settings->DumpRemoteFx) { - rdp->update->pcap_rfx = pcap_open(rdp->settings->DumpRemoteFxFile, TRUE); + up->pcap_rfx = pcap_open(rdp->settings->DumpRemoteFxFile, TRUE); - if (rdp->update->pcap_rfx) - rdp->update->dump_rfx = TRUE; + if (up->pcap_rfx) + up->dump_rfx = TRUE; } } @@ -171,9 +173,10 @@ BOOL freerdp_connect(freerdp* instance) if (instance->settings->PlayRemoteFx) { wStream* s; - rdpUpdate* update; + rdp_update_internal* update = update_cast(instance->update); pcap_record record; - update = instance->update; + + WINPR_ASSERT(update); update->pcap_rfx = pcap_open(settings->PlayRemoteFxFile, FALSE); status = FALSE; @@ -197,14 +200,14 @@ BOOL freerdp_connect(freerdp* instance) Stream_SetLength(s, record.length); Stream_SetPosition(s, 0); - if (!update_begin_paint(update)) + if (!update_begin_paint(&update->common)) status = FALSE; else { - if (update_recv_surfcmds(update, s) < 0) + if (update_recv_surfcmds(&update->common, s) < 0) status = FALSE; - if (!update_end_paint(update)) + if (!update_end_paint(&update->common)) status = FALSE; } @@ -380,9 +383,11 @@ wMessageQueue* freerdp_get_message_queue(freerdp* instance, DWORD id) switch (id) { case FREERDP_UPDATE_MESSAGE_QUEUE: - WINPR_ASSERT(instance->update); - queue = instance->update->queue; - break; + { + rdp_update_internal* update = update_cast(instance->update); + queue = update->queue; + } + break; case FREERDP_INPUT_MESSAGE_QUEUE: WINPR_ASSERT(instance->input); @@ -467,6 +472,7 @@ BOOL freerdp_disconnect(freerdp* instance) { BOOL rc = TRUE; rdpRdp* rdp; + rdp_update_internal* up; if (!instance || !instance->context) return FALSE; @@ -477,6 +483,8 @@ BOOL freerdp_disconnect(freerdp* instance) if (!rdp_client_disconnect(rdp)) rc = FALSE; + up = update_cast(rdp->update); + update_post_disconnect(instance->update); if (instance->settings->AsyncInput) @@ -488,11 +496,11 @@ BOOL freerdp_disconnect(freerdp* instance) IFCALL(instance->PostDisconnect, instance); - if (instance->update->pcap_rfx) + if (up->pcap_rfx) { - instance->update->dump_rfx = FALSE; - pcap_close(instance->update->pcap_rfx); - instance->update->pcap_rfx = NULL; + up->dump_rfx = FALSE; + pcap_close(up->pcap_rfx); + up->pcap_rfx = NULL; } freerdp_channels_close(instance->context->channels, instance); diff --git a/libfreerdp/core/message.c b/libfreerdp/core/message.c index 2a2381842..83f946253 100644 --- a/libfreerdp/core/message.c +++ b/libfreerdp/core/message.c @@ -49,25 +49,32 @@ static BOOL update_message_BeginPaint(rdpContext* context) { + rdp_update_internal* up; + if (!context || !context->update) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, BeginPaint), NULL, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, BeginPaint), NULL, + NULL); } static BOOL update_message_EndPaint(rdpContext* context) { + rdp_update_internal* up; + if (!context || !context->update) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, EndPaint), NULL, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, EndPaint), NULL, + NULL); } static BOOL update_message_SetBounds(rdpContext* context, const rdpBounds* bounds) { rdpBounds* wParam = NULL; + rdp_update_internal* up; if (!context || !context->update) return FALSE; @@ -82,31 +89,39 @@ static BOOL update_message_SetBounds(rdpContext* context, const rdpBounds* bound CopyMemory(wParam, bounds, sizeof(rdpBounds)); } - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, SetBounds), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SetBounds), + (void*)wParam, NULL); } static BOOL update_message_Synchronize(rdpContext* context) { + rdp_update_internal* up; + if (!context || !context->update) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, Synchronize), NULL, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, Synchronize), NULL, + NULL); } static BOOL update_message_DesktopResize(rdpContext* context) { + rdp_update_internal* up; + if (!context || !context->update) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, DesktopResize), NULL, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, DesktopResize), NULL, + NULL); } static BOOL update_message_BitmapUpdate(rdpContext* context, const BITMAP_UPDATE* bitmap) { BITMAP_UPDATE* wParam; + rdp_update_internal* up; if (!context || !context->update || !bitmap) return FALSE; @@ -116,13 +131,15 @@ static BOOL update_message_BitmapUpdate(rdpContext* context, const BITMAP_UPDATE if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, BitmapUpdate), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, BitmapUpdate), + (void*)wParam, NULL); } static BOOL update_message_Palette(rdpContext* context, const PALETTE_UPDATE* palette) { PALETTE_UPDATE* wParam; + rdp_update_internal* up; if (!context || !context->update || !palette) return FALSE; @@ -132,13 +149,15 @@ static BOOL update_message_Palette(rdpContext* context, const PALETTE_UPDATE* pa if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, MakeMessageId(Update, Palette), + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, Palette), (void*)wParam, NULL); } static BOOL update_message_PlaySound(rdpContext* context, const PLAY_SOUND_UPDATE* playSound) { PLAY_SOUND_UPDATE* wParam; + rdp_update_internal* up; if (!context || !context->update || !playSound) return FALSE; @@ -149,16 +168,21 @@ static BOOL update_message_PlaySound(rdpContext* context, const PLAY_SOUND_UPDAT return FALSE; CopyMemory(wParam, playSound, sizeof(PLAY_SOUND_UPDATE)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, PlaySound), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, PlaySound), + (void*)wParam, NULL); } static BOOL update_message_SetKeyboardIndicators(rdpContext* context, UINT16 led_flags) { + rdp_update_internal* up; + if (!context || !context->update) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SetKeyboardIndicators), (void*)(size_t)led_flags, NULL); } @@ -166,17 +190,21 @@ static BOOL update_message_SetKeyboardIndicators(rdpContext* context, UINT16 led static BOOL update_message_SetKeyboardImeStatus(rdpContext* context, UINT16 imeId, UINT32 imeState, UINT32 imeConvMode) { + rdp_update_internal* up; + if (!context || !context->update) return FALSE; - return MessageQueue_Post( - context->update->queue, (void*)context, MakeMessageId(Update, SetKeyboardImeStatus), - (void*)(size_t)((imeId << 16UL) | imeState), (void*)(size_t)imeConvMode); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SetKeyboardImeStatus), + (void*)(size_t)((imeId << 16UL) | imeState), + (void*)(size_t)imeConvMode); } static BOOL update_message_RefreshRect(rdpContext* context, BYTE count, const RECTANGLE_16* areas) { RECTANGLE_16* lParam; + rdp_update_internal* up; if (!context || !context->update || !areas) return FALSE; @@ -187,14 +215,16 @@ static BOOL update_message_RefreshRect(rdpContext* context, BYTE count, const RE return FALSE; CopyMemory(lParam, areas, sizeof(RECTANGLE_16) * count); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, RefreshRect), (void*)(size_t)count, - (void*)lParam); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, RefreshRect), + (void*)(size_t)count, (void*)lParam); } static BOOL update_message_SuppressOutput(rdpContext* context, BYTE allow, const RECTANGLE_16* area) { RECTANGLE_16* lParam = NULL; + rdp_update_internal* up; if (!context || !context->update) return FALSE; @@ -209,14 +239,15 @@ static BOOL update_message_SuppressOutput(rdpContext* context, BYTE allow, const CopyMemory(lParam, area, sizeof(RECTANGLE_16)); } - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, SuppressOutput), (void*)(size_t)allow, - (void*)lParam); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SuppressOutput), + (void*)(size_t)allow, (void*)lParam); } static BOOL update_message_SurfaceCommand(rdpContext* context, wStream* s) { wStream* wParam; + rdp_update_internal* up; if (!context || !context->update || !s) return FALSE; @@ -228,14 +259,17 @@ static BOOL update_message_SurfaceCommand(rdpContext* context, wStream* s) Stream_Copy(s, wParam, Stream_GetRemainingLength(s)); Stream_SetPosition(wParam, 0); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, SurfaceCommand), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SurfaceCommand), + (void*)wParam, NULL); } static BOOL update_message_SurfaceBits(rdpContext* context, const SURFACE_BITS_COMMAND* surfaceBitsCommand) { SURFACE_BITS_COMMAND* wParam; + rdp_update_internal* up; if (!context || !context->update || !surfaceBitsCommand) return FALSE; @@ -245,14 +279,16 @@ static BOOL update_message_SurfaceBits(rdpContext* context, if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, SurfaceBits), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SurfaceBits), + (void*)wParam, NULL); } static BOOL update_message_SurfaceFrameMarker(rdpContext* context, const SURFACE_FRAME_MARKER* surfaceFrameMarker) { SURFACE_FRAME_MARKER* wParam; + rdp_update_internal* up; if (!context || !context->update || !surfaceFrameMarker) return FALSE; @@ -263,16 +299,21 @@ static BOOL update_message_SurfaceFrameMarker(rdpContext* context, return FALSE; CopyMemory(wParam, surfaceFrameMarker, sizeof(SURFACE_FRAME_MARKER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(Update, SurfaceFrameMarker), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SurfaceFrameMarker), + (void*)wParam, NULL); } static BOOL update_message_SurfaceFrameAcknowledge(rdpContext* context, UINT32 frameId) { + rdp_update_internal* up; + if (!context || !context->update) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(Update, SurfaceFrameAcknowledge), (void*)(size_t)frameId, NULL); } @@ -282,6 +323,7 @@ static BOOL update_message_SurfaceFrameAcknowledge(rdpContext* context, UINT32 f static BOOL update_message_DstBlt(rdpContext* context, const DSTBLT_ORDER* dstBlt) { DSTBLT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !dstBlt) return FALSE; @@ -292,13 +334,16 @@ static BOOL update_message_DstBlt(rdpContext* context, const DSTBLT_ORDER* dstBl return FALSE; CopyMemory(wParam, dstBlt, sizeof(DSTBLT_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, DstBlt), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, DstBlt), + (void*)wParam, NULL); } static BOOL update_message_PatBlt(rdpContext* context, PATBLT_ORDER* patBlt) { PATBLT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !patBlt) return FALSE; @@ -310,13 +355,16 @@ static BOOL update_message_PatBlt(rdpContext* context, PATBLT_ORDER* patBlt) CopyMemory(wParam, patBlt, sizeof(PATBLT_ORDER)); wParam->brush.data = (BYTE*)wParam->brush.p8x8; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, PatBlt), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, PatBlt), + (void*)wParam, NULL); } static BOOL update_message_ScrBlt(rdpContext* context, const SCRBLT_ORDER* scrBlt) { SCRBLT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !scrBlt) return FALSE; @@ -327,13 +375,16 @@ static BOOL update_message_ScrBlt(rdpContext* context, const SCRBLT_ORDER* scrBl return FALSE; CopyMemory(wParam, scrBlt, sizeof(SCRBLT_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, ScrBlt), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, ScrBlt), + (void*)wParam, NULL); } static BOOL update_message_OpaqueRect(rdpContext* context, const OPAQUE_RECT_ORDER* opaqueRect) { OPAQUE_RECT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !opaqueRect) return FALSE; @@ -344,14 +395,17 @@ static BOOL update_message_OpaqueRect(rdpContext* context, const OPAQUE_RECT_ORD return FALSE; CopyMemory(wParam, opaqueRect, sizeof(OPAQUE_RECT_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, OpaqueRect), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, OpaqueRect), + (void*)wParam, NULL); } static BOOL update_message_DrawNineGrid(rdpContext* context, const DRAW_NINE_GRID_ORDER* drawNineGrid) { DRAW_NINE_GRID_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !drawNineGrid) return FALSE; @@ -362,13 +416,16 @@ static BOOL update_message_DrawNineGrid(rdpContext* context, return FALSE; CopyMemory(wParam, drawNineGrid, sizeof(DRAW_NINE_GRID_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, DrawNineGrid), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, DrawNineGrid), + (void*)wParam, NULL); } static BOOL update_message_MultiDstBlt(rdpContext* context, const MULTI_DSTBLT_ORDER* multiDstBlt) { MULTI_DSTBLT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !multiDstBlt) return FALSE; @@ -379,13 +436,16 @@ static BOOL update_message_MultiDstBlt(rdpContext* context, const MULTI_DSTBLT_O return FALSE; CopyMemory(wParam, multiDstBlt, sizeof(MULTI_DSTBLT_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, MultiDstBlt), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, MultiDstBlt), + (void*)wParam, NULL); } static BOOL update_message_MultiPatBlt(rdpContext* context, const MULTI_PATBLT_ORDER* multiPatBlt) { MULTI_PATBLT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !multiPatBlt) return FALSE; @@ -397,13 +457,16 @@ static BOOL update_message_MultiPatBlt(rdpContext* context, const MULTI_PATBLT_O CopyMemory(wParam, multiPatBlt, sizeof(MULTI_PATBLT_ORDER)); wParam->brush.data = (BYTE*)wParam->brush.p8x8; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, MultiPatBlt), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, MultiPatBlt), + (void*)wParam, NULL); } static BOOL update_message_MultiScrBlt(rdpContext* context, const MULTI_SCRBLT_ORDER* multiScrBlt) { MULTI_SCRBLT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !multiScrBlt) return FALSE; @@ -414,14 +477,17 @@ static BOOL update_message_MultiScrBlt(rdpContext* context, const MULTI_SCRBLT_O return FALSE; CopyMemory(wParam, multiScrBlt, sizeof(MULTI_SCRBLT_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, MultiScrBlt), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, MultiScrBlt), + (void*)wParam, NULL); } static BOOL update_message_MultiOpaqueRect(rdpContext* context, const MULTI_OPAQUE_RECT_ORDER* multiOpaqueRect) { MULTI_OPAQUE_RECT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !multiOpaqueRect) return FALSE; @@ -432,7 +498,9 @@ static BOOL update_message_MultiOpaqueRect(rdpContext* context, return FALSE; CopyMemory(wParam, multiOpaqueRect, sizeof(MULTI_OPAQUE_RECT_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, MultiOpaqueRect), (void*)wParam, NULL); } @@ -440,6 +508,7 @@ static BOOL update_message_MultiDrawNineGrid(rdpContext* context, const MULTI_DRAW_NINE_GRID_ORDER* multiDrawNineGrid) { MULTI_DRAW_NINE_GRID_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !multiDrawNineGrid) return FALSE; @@ -451,13 +520,16 @@ static BOOL update_message_MultiDrawNineGrid(rdpContext* context, CopyMemory(wParam, multiDrawNineGrid, sizeof(MULTI_DRAW_NINE_GRID_ORDER)); /* TODO: complete copy */ - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, MultiDrawNineGrid), (void*)wParam, NULL); } static BOOL update_message_LineTo(rdpContext* context, const LINE_TO_ORDER* lineTo) { LINE_TO_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !lineTo) return FALSE; @@ -468,13 +540,16 @@ static BOOL update_message_LineTo(rdpContext* context, const LINE_TO_ORDER* line return FALSE; CopyMemory(wParam, lineTo, sizeof(LINE_TO_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, LineTo), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, LineTo), + (void*)wParam, NULL); } static BOOL update_message_Polyline(rdpContext* context, const POLYLINE_ORDER* polyline) { POLYLINE_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !polyline) return FALSE; @@ -494,13 +569,16 @@ static BOOL update_message_Polyline(rdpContext* context, const POLYLINE_ORDER* p } CopyMemory(wParam->points, polyline->points, sizeof(DELTA_POINT) * wParam->numDeltaEntries); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, Polyline), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, Polyline), + (void*)wParam, NULL); } static BOOL update_message_MemBlt(rdpContext* context, MEMBLT_ORDER* memBlt) { MEMBLT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !memBlt) return FALSE; @@ -511,13 +589,16 @@ static BOOL update_message_MemBlt(rdpContext* context, MEMBLT_ORDER* memBlt) return FALSE; CopyMemory(wParam, memBlt, sizeof(MEMBLT_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, MemBlt), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, MemBlt), + (void*)wParam, NULL); } static BOOL update_message_Mem3Blt(rdpContext* context, MEM3BLT_ORDER* mem3Blt) { MEM3BLT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !mem3Blt) return FALSE; @@ -529,13 +610,16 @@ static BOOL update_message_Mem3Blt(rdpContext* context, MEM3BLT_ORDER* mem3Blt) CopyMemory(wParam, mem3Blt, sizeof(MEM3BLT_ORDER)); wParam->brush.data = (BYTE*)wParam->brush.p8x8; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, Mem3Blt), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, Mem3Blt), + (void*)wParam, NULL); } static BOOL update_message_SaveBitmap(rdpContext* context, const SAVE_BITMAP_ORDER* saveBitmap) { SAVE_BITMAP_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !saveBitmap) return FALSE; @@ -546,13 +630,16 @@ static BOOL update_message_SaveBitmap(rdpContext* context, const SAVE_BITMAP_ORD return FALSE; CopyMemory(wParam, saveBitmap, sizeof(SAVE_BITMAP_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, SaveBitmap), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, SaveBitmap), + (void*)wParam, NULL); } static BOOL update_message_GlyphIndex(rdpContext* context, GLYPH_INDEX_ORDER* glyphIndex) { GLYPH_INDEX_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !glyphIndex) return FALSE; @@ -564,13 +651,16 @@ static BOOL update_message_GlyphIndex(rdpContext* context, GLYPH_INDEX_ORDER* gl CopyMemory(wParam, glyphIndex, sizeof(GLYPH_INDEX_ORDER)); wParam->brush.data = (BYTE*)wParam->brush.p8x8; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, GlyphIndex), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, GlyphIndex), + (void*)wParam, NULL); } static BOOL update_message_FastIndex(rdpContext* context, const FAST_INDEX_ORDER* fastIndex) { FAST_INDEX_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !fastIndex) return FALSE; @@ -581,13 +671,16 @@ static BOOL update_message_FastIndex(rdpContext* context, const FAST_INDEX_ORDER return FALSE; CopyMemory(wParam, fastIndex, sizeof(FAST_INDEX_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, FastIndex), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, FastIndex), + (void*)wParam, NULL); } static BOOL update_message_FastGlyph(rdpContext* context, const FAST_GLYPH_ORDER* fastGlyph) { FAST_GLYPH_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !fastGlyph) return FALSE; @@ -616,13 +709,15 @@ static BOOL update_message_FastGlyph(rdpContext* context, const FAST_GLYPH_ORDER wParam->glyphData.aj = NULL; } - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, FastGlyph), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, FastGlyph), + (void*)wParam, NULL); } static BOOL update_message_PolygonSC(rdpContext* context, const POLYGON_SC_ORDER* polygonSC) { POLYGON_SC_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !polygonSC) return FALSE; @@ -642,13 +737,16 @@ static BOOL update_message_PolygonSC(rdpContext* context, const POLYGON_SC_ORDER } CopyMemory(wParam->points, polygonSC, sizeof(DELTA_POINT) * wParam->numPoints); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, PolygonSC), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, PolygonSC), + (void*)wParam, NULL); } static BOOL update_message_PolygonCB(rdpContext* context, POLYGON_CB_ORDER* polygonCB) { POLYGON_CB_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !polygonCB) return FALSE; @@ -669,13 +767,16 @@ static BOOL update_message_PolygonCB(rdpContext* context, POLYGON_CB_ORDER* poly CopyMemory(wParam->points, polygonCB, sizeof(DELTA_POINT) * wParam->numPoints); wParam->brush.data = (BYTE*)wParam->brush.p8x8; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, PolygonCB), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, PolygonCB), + (void*)wParam, NULL); } static BOOL update_message_EllipseSC(rdpContext* context, const ELLIPSE_SC_ORDER* ellipseSC) { ELLIPSE_SC_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !ellipseSC) return FALSE; @@ -686,13 +787,16 @@ static BOOL update_message_EllipseSC(rdpContext* context, const ELLIPSE_SC_ORDER return FALSE; CopyMemory(wParam, ellipseSC, sizeof(ELLIPSE_SC_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, EllipseSC), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, EllipseSC), + (void*)wParam, NULL); } static BOOL update_message_EllipseCB(rdpContext* context, const ELLIPSE_CB_ORDER* ellipseCB) { ELLIPSE_CB_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !ellipseCB) return FALSE; @@ -704,8 +808,10 @@ static BOOL update_message_EllipseCB(rdpContext* context, const ELLIPSE_CB_ORDER CopyMemory(wParam, ellipseCB, sizeof(ELLIPSE_CB_ORDER)); wParam->brush.data = (BYTE*)wParam->brush.p8x8; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PrimaryUpdate, EllipseCB), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PrimaryUpdate, EllipseCB), + (void*)wParam, NULL); } /* Secondary Update */ @@ -714,6 +820,7 @@ static BOOL update_message_CacheBitmap(rdpContext* context, const CACHE_BITMAP_ORDER* cacheBitmapOrder) { CACHE_BITMAP_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !cacheBitmapOrder) return FALSE; @@ -723,14 +830,16 @@ static BOOL update_message_CacheBitmap(rdpContext* context, if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(SecondaryUpdate, CacheBitmap), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(SecondaryUpdate, CacheBitmap), + (void*)wParam, NULL); } static BOOL update_message_CacheBitmapV2(rdpContext* context, CACHE_BITMAP_V2_ORDER* cacheBitmapV2Order) { CACHE_BITMAP_V2_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !cacheBitmapV2Order) return FALSE; @@ -740,7 +849,8 @@ static BOOL update_message_CacheBitmapV2(rdpContext* context, if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(SecondaryUpdate, CacheBitmapV2), (void*)wParam, NULL); } @@ -748,6 +858,7 @@ static BOOL update_message_CacheBitmapV3(rdpContext* context, CACHE_BITMAP_V3_ORDER* cacheBitmapV3Order) { CACHE_BITMAP_V3_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !cacheBitmapV3Order) return FALSE; @@ -757,7 +868,8 @@ static BOOL update_message_CacheBitmapV3(rdpContext* context, if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(SecondaryUpdate, CacheBitmapV3), (void*)wParam, NULL); } @@ -765,6 +877,7 @@ static BOOL update_message_CacheColorTable(rdpContext* context, const CACHE_COLOR_TABLE_ORDER* cacheColorTableOrder) { CACHE_COLOR_TABLE_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !cacheColorTableOrder) return FALSE; @@ -774,13 +887,15 @@ static BOOL update_message_CacheColorTable(rdpContext* context, if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(SecondaryUpdate, CacheColorTable), (void*)wParam, NULL); } static BOOL update_message_CacheGlyph(rdpContext* context, const CACHE_GLYPH_ORDER* cacheGlyphOrder) { CACHE_GLYPH_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !cacheGlyphOrder) return FALSE; @@ -790,14 +905,16 @@ static BOOL update_message_CacheGlyph(rdpContext* context, const CACHE_GLYPH_ORD if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(SecondaryUpdate, CacheGlyph), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(SecondaryUpdate, CacheGlyph), + (void*)wParam, NULL); } static BOOL update_message_CacheGlyphV2(rdpContext* context, const CACHE_GLYPH_V2_ORDER* cacheGlyphV2Order) { CACHE_GLYPH_V2_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !cacheGlyphV2Order) return FALSE; @@ -807,13 +924,15 @@ static BOOL update_message_CacheGlyphV2(rdpContext* context, if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(SecondaryUpdate, CacheGlyphV2), (void*)wParam, NULL); } static BOOL update_message_CacheBrush(rdpContext* context, const CACHE_BRUSH_ORDER* cacheBrushOrder) { CACHE_BRUSH_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !cacheBrushOrder) return FALSE; @@ -823,8 +942,9 @@ static BOOL update_message_CacheBrush(rdpContext* context, const CACHE_BRUSH_ORD if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(SecondaryUpdate, CacheBrush), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(SecondaryUpdate, CacheBrush), + (void*)wParam, NULL); } /* Alternate Secondary Update */ @@ -834,6 +954,7 @@ update_message_CreateOffscreenBitmap(rdpContext* context, const CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap) { CREATE_OFFSCREEN_BITMAP_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !createOffscreenBitmap) return FALSE; @@ -856,7 +977,9 @@ update_message_CreateOffscreenBitmap(rdpContext* context, CopyMemory(wParam->deleteList.indices, createOffscreenBitmap->deleteList.indices, wParam->deleteList.cIndices); - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, CreateOffscreenBitmap), (void*)wParam, NULL); } @@ -865,6 +988,7 @@ static BOOL update_message_SwitchSurface(rdpContext* context, const SWITCH_SURFACE_ORDER* switchSurface) { SWITCH_SURFACE_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !switchSurface) return FALSE; @@ -875,8 +999,10 @@ static BOOL update_message_SwitchSurface(rdpContext* context, return FALSE; CopyMemory(wParam, switchSurface, sizeof(SWITCH_SURFACE_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(AltSecUpdate, SwitchSurface), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, SwitchSurface), + (void*)wParam, NULL); } static BOOL @@ -884,6 +1010,7 @@ update_message_CreateNineGridBitmap(rdpContext* context, const CREATE_NINE_GRID_BITMAP_ORDER* createNineGridBitmap) { CREATE_NINE_GRID_BITMAP_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !createNineGridBitmap) return FALSE; @@ -894,7 +1021,9 @@ update_message_CreateNineGridBitmap(rdpContext* context, return FALSE; CopyMemory(wParam, createNineGridBitmap, sizeof(CREATE_NINE_GRID_BITMAP_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, CreateNineGridBitmap), (void*)wParam, NULL); } @@ -902,6 +1031,7 @@ update_message_CreateNineGridBitmap(rdpContext* context, static BOOL update_message_FrameMarker(rdpContext* context, const FRAME_MARKER_ORDER* frameMarker) { FRAME_MARKER_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !frameMarker) return FALSE; @@ -912,14 +1042,17 @@ static BOOL update_message_FrameMarker(rdpContext* context, const FRAME_MARKER_O return FALSE; CopyMemory(wParam, frameMarker, sizeof(FRAME_MARKER_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(AltSecUpdate, FrameMarker), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, FrameMarker), + (void*)wParam, NULL); } static BOOL update_message_StreamBitmapFirst(rdpContext* context, const STREAM_BITMAP_FIRST_ORDER* streamBitmapFirst) { STREAM_BITMAP_FIRST_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !streamBitmapFirst) return FALSE; @@ -931,7 +1064,9 @@ static BOOL update_message_StreamBitmapFirst(rdpContext* context, CopyMemory(wParam, streamBitmapFirst, sizeof(STREAM_BITMAP_FIRST_ORDER)); /* TODO: complete copy */ - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, StreamBitmapFirst), (void*)wParam, NULL); } @@ -939,6 +1074,7 @@ static BOOL update_message_StreamBitmapNext(rdpContext* context, const STREAM_BITMAP_NEXT_ORDER* streamBitmapNext) { STREAM_BITMAP_NEXT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !streamBitmapNext) return FALSE; @@ -950,7 +1086,9 @@ static BOOL update_message_StreamBitmapNext(rdpContext* context, CopyMemory(wParam, streamBitmapNext, sizeof(STREAM_BITMAP_NEXT_ORDER)); /* TODO: complete copy */ - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, StreamBitmapNext), (void*)wParam, NULL); } @@ -958,6 +1096,7 @@ static BOOL update_message_DrawGdiPlusFirst(rdpContext* context, const DRAW_GDIPLUS_FIRST_ORDER* drawGdiPlusFirst) { DRAW_GDIPLUS_FIRST_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !drawGdiPlusFirst) return FALSE; @@ -969,7 +1108,8 @@ static BOOL update_message_DrawGdiPlusFirst(rdpContext* context, CopyMemory(wParam, drawGdiPlusFirst, sizeof(DRAW_GDIPLUS_FIRST_ORDER)); /* TODO: complete copy */ - return MessageQueue_Post(context->update->queue, (void*)context, + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusFirst), (void*)wParam, NULL); } @@ -977,6 +1117,7 @@ static BOOL update_message_DrawGdiPlusNext(rdpContext* context, const DRAW_GDIPLUS_NEXT_ORDER* drawGdiPlusNext) { DRAW_GDIPLUS_NEXT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !drawGdiPlusNext) return FALSE; @@ -988,7 +1129,9 @@ static BOOL update_message_DrawGdiPlusNext(rdpContext* context, CopyMemory(wParam, drawGdiPlusNext, sizeof(DRAW_GDIPLUS_NEXT_ORDER)); /* TODO: complete copy */ - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusNext), (void*)wParam, NULL); } @@ -996,6 +1139,7 @@ static BOOL update_message_DrawGdiPlusEnd(rdpContext* context, const DRAW_GDIPLUS_END_ORDER* drawGdiPlusEnd) { DRAW_GDIPLUS_END_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !drawGdiPlusEnd) return FALSE; @@ -1007,8 +1151,10 @@ static BOOL update_message_DrawGdiPlusEnd(rdpContext* context, CopyMemory(wParam, drawGdiPlusEnd, sizeof(DRAW_GDIPLUS_END_ORDER)); /* TODO: complete copy */ - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(AltSecUpdate, DrawGdiPlusEnd), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusEnd), + (void*)wParam, NULL); } static BOOL @@ -1016,6 +1162,7 @@ update_message_DrawGdiPlusCacheFirst(rdpContext* context, const DRAW_GDIPLUS_CACHE_FIRST_ORDER* drawGdiPlusCacheFirst) { DRAW_GDIPLUS_CACHE_FIRST_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !drawGdiPlusCacheFirst) return FALSE; @@ -1027,7 +1174,9 @@ update_message_DrawGdiPlusCacheFirst(rdpContext* context, CopyMemory(wParam, drawGdiPlusCacheFirst, sizeof(DRAW_GDIPLUS_CACHE_FIRST_ORDER)); /* TODO: complete copy */ - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusCacheFirst), (void*)wParam, NULL); } @@ -1037,6 +1186,7 @@ update_message_DrawGdiPlusCacheNext(rdpContext* context, const DRAW_GDIPLUS_CACHE_NEXT_ORDER* drawGdiPlusCacheNext) { DRAW_GDIPLUS_CACHE_NEXT_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !drawGdiPlusCacheNext) return FALSE; @@ -1048,7 +1198,9 @@ update_message_DrawGdiPlusCacheNext(rdpContext* context, CopyMemory(wParam, drawGdiPlusCacheNext, sizeof(DRAW_GDIPLUS_CACHE_NEXT_ORDER)); /* TODO: complete copy */ - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusCacheNext), (void*)wParam, NULL); } @@ -1058,6 +1210,7 @@ update_message_DrawGdiPlusCacheEnd(rdpContext* context, const DRAW_GDIPLUS_CACHE_END_ORDER* drawGdiPlusCacheEnd) { DRAW_GDIPLUS_CACHE_END_ORDER* wParam; + rdp_update_internal* up; if (!context || !context->update || !drawGdiPlusCacheEnd) return FALSE; @@ -1069,7 +1222,9 @@ update_message_DrawGdiPlusCacheEnd(rdpContext* context, CopyMemory(wParam, drawGdiPlusCacheEnd, sizeof(DRAW_GDIPLUS_CACHE_END_ORDER)); /* TODO: complete copy */ - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(AltSecUpdate, DrawGdiPlusCacheEnd), (void*)wParam, NULL); } @@ -1080,6 +1235,7 @@ static BOOL update_message_WindowCreate(rdpContext* context, const WINDOW_ORDER_ { WINDOW_ORDER_INFO* wParam; WINDOW_STATE_ORDER* lParam; + rdp_update_internal* up; if (!context || !context->update || !orderInfo || !windowState) return FALSE; @@ -1099,9 +1255,10 @@ static BOOL update_message_WindowCreate(rdpContext* context, const WINDOW_ORDER_ } CopyMemory(lParam, windowState, sizeof(WINDOW_STATE_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(WindowUpdate, WindowCreate), (void*)wParam, - (void*)lParam); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, WindowCreate), + (void*)wParam, (void*)lParam); } static BOOL update_message_WindowUpdate(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, @@ -1109,6 +1266,7 @@ static BOOL update_message_WindowUpdate(rdpContext* context, const WINDOW_ORDER_ { WINDOW_ORDER_INFO* wParam; WINDOW_STATE_ORDER* lParam; + rdp_update_internal* up; if (!context || !context->update || !orderInfo || !windowState) return FALSE; @@ -1128,9 +1286,10 @@ static BOOL update_message_WindowUpdate(rdpContext* context, const WINDOW_ORDER_ } CopyMemory(lParam, windowState, sizeof(WINDOW_STATE_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(WindowUpdate, WindowUpdate), (void*)wParam, - (void*)lParam); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, WindowUpdate), + (void*)wParam, (void*)lParam); } static BOOL update_message_WindowIcon(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, @@ -1138,6 +1297,7 @@ static BOOL update_message_WindowIcon(rdpContext* context, const WINDOW_ORDER_IN { WINDOW_ORDER_INFO* wParam; WINDOW_ICON_ORDER* lParam; + rdp_update_internal* up; if (!context || !context->update || !orderInfo || !windowIcon) return FALSE; @@ -1194,8 +1354,9 @@ static BOOL update_message_WindowIcon(rdpContext* context, const WINDOW_ORDER_IN windowIcon->iconInfo->cbColorTable); } - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(WindowUpdate, WindowIcon), (void*)wParam, (void*)lParam); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, WindowIcon), + (void*)wParam, (void*)lParam); out_fail: if (lParam && lParam->iconInfo) @@ -1216,6 +1377,7 @@ static BOOL update_message_WindowCachedIcon(rdpContext* context, const WINDOW_OR { WINDOW_ORDER_INFO* wParam; WINDOW_CACHED_ICON_ORDER* lParam; + rdp_update_internal* up; if (!context || !context->update || !orderInfo || !windowCachedIcon) return FALSE; @@ -1235,7 +1397,9 @@ static BOOL update_message_WindowCachedIcon(rdpContext* context, const WINDOW_OR } CopyMemory(lParam, windowCachedIcon, sizeof(WINDOW_CACHED_ICON_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, WindowCachedIcon), (void*)wParam, (void*)lParam); } @@ -1243,6 +1407,7 @@ static BOOL update_message_WindowCachedIcon(rdpContext* context, const WINDOW_OR static BOOL update_message_WindowDelete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo) { WINDOW_ORDER_INFO* wParam; + rdp_update_internal* up; if (!context || !context->update || !orderInfo) return FALSE; @@ -1253,8 +1418,10 @@ static BOOL update_message_WindowDelete(rdpContext* context, const WINDOW_ORDER_ return FALSE; CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO)); - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(WindowUpdate, WindowDelete), (void*)wParam, NULL); + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, WindowDelete), + (void*)wParam, NULL); } static BOOL update_message_NotifyIconCreate(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo, @@ -1262,6 +1429,7 @@ static BOOL update_message_NotifyIconCreate(rdpContext* context, const WINDOW_OR { WINDOW_ORDER_INFO* wParam; NOTIFY_ICON_STATE_ORDER* lParam; + rdp_update_internal* up; if (!context || !context->update || !orderInfo || !notifyIconState) return FALSE; @@ -1281,7 +1449,9 @@ static BOOL update_message_NotifyIconCreate(rdpContext* context, const WINDOW_OR } CopyMemory(lParam, notifyIconState, sizeof(NOTIFY_ICON_STATE_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, NotifyIconCreate), (void*)wParam, (void*)lParam); } @@ -1291,6 +1461,7 @@ static BOOL update_message_NotifyIconUpdate(rdpContext* context, const WINDOW_OR { WINDOW_ORDER_INFO* wParam; NOTIFY_ICON_STATE_ORDER* lParam; + rdp_update_internal* up; if (!context || !context->update || !orderInfo || !notifyIconState) return FALSE; @@ -1310,7 +1481,9 @@ static BOOL update_message_NotifyIconUpdate(rdpContext* context, const WINDOW_OR } CopyMemory(lParam, notifyIconState, sizeof(NOTIFY_ICON_STATE_ORDER)); - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, NotifyIconUpdate), (void*)wParam, (void*)lParam); } @@ -1318,6 +1491,7 @@ static BOOL update_message_NotifyIconUpdate(rdpContext* context, const WINDOW_OR static BOOL update_message_NotifyIconDelete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo) { WINDOW_ORDER_INFO* wParam; + rdp_update_internal* up; if (!context || !context->update || !orderInfo) return FALSE; @@ -1328,7 +1502,9 @@ static BOOL update_message_NotifyIconDelete(rdpContext* context, const WINDOW_OR return FALSE; CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO)); - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, NotifyIconDelete), (void*)wParam, NULL); } @@ -1337,6 +1513,7 @@ static BOOL update_message_MonitoredDesktop(rdpContext* context, const WINDOW_OR { WINDOW_ORDER_INFO* wParam; MONITORED_DESKTOP_ORDER* lParam; + rdp_update_internal* up; if (!context || !context->update || !orderInfo || !monitoredDesktop) return FALSE; @@ -1364,7 +1541,8 @@ static BOOL update_message_MonitoredDesktop(rdpContext* context, const WINDOW_OR CopyMemory(lParam->windowIds, monitoredDesktop->windowIds, lParam->numWindowIds); } - return MessageQueue_Post(context->update->queue, (void*)context, + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, MonitoredDesktop), (void*)wParam, (void*)lParam); } @@ -1373,6 +1551,7 @@ static BOOL update_message_NonMonitoredDesktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo) { WINDOW_ORDER_INFO* wParam; + rdp_update_internal* up; if (!context || !context->update || !orderInfo) return FALSE; @@ -1383,7 +1562,9 @@ static BOOL update_message_NonMonitoredDesktop(rdpContext* context, return FALSE; CopyMemory(wParam, orderInfo, sizeof(WINDOW_ORDER_INFO)); - return MessageQueue_Post(context->update->queue, (void*)context, + + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(WindowUpdate, NonMonitoredDesktop), (void*)wParam, NULL); } @@ -1393,6 +1574,7 @@ static BOOL update_message_PointerPosition(rdpContext* context, const POINTER_POSITION_UPDATE* pointerPosition) { POINTER_POSITION_UPDATE* wParam; + rdp_update_internal* up; if (!context || !context->update || !pointerPosition) return FALSE; @@ -1402,7 +1584,8 @@ static BOOL update_message_PointerPosition(rdpContext* context, if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerPosition), (void*)wParam, NULL); } @@ -1410,6 +1593,7 @@ static BOOL update_message_PointerSystem(rdpContext* context, const POINTER_SYSTEM_UPDATE* pointerSystem) { POINTER_SYSTEM_UPDATE* wParam; + rdp_update_internal* up; if (!context || !context->update || !pointerSystem) return FALSE; @@ -1419,14 +1603,16 @@ static BOOL update_message_PointerSystem(rdpContext* context, if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PointerUpdate, PointerSystem), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerSystem), + (void*)wParam, NULL); } static BOOL update_message_PointerColor(rdpContext* context, const POINTER_COLOR_UPDATE* pointerColor) { POINTER_COLOR_UPDATE* wParam; + rdp_update_internal* up; if (!context || !context->update || !pointerColor) return FALSE; @@ -1436,13 +1622,15 @@ static BOOL update_message_PointerColor(rdpContext* context, if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PointerUpdate, PointerColor), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerColor), + (void*)wParam, NULL); } static BOOL update_message_PointerLarge(rdpContext* context, const POINTER_LARGE_UPDATE* pointer) { POINTER_LARGE_UPDATE* wParam; + rdp_update_internal* up; if (!context || !context->update || !pointer) return FALSE; @@ -1452,13 +1640,15 @@ static BOOL update_message_PointerLarge(rdpContext* context, const POINTER_LARGE if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PointerUpdate, PointerLarge), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerLarge), + (void*)wParam, NULL); } static BOOL update_message_PointerNew(rdpContext* context, const POINTER_NEW_UPDATE* pointerNew) { POINTER_NEW_UPDATE* wParam; + rdp_update_internal* up; if (!context || !context->update || !pointerNew) return FALSE; @@ -1468,14 +1658,16 @@ static BOOL update_message_PointerNew(rdpContext* context, const POINTER_NEW_UPD if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PointerUpdate, PointerNew), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerNew), + (void*)wParam, NULL); } static BOOL update_message_PointerCached(rdpContext* context, const POINTER_CACHED_UPDATE* pointerCached) { POINTER_CACHED_UPDATE* wParam; + rdp_update_internal* up; if (!context || !context->update || !pointerCached) return FALSE; @@ -1485,8 +1677,9 @@ static BOOL update_message_PointerCached(rdpContext* context, if (!wParam) return FALSE; - return MessageQueue_Post(context->update->queue, (void*)context, - MakeMessageId(PointerUpdate, PointerCached), (void*)wParam, NULL); + up = update_cast(context->update); + return MessageQueue_Post(up->queue, (void*)context, MakeMessageId(PointerUpdate, PointerCached), + (void*)wParam, NULL); } /* Message Queue */ @@ -2435,6 +2628,7 @@ int update_message_queue_process_message(rdpUpdate* update, wMessage* message) int status; int msgClass; int msgType; + rdp_update_internal* up = update_cast(update); if (!update || !message) return -1; @@ -2444,7 +2638,7 @@ int update_message_queue_process_message(rdpUpdate* update, wMessage* message) msgClass = GetMessageClass(message->id); msgType = GetMessageType(message->id); - status = update_message_process_class(update->proxy, message, msgClass, msgType); + status = update_message_process_class(up->proxy, message, msgClass, msgType); update_message_free_class(message, msgClass, msgType); if (status < 0) @@ -2474,12 +2668,10 @@ int update_message_queue_process_pending_messages(rdpUpdate* update) int status; wMessage message; wMessageQueue* queue; - - if (!update || !update->queue) - return -1; + rdp_update_internal* up = update_cast(update); status = 1; - queue = update->queue; + queue = up->queue; while (MessageQueue_Peek(queue, &message, TRUE)) { @@ -2671,20 +2863,13 @@ static DWORD WINAPI update_message_proxy_thread(LPVOID arg) { rdpUpdate* update = (rdpUpdate*)arg; wMessage message; + rdp_update_internal* up = update_cast(update); - if (!update || !update->queue) - { - WLog_ERR(TAG, "update=%p, update->queue=%p", (void*)update, - (void*)(update ? update->queue : NULL)); - ExitThread(1); - return 1; - } - - while (MessageQueue_Wait(update->queue)) + while (MessageQueue_Wait(up->queue)) { int status = 0; - if (MessageQueue_Peek(update->queue, &message, TRUE)) + if (MessageQueue_Peek(up->queue, &message, TRUE)) status = update_message_queue_process_message(update, &message); if (!status) @@ -2722,7 +2907,8 @@ void update_message_proxy_free(rdpUpdateProxy* message) { if (message) { - if (MessageQueue_PostQuit(message->update->queue, 0)) + rdp_update_internal* up = update_cast(message->update); + if (MessageQueue_PostQuit(up->queue, 0)) WaitForSingleObject(message->thread, INFINITE); CloseHandle(message->thread); diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 63e544e9b..c2c37c8f0 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -2025,6 +2025,7 @@ static CACHE_BITMAP_ORDER* update_read_cache_bitmap_order(rdpUpdate* update, wSt BOOL compressed, UINT16 flags) { CACHE_BITMAP_ORDER* cache_bitmap; + rdp_update_internal* up = update_cast(update); if (!update || !s) return NULL; @@ -2045,8 +2046,7 @@ static CACHE_BITMAP_ORDER* update_read_cache_bitmap_order(rdpUpdate* update, wSt if ((cache_bitmap->bitmapBpp < 1) || (cache_bitmap->bitmapBpp > 32)) { - WLog_Print(update->log, WLOG_ERROR, "invalid bitmap bpp %" PRIu32 "", - cache_bitmap->bitmapBpp); + WLog_Print(up->log, WLOG_ERROR, "invalid bitmap bpp %" PRIu32 "", cache_bitmap->bitmapBpp); goto fail; } @@ -2306,6 +2306,7 @@ static CACHE_BITMAP_V3_ORDER* update_read_cache_bitmap_v3_order(rdpUpdate* updat UINT32 new_len; BYTE* new_data; CACHE_BITMAP_V3_ORDER* cache_bitmap_v3; + rdp_update_internal* up = update_cast(update); if (!update || !s) return NULL; @@ -2333,7 +2334,7 @@ static CACHE_BITMAP_V3_ORDER* update_read_cache_bitmap_v3_order(rdpUpdate* updat if ((bitmapData->bpp < 1) || (bitmapData->bpp > 32)) { - WLog_Print(update->log, WLOG_ERROR, "invalid bpp value %" PRIu32 "", bitmapData->bpp); + WLog_Print(up->log, WLOG_ERROR, "invalid bpp value %" PRIu32 "", bitmapData->bpp); goto fail; } @@ -2708,6 +2709,7 @@ static CACHE_BRUSH_ORDER* update_read_cache_brush_order(rdpUpdate* update, wStre BOOL rc; BYTE iBitmapFormat; BOOL compressed = FALSE; + rdp_update_internal* up = update_cast(update); CACHE_BRUSH_ORDER* cache_brush = calloc(1, sizeof(CACHE_BRUSH_ORDER)); if (!cache_brush) @@ -2736,7 +2738,7 @@ static CACHE_BRUSH_ORDER* update_read_cache_brush_order(rdpUpdate* update, wStre { if (cache_brush->length != 8) { - WLog_Print(update->log, WLOG_ERROR, "incompatible 1bpp brush of length:%" PRIu32 "", + WLog_Print(up->log, WLOG_ERROR, "incompatible 1bpp brush of length:%" PRIu32 "", cache_brush->length); goto fail; } @@ -2787,10 +2789,15 @@ fail: free_cache_brush_order(update->context, cache_brush); return NULL; } -int update_approximate_cache_brush_order(const CACHE_BRUSH_ORDER* cache_brush, UINT16* flags) + +size_t update_approximate_cache_brush_order(const CACHE_BRUSH_ORDER* cache_brush, UINT16* flags) { + WINPR_UNUSED(cache_brush); + WINPR_UNUSED(flags); + return 64; } + BOOL update_write_cache_brush_order(wStream* s, const CACHE_BRUSH_ORDER* cache_brush, UINT16* flags) { int i; @@ -2919,12 +2926,20 @@ update_read_create_offscreen_bitmap_order(wStream* s, return TRUE; } -int update_approximate_create_offscreen_bitmap_order( + +size_t update_approximate_create_offscreen_bitmap_order( const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap) { - const OFFSCREEN_DELETE_LIST* deleteList = &(create_offscreen_bitmap->deleteList); + const OFFSCREEN_DELETE_LIST* deleteList; + + WINPR_ASSERT(create_offscreen_bitmap); + + deleteList = &(create_offscreen_bitmap->deleteList); + WINPR_ASSERT(deleteList); + return 32 + deleteList->cIndices * 2; } + BOOL update_write_create_offscreen_bitmap_order( wStream* s, const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap) { @@ -2968,13 +2983,13 @@ static BOOL update_read_switch_surface_order(wStream* s, SWITCH_SURFACE_ORDER* s Stream_Read_UINT16(s, switch_surface->bitmapId); /* bitmapId (2 bytes) */ return TRUE; } -int update_approximate_switch_surface_order(const SWITCH_SURFACE_ORDER* switch_surface) +size_t update_approximate_switch_surface_order(const SWITCH_SURFACE_ORDER* switch_surface) { return 2; } BOOL update_write_switch_surface_order(wStream* s, const SWITCH_SURFACE_ORDER* switch_surface) { - int inf = update_approximate_switch_surface_order(switch_surface); + size_t inf = update_approximate_switch_surface_order(switch_surface); if (!Stream_EnsureRemainingCapacity(s, inf)) return FALSE; @@ -3425,20 +3440,31 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) { BYTE field; BOOL rc = FALSE; + rdp_update_internal* up = update_cast(update); rdpContext* context = update->context; rdpPrimaryUpdate* primary = update->primary; - ORDER_INFO* orderInfo = &(primary->order_info); - rdpSettings* settings = context->settings; + ORDER_INFO* orderInfo; + rdpSettings* settings; const char* orderName; BOOL defaultReturn; + WINPR_ASSERT(s); + WINPR_ASSERT(primary); + + orderInfo = &(primary->order_info); + WINPR_ASSERT(orderInfo); + WINPR_ASSERT(context); + + settings = context->settings; + WINPR_ASSERT(settings); + defaultReturn = freerdp_settings_get_bool(settings, FreeRDP_DeactivateClientDecoding); if (flags & ORDER_TYPE_CHANGE) { if (Stream_GetRemainingLength(s) < 1) { - WLog_Print(update->log, WLOG_ERROR, "Stream_GetRemainingLength(s) < 1"); + WLog_Print(up->log, WLOG_ERROR, "Stream_GetRemainingLength(s) < 1"); return FALSE; } @@ -3446,9 +3472,9 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) } orderName = primary_order_string(orderInfo->orderType); - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); - if (!check_primary_order_supported(update->log, settings, orderInfo->orderType, orderName)) + if (!check_primary_order_supported(up->log, settings, orderInfo->orderType, orderName)) return FALSE; field = get_primary_drawing_order_field_bytes(orderInfo->orderType, &rc); @@ -3457,7 +3483,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) if (!update_read_field_flags(s, &(orderInfo->fieldFlags), flags, field)) { - WLog_Print(update->log, WLOG_ERROR, "update_read_field_flags() failed"); + WLog_Print(up->log, WLOG_ERROR, "update_read_field_flags() failed"); return FALSE; } @@ -3467,7 +3493,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) { if (!update_read_bounds(s, &orderInfo->bounds)) { - WLog_Print(update->log, WLOG_ERROR, "update_read_bounds() failed"); + WLog_Print(up->log, WLOG_ERROR, "update_read_bounds() failed"); return FALSE; } } @@ -3480,7 +3506,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) orderInfo->deltaCoordinates = (flags & ORDER_DELTA_COORDINATES) ? TRUE : FALSE; - if (!read_primary_order(update->log, orderName, s, orderInfo, primary)) + if (!read_primary_order(up->log, orderName, s, orderInfo, primary)) return FALSE; rc = IFCALLRESULT(TRUE, primary->OrderInfo, context, orderInfo, orderName); @@ -3491,7 +3517,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) { case ORDER_TYPE_DSTBLT: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", orderName, gdi_rop3_code_string(primary->dstblt.bRop), gdi_rop3_code(primary->dstblt.bRop)); rc = IFCALLRESULT(defaultReturn, primary->DstBlt, context, &primary->dstblt); @@ -3500,7 +3526,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_PATBLT: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", orderName, gdi_rop3_code_string(primary->patblt.bRop), gdi_rop3_code(primary->patblt.bRop)); rc = IFCALLRESULT(defaultReturn, primary->PatBlt, context, &primary->patblt); @@ -3509,7 +3535,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_SCRBLT: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", orderName, gdi_rop3_code_string(primary->scrblt.bRop), gdi_rop3_code(primary->scrblt.bRop)); rc = IFCALLRESULT(defaultReturn, primary->ScrBlt, context, &primary->scrblt); @@ -3518,14 +3544,14 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_OPAQUE_RECT: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->OpaqueRect, context, &primary->opaque_rect); } break; case ORDER_TYPE_DRAW_NINE_GRID: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->DrawNineGrid, context, &primary->draw_nine_grid); } @@ -3533,7 +3559,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_MULTI_DSTBLT: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", orderName, gdi_rop3_code_string(primary->multi_dstblt.bRop), gdi_rop3_code(primary->multi_dstblt.bRop)); rc = IFCALLRESULT(defaultReturn, primary->MultiDstBlt, context, &primary->multi_dstblt); @@ -3542,7 +3568,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_MULTI_PATBLT: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", orderName, gdi_rop3_code_string(primary->multi_patblt.bRop), gdi_rop3_code(primary->multi_patblt.bRop)); rc = IFCALLRESULT(defaultReturn, primary->MultiPatBlt, context, &primary->multi_patblt); @@ -3551,7 +3577,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_MULTI_SCRBLT: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", orderName, gdi_rop3_code_string(primary->multi_scrblt.bRop), gdi_rop3_code(primary->multi_scrblt.bRop)); rc = IFCALLRESULT(defaultReturn, primary->MultiScrBlt, context, &primary->multi_scrblt); @@ -3560,7 +3586,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_MULTI_OPAQUE_RECT: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->MultiOpaqueRect, context, &primary->multi_opaque_rect); } @@ -3568,7 +3594,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_MULTI_DRAW_NINE_GRID: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->MultiDrawNineGrid, context, &primary->multi_draw_nine_grid); } @@ -3576,21 +3602,21 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_LINE_TO: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->LineTo, context, &primary->line_to); } break; case ORDER_TYPE_POLYLINE: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->Polyline, context, &primary->polyline); } break; case ORDER_TYPE_MEMBLT: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", orderName, gdi_rop3_code_string(primary->memblt.bRop), gdi_rop3_code(primary->memblt.bRop)); rc = IFCALLRESULT(defaultReturn, primary->MemBlt, context, &primary->memblt); @@ -3599,7 +3625,7 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_MEM3BLT: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s rop=%s [0x%08" PRIx32 "]", orderName, gdi_rop3_code_string(primary->mem3blt.bRop), gdi_rop3_code(primary->mem3blt.bRop)); rc = IFCALLRESULT(defaultReturn, primary->Mem3Blt, context, &primary->mem3blt); @@ -3608,68 +3634,68 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) case ORDER_TYPE_SAVE_BITMAP: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->SaveBitmap, context, &primary->save_bitmap); } break; case ORDER_TYPE_GLYPH_INDEX: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->GlyphIndex, context, &primary->glyph_index); } break; case ORDER_TYPE_FAST_INDEX: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->FastIndex, context, &primary->fast_index); } break; case ORDER_TYPE_FAST_GLYPH: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->FastGlyph, context, &primary->fast_glyph); } break; case ORDER_TYPE_POLYGON_SC: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->PolygonSC, context, &primary->polygon_sc); } break; case ORDER_TYPE_POLYGON_CB: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->PolygonCB, context, &primary->polygon_cb); } break; case ORDER_TYPE_ELLIPSE_SC: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->EllipseSC, context, &primary->ellipse_sc); } break; case ORDER_TYPE_ELLIPSE_CB: { - WLog_Print(update->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Primary Drawing Order %s", orderName); rc = IFCALLRESULT(defaultReturn, primary->EllipseCB, context, &primary->ellipse_cb); } break; default: - WLog_Print(update->log, WLOG_WARN, "Primary Drawing Order %s not supported", orderName); + WLog_Print(up->log, WLOG_WARN, "Primary Drawing Order %s not supported", orderName); break; } if (!rc) { - WLog_Print(update->log, WLOG_WARN, "Primary Drawing Order %s failed", orderName); + WLog_Print(up->log, WLOG_WARN, "Primary Drawing Order %s failed", orderName); return FALSE; } @@ -3689,6 +3715,7 @@ static BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flag UINT16 extraFlags; INT16 orderLength; INT32 orderLengthFull; + rdp_update_internal* up = update_cast(update); rdpContext* context = update->context; rdpSettings* settings = context->settings; rdpSecondaryUpdate* secondary = update->secondary; @@ -3700,7 +3727,7 @@ static BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flag rem = Stream_GetRemainingLength(s); if (rem < 5) { - WLog_Print(update->log, WLOG_ERROR, "Stream_GetRemainingLength(s) < 5"); + WLog_Print(up->log, WLOG_ERROR, "Stream_GetRemainingLength(s) < 5"); return FALSE; } @@ -3710,7 +3737,7 @@ static BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flag start = Stream_GetPosition(s); name = secondary_order_string(orderType); - WLog_Print(update->log, WLOG_DEBUG, "Secondary Drawing Order %s", name); + WLog_Print(up->log, WLOG_DEBUG, "Secondary Drawing Order %s", name); rc = IFCALLRESULT(TRUE, secondary->CacheOrderInfo, context, orderLength, extraFlags, orderType, name); if (!rc) @@ -3728,12 +3755,12 @@ static BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flag orderLengthFull = orderLength + 7; if ((orderLengthFull < 0) || (rem < (size_t)orderLengthFull)) { - WLog_Print(update->log, WLOG_ERROR, "Stream_GetRemainingLength(s) %" PRIuz " < %" PRId32, - rem, orderLengthFull); + WLog_Print(up->log, WLOG_ERROR, "Stream_GetRemainingLength(s) %" PRIuz " < %" PRId32, rem, + orderLengthFull); return FALSE; } - if (!check_secondary_order_supported(update->log, settings, orderType, name)) + if (!check_secondary_order_supported(up->log, settings, orderType, name)) return FALSE; switch (orderType) @@ -3844,28 +3871,28 @@ static BOOL update_recv_secondary_order(rdpUpdate* update, wStream* s, BYTE flag break; default: - WLog_Print(update->log, WLOG_WARN, "SECONDARY ORDER %s not supported", name); + WLog_Print(up->log, WLOG_WARN, "SECONDARY ORDER %s not supported", name); break; } if (!rc) { - WLog_Print(update->log, WLOG_ERROR, "SECONDARY ORDER %s failed", name); + WLog_Print(up->log, WLOG_ERROR, "SECONDARY ORDER %s failed", name); } end = start + orderLengthFull; pos = Stream_GetPosition(s); if (pos > end) { - WLog_Print(update->log, WLOG_WARN, "SECONDARY_ORDER %s: read %" PRIuz "bytes too much", - name, pos - end); + WLog_Print(up->log, WLOG_WARN, "SECONDARY_ORDER %s: read %" PRIuz "bytes too much", name, + pos - end); return FALSE; } diff = end - pos; if (diff > 0) { - WLog_Print(update->log, WLOG_DEBUG, - "SECONDARY_ORDER %s: read %" PRIuz "bytes short, skipping", name, diff); + WLog_Print(up->log, WLOG_DEBUG, "SECONDARY_ORDER %s: read %" PRIuz "bytes short, skipping", + name, diff); if (!Stream_SafeSeek(s, diff)) return FALSE; } @@ -3946,17 +3973,18 @@ static BOOL update_recv_altsec_order(rdpUpdate* update, wStream* s, BYTE flags) { BYTE orderType = flags >>= 2; /* orderType is in higher 6 bits of flags field */ BOOL rc = FALSE; + rdp_update_internal* up = update_cast(update); rdpContext* context = update->context; rdpSettings* settings = context->settings; rdpAltSecUpdate* altsec = update->altsec; const char* orderName = altsec_order_string(orderType); - WLog_Print(update->log, WLOG_DEBUG, "Alternate Secondary Drawing Order %s", orderName); + WLog_Print(up->log, WLOG_DEBUG, "Alternate Secondary Drawing Order %s", orderName); rc = IFCALLRESULT(TRUE, altsec->DrawOrderInfo, context, orderType, orderName); if (!rc) return FALSE; - if (!check_alt_order_supported(update->log, settings, orderType, orderName)) + if (!check_alt_order_supported(up->log, settings, orderType, orderName)) return FALSE; if (!read_altsec_order(s, orderType, altsec)) @@ -4030,8 +4058,7 @@ static BOOL update_recv_altsec_order(rdpUpdate* update, wStream* s, BYTE flags) if (!rc) { - WLog_Print(update->log, WLOG_WARN, "Alternate Secondary Drawing Order %s failed", - orderName); + WLog_Print(up->log, WLOG_WARN, "Alternate Secondary Drawing Order %s failed", orderName); } return rc; @@ -4040,10 +4067,11 @@ BOOL update_recv_order(rdpUpdate* update, wStream* s) { BOOL rc; BYTE controlFlags; + rdp_update_internal* up = update_cast(update); if (Stream_GetRemainingLength(s) < 1) { - WLog_Print(update->log, WLOG_ERROR, "Stream_GetRemainingLength(s) < 1"); + WLog_Print(up->log, WLOG_ERROR, "Stream_GetRemainingLength(s) < 1"); return FALSE; } @@ -4057,7 +4085,7 @@ BOOL update_recv_order(rdpUpdate* update, wStream* s) rc = update_recv_primary_order(update, s, controlFlags); if (!rc) - WLog_Print(update->log, WLOG_ERROR, "order flags %02" PRIx8 " failed", controlFlags); + WLog_Print(up->log, WLOG_ERROR, "order flags %02" PRIx8 " failed", controlFlags); return rc; } diff --git a/libfreerdp/core/orders.h b/libfreerdp/core/orders.h index d429dff70..a5eec0b6b 100644 --- a/libfreerdp/core/orders.h +++ b/libfreerdp/core/orders.h @@ -268,18 +268,18 @@ FREERDP_LOCAL BOOL update_write_cache_glyph_v2_order(wStream* s, const CACHE_GLYPH_V2_ORDER* cache_glyph_v2, UINT16* flags); -FREERDP_LOCAL int update_approximate_cache_brush_order(const CACHE_BRUSH_ORDER* cache_brush, - UINT16* flags); +FREERDP_LOCAL size_t update_approximate_cache_brush_order(const CACHE_BRUSH_ORDER* cache_brush, + UINT16* flags); FREERDP_LOCAL BOOL update_write_cache_brush_order(wStream* s, const CACHE_BRUSH_ORDER* cache_brush_order, UINT16* flags); -FREERDP_LOCAL int update_approximate_create_offscreen_bitmap_order( +FREERDP_LOCAL size_t update_approximate_create_offscreen_bitmap_order( const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap); FREERDP_LOCAL BOOL update_write_create_offscreen_bitmap_order( wStream* s, const CREATE_OFFSCREEN_BITMAP_ORDER* create_offscreen_bitmap); -FREERDP_LOCAL int +FREERDP_LOCAL size_t update_approximate_switch_surface_order(const SWITCH_SURFACE_ORDER* switch_surface); FREERDP_LOCAL BOOL update_write_switch_surface_order(wStream* s, const SWITCH_SURFACE_ORDER* switch_surface); diff --git a/libfreerdp/core/surface.c b/libfreerdp/core/surface.c index 988f93787..1b49242d6 100644 --- a/libfreerdp/core/surface.c +++ b/libfreerdp/core/surface.c @@ -145,14 +145,16 @@ fail: static BOOL update_recv_surfcmd_frame_marker(rdpUpdate* update, wStream* s) { SURFACE_FRAME_MARKER marker = { 0 }; + rdp_update_internal* up = update_cast(update); + + WINPR_ASSERT(s); if (Stream_GetRemainingLength(s) < 6) return FALSE; Stream_Read_UINT16(s, marker.frameAction); Stream_Read_UINT32(s, marker.frameId); - WLog_Print(update->log, WLOG_DEBUG, - "SurfaceFrameMarker: action: %s (%" PRIu32 ") id: %" PRIu32 "", + WLog_Print(up->log, WLOG_DEBUG, "SurfaceFrameMarker: action: %s (%" PRIu32 ") id: %" PRIu32 "", (!marker.frameAction) ? "Begin" : "End", marker.frameAction, marker.frameId); if (!update->SurfaceFrameMarker) @@ -167,6 +169,9 @@ static BOOL update_recv_surfcmd_frame_marker(rdpUpdate* update, wStream* s) int update_recv_surfcmds(rdpUpdate* update, wStream* s) { UINT16 cmdType; + rdp_update_internal* up = update_cast(update); + + WINPR_ASSERT(s); while (Stream_GetRemainingLength(s) >= 2) { @@ -195,12 +200,12 @@ int update_recv_surfcmds(rdpUpdate* update, wStream* s) return -1; } - if (update->dump_rfx) + if (up->dump_rfx) { const size_t size = Stream_GetPosition(s) - start; /* TODO: treat return values */ - pcap_add_record(update->pcap_rfx, mark, size); - pcap_flush(update->pcap_rfx); + pcap_add_record(up->pcap_rfx, mark, size); + pcap_flush(up->pcap_rfx); } } diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 8a10dda62..19ecd196c 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -145,8 +145,10 @@ static BOOL update_read_bitmap_data(rdpUpdate* update, wStream* s, BITMAP_DATA* return TRUE; } -static BOOL update_write_bitmap_data(rdpUpdate* update, wStream* s, BITMAP_DATA* bitmapData) +static BOOL update_write_bitmap_data(rdpUpdate* update_pub, wStream* s, BITMAP_DATA* bitmapData) { + rdp_update_internal* update = update_cast(update_pub); + if (!Stream_EnsureRemainingCapacity(s, 64 + bitmapData->bitmapLength)) return FALSE; @@ -158,7 +160,7 @@ static BOOL update_write_bitmap_data(rdpUpdate* update, wStream* s, BITMAP_DATA* if (bitmapData->compressed) bitmapData->flags |= BITMAP_COMPRESSION; - if (update->context->settings->NoBitmapCompressionHeader) + if (update->common.context->settings->NoBitmapCompressionHeader) { bitmapData->flags |= NO_BITMAP_COMPRESSION_HDR; bitmapData->cbCompMainBodySize = bitmapData->bitmapLength; @@ -202,6 +204,7 @@ BITMAP_UPDATE* update_read_bitmap_update(rdpUpdate* update, wStream* s) { UINT32 i; BITMAP_UPDATE* bitmapUpdate = calloc(1, sizeof(BITMAP_UPDATE)); + rdp_update_internal* up = update_cast(update); if (!bitmapUpdate) goto fail; @@ -210,7 +213,7 @@ BITMAP_UPDATE* update_read_bitmap_update(rdpUpdate* update, wStream* s) goto fail; Stream_Read_UINT16(s, bitmapUpdate->number); /* numberRectangles (2 bytes) */ - WLog_Print(update->log, WLOG_TRACE, "BitmapUpdate: %" PRIu32 "", bitmapUpdate->number); + WLog_Print(up->log, WLOG_TRACE, "BitmapUpdate: %" PRIu32 "", bitmapUpdate->number); if (bitmapUpdate->number > bitmapUpdate->count) { @@ -772,6 +775,7 @@ BOOL update_recv(rdpUpdate* update, wStream* s) { BOOL rc = FALSE; UINT16 updateType; + rdp_update_internal* up = update_cast(update); rdpContext* context = update->context; if (Stream_GetRemainingLength(s) < 2) @@ -781,7 +785,7 @@ BOOL update_recv(rdpUpdate* update, wStream* s) } Stream_Read_UINT16(s, updateType); /* updateType (2 bytes) */ - WLog_Print(update->log, WLOG_TRACE, "%s Update Data PDU", update_type_to_string(updateType)); + WLog_Print(up->log, WLOG_TRACE, "%s Update Data PDU", update_type_to_string(updateType)); if (!update_begin_paint(update)) goto fail; @@ -849,9 +853,13 @@ fail: void update_reset_state(rdpUpdate* update) { + rdp_update_internal* up = update_cast(update); rdpPrimaryUpdate* primary = update->primary; rdpAltSecUpdate* altsec = update->altsec; + WINPR_ASSERT(primary); + WINPR_ASSERT(altsec); + if (primary->fast_glyph.glyphData.aj) { free(primary->fast_glyph.glyphData.aj); @@ -883,7 +891,7 @@ void update_reset_state(rdpUpdate* update) ZeroMemory(&primary->ellipse_cb, sizeof(ELLIPSE_CB_ORDER)); primary->order_info.orderType = ORDER_TYPE_PATBLT; - if (!update->initialState) + if (!up->initialState) { altsec->switch_surface.bitmapId = SCREEN_BITMAP_SURFACE; IFCALL(altsec->SwitchSurface, update->context, &(altsec->switch_surface)); @@ -892,36 +900,40 @@ void update_reset_state(rdpUpdate* update) BOOL update_post_connect(rdpUpdate* update) { - update->asynchronous = update->context->settings->AsyncUpdate; + rdp_update_internal* up = update_cast(update); - if (update->asynchronous) - if (!(update->proxy = update_message_proxy_new(update))) + up->asynchronous = update->context->settings->AsyncUpdate; + + if (up->asynchronous) + if (!(up->proxy = update_message_proxy_new(update))) return FALSE; update->altsec->switch_surface.bitmapId = SCREEN_BITMAP_SURFACE; IFCALL(update->altsec->SwitchSurface, update->context, &(update->altsec->switch_surface)); - update->initialState = FALSE; + up->initialState = FALSE; return TRUE; } void update_post_disconnect(rdpUpdate* update) { - update->asynchronous = update->context->settings->AsyncUpdate; + rdp_update_internal* up = update_cast(update); - if (update->asynchronous) - update_message_proxy_free(update->proxy); + up->asynchronous = update->context->settings->AsyncUpdate; - update->initialState = TRUE; + if (up->asynchronous) + update_message_proxy_free(up->proxy); + + up->initialState = TRUE; } static BOOL _update_begin_paint(rdpContext* context) { wStream* s; - rdpUpdate* update = context->update; + rdp_update_internal* update = update_cast(context->update); if (update->us) { - if (!update_end_paint(update)) + if (!update_end_paint(&update->common)) return FALSE; } @@ -942,7 +954,7 @@ static BOOL _update_begin_paint(rdpContext* context) static BOOL _update_end_paint(rdpContext* context) { wStream* s; - rdpUpdate* update = context->update; + rdp_update_internal* update = update_cast(context->update); if (!update->us) return FALSE; @@ -969,12 +981,15 @@ static BOOL _update_end_paint(rdpContext* context) static void update_flush(rdpContext* context) { - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + update = update_cast(context->update); if (update->numberOrders > 0) { - update_end_paint(update); - update_begin_paint(update); + update_end_paint(&update->common); + update_begin_paint(&update->common); } } @@ -983,15 +998,19 @@ static void update_force_flush(rdpContext* context) update_flush(context); } -static BOOL update_check_flush(rdpContext* context, int size) +static BOOL update_check_flush(rdpContext* context, size_t size) { wStream* s; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + update = update_cast(context->update); + s = update->us; if (!update->us) { - update_begin_paint(update); + update_begin_paint(&update->common); return FALSE; } @@ -1006,7 +1025,12 @@ static BOOL update_check_flush(rdpContext* context, int size) static BOOL update_set_bounds(rdpContext* context, const rdpBounds* bounds) { - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + + update = update_cast(context->update); + CopyMemory(&update->previousBounds, &update->currentBounds, sizeof(rdpBounds)); if (!bounds) @@ -1037,7 +1061,13 @@ static BOOL update_bounds_equals(rdpBounds* bounds1, rdpBounds* bounds2) static int update_prepare_bounds(rdpContext* context, ORDER_INFO* orderInfo) { int length = 0; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(orderInfo); + + update = update_cast(context->update); + orderInfo->boundsFlags = 0; if (update_bounds_is_null(&update->currentBounds)) @@ -1384,11 +1414,17 @@ static BOOL update_send_play_sound(rdpContext* context, const PLAY_SOUND_UPDATE* static BOOL update_send_dstblt(rdpContext* context, const DSTBLT_ORDER* dstblt) { wStream* s; - UINT32 offset; + size_t offset; UINT32 headerLength; ORDER_INFO orderInfo; int inf; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(dstblt); + + update = update_cast(context->update); + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_DSTBLT); inf = update_approximate_dstblt_order(&orderInfo, dstblt); update_check_flush(context, headerLength + inf); @@ -1418,7 +1454,12 @@ static BOOL update_send_patblt(rdpContext* context, PATBLT_ORDER* patblt) size_t offset; int headerLength; ORDER_INFO orderInfo; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(patblt); + update = update_cast(context->update); + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_PATBLT); update_check_flush(context, headerLength + update_approximate_patblt_order(&orderInfo, patblt)); s = update->us; @@ -1445,7 +1486,12 @@ static BOOL update_send_scrblt(rdpContext* context, const SCRBLT_ORDER* scrblt) UINT32 headerLength; ORDER_INFO orderInfo; int inf; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(scrblt); + update = update_cast(context->update); + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_SCRBLT); inf = update_approximate_scrblt_order(&orderInfo, scrblt); update_check_flush(context, headerLength + inf); @@ -1472,7 +1518,12 @@ static BOOL update_send_opaque_rect(rdpContext* context, const OPAQUE_RECT_ORDER size_t offset; int headerLength; ORDER_INFO orderInfo; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(opaque_rect); + update = update_cast(context->update); + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_OPAQUE_RECT); update_check_flush(context, headerLength + update_approximate_opaque_rect_order(&orderInfo, opaque_rect)); @@ -1500,7 +1551,11 @@ static BOOL update_send_line_to(rdpContext* context, const LINE_TO_ORDER* line_t int headerLength; ORDER_INFO orderInfo; int inf; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(line_to); + update = update_cast(context->update); headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_LINE_TO); inf = update_approximate_line_to_order(&orderInfo, line_to); update_check_flush(context, headerLength + inf); @@ -1527,7 +1582,11 @@ static BOOL update_send_memblt(rdpContext* context, MEMBLT_ORDER* memblt) size_t offset; int headerLength; ORDER_INFO orderInfo; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(memblt); + update = update_cast(context->update); headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_MEMBLT); update_check_flush(context, headerLength + update_approximate_memblt_order(&orderInfo, memblt)); s = update->us; @@ -1554,7 +1613,12 @@ static BOOL update_send_glyph_index(rdpContext* context, GLYPH_INDEX_ORDER* glyp int headerLength; int inf; ORDER_INFO orderInfo; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(glyph_index); + update = update_cast(context->update); + headerLength = update_prepare_order_info(context, &orderInfo, ORDER_TYPE_GLYPH_INDEX); inf = update_approximate_glyph_index_order(&orderInfo, glyph_index); update_check_flush(context, headerLength + inf); @@ -1588,7 +1652,12 @@ static BOOL update_send_cache_bitmap(rdpContext* context, const CACHE_BITMAP_ORD int inf; UINT16 extraFlags; INT16 orderLength; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(cache_bitmap); + update = update_cast(context->update); + extraFlags = 0; headerLength = 6; orderType = cache_bitmap->compressed ? ORDER_TYPE_CACHE_BITMAP_COMPRESSED @@ -1631,7 +1700,12 @@ static BOOL update_send_cache_bitmap_v2(rdpContext* context, CACHE_BITMAP_V2_ORD int headerLength; UINT16 extraFlags; INT16 orderLength; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(cache_bitmap_v2); + update = update_cast(context->update); + extraFlags = 0; headerLength = 6; orderType = cache_bitmap_v2->compressed ? ORDER_TYPE_BITMAP_COMPRESSED_V2 @@ -1679,7 +1753,12 @@ static BOOL update_send_cache_bitmap_v3(rdpContext* context, CACHE_BITMAP_V3_ORD int headerLength; UINT16 extraFlags; INT16 orderLength; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(cache_bitmap_v3); + update = update_cast(context->update); + extraFlags = 0; headerLength = 6; orderType = ORDER_TYPE_BITMAP_COMPRESSED_V3; @@ -1720,7 +1799,12 @@ static BOOL update_send_cache_color_table(rdpContext* context, size_t bm, em, inf; int headerLength; INT16 orderLength; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(cache_color_table); + update = update_cast(context->update); + flags = 0; headerLength = 6; inf = update_approximate_cache_color_table_order(cache_color_table, &flags); @@ -1759,7 +1843,12 @@ static BOOL update_send_cache_glyph(rdpContext* context, const CACHE_GLYPH_ORDER size_t bm, em, inf; int headerLength; INT16 orderLength; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(cache_glyph); + update = update_cast(context->update); + flags = 0; headerLength = 6; inf = update_approximate_cache_glyph_order(cache_glyph, &flags); @@ -1799,7 +1888,12 @@ static BOOL update_send_cache_glyph_v2(rdpContext* context, size_t bm, em, inf; int headerLength; INT16 orderLength; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(cache_glyph_v2); + update = update_cast(context->update); + flags = 0; headerLength = 6; inf = update_approximate_cache_glyph_v2_order(cache_glyph_v2, &flags); @@ -1838,7 +1932,12 @@ static BOOL update_send_cache_brush(rdpContext* context, const CACHE_BRUSH_ORDER size_t bm, em, inf; int headerLength; INT16 orderLength; - rdpUpdate* update = context->update; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(cache_brush); + update = update_cast(context->update); + flags = 0; headerLength = 6; inf = update_approximate_cache_brush_order(cache_brush, &flags); @@ -1881,8 +1980,13 @@ static BOOL update_send_create_offscreen_bitmap_order( size_t bm, em, inf; BYTE orderType; BYTE controlFlags; - int headerLength; - rdpUpdate* update = context->update; + size_t headerLength; + rdp_update_internal* update; + + WINPR_ASSERT(context); + WINPR_ASSERT(create_offscreen_bitmap); + update = update_cast(context->update); + headerLength = 1; orderType = ORDER_TYPE_CREATE_OFFSCREEN_BITMAP; controlFlags = ORDER_SECONDARY | (orderType << 2); @@ -1918,13 +2022,13 @@ static BOOL update_send_switch_surface_order(rdpContext* context, size_t bm, em, inf; BYTE orderType; BYTE controlFlags; - int headerLength; - rdpUpdate* update; + size_t headerLength; + rdp_update_internal* update; - if (!context || !switch_surface || !context->update) - return FALSE; + WINPR_ASSERT(context); + WINPR_ASSERT(switch_surface); + update = update_cast(context->update); - update = context->update; headerLength = 1; orderType = ORDER_TYPE_SWITCH_SURFACE; controlFlags = ORDER_SECONDARY | (orderType << 2); @@ -2122,6 +2226,7 @@ BOOL update_read_refresh_rect(rdpUpdate* update, wStream* s) int index; BYTE numberOfAreas; RECTANGLE_16* areas; + rdp_update_internal* up = update_cast(update); if (Stream_GetRemainingLength(s) < 4) return FALSE; @@ -2148,7 +2253,7 @@ BOOL update_read_refresh_rect(rdpUpdate* update, wStream* s) if (update->context->settings->RefreshRect) IFCALL(update->RefreshRect, update->context, numberOfAreas, areas); else - WLog_Print(update->log, WLOG_WARN, "ignoring refresh rect request from client"); + WLog_Print(up->log, WLOG_WARN, "ignoring refresh rect request from client"); free(areas); return TRUE; @@ -2156,6 +2261,7 @@ BOOL update_read_refresh_rect(rdpUpdate* update, wStream* s) BOOL update_read_suppress_output(rdpUpdate* update, wStream* s) { + rdp_update_internal* up = update_cast(update); RECTANGLE_16* prect = NULL; RECTANGLE_16 rect = { 0 }; BYTE allowDisplayUpdates; @@ -2181,7 +2287,7 @@ BOOL update_read_suppress_output(rdpUpdate* update, wStream* s) if (update->context->settings->SuppressOutput) IFCALL(update->SuppressOutput, update->context, allowDisplayUpdates, prect); else - WLog_Print(update->log, WLOG_WARN, "ignoring suppress output request from client"); + WLog_Print(up->log, WLOG_WARN, "ignoring suppress output request from client"); return TRUE; } @@ -2293,9 +2399,12 @@ static BOOL update_send_new_or_existing_window(rdpContext* context, const WINDOW_STATE_ORDER* stateOrder) { wStream* s; - rdpUpdate* update = context->update; BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2); UINT16 orderSize = update_calculate_new_or_existing_window(orderInfo, stateOrder); + rdp_update_internal* update; + + WINPR_ASSERT(context); + update = update_cast(context->update); update_check_flush(context, orderSize); @@ -2464,10 +2573,13 @@ static BOOL update_send_window_icon(rdpContext* context, const WINDOW_ORDER_INFO const WINDOW_ICON_ORDER* iconOrder) { wStream* s; - rdpUpdate* update = context->update; BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2); ICON_INFO* iconInfo = iconOrder->iconInfo; UINT16 orderSize = update_calculate_window_icon_order(orderInfo, iconOrder); + rdp_update_internal* update; + + WINPR_ASSERT(context); + update = update_cast(context->update); update_check_flush(context, orderSize); @@ -2515,10 +2627,13 @@ static BOOL update_send_window_cached_icon(rdpContext* context, const WINDOW_ORD const WINDOW_CACHED_ICON_ORDER* cachedIconOrder) { wStream* s; - rdpUpdate* update = context->update; BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2); UINT16 orderSize = 14; CACHED_ICON_INFO cachedIcon = cachedIconOrder->cachedIcon; + rdp_update_internal* update; + + WINPR_ASSERT(context); + update = update_cast(context->update); update_check_flush(context, orderSize); @@ -2544,9 +2659,13 @@ static BOOL update_send_window_cached_icon(rdpContext* context, const WINDOW_ORD static BOOL update_send_window_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo) { wStream* s; - rdpUpdate* update = context->update; BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2); UINT16 orderSize = 11; + rdp_update_internal* update; + + WINPR_ASSERT(context); + update = update_cast(context->update); + update_check_flush(context, orderSize); s = update->us; @@ -2614,11 +2733,14 @@ update_send_new_or_existing_notification_icons(rdpContext* context, const NOTIFY_ICON_STATE_ORDER* iconStateOrder) { wStream* s; - rdpUpdate* update = context->update; BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2); BOOL versionFieldPresent = FALSE; UINT16 orderSize = update_calculate_new_or_existing_notification_icons_order(orderInfo, iconStateOrder); + rdp_update_internal* update; + + WINPR_ASSERT(context); + update = update_cast(context->update); update_check_flush(context, orderSize); @@ -2726,9 +2848,13 @@ static BOOL update_send_notify_icon_update(rdpContext* context, const WINDOW_ORD static BOOL update_send_notify_icon_delete(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo) { wStream* s; - rdpUpdate* update = context->update; BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2); UINT16 orderSize = 15; + rdp_update_internal* update; + + WINPR_ASSERT(context); + update = update_cast(context->update); + update_check_flush(context, orderSize); s = update->us; @@ -2769,9 +2895,13 @@ static BOOL update_send_monitored_desktop(rdpContext* context, const WINDOW_ORDE { UINT32 i; wStream* s; - rdpUpdate* update = context->update; BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2); UINT16 orderSize = update_calculate_monitored_desktop(orderInfo, monitoredDesktop); + rdp_update_internal* update; + + WINPR_ASSERT(context); + update = update_cast(context->update); + update_check_flush(context, orderSize); s = update->us; @@ -2807,9 +2937,13 @@ static BOOL update_send_non_monitored_desktop(rdpContext* context, const WINDOW_ORDER_INFO* orderInfo) { wStream* s; - rdpUpdate* update = context->update; BYTE controlFlags = ORDER_SECONDARY | (ORDER_TYPE_WINDOW << 2); UINT16 orderSize = 7; + rdp_update_internal* update; + + WINPR_ASSERT(context); + update = update_cast(context->update); + update_check_flush(context, orderSize); s = update->us; @@ -2908,42 +3042,42 @@ void update_free_window_state(WINDOW_STATE_ORDER* window_state) rdpUpdate* update_new(rdpRdp* rdp) { const wObject cb = { NULL, NULL, NULL, update_free_queued_message, NULL }; - rdpUpdate* update; + rdp_update_internal* update; OFFSCREEN_DELETE_LIST* deleteList; WINPR_UNUSED(rdp); - update = (rdpUpdate*)calloc(1, sizeof(rdpUpdate)); + update = (rdp_update_internal*)calloc(1, sizeof(rdp_update_internal)); if (!update) return NULL; update->log = WLog_Get("com.freerdp.core.update"); InitializeCriticalSection(&(update->mux)); - update->pointer = (rdpPointerUpdate*)calloc(1, sizeof(rdpPointerUpdate)); + update->common.pointer = (rdpPointerUpdate*)calloc(1, sizeof(rdpPointerUpdate)); - if (!update->pointer) + if (!update->common.pointer) goto fail; - update->primary = (rdpPrimaryUpdate*)calloc(1, sizeof(rdpPrimaryUpdate)); + update->common.primary = (rdpPrimaryUpdate*)calloc(1, sizeof(rdpPrimaryUpdate)); - if (!update->primary) + if (!update->common.primary) goto fail; - update->secondary = (rdpSecondaryUpdate*)calloc(1, sizeof(rdpSecondaryUpdate)); + update->common.secondary = (rdpSecondaryUpdate*)calloc(1, sizeof(rdpSecondaryUpdate)); - if (!update->secondary) + if (!update->common.secondary) goto fail; - update->altsec = (rdpAltSecUpdate*)calloc(1, sizeof(rdpAltSecUpdate)); + update->common.altsec = (rdpAltSecUpdate*)calloc(1, sizeof(rdpAltSecUpdate)); - if (!update->altsec) + if (!update->common.altsec) goto fail; - update->window = (rdpWindowUpdate*)calloc(1, sizeof(rdpWindowUpdate)); + update->common.window = (rdpWindowUpdate*)calloc(1, sizeof(rdpWindowUpdate)); - if (!update->window) + if (!update->common.window) goto fail; - deleteList = &(update->altsec->create_offscreen_bitmap.deleteList); + deleteList = &(update->common.altsec->create_offscreen_bitmap.deleteList); deleteList->sIndices = 64; deleteList->indices = calloc(deleteList->sIndices, 2); @@ -2951,7 +3085,7 @@ rdpUpdate* update_new(rdpRdp* rdp) goto fail; deleteList->cIndices = 0; - update->SuppressOutput = update_send_suppress_output; + update->common.SuppressOutput = update_send_suppress_output; update->initialState = TRUE; update->autoCalculateBitmapData = TRUE; update->queue = MessageQueue_New(&cb); @@ -2959,9 +3093,9 @@ rdpUpdate* update_new(rdpRdp* rdp) if (!update->queue) goto fail; - return update; + return &update->common; fail: - update_free(update); + update_free(&update->common); return NULL; } @@ -2969,6 +3103,7 @@ void update_free(rdpUpdate* update) { if (update != NULL) { + rdp_update_internal* up = update_cast(update); OFFSCREEN_DELETE_LIST* deleteList = &(update->altsec->create_offscreen_bitmap.deleteList); if (deleteList) @@ -2992,22 +3127,22 @@ void update_free(rdpUpdate* update) free(update->window); } - MessageQueue_Free(update->queue); - DeleteCriticalSection(&update->mux); + MessageQueue_Free(up->queue); + DeleteCriticalSection(&up->mux); free(update); } } void update_lock(rdpUpdate* update) { - WINPR_ASSERT(update); - EnterCriticalSection(&update->mux); + rdp_update_internal* up = update_cast(update); + EnterCriticalSection(&up->mux); } void update_unlock(rdpUpdate* update) { - WINPR_ASSERT(update); - LeaveCriticalSection(&update->mux); + rdp_update_internal* up = update_cast(update); + LeaveCriticalSection(&up->mux); } BOOL update_begin_paint(rdpUpdate* update) diff --git a/libfreerdp/core/update.h b/libfreerdp/core/update.h index 263187554..bb7c20ee9 100644 --- a/libfreerdp/core/update.h +++ b/libfreerdp/core/update.h @@ -38,6 +38,50 @@ #define BITMAP_COMPRESSION 0x0001 #define NO_BITMAP_COMPRESSION_HDR 0x0400 +typedef struct +{ + rdpUpdate common; + + /* internal */ + + wLog* log; + + BOOL dump_rfx; + BOOL play_rfx; + rdpPcap* pcap_rfx; + BOOL initialState; + + BOOL asynchronous; + rdpUpdateProxy* proxy; + wMessageQueue* queue; + + wStream* us; + UINT16 numberOrders; + size_t offsetOrders; /* the offset to patch numberOrders in the stream */ + BOOL combineUpdates; + rdpBounds currentBounds; + rdpBounds previousBounds; + CRITICAL_SECTION mux; + + /* if autoCalculateBitmapData is set to TRUE, the server automatically + * fills BITMAP_DATA struct members: flags, cbCompMainBodySize and cbCompFirstRowSize. + */ + BOOL autoCalculateBitmapData; +} rdp_update_internal; + +static INLINE rdp_update_internal* update_cast(rdpUpdate* update) +{ + union + { + rdpUpdate* pub; + rdp_update_internal* internal; + } cnv; + + WINPR_ASSERT(update); + cnv.pub = update; + return cnv.internal; +} + FREERDP_LOCAL rdpUpdate* update_new(rdpRdp* rdp); FREERDP_LOCAL void update_free(rdpUpdate* update); FREERDP_LOCAL void update_reset_state(rdpUpdate* update); diff --git a/libfreerdp/core/window.c b/libfreerdp/core/window.c index d03217cc8..84cd3c142 100644 --- a/libfreerdp/core/window.c +++ b/libfreerdp/core/window.c @@ -23,6 +23,7 @@ #endif #include +#include #include @@ -703,10 +704,17 @@ static void dump_window_state_order(wLog* log, const char* msg, const WINDOW_ORD static BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_INFO* orderInfo) { + rdp_update_internal* up = update_cast(update); rdpContext* context = update->context; rdpWindowUpdate* window = update->window; + BOOL result = TRUE; + WINPR_ASSERT(s); + WINPR_ASSERT(context); + WINPR_ASSERT(window); + WINPR_ASSERT(orderInfo); + if (Stream_GetRemainingLength(s) < 4) return FALSE; @@ -719,7 +727,7 @@ static BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, if (result) { - WLog_Print(update->log, WLOG_DEBUG, "WindowIcon windowId=0x%" PRIx32 "", + WLog_Print(up->log, WLOG_DEBUG, "WindowIcon windowId=0x%" PRIx32 "", orderInfo->windowId); IFCALLRET(window->WindowIcon, result, context, orderInfo, &window_icon); } @@ -734,7 +742,7 @@ static BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, if (result) { - WLog_Print(update->log, WLOG_DEBUG, "WindowCachedIcon windowId=0x%" PRIx32 "", + WLog_Print(up->log, WLOG_DEBUG, "WindowCachedIcon windowId=0x%" PRIx32 "", orderInfo->windowId); IFCALLRET(window->WindowCachedIcon, result, context, orderInfo, &window_cached_icon); } @@ -742,8 +750,7 @@ static BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, else if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_DELETED) { update_read_window_delete_order(s, orderInfo); - WLog_Print(update->log, WLOG_DEBUG, "WindowDelete windowId=0x%" PRIx32 "", - orderInfo->windowId); + WLog_Print(up->log, WLOG_DEBUG, "WindowDelete windowId=0x%" PRIx32 "", orderInfo->windowId); IFCALLRET(window->WindowDelete, result, context, orderInfo); } else @@ -755,12 +762,12 @@ static BOOL update_recv_window_info_order(rdpUpdate* update, wStream* s, { if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW) { - dump_window_state_order(update->log, "WindowCreate", orderInfo, &windowState); + dump_window_state_order(up->log, "WindowCreate", orderInfo, &windowState); IFCALLRET(window->WindowCreate, result, context, orderInfo, &windowState); } else { - dump_window_state_order(update->log, "WindowUpdate", orderInfo, &windowState); + dump_window_state_order(up->log, "WindowUpdate", orderInfo, &windowState); IFCALLRET(window->WindowUpdate, result, context, orderInfo, &windowState); } @@ -837,10 +844,16 @@ static void update_read_notification_icon_delete_order(wStream* s, WINDOW_ORDER_ static BOOL update_recv_notification_icon_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_INFO* orderInfo) { + rdp_update_internal* up = update_cast(update); rdpContext* context = update->context; rdpWindowUpdate* window = update->window; BOOL result = TRUE; + WINPR_ASSERT(s); + WINPR_ASSERT(orderInfo); + WINPR_ASSERT(context); + WINPR_ASSERT(window); + if (Stream_GetRemainingLength(s) < 8) return FALSE; @@ -850,7 +863,7 @@ static BOOL update_recv_notification_icon_info_order(rdpUpdate* update, wStream* if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_DELETED) { update_read_notification_icon_delete_order(s, orderInfo); - WLog_Print(update->log, WLOG_DEBUG, "NotifyIconDelete"); + WLog_Print(up->log, WLOG_DEBUG, "NotifyIconDelete"); IFCALLRET(window->NotifyIconDelete, result, context, orderInfo); } else @@ -863,12 +876,12 @@ static BOOL update_recv_notification_icon_info_order(rdpUpdate* update, wStream* if (orderInfo->fieldFlags & WINDOW_ORDER_STATE_NEW) { - WLog_Print(update->log, WLOG_DEBUG, "NotifyIconCreate"); + WLog_Print(up->log, WLOG_DEBUG, "NotifyIconCreate"); IFCALLRET(window->NotifyIconCreate, result, context, orderInfo, ¬ify_icon_state); } else { - WLog_Print(update->log, WLOG_DEBUG, "NotifyIconUpdate"); + WLog_Print(up->log, WLOG_DEBUG, "NotifyIconUpdate"); IFCALLRET(window->NotifyIconUpdate, result, context, orderInfo, ¬ify_icon_state); } fail: @@ -962,14 +975,20 @@ static void dump_monitored_desktop(wLog* log, const char* msg, const WINDOW_ORDE static BOOL update_recv_desktop_info_order(rdpUpdate* update, wStream* s, WINDOW_ORDER_INFO* orderInfo) { + rdp_update_internal* up = update_cast(update); rdpContext* context = update->context; rdpWindowUpdate* window = update->window; BOOL result = TRUE; + WINPR_ASSERT(s); + WINPR_ASSERT(orderInfo); + WINPR_ASSERT(context); + WINPR_ASSERT(window); + if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_NONE) { update_read_desktop_non_monitored_order(s, orderInfo); - WLog_Print(update->log, WLOG_DEBUG, "NonMonitoredDesktop, windowId=0x%" PRIx32 "", + WLog_Print(up->log, WLOG_DEBUG, "NonMonitoredDesktop, windowId=0x%" PRIx32 "", orderInfo->windowId); IFCALLRET(window->NonMonitoredDesktop, result, context, orderInfo); } @@ -980,7 +999,7 @@ static BOOL update_recv_desktop_info_order(rdpUpdate* update, wStream* s, if (result) { - dump_monitored_desktop(update->log, "ActivelyMonitoredDesktop", orderInfo, + dump_monitored_desktop(up->log, "ActivelyMonitoredDesktop", orderInfo, &monitored_desktop); IFCALLRET(window->MonitoredDesktop, result, context, orderInfo, &monitored_desktop); } @@ -1010,11 +1029,13 @@ BOOL update_recv_altsec_window_order(rdpUpdate* update, wStream* s) size_t remaining; UINT16 orderSize; WINDOW_ORDER_INFO orderInfo = { 0 }; + rdp_update_internal* up = update_cast(update); + remaining = Stream_GetRemainingLength(s); if (remaining < 6) { - WLog_Print(update->log, WLOG_ERROR, "Stream short"); + WLog_Print(up->log, WLOG_ERROR, "Stream short"); return FALSE; } @@ -1023,7 +1044,7 @@ BOOL update_recv_altsec_window_order(rdpUpdate* update, wStream* s) if (remaining + 1 < orderSize) { - WLog_Print(update->log, WLOG_ERROR, "Stream short orderSize"); + WLog_Print(up->log, WLOG_ERROR, "Stream short orderSize"); return FALSE; } @@ -1041,7 +1062,7 @@ BOOL update_recv_altsec_window_order(rdpUpdate* update, wStream* s) rc = update_recv_desktop_info_order(update, s, &orderInfo); if (!rc) - WLog_Print(update->log, WLOG_ERROR, "windoworder flags %08" PRIx32 " failed", + WLog_Print(up->log, WLOG_ERROR, "windoworder flags %08" PRIx32 " failed", orderInfo.fieldFlags); return rc;