Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpbcgr.RdpbcgrServerDecoder.ParseRoutingTokenOrCookie C# (CSharp) Method

ParseRoutingTokenOrCookie() private method

Parse An optional RDP RoutingToken (parser index is updated according to parsed length)
private ParseRoutingTokenOrCookie ( byte data, byte &routingToken, String &cookie, int &currentIndex ) : void
data byte data to be parsed
routingToken byte
cookie String
currentIndex int current parser index
return void
        private void ParseRoutingTokenOrCookie(byte[] data, ref byte[] routingToken, ref String cookie, ref int currentIndex)
        {
            bool isPresent = false;
            int offset;
            for (offset = 0; currentIndex + offset < data.Length - 1; offset++)
            {
                if (data[currentIndex + offset] == 0x0D && data[currentIndex + offset + 1] == 0x0A)
                {
                    isPresent = true;
                    break;
                }
            }

            if (isPresent)
            {
                routingToken = new byte[offset + 2];
                Array.Copy(data, currentIndex, routingToken, 0, offset + 2);
                cookie = ASCIIEncoding.ASCII.GetString(routingToken);
                if (cookie.StartsWith("Cookie"))
                {// cookie is present
                    routingToken = null;
                }
                else
                {
                    cookie =  null;
                }
                currentIndex += (offset + 2);
            }
            else
            {
                routingToken = null;
                cookie = null;
            }
        }
RdpbcgrServerDecoder