public Field(FieldDescriptor fd, Dictionary<uint, string> unhash, long pos, DbxFile tmpdbx) { this.descriptor = fd; this.name = unhash[fd.hash]; this.absPos = pos; this.dbx = tmpdbx; }
public void InitializeMetaData(BinaryReader fCas) { this.dbxHeader = new DbxHeader(fCas); this.arraySectionStart = this.catEntry.offset + this.dbxHeader.stringOffset + this.dbxHeader.lenString + this.dbxHeader.lenPayload; this.stringSectionStart = this.catEntry.offset + this.dbxHeader.stringOffset; this.payloadSectionStart = this.catEntry.offset + this.dbxHeader.stringOffset + this.dbxHeader.lenString; this.externalGuids = new List <Tuple <byte[], byte[]> >((int)this.dbxHeader.numExternalGuid); int num = 0; while ((long)num < (long)((ulong)this.dbxHeader.numExternalGuid)) { this.externalGuids.Add(new Tuple <byte[], byte[]>(fCas.ReadBytes(16), fCas.ReadBytes(16))); num++; } this.unhash = new Dictionary <uint, string>(); byte[] array = new byte[this.dbxHeader.lenKeyword]; fCas.BaseStream.Read(array, 0, (int)this.dbxHeader.lenKeyword); int num2 = 0; int num3 = 0; while ((long)num3 < (long)((ulong)this.dbxHeader.lenKeyword)) { if (array[num3] == 0) { string @string = Encoding.ASCII.GetString(array, num2, num3 - num2); if (@string != "") { this.unhash.Add(DbxFile.hasher(@string), @string); } num2 = num3 + 1; } num3++; } this.fieldDescriptors = new List <FieldDescriptor>((int)this.dbxHeader.numField); int num4 = 0; while ((long)num4 < (long)((ulong)this.dbxHeader.numField)) { FieldDescriptor item = new FieldDescriptor(fCas); this.fieldDescriptors.Add(item); num4++; } this.complexDescriptors = new List <ComplexDescriptor>((int)this.dbxHeader.numComplex); int num5 = 0; while ((long)num5 < (long)((ulong)this.dbxHeader.numComplex)) { ComplexDescriptor item2 = new ComplexDescriptor(fCas); this.complexDescriptors.Add(item2); num5++; } this.instanceRepeaters = new List <InstanceRepeater>(); int num6 = 0; while ((long)num6 < (long)((ulong)this.dbxHeader.numInstanceRepeater)) { this.instanceRepeaters.Add(new InstanceRepeater(fCas)); num6++; } long num7 = 16L - (fCas.BaseStream.Position - (long)((ulong)this.catEntry.offset)) % 16L; if (num7 != 16L) { fCas.ReadBytes((int)num7); } this.arrayRepeaters = new List <ArrayRepeater>(); int num8 = 0; while ((long)num8 < (long)((ulong)this.dbxHeader.numArrayRepeater)) { this.arrayRepeaters.Add(new ArrayRepeater(fCas)); num8++; } }
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; }
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); }
public void InitializeMetaData(BinaryReader fCas) { this.dbxHeader = new DbxHeader(fCas); this.arraySectionStart = this.catEntry.offset + this.dbxHeader.stringOffset + this.dbxHeader.lenString + this.dbxHeader.lenPayload; this.stringSectionStart = this.catEntry.offset + this.dbxHeader.stringOffset; this.payloadSectionStart = this.catEntry.offset + this.dbxHeader.stringOffset + this.dbxHeader.lenString; this.externalGuids = new List<Tuple<byte[], byte[]>>((int)this.dbxHeader.numExternalGuid); int num = 0; while ((long)num < (long)((ulong)this.dbxHeader.numExternalGuid)) { this.externalGuids.Add(new Tuple<byte[], byte[]>(fCas.ReadBytes(16), fCas.ReadBytes(16))); num++; } this.unhash = new Dictionary<uint, string>(); byte[] array = new byte[this.dbxHeader.lenKeyword]; fCas.BaseStream.Read(array, 0, (int)this.dbxHeader.lenKeyword); int num2 = 0; int num3 = 0; while ((long)num3 < (long)((ulong)this.dbxHeader.lenKeyword)) { if (array[num3] == 0) { string @string = Encoding.ASCII.GetString(array, num2, num3 - num2); if (@string != "") { this.unhash.Add(DbxFile.hasher(@string), @string); } num2 = num3 + 1; } num3++; } this.fieldDescriptors = new List<FieldDescriptor>((int)this.dbxHeader.numField); int num4 = 0; while ((long)num4 < (long)((ulong)this.dbxHeader.numField)) { FieldDescriptor item = new FieldDescriptor(fCas); this.fieldDescriptors.Add(item); num4++; } this.complexDescriptors = new List<ComplexDescriptor>((int)this.dbxHeader.numComplex); int num5 = 0; while ((long)num5 < (long)((ulong)this.dbxHeader.numComplex)) { ComplexDescriptor item2 = new ComplexDescriptor(fCas); this.complexDescriptors.Add(item2); num5++; } this.instanceRepeaters = new List<InstanceRepeater>(); int num6 = 0; while ((long)num6 < (long)((ulong)this.dbxHeader.numInstanceRepeater)) { this.instanceRepeaters.Add(new InstanceRepeater(fCas)); num6++; } long num7 = 16L - (fCas.BaseStream.Position - (long)((ulong)this.catEntry.offset)) % 16L; if (num7 != 16L) { fCas.ReadBytes((int)num7); } this.arrayRepeaters = new List<ArrayRepeater>(); int num8 = 0; while ((long)num8 < (long)((ulong)this.dbxHeader.numArrayRepeater)) { this.arrayRepeaters.Add(new ArrayRepeater(fCas)); num8++; } }