From dfec6228e483393139004a01e90a63facf578e59 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 26 Jan 2021 15:25:06 +0100 Subject: [PATCH] Added OrderInfo callback for primary, seconardy and altsec orders This allows gathering statistics about which orders have been received --- include/freerdp/altsec.h | 5 ++++- include/freerdp/primary.h | 6 +++++- include/freerdp/secondary.h | 6 +++++- libfreerdp/core/orders.c | 13 +++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/freerdp/altsec.h b/include/freerdp/altsec.h index 96a71ed8a..4b4ad32ce 100644 --- a/include/freerdp/altsec.h +++ b/include/freerdp/altsec.h @@ -187,6 +187,7 @@ typedef BOOL (*pDrawGdiPlusCacheNext)(rdpContext* context, const DRAW_GDIPLUS_CACHE_NEXT_ORDER* draw_gdiplus_cache_next); typedef BOOL (*pDrawGdiPlusCacheEnd)(rdpContext* context, const DRAW_GDIPLUS_CACHE_END_ORDER* draw_gdiplus_cache_end); +typedef BOOL (*pDrawOrderInfo)(rdpContext* context, UINT8 orderType, const char* orderName); struct rdp_altsec_update { @@ -205,7 +206,9 @@ struct rdp_altsec_update pDrawGdiPlusCacheFirst DrawGdiPlusCacheFirst; /* 25 */ pDrawGdiPlusCacheNext DrawGdiPlusCacheNext; /* 26 */ pDrawGdiPlusCacheEnd DrawGdiPlusCacheEnd; /* 27 */ - UINT32 paddingB[32 - 28]; /* 28 */ + /* Statistics callback */ + pDrawOrderInfo DrawOrderInfo; /* 28 */ + UINT32 paddingB[32 - 29]; /* 29 */ /* internal */ diff --git a/include/freerdp/primary.h b/include/freerdp/primary.h index 1b66a8550..5b2732b5c 100644 --- a/include/freerdp/primary.h +++ b/include/freerdp/primary.h @@ -462,6 +462,8 @@ typedef BOOL (*pPolygonSC)(rdpContext* context, const POLYGON_SC_ORDER* polygon_ typedef BOOL (*pPolygonCB)(rdpContext* context, POLYGON_CB_ORDER* polygon_cb); typedef BOOL (*pEllipseSC)(rdpContext* context, const ELLIPSE_SC_ORDER* ellipse_sc); typedef BOOL (*pEllipseCB)(rdpContext* context, const ELLIPSE_CB_ORDER* ellipse_cb); +typedef BOOL (*pOrderInfo)(rdpContext* context, const ORDER_INFO* order_info, + const char* order_name); struct rdp_primary_update { @@ -490,7 +492,9 @@ struct rdp_primary_update pPolygonCB PolygonCB; /* 35 */ pEllipseSC EllipseSC; /* 36 */ pEllipseCB EllipseCB; /* 37 */ - UINT32 paddingB[48 - 38]; /* 38 */ + /* Statistics callback */ + pOrderInfo OrderInfo; /* 38 */ + UINT32 paddingB[48 - 39]; /* 39 */ /* internal */ diff --git a/include/freerdp/secondary.h b/include/freerdp/secondary.h index 10be945fd..8961aff85 100644 --- a/include/freerdp/secondary.h +++ b/include/freerdp/secondary.h @@ -172,6 +172,8 @@ typedef BOOL (*pCacheGlyph)(rdpContext* context, const CACHE_GLYPH_ORDER* cache_ typedef BOOL (*pCacheGlyphV2)(rdpContext* context, const CACHE_GLYPH_V2_ORDER* cache_glyph_v2_order); typedef BOOL (*pCacheBrush)(rdpContext* context, const CACHE_BRUSH_ORDER* cache_brush_order); +typedef BOOL (*pCacheOrderInfo)(rdpContext* context, UINT16 orderLength, UINT16 extraFlags, + UINT8 orderType, const char* orderName); struct rdp_secondary_update { @@ -185,7 +187,9 @@ struct rdp_secondary_update pCacheGlyph CacheGlyph; /* 20 */ pCacheGlyphV2 CacheGlyphV2; /* 21 */ pCacheBrush CacheBrush; /* 22 */ - UINT32 paddingE[32 - 23]; /* 23 */ + /* Statistics callback */ + pCacheOrderInfo CacheOrderInfo; /* 23 */ + UINT32 paddingE[32 - 24]; /* 24 */ /* internal */ diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index b6f9891f0..ea45575ec 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -3464,6 +3464,10 @@ static BOOL update_recv_primary_order(rdpUpdate* update, wStream* s, BYTE flags) if (!read_primary_order(update->log, orderName, s, orderInfo, primary)) return FALSE; + rc = IFCALLRESULT(TRUE, primary->OrderInfo, context, orderInfo, orderName); + if (!rc) + return FALSE; + switch (orderInfo->orderType) { case ORDER_TYPE_DSTBLT: @@ -3682,6 +3686,11 @@ 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); + rc = IFCALLRESULT(FALSE, secondary->CacheOrderInfo, context, orderLength, extraFlags, orderType, + name); + if (!rc) + return FALSE; + /* * According to [MS-RDPEGDI] 2.2.2.2.1.2.1.1 the order length must be increased by 13 bytes * including the header. As we already read the header 7 left @@ -3912,6 +3921,10 @@ static BOOL update_recv_altsec_order(rdpUpdate* update, wStream* s, BYTE flags) const char* orderName = altsec_order_string(orderType); WLog_Print(update->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)) return FALSE;