//#endregion public void Read(EndianAwareBinaryReader reader) { this.magic = reader.ReadUInt16(); if (magic != magicConst) { throw new BadImageFormatException(); } this.lastPageSize = reader.ReadUInt16(); this.pageCount = reader.ReadUInt16(); this.relocations = reader.ReadUInt16(); this.headerSize = reader.ReadUInt16(); this.minimumParagraphsNeeded = reader.ReadUInt16(); this.maximumParagraphsNeeded = reader.ReadUInt16(); this.initialStackSegment = reader.ReadUInt16(); this.initialStackPointer = reader.ReadUInt16(); this.checksum = reader.ReadUInt16(); this.initialInstructionPointer = reader.ReadUInt16(); this.initialCodeSegment = reader.ReadUInt16(); this.relocationTablePtr = reader.ReadUInt16(); this.overlayNumber = reader.ReadUInt16(); this.reserved = reader.ReadUInt64(); this.oemIdentifier = reader.ReadUInt16(); this.oemInformation = reader.ReadUInt16(); this.reserved2A = reader.ReadUInt64(); this.reserved2B = reader.ReadUInt64(); this.reserved2C = reader.ReadUInt32(); this.peHeaderPointer = reader.ReadUInt32(); }
internal void Read(EndianAwareBinaryReader reader) { this.imageBase = reader.ReadUInt64(); this.sectionAlignment = reader.ReadUInt32(); this.fileAlignment = reader.ReadUInt32(); this.osVersion.Read(reader); this.binaryVersion.Read(reader); this.subsystemVersion.Read(reader); this.reserved = reader.ReadUInt32(); this.imageSize = reader.ReadUInt32(); this.headerSize = reader.ReadUInt32(); this.fileChecksum = reader.ReadUInt32(); this.subsystem = (PEImageSubsystem)reader.ReadUInt16(); this.dllCharacteristics = (PEImageDllCharacteristics)reader.ReadUInt16(); this.stackReserveSize = reader.ReadUInt64(); this.stackCommitSize = reader.ReadUInt64(); this.heapReserveSize = reader.ReadUInt64(); this.heapCommitSize = reader.ReadUInt64(); this.loaderFlags = reader.ReadUInt32(); this.dataDirectoryCount = reader.ReadUInt32(); }
public AssetEntry(EndianAwareBinaryReader reader, Layer layer) { Layer = layer; Size = reader.ReadInt32(); RelativeDataOffset = reader.ReadInt32(); DataSize = reader.ReadInt32(); Unknown1 = reader.ReadInt32(); AssetID = reader.ReadUInt64(); // this might be a hash of the filepath? AssetType = (AssetType)reader.ReadUInt32(); Unknown2 = reader.ReadInt16(); Unknown3 = reader.ReadInt16(); }
public DirectoryEntry(EndianAwareBinaryReader reader, int size) { var offset = reader.BaseStream.Position + size; AssetID = reader.ReadUInt64(); Unknown2 = reader.ReadInt32(); // size of next block? Unknown3 = reader.ReadInt32(); // file hash of size? Unknown4 = reader.ReadInt32(); Unknown5 = reader.ReadInt32(); Unknown6 = reader.ReadInt32(); Unknown7 = reader.ReadInt32(); FileName = reader.ReadCString(); reader.Seek(offset, SeekOrigin.Begin); }
public object Deserialize(EndianAwareBinaryReader reader, SerializedType serializedType, int?length = null) { int?effectiveLength = null; var typeParent = TypeNode.Parent as TypeNode; if (length != null) { effectiveLength = length.Value; } else if (TypeNode.FieldLengthBinding != null) { object lengthValue = TypeNode.FieldLengthBinding.GetValue(this); effectiveLength = Convert.ToInt32(lengthValue); } else if (typeParent != null && typeParent.ItemLengthBinding != null) { object lengthValue = typeParent.ItemLengthBinding.GetValue((ValueNode)Parent); effectiveLength = Convert.ToInt32(lengthValue); } else if (TypeNode.FieldCountBinding != null) { object countValue = TypeNode.FieldCountBinding.GetValue(this); effectiveLength = Convert.ToInt32(countValue); } else if (serializedType == SerializedType.ByteArray || serializedType == SerializedType.SizedString) { checked { effectiveLength = (int)_remainder; } } object value; switch (serializedType) { case SerializedType.Int1: value = reader.ReadSByte(); break; case SerializedType.UInt1: value = reader.ReadByte(GetBitSize()); break; case SerializedType.Int2: value = reader.ReadInt16(); break; case SerializedType.UInt2: value = reader.ReadUInt16(); break; case SerializedType.Int4: value = reader.ReadInt32(); break; case SerializedType.UInt4: value = reader.ReadUInt32(); break; case SerializedType.Int8: value = reader.ReadInt64(); break; case SerializedType.UInt8: value = reader.ReadUInt64(); break; case SerializedType.Float4: value = reader.ReadSingle(); break; case SerializedType.Float8: value = reader.ReadDouble(); break; case SerializedType.ByteArray: { Debug.Assert(effectiveLength != null, "effectiveLength != null"); value = reader.ReadBytes(effectiveLength.Value); break; } case SerializedType.NullTerminatedString: { byte[] data = ReadNullTerminatedString(reader).ToArray(); value = Encoding.GetString(data, 0, data.Length); break; } case SerializedType.SizedString: { Debug.Assert(effectiveLength != null, "effectiveLength != null"); byte[] data = reader.ReadBytes(effectiveLength.Value); value = Encoding.GetString(data, 0, data.Length).TrimEnd('\0'); break; } case SerializedType.LengthPrefixedString: { value = reader.ReadString(); break; } default: throw new NotSupportedException(); } return(value); }