void* shadow_multiclient_get_subscriber(rdpShadowMultiClientEvent* event) { struct rdp_shadow_multiclient_subscriber* subscriber; if (!event) return NULL; EnterCriticalSection(&(event->lock)); subscriber = (struct rdp_shadow_multiclient_subscriber*) calloc(1, sizeof(struct rdp_shadow_multiclient_subscriber)); if (!subscriber) goto out_error; subscriber->ref = event; subscriber->pleaseHandle = FALSE; if (ArrayList_Add(event->subscribers, subscriber) < 0) goto out_free; WLog_VRB(TAG, "Get subscriber %p. Wait event %d. %d clients.\n", (void *)subscriber, event->eventid, event->consuming); (void)_Consume(subscriber, TRUE); WLog_VRB(TAG, "Get subscriber %p. Quit event %d. %d clients.\n", (void *)subscriber, event->eventid, event->consuming); LeaveCriticalSection(&(event->lock)); return subscriber; out_free: free(subscriber); out_error: LeaveCriticalSection(&(event->lock)); return NULL; }
/* * Consume my share and release my register * If we have update event and pleaseHandle flag * We need to consume. Anyway we need to clear * pleaseHandle flag */ void shadow_multiclient_release_subscriber(void* subscriber) { struct rdp_shadow_multiclient_subscriber* s; rdpShadowMultiClientEvent* event; if (!subscriber) return; s = (struct rdp_shadow_multiclient_subscriber*)subscriber; event = s->ref; EnterCriticalSection(&(event->lock)); WLog_VRB(TAG, "Release Subscriber %p. Drop event %d. %d clients.\n", subscriber, event->eventid, event->consuming); (void)_Consume(s, FALSE); WLog_VRB(TAG, "Release Subscriber %p. Quit event %d. %d clients.\n", subscriber, event->eventid, event->consuming); ArrayList_Remove(event->subscribers, subscriber); LeaveCriticalSection(&(event->lock)); free(subscriber); return; }
static BOOL autodetect_send_netchar_result(rdpContext* context, UINT16 sequenceNumber) { wStream* s; s = rdp_message_channel_pdu_init(context->rdp); if (!s) return FALSE; WLog_VRB(AUTODETECT_TAG, "sending Bandwidth Network Characteristics Result PDU"); if (context->rdp->autodetect->netCharBandwidth > 0) { Stream_Write_UINT8(s, 0x12); /* headerLength (1 byte) */ Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_REQUEST); /* headerTypeId (1 byte) */ Stream_Write_UINT16(s, sequenceNumber); /* sequenceNumber (2 bytes) */ Stream_Write_UINT16(s, 0x08C0); /* requestType (2 bytes) */ Stream_Write_UINT32(s, context->rdp->autodetect->netCharBaseRTT); /* baseRTT (4 bytes) */ Stream_Write_UINT32(s, context->rdp->autodetect->netCharBandwidth); /* bandwidth (4 bytes) */ Stream_Write_UINT32(s, context->rdp->autodetect->netCharAverageRTT); /* averageRTT (4 bytes) */ } else { Stream_Write_UINT8(s, 0x0E); /* headerLength (1 byte) */ Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_REQUEST); /* headerTypeId (1 byte) */ Stream_Write_UINT16(s, sequenceNumber); /* sequenceNumber (2 bytes) */ Stream_Write_UINT16(s, 0x0840); /* requestType (2 bytes) */ Stream_Write_UINT32(s, context->rdp->autodetect->netCharBaseRTT); /* baseRTT (4 bytes) */ Stream_Write_UINT32(s, context->rdp->autodetect->netCharAverageRTT); /* averageRTT (4 bytes) */ } return rdp_send_message_channel_pdu(context->rdp, s, SEC_AUTODETECT_REQ); }
int rdp_recv_autodetect_request_packet(rdpRdp* rdp, wStream* s) { AUTODETECT_REQ_PDU autodetectReqPdu; BOOL success = FALSE; if (Stream_GetRemainingLength(s) < 6) return -1; Stream_Read_UINT8(s, autodetectReqPdu.headerLength); /* headerLength (1 byte) */ Stream_Read_UINT8(s, autodetectReqPdu.headerTypeId); /* headerTypeId (1 byte) */ Stream_Read_UINT16(s, autodetectReqPdu.sequenceNumber); /* sequenceNumber (2 bytes) */ Stream_Read_UINT16(s, autodetectReqPdu.requestType); /* requestType (2 bytes) */ WLog_VRB(AUTODETECT_TAG, "rdp_recv_autodetect_request_packet: headerLength=%"PRIu8", headerTypeId=%"PRIu8", sequenceNumber=%"PRIu16", requestType=%04"PRIx16"", autodetectReqPdu.headerLength, autodetectReqPdu.headerTypeId, autodetectReqPdu.sequenceNumber, autodetectReqPdu.requestType); if (autodetectReqPdu.headerTypeId != TYPE_ID_AUTODETECT_REQUEST) return -1; switch (autodetectReqPdu.requestType) { case RDP_RTT_REQUEST_TYPE_CONTINUOUS: case RDP_RTT_REQUEST_TYPE_CONNECTTIME: /* RTT Measure Request (RDP_RTT_REQUEST) - MS-RDPBCGR 2.2.14.1.1 */ success = autodetect_recv_rtt_measure_request(rdp, s, &autodetectReqPdu); break; case RDP_BW_START_REQUEST_TYPE_CONTINUOUS: case RDP_BW_START_REQUEST_TYPE_TUNNEL: case RDP_BW_START_REQUEST_TYPE_CONNECTTIME: /* Bandwidth Measure Start (RDP_BW_START) - MS-RDPBCGR 2.2.14.1.2 */ success = autodetect_recv_bandwidth_measure_start(rdp, s, &autodetectReqPdu); break; case RDP_BW_PAYLOAD_REQUEST_TYPE: /* Bandwidth Measure Payload (RDP_BW_PAYLOAD) - MS-RDPBCGR 2.2.14.1.3 */ success = autodetect_recv_bandwidth_measure_payload(rdp, s, &autodetectReqPdu); break; case RDP_BW_STOP_REQUEST_TYPE_CONNECTTIME: case RDP_BW_STOP_REQUEST_TYPE_CONTINUOUS: case RDP_BW_STOP_REQUEST_TYPE_TUNNEL: /* Bandwidth Measure Stop (RDP_BW_STOP) - MS-RDPBCGR 2.2.14.1.4 */ success = autodetect_recv_bandwidth_measure_stop(rdp, s, &autodetectReqPdu); break; case 0x0840: case 0x0880: case 0x08C0: /* Network Characteristics Result (RDP_NETCHAR_RESULT) - MS-RDPBCGR 2.2.14.1.5 */ success = autodetect_recv_netchar_result(rdp, s, &autodetectReqPdu); break; default: break; } return success ? 0 : -1; }
void rfx_context_free(RFX_CONTEXT* context) { RFX_CONTEXT_PRIV *priv; assert(NULL != context); assert(NULL != context->priv); assert(NULL != context->priv->TilePool); assert(NULL != context->priv->BufferPool); priv = context->priv; free(context->quants); ObjectPool_Free(priv->TilePool); rfx_profiler_print(context); rfx_profiler_free(context); if (priv->UseThreads) { CloseThreadpool(context->priv->ThreadPool); DestroyThreadpoolEnvironment(&context->priv->ThreadPoolEnv); free(priv->workObjects); free(priv->tileWorkParams); #ifdef WITH_PROFILER WLog_VRB(TAG, "WARNING: Profiling results probably unusable with multithreaded RemoteFX codec!"); #endif } BufferPool_Free(context->priv->BufferPool); free(context->priv); free(context); }
int freerds_orders_mem_blt(rdsConnection* connection, int cache_id, int color_table, int x, int y, int cx, int cy, int rop, int srcx, int srcy, int cache_idx, rdsRect* rect) { MEMBLT_ORDER memblt; rdpPrimaryUpdate* primary = connection->client->update->primary; WLog_VRB(TAG, "%s id: %d index: %d width: %d height: %d", __FUNCTION__, cache_id, cache_idx, cx, cy); memblt.nLeftRect = x; memblt.nTopRect = y; memblt.nWidth = cx; memblt.nHeight = cy; memblt.bRop = rop; memblt.nXSrc = srcx; memblt.nYSrc = srcy; memblt.cacheId = cache_id; memblt.cacheIndex = cache_idx; memblt.colorIndex = color_table; freerds_set_bounds_rect(connection, rect); IFCALL(primary->MemBlt, (rdpContext*) connection, &memblt); return 0; }
static BOOL autodetect_send_bandwidth_measure_results(rdpRdp* rdp, UINT16 responseType, UINT16 sequenceNumber) { BOOL success = TRUE; wStream* s; UINT32 timeDelta; /* Compute the total time */ timeDelta = GetTickCountPrecise() - rdp->autodetect->bandwidthMeasureStartTime; /* Send the result PDU to the server */ s = rdp_message_channel_pdu_init(rdp); if (!s) return FALSE; WLog_VRB(AUTODETECT_TAG, "sending Bandwidth Measure Results PDU -> timeDelta=%u, byteCount=%u", timeDelta, rdp->autodetect->bandwidthMeasureByteCount); Stream_Write_UINT8(s, 0x0E); /* headerLength (1 byte) */ Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_RESPONSE); /* headerTypeId (1 byte) */ Stream_Write_UINT16(s, sequenceNumber); /* sequenceNumber (2 bytes) */ Stream_Write_UINT16(s, responseType); /* responseType (1 byte) */ Stream_Write_UINT32(s, timeDelta); /* timeDelta (4 bytes) */ Stream_Write_UINT32(s, rdp->autodetect->bandwidthMeasureByteCount); /* byteCount (4 bytes) */ IFCALLRET(rdp->autodetect->ClientBandwidthMeasureResult, success, rdp->context, rdp->autodetect); if (!success) return FALSE; return rdp_send_message_channel_pdu(rdp, s, SEC_AUTODETECT_RSP); }
int freerds_orders_text(rdsConnection* connection, RDS_MSG_GLYPH_INDEX* msg, rdsRect* rect) { GLYPH_INDEX_ORDER glyphIndex; rdpPrimaryUpdate* primary = connection->client->update->primary; WLog_VRB(TAG, "%s: cacheId: %d", __FUNCTION__, msg->cacheId); glyphIndex.backColor = msg->backColor; glyphIndex.foreColor = msg->foreColor; glyphIndex.cacheId = msg->cacheId; glyphIndex.flAccel = msg->flAccel; glyphIndex.ulCharInc = msg->ulCharInc; glyphIndex.fOpRedundant = msg->fOpRedundant; glyphIndex.bkLeft = msg->bkLeft; glyphIndex.bkTop = msg->bkTop; glyphIndex.bkRight = msg->bkRight; glyphIndex.bkBottom = msg->bkBottom; glyphIndex.opLeft = msg->opLeft; glyphIndex.opTop = msg->opTop; glyphIndex.opRight = msg->opRight; glyphIndex.opBottom = msg->opBottom; CopyMemory(&glyphIndex.brush, &msg->brush, sizeof(rdpBrush)); glyphIndex.brush.data = glyphIndex.brush.p8x8; glyphIndex.x = msg->x; glyphIndex.y = msg->y; glyphIndex.cbData = msg->cbData; CopyMemory(glyphIndex.data, msg->data, glyphIndex.cbData); freerds_set_bounds_rect(connection, rect); IFCALL(primary->GlyphIndex, (rdpContext*) connection, &glyphIndex); return 0; }
static void _Publish(rdpShadowMultiClientEvent* event) { wArrayList* subscribers; struct rdp_shadow_multiclient_subscriber* subscriber = NULL; int i; subscribers = event->subscribers; assert(event->consuming == 0); /* Count subscribing clients */ ArrayList_Lock(subscribers); for (i = 0; i < ArrayList_Count(subscribers); i++) { subscriber = (struct rdp_shadow_multiclient_subscriber *)ArrayList_GetItem(subscribers, i); /* Set flag to subscriber: I acknowledge and please handle */ subscriber->pleaseHandle = TRUE; event->consuming++; } ArrayList_Unlock(subscribers); if (event->consuming > 0) { event->eventid = (event->eventid & 0xff) + 1; WLog_VRB(TAG, "Server published event %d. %d clients.\n", event->eventid, event->consuming); ResetEvent(event->doneEvent); SetEvent(event->event); } return; }
int freerds_orders_pat_blt(rdsConnection* connection, int x, int y, int cx, int cy, int rop, int bg_color, int fg_color, rdpBrush* brush, rdsRect* rect) { PATBLT_ORDER patblt; rdpPrimaryUpdate* primary = connection->client->update->primary; WLog_VRB(TAG, "%s", __FUNCTION__); patblt.nLeftRect = x; patblt.nTopRect = y; patblt.nWidth = cx; patblt.nHeight = cy; patblt.bRop = (UINT32) rop; patblt.backColor = (UINT32) fg_color; patblt.foreColor = (UINT32) bg_color; patblt.brush.x = brush->x; patblt.brush.y = brush->y; patblt.brush.style = brush->style; patblt.brush.data = patblt.brush.p8x8; CopyMemory(patblt.brush.data, brush->data, 8); patblt.brush.hatch = patblt.brush.data[0]; freerds_set_bounds_rect(connection, rect); IFCALL(primary->PatBlt, (rdpContext*) connection, &patblt); return 0; }
static void _WaitForSubscribers(rdpShadowMultiClientEvent* event) { if (event->consuming > 0) { /* Wait for clients done */ WLog_VRB(TAG, "Server wait event %d. %d clients.\n", event->eventid, event->consuming); LeaveCriticalSection(&(event->lock)); WaitForSingleObject(event->doneEvent, INFINITE); EnterCriticalSection(&(event->lock)); WLog_VRB(TAG, "Server quit event %d. %d clients.\n", event->eventid, event->consuming); } /* Last subscriber should have already reset the event */ assert(WaitForSingleObject(event->event, 0) != WAIT_OBJECT_0); return; }
int freerds_reset(rdsConnection* connection, RDS_MSG_RESET* msg) { WLog_VRB(TAG, "%s", __FUNCTION__); connection->settings->DesktopWidth = msg->DesktopWidth; connection->settings->DesktopHeight = msg->DesktopHeight; connection->settings->ColorDepth = msg->ColorDepth; return 0; }
int freerds_orders_end_paint(rdsConnection* connection) { rdpUpdate* update = ((rdpContext*) connection)->update; WLog_VRB(TAG, "%s", __FUNCTION__); update->EndPaint((rdpContext*) connection); return 0; }
static BOOL autodetect_recv_rtt_measure_request(rdpRdp* rdp, wStream* s, AUTODETECT_REQ_PDU* autodetectReqPdu) { if (autodetectReqPdu->headerLength != 0x06) return FALSE; WLog_VRB(AUTODETECT_TAG, "received RTT Measure Request PDU"); /* Send a response to the server */ return autodetect_send_rtt_measure_response(rdp, autodetectReqPdu->sequenceNumber); }
int freerds_orders_send_create_os_surface(rdsConnection* connection, CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap) { rdpAltSecUpdate* altsec = connection->client->update->altsec; WLog_VRB(TAG, "%s: id: %d width: %d height: %d", __FUNCTION__, createOffscreenBitmap->id, createOffscreenBitmap->cx, createOffscreenBitmap->cy); IFCALL(altsec->CreateOffscreenBitmap, (rdpContext*) connection, createOffscreenBitmap); return 0; }
static BOOL autodetect_send_bandwidth_measure_stop(rdpContext* context, UINT16 payloadLength, UINT16 sequenceNumber, UINT16 requestType) { wStream* s; UCHAR *buffer = NULL; BOOL bResult = FALSE; s = rdp_message_channel_pdu_init(context->rdp); if (!s) return FALSE; WLog_VRB(AUTODETECT_TAG, "sending Bandwidth Measure Stop PDU -> payloadLength=%u", payloadLength); /* 4-bytes aligned */ payloadLength &= ~3; Stream_Write_UINT8(s, requestType == RDP_BW_STOP_REQUEST_TYPE_CONNECTTIME ? 0x08 : 0x06); /* headerLength (1 byte) */ Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_REQUEST); /* headerTypeId (1 byte) */ Stream_Write_UINT16(s, sequenceNumber); /* sequenceNumber (2 bytes) */ Stream_Write_UINT16(s, requestType); /* requestType (2 bytes) */ if (requestType == RDP_BW_STOP_REQUEST_TYPE_CONNECTTIME) { Stream_Write_UINT16(s, payloadLength); /* payloadLength (2 bytes) */ if (payloadLength > 0) { if (!Stream_EnsureRemainingCapacity(s, payloadLength)) { Stream_Release(s); return FALSE; } /* Random data (better measurement in case the line is compressed) */ buffer = malloc(payloadLength); if (NULL == buffer) { Stream_Release(s); return FALSE; } winpr_RAND(buffer, payloadLength); Stream_Write(s, buffer, payloadLength); } } bResult = rdp_send_message_channel_pdu(context->rdp, s, SEC_AUTODETECT_REQ); if (!bResult) { Stream_Release(s); } free(buffer); return bResult; }
int freerds_set_system_pointer(rdsConnection* connection, RDS_MSG_SET_SYSTEM_POINTER* msg) { POINTER_SYSTEM_UPDATE *pointer_system; rdpPointerUpdate* pointer = connection->client->update->pointer; WLog_VRB(TAG, "%s", __FUNCTION__); pointer_system = &(pointer->pointer_system); pointer_system->type = msg->ptrType; IFCALL(pointer->PointerSystem, (rdpContext *)connection, pointer_system); return 0; }
int freerds_orders_send_switch_os_surface(rdsConnection* connection, int id) { SWITCH_SURFACE_ORDER switch_surface; rdpAltSecUpdate* altsec = connection->client->update->altsec; WLog_VRB(TAG, "%s: id: %d", __FUNCTION__, id); switch_surface.bitmapId = id & 0xFFFF; IFCALL(altsec->SwitchSurface, (rdpContext*) connection, &switch_surface); return 0; }
BOOL shadow_multiclient_consume(void* subscriber) { struct rdp_shadow_multiclient_subscriber* s; rdpShadowMultiClientEvent* event; BOOL ret = FALSE; if (!subscriber) return ret; s = (struct rdp_shadow_multiclient_subscriber*)subscriber; event = s->ref; EnterCriticalSection(&(event->lock)); WLog_VRB(TAG, "Subscriber %p wait event %d. %d clients.\n", subscriber, event->eventid, event->consuming); ret = _Consume(s, TRUE); WLog_VRB(TAG, "Subscriber %p quit event %d. %d clients.\n", subscriber, event->eventid, event->consuming); LeaveCriticalSection(&(event->lock)); return ret; }
int freerds_orders_send_frame_marker(rdsConnection* connection, UINT32 action, UINT32 id) { SURFACE_FRAME_MARKER surfaceFrameMarker; rdpUpdate* update = connection->client->update; WLog_VRB(TAG, "%s: action: %d id: %d", __FUNCTION__, action, id); surfaceFrameMarker.frameAction = action; surfaceFrameMarker.frameId = id; IFCALL(update->SurfaceFrameMarker, (rdpContext*) connection, &surfaceFrameMarker); return 0; }
int freerds_orders_send_palette(rdsConnection* connection, int* palette, int cache_id) { CACHE_COLOR_TABLE_ORDER cache_color_table; rdpSecondaryUpdate* secondary = connection->client->update->secondary; WLog_VRB(TAG, "%s", __FUNCTION__); cache_color_table.cacheIndex = cache_id; cache_color_table.numberColors = 256; CopyMemory(&(cache_color_table.colorTable), palette, 256 * 4); IFCALL(secondary->CacheColorTable, (rdpContext*) connection, &cache_color_table); return 0; }
static BOOL autodetect_send_rtt_measure_response(rdpRdp* rdp, UINT16 sequenceNumber) { wStream* s; /* Send the response PDU to the server */ s = rdp_message_channel_pdu_init(rdp); if (!s) return FALSE; WLog_VRB(AUTODETECT_TAG, "sending RTT Measure Response PDU"); Stream_Write_UINT8(s, 0x06); /* headerLength (1 byte) */ Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_RESPONSE); /* headerTypeId (1 byte) */ Stream_Write_UINT16(s, sequenceNumber); /* sequenceNumber (2 bytes) */ Stream_Write_UINT16(s, RDP_RTT_RESPONSE_TYPE); /* responseType (1 byte) */ return rdp_send_message_channel_pdu(rdp, s, SEC_AUTODETECT_RSP); }
static BOOL autodetect_send_bandwidth_measure_start(rdpContext* context, UINT16 sequenceNumber, UINT16 requestType) { wStream* s; s = rdp_message_channel_pdu_init(context->rdp); if (!s) return FALSE; WLog_VRB(AUTODETECT_TAG, "sending Bandwidth Measure Start PDU"); Stream_Write_UINT8(s, 0x06); /* headerLength (1 byte) */ Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_REQUEST); /* headerTypeId (1 byte) */ Stream_Write_UINT16(s, sequenceNumber); /* sequenceNumber (2 bytes) */ Stream_Write_UINT16(s, requestType); /* requestType (2 bytes) */ return rdp_send_message_channel_pdu(context->rdp, s, SEC_AUTODETECT_REQ); }
static BOOL autodetect_recv_netchar_result(rdpRdp* rdp, wStream* s, AUTODETECT_REQ_PDU* autodetectReqPdu) { BOOL success = TRUE; switch (autodetectReqPdu->requestType) { case 0x0840: /* baseRTT and averageRTT fields are present (bandwidth field is not) */ if ((autodetectReqPdu->headerLength != 0x0E) || (Stream_GetRemainingLength(s) < 8)) return FALSE; Stream_Read_UINT32(s, rdp->autodetect->netCharBaseRTT); /* baseRTT (4 bytes) */ Stream_Read_UINT32(s, rdp->autodetect->netCharAverageRTT); /* averageRTT (4 bytes) */ break; case 0x0880: /* bandwidth and averageRTT fields are present (baseRTT field is not) */ if ((autodetectReqPdu->headerLength != 0x0E) || (Stream_GetRemainingLength(s) < 8)) return FALSE; Stream_Read_UINT32(s, rdp->autodetect->netCharBandwidth); /* bandwidth (4 bytes) */ Stream_Read_UINT32(s, rdp->autodetect->netCharAverageRTT); /* averageRTT (4 bytes) */ break; case 0x08C0: /* baseRTT, bandwidth, and averageRTT fields are present */ if ((autodetectReqPdu->headerLength != 0x12) || (Stream_GetRemainingLength(s) < 12)) return FALSE; Stream_Read_UINT32(s, rdp->autodetect->netCharBaseRTT); /* baseRTT (4 bytes) */ Stream_Read_UINT32(s, rdp->autodetect->netCharBandwidth); /* bandwidth (4 bytes) */ Stream_Read_UINT32(s, rdp->autodetect->netCharAverageRTT); /* averageRTT (4 bytes) */ break; } WLog_VRB(AUTODETECT_TAG, "received Network Characteristics Result PDU -> baseRTT=%"PRIu32", bandwidth=%"PRIu32", averageRTT=%"PRIu32"", rdp->autodetect->netCharBaseRTT, rdp->autodetect->netCharBandwidth, rdp->autodetect->netCharAverageRTT); IFCALLRET(rdp->autodetect->NetworkCharacteristicsResult, success, rdp->context, autodetectReqPdu->sequenceNumber); return success; }
static BOOL autodetect_recv_rtt_measure_response(rdpRdp* rdp, wStream* s, AUTODETECT_RSP_PDU* autodetectRspPdu) { BOOL success = TRUE; if (autodetectRspPdu->headerLength != 0x06) return FALSE; WLog_VRB(AUTODETECT_TAG, "received RTT Measure Response PDU"); rdp->autodetect->netCharAverageRTT = GetTickCountPrecise() - rdp->autodetect->rttMeasureStartTime; if (rdp->autodetect->netCharBaseRTT == 0 || rdp->autodetect->netCharBaseRTT > rdp->autodetect->netCharAverageRTT) rdp->autodetect->netCharBaseRTT = rdp->autodetect->netCharAverageRTT; IFCALLRET(rdp->autodetect->RTTMeasureResponse, success, rdp->context, autodetectRspPdu->sequenceNumber); return success; }
static BOOL autodetect_send_rtt_measure_request(rdpContext* context, UINT16 sequenceNumber, UINT16 requestType) { wStream* s; s = rdp_message_channel_pdu_init(context->rdp); if (!s) return FALSE; WLog_VRB(AUTODETECT_TAG, "sending RTT Measure Request PDU"); Stream_Write_UINT8(s, 0x06); /* headerLength (1 byte) */ Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_REQUEST); /* headerTypeId (1 byte) */ Stream_Write_UINT16(s, sequenceNumber); /* sequenceNumber (2 bytes) */ Stream_Write_UINT16(s, requestType); /* requestType (2 bytes) */ context->rdp->autodetect->rttMeasureStartTime = GetTickCountPrecise(); return rdp_send_message_channel_pdu(context->rdp, s, SEC_AUTODETECT_REQ); }
static BOOL autodetect_recv_bandwidth_measure_start(rdpRdp* rdp, wStream* s, AUTODETECT_REQ_PDU* autodetectReqPdu) { if (autodetectReqPdu->headerLength != 0x06) return FALSE; WLog_VRB(AUTODETECT_TAG, "received Bandwidth Measure Start PDU - time=%lu", GetTickCountPrecise()); /* Initialize bandwidth measurement parameters */ rdp->autodetect->bandwidthMeasureStartTime = GetTickCountPrecise(); rdp->autodetect->bandwidthMeasureByteCount = 0; /* Continuous Auto-Detection: mark the start of the measurement */ if (autodetectReqPdu->requestType == RDP_BW_START_REQUEST_TYPE_CONTINUOUS) { rdp->autodetect->bandwidthMeasureStarted = TRUE; } return TRUE; }
int freerds_orders_send_font(rdsConnection* connection, RDS_MSG_CACHE_GLYPH* msg) { rdpSecondaryUpdate* secondary = connection->client->update->secondary; WLog_VRB(TAG, "%s: cacheId: %d cacheIndex: %d", __FUNCTION__, msg->cacheId, msg->glyphData[0].cacheIndex); if (secondary->glyph_v2) { CACHE_GLYPH_V2_ORDER cache_glyph_v2; cache_glyph_v2.flags = 0; cache_glyph_v2.cacheId = msg->cacheId; cache_glyph_v2.cGlyphs = 1; cache_glyph_v2.glyphData[0].cacheIndex = msg->glyphData[0].cacheIndex; cache_glyph_v2.glyphData[0].x = msg->glyphData[0].x; cache_glyph_v2.glyphData[0].y = msg->glyphData[0].y; cache_glyph_v2.glyphData[0].cx = msg->glyphData[0].cx; cache_glyph_v2.glyphData[0].cy = msg->glyphData[0].cy; cache_glyph_v2.glyphData[0].aj = msg->glyphData[0].aj; cache_glyph_v2.unicodeCharacters = NULL; IFCALL(secondary->CacheGlyphV2, (rdpContext*) connection, &cache_glyph_v2); } else { CACHE_GLYPH_ORDER cache_glyph; cache_glyph.cacheId = msg->cacheId; cache_glyph.cGlyphs = 1; cache_glyph.glyphData[0].cacheIndex = msg->glyphData[0].cacheIndex; cache_glyph.glyphData[0].x = msg->glyphData[0].x; cache_glyph.glyphData[0].y = msg->glyphData[0].y; cache_glyph.glyphData[0].cx = msg->glyphData[0].cx; cache_glyph.glyphData[0].cy = msg->glyphData[0].cy; cache_glyph.glyphData[0].aj = msg->glyphData[0].aj; cache_glyph.unicodeCharacters = NULL; IFCALL(secondary->CacheGlyph, (rdpContext*) connection, &cache_glyph); } return 0; }
BOOL autodetect_send_bandwidth_measure_payload(rdpContext* context, UINT16 payloadLength, UINT16 sequenceNumber) { wStream* s; UCHAR* buffer = NULL; BOOL bResult = FALSE; s = rdp_message_channel_pdu_init(context->rdp); if (!s) return FALSE; WLog_VRB(AUTODETECT_TAG, "sending Bandwidth Measure Payload PDU -> payloadLength=%"PRIu16"", payloadLength); /* 4-bytes aligned */ payloadLength &= ~3; if (!Stream_EnsureRemainingCapacity(s, 8 + payloadLength)) { Stream_Release(s); return FALSE; } Stream_Write_UINT8(s, 0x08); /* headerLength (1 byte) */ Stream_Write_UINT8(s, TYPE_ID_AUTODETECT_REQUEST); /* headerTypeId (1 byte) */ Stream_Write_UINT16(s, sequenceNumber); /* sequenceNumber (2 bytes) */ Stream_Write_UINT16(s, RDP_BW_PAYLOAD_REQUEST_TYPE); /* requestType (2 bytes) */ Stream_Write_UINT16(s, payloadLength); /* payloadLength (2 bytes) */ /* Random data (better measurement in case the line is compressed) */ buffer = (UCHAR*)malloc(payloadLength); if (NULL == buffer) { Stream_Release(s); return FALSE; } winpr_RAND(buffer, payloadLength); Stream_Write(s, buffer, payloadLength); bResult = rdp_send_message_channel_pdu(context->rdp, s, SEC_AUTODETECT_REQ); free(buffer); return bResult; }
int freerds_orders_send_brush(rdsConnection* connection, int width, int height, int bpp, int type, int size, char* data, int cache_id) { CACHE_BRUSH_ORDER cache_brush; rdpSecondaryUpdate* secondary = connection->client->update->secondary; WLog_VRB(TAG, "%s", __FUNCTION__); cache_brush.index = cache_id; cache_brush.bpp = bpp; cache_brush.cx = width; cache_brush.cy = height; cache_brush.style = type; cache_brush.length = size; CopyMemory(cache_brush.data, data, cache_brush.length); IFCALL(secondary->CacheBrush, (rdpContext*) connection, &cache_brush); return 0; }