Example #1
0
 public void ReadFromStream(Stream stream)
 {
     BinaryReader br = new BinaryReader(stream);
     Unknown1 = br.ReadBigInt32();
     Unknown2 = br.ReadBigInt32();
     Unknown3 = br.ReadBigInt32();
     Unknown4 = br.ReadBigInt32();
 }
Example #2
0
        public void ReadFromStream(Stream stream)
        {
            BinaryReader br = new BinaryReader(stream);
            Magic = br.ReadInt32();
            if (Magic != MagicNumber)
                throw new Exception("Неверная сигнатура файла: " + Magic);

            Type = (SectionType)br.ReadInt32();
            Version = br.ReadBigInt32();
            Unknown2 = br.ReadBigInt32();
            SectionLength = br.ReadBigInt32();
            Junk = stream.EnsureRead(28);
        }
Example #3
0
 public void ReadFromStream(Stream stream)
 {
     BinaryReader br = new BinaryReader(stream);
     Magic = br.ReadBigUInt32();
     Unknown1 = br.ReadByte();
     Unknown2 = br.ReadByte();
     Format = (GtexPixelFromat)br.ReadByte();
     MipMapCount = br.ReadByte();
     Unknown3 = br.ReadByte();
     IsCubeMap = br.ReadByte() == 1;
     Width = br.ReadBigInt16();
     Height = br.ReadBigInt16();
     Depth = br.ReadBigInt16();
     LinerSize = br.ReadBigInt32();
     DataOffset = br.ReadBigInt32();
 }
Example #4
0
        public void ReadFromStream(Stream stream)
        {
            BinaryReader br = new BinaryReader(stream);

            IsFirstBlock = stream.Position == YkdHeader.Size;

            Type = br.ReadUInt32();
            Index = br.ReadUInt32();
            AssociatedIndex = br.ReadUInt32();
            Unknown = br.ReadUInt32();

            for (int i = 0; i < TransformationMatrix.Length; i++)
                TransformationMatrix[i] = br.ReadBigInt32();

            Offsets = stream.ReadContent<YkdOffsets>();
            Entries = new YkdBlockEntry[Offsets.Count];
            for (int i = 0; i < Offsets.Count; i++)
            {
                stream.SetPosition(Offsets[i]);
                Entries[i] = stream.ReadContent<YkdBlockEntry>();
            }

            if (!IsFirstBlock)
            {
                switch (Type)
                {
                    case 0:
                        ZeroTail = stream.ReadContent<YkdBlockOptionalTail>();
                        break;
                    case 4:
                        Tails4 = stream.ReadContent<YkdBlockOptionalTails>();
                        break;
                    case 5:
                    case 6:
                        Tail56 = new int[12];
                        for (int i = 0; i < Tail56.Length; i++)
                            Tail56[i] = br.ReadInt32();
                        break;
                }
            }
        }
        internal screenshotItem shotReachBeta(BinaryReader br, int fileStart, screenshotItem screenshot)
        {
            br.BaseStream.Position = fileStart + 4;
            int blfLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 4;
            int chdrLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 12;
            int blfVersion = br.ReadBigInt16();
            br.BaseStream.Position += 46; // Move forward 46 bytes to get to the mapID
            int mapId = br.ReadBigInt32() + 10000;
            br.BaseStream.Position += 12; // Move forward 12 to get to the created time
            int shotTime = br.ReadBigInt32();
            br.BaseStream.Position += 64; // Move forward 64 bytes to get to the title
            string shotTitle = Encoding.BigEndianUnicode.GetString(br.ReadBytes(256)).Trim('\0');
            br.BaseStream.Position = fileStart + blfLength + chdrLength + 4;
            int scncLength = 0; // The scnc block doesn't exist in Halo: Reach Beta screenshots
            br.BaseStream.Position = fileStart + blfLength + chdrLength + scncLength + 12;
            int jpegLength = br.ReadBigInt32();
            int jpegOffset = (int)br.BaseStream.Position;

            screenshot.blfVersion = blfVersion;
            screenshot.headerLength = blfLength + chdrLength + scncLength + 16;
            screenshot.headerStart = (fileStart - 49152) / 4096;
            screenshot.jpegLength = jpegLength;
            screenshot.jpegOffset = jpegOffset;
            screenshot.mapID = mapId;
            screenshot.fileTime = shotTime;
            screenshot.shotTitle = shotTitle;

            return screenshot;
        }
        internal screenshotItem shotReach(BinaryReader br, int fileStart, screenshotItem screenshot)
        {
            int headerStart = (fileStart - 49152) / 4096;
            br.BaseStream.Position = fileStart + 4;
            int blfLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 4;
            int chdrLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 12;
            int blfVersion = br.ReadBigInt16();
            br.BaseStream.Position += 46; // Move forward 46 bytes to get to the mapID
            int mapId = br.ReadBigInt32();
            if (screenshot.gameID == 4 && mapId == 10080)
                mapId += 1; // This is done to prevent a discrepancy with Halo: Reach's "Installation 04"
            br.BaseStream.Position += 12; // Move forward 12 bytes to get to the created timestamp
            int createTime = br.ReadBigInt32();
            br.BaseStream.Position += 32;
            int modTime = br.ReadBigInt32();
            br.BaseStream.Position += 28; // Move forward 28 bytes to get to the title
            string shotTitle = Encoding.BigEndianUnicode.GetString(br.ReadBytes(256)).Trim('\0');
            br.BaseStream.Position = fileStart + blfLength + chdrLength + 4;
            int scncLength = br.ReadBigInt32();
            br.BaseStream.Position = screenshot.hashTable + ((headerStart * 24) + 21); // Since the header in Reach Retail screenshot files spans more than one block, we need to find out where to go next from the hash table
            int nextBlock = (br.ReadBigInt24() * 4096) + 49152;
            int bytesRemain = (blfLength + chdrLength + scncLength) - 4096;
            br.BaseStream.Position = nextBlock + bytesRemain + 12;
            int jpegLength = br.ReadBigInt32();
            int jpegOffset = (int)br.BaseStream.Position;

            screenshot.blfVersion = blfVersion;
            screenshot.headerLength = blfLength + chdrLength + scncLength + 16;
            screenshot.headerStart = headerStart;
            screenshot.jpegLength = jpegLength;
            screenshot.jpegOffset = jpegOffset;
            screenshot.mapID = mapId;
            screenshot.fileTime = createTime;
            screenshot.shotTitle = shotTitle;

            return screenshot;
        }
        internal screenshotItem shotHalo3ODST(BinaryReader br, int fileStart, screenshotItem screenshot)
        {
            br.BaseStream.Position = fileStart + 4;
            int blfLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 4;
            int chdrLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + 12;
            int blfVersion = br.ReadBigInt16();
            br.BaseStream.Position += 10; // Move forward 10 bytes to get to the start of the title
            string shotTitle = Encoding.BigEndianUnicode.GetString(br.ReadBytes(32)).Trim('\0');
            br.BaseStream.Position += 172; // Move forward 172 bytes to get to the shot time
            int shotTime = br.ReadBigInt32();
            br.BaseStream.Position += 8;
            int mapId = br.ReadBigInt32();
            br.BaseStream.Position += 8;
            byte fireFight = br.ReadByte();
            if (fireFight != 0)
                mapId += 10000 + fireFight;
            br.BaseStream.Position = fileStart + blfLength + chdrLength + 4;
            int scncLength = 0; // The scnc block doesn't exist in versions prior to 12070, so we'll check for that
            if (blfVersion >= 12070)
                scncLength = br.ReadBigInt32();
            br.BaseStream.Position = fileStart + blfLength + chdrLength + scncLength + 12;
            int jpegLength = br.ReadBigInt32();
            int jpegOffset = (int)br.BaseStream.Position;

            screenshot.blfVersion = blfVersion;
            screenshot.headerLength = blfLength + chdrLength + scncLength + 16;
            screenshot.headerStart = (fileStart - 49152) / 4096;
            screenshot.jpegLength = jpegLength;
            screenshot.jpegOffset = jpegOffset;
            screenshot.fileTime = shotTime;
            screenshot.mapID = mapId;
            screenshot.shotTitle = shotTitle;

            return screenshot;
        }
