예제 #1
0
        public void InitializeFilename(BinaryReader fCas)
        {
            fCas.BaseStream.Position = (long)((ulong)this.payloadSectionStart);
            foreach (InstanceRepeater current in this.instanceRepeaters)
            {
                int num = 0;
                while ((long)num < (long)((ulong)current.repetitions))
                {
                    byte[] first = fCas.ReadBytes(16);
                    if (first.SequenceEqual(this.dbxHeader.primaryInstanceGuid))
                    {
                        ComplexDescriptor complexDescriptor  = this.complexDescriptors[(int)current.complexIndex];
                        FieldDescriptor   fieldDescriptor    = this.fieldDescriptors[(int)complexDescriptor.fieldStartIndex];
                        ComplexDescriptor complexDescriptor2 = this.complexDescriptors[(int)fieldDescriptor.reference];
                        while (true)
                        {
                            if (complexDescriptor2.numField > 1)
                            {
                                for (int i = 0; i < (int)complexDescriptor2.numField; i++)
                                {
                                    fieldDescriptor = this.fieldDescriptors[(int)(complexDescriptor2.fieldStartIndex + (uint)i)];
                                    if (!(this.unhash[fieldDescriptor.hash] != "Name"))
                                    {
                                        goto IL_199;
                                    }
                                }
                            }
                            if (complexDescriptor2.numField == 0)
                            {
                                break;
                            }
                            complexDescriptor2 = this.complexDescriptors[(int)this.fieldDescriptors[(int)complexDescriptor2.fieldStartIndex].reference];
                        }
                        for (int j = 0; j < (int)complexDescriptor.numField; j++)
                        {
                            fieldDescriptor = this.fieldDescriptors[(int)(complexDescriptor.fieldStartIndex + (uint)j)];
                            if (!(this.unhash[fieldDescriptor.hash] != "Name"))
                            {
                                goto IL_199;
                            }
                        }
                        throw new Exception("No Name found.");
IL_199:
                        fCas.BaseStream.Position += (long)((ulong)fieldDescriptor.offset);
                        fCas.BaseStream.Position  = (long)((ulong)(this.stringSectionStart + fCas.ReadUInt32()));
                        this.filename             = DbxFile.readNullTerminatedString(fCas);
                        return;
                    }
                    fCas.BaseStream.Position += (long)((ulong)this.complexDescriptors[(int)current.complexIndex].size);
                    num++;
                }
            }
        }
예제 #2
0
        private Field parseField(FieldDescriptor fieldDesc, BinaryReader b)
        {
            Field     field = new Field(fieldDesc, this.unhash, b.BaseStream.Position - (long)((ulong)this.catEntry.offset), this);
            FieldType type  = fieldDesc.type;

            if (type <= FieldType.Int8)
            {
                if (type <= FieldType.Array)
                {
                    if (type <= FieldType.Complex)
                    {
                        if (type != FieldType.Inheritance && type != FieldType.Complex)
                        {
                            return(field);
                        }
                    }
                    else
                    {
                        if (type == FieldType.Guid)
                        {
                            field.value = b.ReadUInt32();
                            return(field);
                        }
                        if (type != FieldType.Array)
                        {
                            return(field);
                        }
                        ArrayRepeater     arrayRepeater = this.arrayRepeaters[b.ReadInt32()];
                        ComplexDescriptor cd            = this.complexDescriptors[(int)fieldDesc.reference];
                        FieldDescriptor   fieldDesc2    = this.fieldDescriptors[(int)cd.fieldStartIndex];
                        if (arrayRepeater.repetitions == 0u)
                        {
                            field.value = "*nullArray*";
                            return(field);
                        }
                        b.BaseStream.Position = (long)((ulong)(this.arraySectionStart + arrayRepeater.offset));
                        Complex complex = new Complex(cd, this.unhash);
                        int     num     = 0;
                        while ((long)num < (long)((ulong)arrayRepeater.repetitions))
                        {
                            complex.fields.Add(this.parseField(fieldDesc2, b));
                            num++;
                        }
                        field.value = complex;
                        return(field);
                    }
                }
                else
                {
                    if (type <= FieldType.String)
                    {
                        if (type == FieldType.Enum)
                        {
                            Enum @enum = new Enum();
                            @enum.selection = b.ReadUInt32();
                            ComplexDescriptor complexDescriptor = this.complexDescriptors[(int)fieldDesc.reference];
                            for (int i = 0; i < (int)complexDescriptor.numField; i++)
                            {
                                Field field2 = new Field(this.fieldDescriptors[(int)(complexDescriptor.fieldStartIndex + (uint)i)], this.unhash, b.BaseStream.Position, this);
                                @enum.choices.Add(new Tuple <uint, string>(field2.descriptor.offset, field2.name));
                            }
                            field.value = @enum;
                            return(field);
                        }
                        if (type != FieldType.String)
                        {
                            return(field);
                        }
                        long position = b.BaseStream.Position;
                        b.BaseStream.Position = (long)((ulong)(this.stringSectionStart + b.ReadUInt32()));
                        field.value           = DbxFile.readNullTerminatedString(b);
                        b.BaseStream.Position = position + 4L;
                        return(field);
                    }
                    else
                    {
                        if (type == FieldType.Bool)
                        {
                            field.value = (b.ReadByte() != 0);
                            return(field);
                        }
                        if (type != FieldType.Int8)
                        {
                            return(field);
                        }
                        field.value = b.ReadByte();
                        return(field);
                    }
                }
            }
            else
            {
                if (type <= FieldType.UInt32)
                {
                    if (type <= FieldType.Int16)
                    {
                        if (type == FieldType.UInt16)
                        {
                            field.value = b.ReadUInt16();
                            return(field);
                        }
                        if (type != FieldType.Int16)
                        {
                            return(field);
                        }
                        field.value = b.ReadInt16();
                        return(field);
                    }
                    else
                    {
                        if (type == FieldType.Int32)
                        {
                            field.value = b.ReadInt32();
                            return(field);
                        }
                        if (type != FieldType.UInt32)
                        {
                            return(field);
                        }
                        field.value = b.ReadUInt32();
                        return(field);
                    }
                }
                else
                {
                    if (type <= FieldType.Double)
                    {
                        if (type == FieldType.Single)
                        {
                            field.value = b.ReadSingle();
                            return(field);
                        }
                        if (type != FieldType.Double)
                        {
                            return(field);
                        }
                        field.value = b.ReadDouble();
                        return(field);
                    }
                    else
                    {
                        if (type == FieldType.RawGuid)
                        {
                            field.value = b.ReadBytes(16);
                            return(field);
                        }
                        if (type != FieldType.Complex2)
                        {
                            return(field);
                        }
                    }
                }
            }
            field.value = this.parseComplex((int)fieldDesc.reference, b);
            return(field);
        }