Removed internal members of rdpUpdate from API header

This commit is contained in:
Armin Novak
2022-01-11 16:01:33 +01:00
committed by akallabeth
parent 8cf0a21acd
commit d210ac5e33
9 changed files with 743 additions and 342 deletions

View File

@@ -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 */

View File

@@ -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);

File diff suppressed because it is too large Load Diff

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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)

View File

@@ -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);

View File

@@ -23,6 +23,7 @@
#endif
#include <winpr/crt.h>
#include <winpr/assert.h>
#include <freerdp/log.h>
@@ -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, &notify_icon_state);
}
else
{
WLog_Print(update->log, WLOG_DEBUG, "NotifyIconUpdate");
WLog_Print(up->log, WLOG_DEBUG, "NotifyIconUpdate");
IFCALLRET(window->NotifyIconUpdate, result, context, orderInfo, &notify_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;