Example #1
0
        protected void WalkRecords()
        {
            int len = 0;

            int startpoint = this.inRecordDataSeq.StartPoint;

            int datalen = this.inRecordDataSeq.Length;

            byte[] records = new byte[datalen];

            Array.Copy(this.inValue, startpoint, records, 0, datalen);

            for (int cnt = 1; cnt <= this.RecordCount; cnt++)
            {
                DecoderSequence recseq = new DecoderSequence(startpoint, datalen);

                len = (int)DecodeField(records, this.inRecordLenSeq);

                WalkRecord(records, recseq, len);

                startpoint = len + 4;

                datalen = datalen - (len + 4);

                Array.Copy(records, startpoint, records, 0, datalen);
            }
        }
Example #2
0
        protected string DecodeFieldStringInternal(byte[] subValue, DecoderSequence seq)
        {
            string ret = String.Empty;

            ret = DecodeFieldInternal(subValue, seq).ToString();

            ret = String.Format("{0}>", ret);

            return(ret);
        }
Example #3
0
            protected void LoadInternal(byte[] value, DecoderSequence dataSeq, int flags, DateTime timeStamp)
            {
                this.inFlags = (TrustFlagsSuffix)Enum.Parse(typeof(TrustFlagsSuffix), flags.ToString());

                this.inTimestamp = timeStamp;

                dataSeq.FieldType = FIELD_TYPES.u;

                this.inSuffix = (string)DecodeField(value, dataSeq);
            }
Example #4
0
            protected DecoderSequence NextSequence(byte[] value, ref int len, FIELD_TYPES fieldtype)
            {
                DecoderSequence ret = new DecoderSequence(0, 0);

                this.inDataLenSeq.StartPoint = this.inDataLenSeq.StartPoint + len;

                len = (int)DecodeField(value, this.inDataLenSeq);

                this.inDataLenSeq.StartPoint = this.inDataLenSeq.StartPoint + this.inDataLenSeq.Length;

                ret = new DecoderSequence(this.inDataLenSeq.StartPoint, len, fieldtype);

                return(ret);
            }
Example #5
0
        public string DecodeFieldString(byte[] value, DecoderSequence seq)
        {
            string ret = string.Empty;

            if (!seq.IsArray)
            {
                byte[] subval = new byte[seq.Length];

                Array.Copy(value, seq.StartPoint, subval, 0, seq.Length);

                ret = DecodeFieldStringInternal(subval, seq);
            }

            return(ret);
        }
Example #6
0
        public object DecodeField(byte[] value, DecoderSequence seq)
        {
            object ret = null;

            if (!seq.IsArray)
            {
                byte[] subval = new byte[seq.Length];

                Array.Copy(value, seq.StartPoint, subval, 0, seq.Length);

                ret = DecodeFieldInternal(subval, seq);
            }

            return(ret);
        }
Example #7
0
            protected void LoadInternal(byte[] value, int flags, DateTime timeStamp)
            {
                int len = 0;

                this.inFlags = (TrustFlagsName)Enum.Parse(typeof(TrustFlagsName), flags.ToString());

                this.inTimestamp = timeStamp;


                DecoderSequence dataseq = NextSequence(value, ref len, FIELD_TYPES.S);

                this.inSID = (SecurityIdentifier)DecodeField(value, dataseq);

                dataseq = NextSequence(value, ref len, FIELD_TYPES.u);

                this.inDnsName = (string)DecodeField(value, dataseq);

                NextSequence(value, ref len, FIELD_TYPES.u);

                this.inNetBios = (string)DecodeField(value, dataseq);
            }
Example #8
0
        protected void WalkRecord(byte[] recordData, DecoderSequence recSeq, int recLen)
        {
            DateTime timestamp = DateTime.MinValue;

            int flags = 0;

            TrustRecordType recordtype = 0;

            flags = (int)DecodeField(recordData, inFlagsSeq);

            timestamp = (DateTime)DecodeField(recordData, inTimeStampSeq);

            recordtype = (TrustRecordType)DecodeField(recordData, inRecordTypeSeq);

            if (recordtype == TrustRecordType.ForestTrustDomainInfo)
            {
                DecodeNameData(recordData, recLen, flags, timestamp);
            }

            else
            {
                DecodeSuffixData(recordData, recLen, flags, timestamp);
            }
        }
Example #9
0
        private object DecodeFieldInternal(byte[] subValue, DecoderSequence seq)
        {
            object ret = null;

            switch (seq.FieldType)
            {
            case FIELD_TYPES.i:

                switch (seq.Length)
                {
                case 1:

                    ret = (int)subValue[0];

                    break;

                case 4:

                    ret = BitConverter.ToInt32(subValue, 0);

                    break;

                case 8:

                    ret = BitConverter.ToInt64(subValue, 0);

                    break;
                }

                break;

            case FIELD_TYPES.u:
                ret = Encoding.UTF8.GetString(subValue);

                break;

            case FIELD_TYPES.a:

                int ce = CheckEncoding(subValue);

                switch (ce)
                {
                case 4:
                    ret = Encoding.ASCII.GetString(subValue);

                    break;

                case 8:
                    ret = Encoding.UTF8.GetString(subValue);

                    break;

                case 32:
                    ret = Encoding.UTF32.GetString(subValue);

                    break;
                }

                break;

            case FIELD_TYPES.D:

                Int64 lval = BitConverter.ToInt64(subValue, 0);

                // we got seconds, not ticks (100 nanosecond steps)
                lval = lval * (Int64)Math.Pow(10, 7);

                ret = DateTime.FromFileTime(lval);

                break;

            case FIELD_TYPES.d:

                long ht = BitConverter.ToInt32(subValue, 0);

                long lt = BitConverter.ToInt32(subValue, 4);

                if (lt < 0)
                {
                    ht += 1;
                }

                lval = (ht << 32);

                lval = lval + lt;

                ret = DateTime.FromFileTime(lval);

                break;

            case FIELD_TYPES.G:

                ret = new Guid(subValue);

                break;

            case FIELD_TYPES.S:

                ret = new SecurityIdentifier(subValue, 0);

                break;
            }

            return(ret);
        }
Example #10
0
 public TrustInfoSuffix(byte[] value, DecoderSequence dataSeq, int flags, DateTime timeStamp)
 {
     LoadInternal(value, dataSeq, flags, timeStamp);
 }