Example #8
0
        private void ProcessRelaSection(Elf elf, Elf.ElfSection relocs, Elf.ElfSection section, Elf.ElfSection symtab)
        {
            if (relocs.sh_entsize != 12)
                throw new InvalidDataException("Invalid relocs format (sh_entsize != 12)");
            if (symtab.sh_type != Elf.ElfSection.Type.SHT_SYMTAB)
                throw new InvalidDataException("Symbol table does not have type SHT_SYMTAB");

            var reader = new BinaryReader(new MemoryStream(relocs.data));
            int count = relocs.data.Length / 12;

            for (int i = 0; i < count; i++)
            {
                uint r_offset = reader.ReadBigUInt32();
                uint r_info = reader.ReadBigUInt32();
                int r_addend = reader.ReadBigInt32();

                Elf.Reloc reloc = (Elf.Reloc)(r_info & 0xFF);
                int symIndex = (int)(r_info >> 8);

                if (symIndex == 0)
                    throw new InvalidDataException("linking to undefined symbol");
                if (!_sectionBases.ContainsKey(section))
                    continue; // we don't care about this

                string symName = _symbolTableContents[symtab][symIndex];
                //Console.WriteLine("{0,-30} {1}", symName, reloc);

                Word source = _sectionBases[section] + r_offset;
                Word dest = ResolveSymbol(elf, symName).address + r_addend;

                //Console.WriteLine("Linking from {0} to {1}", source, dest);

                if (!KamekUseReloc(reloc, source, dest))
                    _fixups.Add(new Fixup { type = reloc, source = source, dest = dest });
            }
        }
Example #9
0
 public void ReadFromStream(Stream stream)
 {
     BinaryReader br = new BinaryReader(stream);
     Offset = br.ReadBigInt32();
     Length = br.ReadBigInt32();
 }