// Return True if flowMarker is detected // In these case we have FlowTestPDU, FlowResponsePDU or FlowStopPDU // and not ShareControl header. inline bool peekFlowPDU(const InStream & stream) { if (!stream.in_check_rem(2)) { throw Error(ERR_SEC); } return (stream.get_data()[stream.get_offset()] == 0) && (stream.get_data()[stream.get_offset()+1] == 0x80); }
explicit ShareData_Recv(InStream & stream, rdp_mppc_dec * dec = nullptr) //============================================================================== : CheckShareData_Recv(stream) , share_id(stream.in_uint32_le()) , pad1(stream.in_uint8()) , streamid(stream.in_uint8()) , len(stream.in_uint16_le()) , pdutype2(stream.in_uint8()) , compressedType(stream.in_uint8()) , compressedLen(stream.in_uint16_le()) , payload([&stream, dec, this]() { if (this->compressedType & PACKET_COMPRESSED) { if (!dec) { LOG(LOG_INFO, "ShareData_Recv: got unexpected compressed share data"); throw Error(ERR_SEC); } const uint8_t * rdata; uint32_t rlen; dec->decompress(stream.get_data()+stream.get_offset(), stream.in_remain(), this->compressedType, rdata, rlen); return InStream(rdata, 0, rlen); } else { return InStream(stream.get_current(), stream.in_remain()); } }()) // BEGIN CONSTRUCTOR { //LOG( LOG_INFO, "ShareData_Recv: pdutype2=%u len=%u compressedLen=%u payload_size=%u" // , this->pdutype2, this->len, this->compressedLen, this->payload.size()); stream.in_skip_bytes(stream.in_remain()); } // END CONSTRUCTOR
explicit ShareFlow_Recv(InStream & stream) : flowMarker([&stream]{ if (!stream.in_check_rem(2+1+1+1+1+2)){ LOG(LOG_ERR, "Truncated " "[2: ShareFlow PDU packet]" "[1: ShareFlow pad]" "[1: ShareFlow PDU type]" "[1: flow Identifier]" "[1: flow number]" "[2: ShareFlow PDU packet] , remains=%zu", stream.in_remain()); throw Error(ERR_SEC); } return stream.in_uint16_le(); }()) , pad(stream.in_uint8()) , pduTypeFlow(stream.in_uint8()) , flowIdentifier(stream.in_uint8()) , flowNumber(stream.in_uint8()) , mcs_channel(stream.in_uint16_le()) { LOG(LOG_INFO, "Flow control packet %.4x (offset=%zu)", this->flowMarker, stream.get_offset()); if (this->flowMarker != 0x8000) { LOG(LOG_ERR, "Expected flow control packet, got %.4x", this->flowMarker); throw Error(ERR_SEC); } LOG(LOG_INFO, "PDUTypeFlow=%u", this->pduTypeFlow); if (stream.in_remain()) { LOG(LOG_INFO, "trailing bytes in FlowPDU, remains %zu bytes", stream.in_remain()); } }