Пример #1
0
        void Decode(byte[] buffer, int startIndex, int length)
        {
            if (buffer == null)
            {
                throw new ArgumentNullException(nameof(buffer));
            }

            if (startIndex < 0 || startIndex > buffer.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(startIndex));
            }

            if (length < 48 || length > (buffer.Length - startIndex))
            {
                throw new ArgumentOutOfRangeException(nameof(length));
            }

            int index = startIndex;

            // Size (4 bytes): A 32-bit unsigned integer that defines the length, in bytes, of the Value field in the AV_PAIR (section 2.2.2.1) structure.
            Size   = BitConverterLE.ToInt32(buffer, index);
            index += 4;

            // Z4 (4 bytes): A 32-bit integer value containing 0x00000000.
            index += 4;

            // CustomData (8 bytes): An 8-byte platform-specific blob containing info only relevant when the client and the server are on the same host.
            CustomData = new byte[8];
            Buffer.BlockCopy(buffer, index, CustomData, 0, 8);
            index += 8;

            // MachineID (32 bytes): A 256-bit random number created at computer startup to identify the calling machine.
            MachineId = new byte[32];
            Buffer.BlockCopy(buffer, index, MachineId, 0, 32);
        }
Пример #2
0
        static int DecodeFlags(byte[] buffer, ref int index)
        {
            short nbytes = BitConverterLE.ToInt16(buffer, index);
            int   value  = BitConverterLE.ToInt32(buffer, index + 2);

            index += 6;

            return(value);
        }
Пример #3
0
        static int DecodeFlags(byte[] buffer, ref int index)
        {
            short nbytes = BitConverterLE.ToInt16(buffer, index);
            int   flags;

            index += 2;

            switch (nbytes)
            {
            case 4:  flags = BitConverterLE.ToInt32(buffer, index); break;

            case 2:  flags = BitConverterLE.ToInt16(buffer, index); break;

            default: flags = 0; break;
            }

            index += nbytes;

            return(flags);
        }
Пример #4
0
        static int DecodeFlags(byte[] buffer, ref int index, out short size)
        {
            size = BitConverterLE.ToInt16(buffer, index);
            int flags;

            index += 2;

            switch (size)
            {
            case 4:  flags = BitConverterLE.ToInt32(buffer, index); break;

            case 2:  flags = BitConverterLE.ToInt16(buffer, index); break;

            default: flags = 0; break;
            }

            index += size;

            return(flags);
        }