/// <summary> /// Decode RDPBCGR PDUs from the received message bytes /// </summary> /// <param name="endPoint">the endpoint from which the message bytes are received.</param> /// <param name="receivedBytes">the received message bytes to be decoded.</param> /// <param name="consumedLength">the length of message bytes consumed by decoder.</param> /// <param name="expectedLength">the length of message bytes the decoder expects to receive.</param> /// <returns>the stack packets decoded from the received message bytes.</returns> internal StackPacket[] DecodePacketCallback( object endPoint, byte[] receivedBytes, out int consumedLength, out int expectedLength) { StackPacket pdu = null; expectedLength = 0; // Get bytes for only one packet byte[] packetData = GetPacket(receivedBytes); if (null == packetData) { // Received bytes does not contain enough data consumedLength = 0; return null; } consumedLength = packetData.Length; // Decode PDU try { pdu = DecodePdu(packetData); if (pdu.GetType() == typeof(Server_X_224_Connection_Confirm_Pdu)) { // Negotiation-based security-enhanced Connection client.UpdateTransport(); } } catch (FormatException e) { pdu = new ErrorPdu(e); } // Update client context and client clientContext.UpdateContext(pdu); client.CheckDecryptionCount(); return new StackPacket[] { pdu }; }
/// <summary> /// Decode RDPBCGR PDUs from the received message bytes /// </summary> /// <param name="endPoint">the endpoint from which the message bytes are received.</param> /// <param name="receivedBytes">the received message bytes to be decoded.</param> /// <param name="consumedLength">the length of message bytes consumed by decoder.</param> /// <param name="expectedLength">the length of message bytes the decoder expects to receive.</param> /// <returns>the stack packets decoded from the received message bytes.</returns> internal StackPacket[] DecodePacketCallback( object endPoint, byte[] receivedBytes, out int consumedLength, out int expectedLength) { StackPacket pdu = null; expectedLength = 0; // Get bytes for only one packet byte[] packetData = GetPacket(receivedBytes); if (null == packetData) { // Received bytes does not contain enough data consumedLength = 0; return null; } consumedLength = packetData.Length; for (int i = 0; i < server.ServerContext.SessionContexts.Count; i++) { if (endPoint == server.ServerContext.SessionContexts[i].Identity) { try { // ETW Provider Dump Message string messageName; if (ConstValue.SLOW_PATH_PDU_INDICATOR_VALUE == packetData[ConstValue.SLOW_PATH_PDU_INDICATOR_INDEX]) { // Slow-Path messageName = "RDPBCGR:ReceivedSlowPathPDU"; } else { // Fast-Path messageName = "RDPBCGR:ReceivedFastPathPDU"; } ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer0, "Received Original RDPBCGR Message", packetData); pdu = DecodePdu(server.ServerContext.SessionContexts[i], packetData); } catch (FormatException e) { pdu = new ErrorPdu(e, packetData); } // Update client context and client server.ServerContext.SessionContexts[i].UpdateContext(pdu); server.CheckDecryptionCount(server.ServerContext.SessionContexts[i]); break; } else { pdu = null; } } return new StackPacket[] { pdu }; }