int rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) { UINT16 index; RDPGFX_RECT16* fillRect; RDPGFX_SOLID_FILL_PDU pdu; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin; RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface; if (Stream_GetRemainingLength(s) < 8) return -1; Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ rdpgfx_read_color32(s, &(pdu.fillPixel)); /* fillPixel (4 bytes) */ Stream_Read_UINT16(s, pdu.fillRectCount); /* fillRectCount (2 bytes) */ if (Stream_GetRemainingLength(s) < (size_t) (pdu.fillRectCount * 8)) return -1; pdu.fillRects = (RDPGFX_RECT16*) calloc(pdu.fillRectCount, sizeof(RDPGFX_RECT16)); if (!pdu.fillRects) return -1; for (index = 0; index < pdu.fillRectCount; index++) { fillRect = &(pdu.fillRects[index]); rdpgfx_read_rect16(s, fillRect); } WLog_Print(gfx->log, WLOG_DEBUG, "RecvSolidFillPdu: surfaceId: %d fillRectCount: %d", pdu.surfaceId, pdu.fillRectCount); if (context && context->SolidFill) { context->SolidFill(context, &pdu); } free(pdu.fillRects); return 1; }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ static UINT rdpgfx_recv_solid_fill_pdu(RDPGFX_CHANNEL_CALLBACK* callback, wStream* s) { UINT16 index; RECTANGLE_16* fillRect; RDPGFX_SOLID_FILL_PDU pdu; RDPGFX_PLUGIN* gfx = (RDPGFX_PLUGIN*) callback->plugin; RdpgfxClientContext* context = (RdpgfxClientContext*) gfx->iface.pInterface; UINT error; if (Stream_GetRemainingLength(s) < 8) { WLog_Print(gfx->log, WLOG_ERROR, "not enough data!"); return ERROR_INVALID_DATA; } Stream_Read_UINT16(s, pdu.surfaceId); /* surfaceId (2 bytes) */ if ((error = rdpgfx_read_color32(s, &(pdu.fillPixel)))) /* fillPixel (4 bytes) */ { WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_color32 failed with error %"PRIu32"!", error); return error; } Stream_Read_UINT16(s, pdu.fillRectCount); /* fillRectCount (2 bytes) */ if (Stream_GetRemainingLength(s) < (size_t)(pdu.fillRectCount * 8)) { WLog_Print(gfx->log, WLOG_ERROR, "not enough data!"); return ERROR_INVALID_DATA; } pdu.fillRects = (RECTANGLE_16*) calloc(pdu.fillRectCount, sizeof(RECTANGLE_16)); if (!pdu.fillRects) { WLog_Print(gfx->log, WLOG_ERROR, "calloc failed!"); return CHANNEL_RC_NO_MEMORY; } for (index = 0; index < pdu.fillRectCount; index++) { fillRect = &(pdu.fillRects[index]); if ((error = rdpgfx_read_rect16(s, fillRect))) { WLog_Print(gfx->log, WLOG_ERROR, "rdpgfx_read_rect16 failed with error %"PRIu32"!", error); free(pdu.fillRects); return error; } } WLog_Print(gfx->log, WLOG_DEBUG, "RecvSolidFillPdu: surfaceId: %"PRIu16" fillRectCount: %"PRIu16"", pdu.surfaceId, pdu.fillRectCount); if (context) { IFCALLRET(context->SolidFill, error, context, &pdu); if (error) WLog_Print(gfx->log, WLOG_ERROR, "context->SolidFill failed with error %"PRIu32"", error); } free(pdu.fillRects); return error; }