Beispiel #1
0
 public void Read(CBinaryReader br, uint BaseAddress)
 {
     br.Seek(Header.SectionNameAddress - BaseAddress, SeekOrigin.Begin);
     while (br.PeekChar() != 0)
     {
         Name = Name + br.ReadChar();
     }
     br.Seek(Header.RawAddress, SeekOrigin.Begin);
     Data = br.ReadBytes((int)Header.RawSize);
 }
Beispiel #2
0
 public void Read(CBinaryReader br, uint BaseAddress)
 {
     br.Seek((long)(this.Header.SectionNameAddress - BaseAddress), SeekOrigin.Begin);
     while (br.PeekChar() != 0)
     {
         this.Name = this.Name + br.ReadChar();
     }
     br.Seek((long)this.Header.RawAddress, SeekOrigin.Begin);
     this.Data = br.ReadBytes((int)this.Header.RawSize);
 }
Beispiel #3
0
        private void readImageData(CBinaryReader br)
        {
            br.Seek((long)this.Header.HeaderSize, SeekOrigin.Begin);
            int count = (int)(this.Header.FileSize - this.Header.HeaderSize);

            this.Image = new byte[count];
            this.Image = br.ReadBytes(count);
        }
Beispiel #4
0
 private void init(CBinaryReader br)
 {
     br.Seek(0L, SeekOrigin.Begin);
     this.Header = new XPRHeader(br);
     if (this.IsValid)
     {
         this.readImageData(br);
     }
 }
Beispiel #5
0
 public XbeInfo(byte[] Xbe)
 {
     br     = new CBinaryReader(EndianType.LittleEndian, new MemoryStream(Xbe));
     Header = new XbeHeader(br);
     if (Header.IsValid)
     {
         br.Seek(Header.CertificateAddress - Header.BaseAddress, SeekOrigin.Begin);
         Certifcate = new XbeCertifcate(br);
         br.Seek(Header.SectionHeadersAddress - Header.BaseAddress, SeekOrigin.Begin);
         for (uint i = 0; i < Header.NumberOfSections; i++)
         {
             Sections.Add(new XbeSection(br));
         }
         foreach (XbeSection section in Sections)
         {
             section.Read(br, Header.BaseAddress);
         }
     }
 }
Beispiel #6
0
 public XdbfHeader(CBinaryReader b)
 {
     b.Seek(0L, SeekOrigin.Begin);
     MagicBytes     = b.ReadBytes(4);
     Version        = b.ReadUInt16();
     Reserved       = b.ReadUInt16();
     NumEntries     = b.ReadUInt32();
     NumEntriesCopy = b.ReadUInt32();
     UnknownA       = b.ReadUInt32();
     UnknownB       = b.ReadUInt32();
 }
Beispiel #7
0
 public XdbfTable(CBinaryReader b, XdbfHeader header)
 {
     b.Seek(30L, SeekOrigin.Begin);
     for (int i = 0; i < header.NumEntries; i++)
     {
         base.Add(new XdbfTableEntry(b));
     }
     while (b.PeekChar() == 0)
     {
         b.ReadByte();
     }
 }
Beispiel #8
0
 public byte[] GetResource(uint Signature, ushort Type)
 {
     foreach (XdbfTableEntry entry in entries)
     {
         if ((entry.Identifier == Signature) && (entry.Type == Type))
         {
             br.Seek(dataOffset + entry.Offset, SeekOrigin.Begin);
             return(br.ReadBytes((int)entry.Size));
         }
     }
     return(new byte[0]);
 }
Beispiel #9
0
 public byte[] GetFile(string Path)
 {
     try
     {
         GDFDirTable folder = GetFolder(rootDir, Path);
         string      str    = Path.Contains(@"\") ? Path.Substring(Path.LastIndexOf(@"\") + 1) : Path;
         foreach (GDFDirEntry entry in folder)
         {
             if (entry.Name.ToLower() == str.ToLower())
             {
                 fr.Seek(volDesc.RootOffset + (entry.Sector * volDesc.SectorSize), SeekOrigin.Begin);
                 return(fr.ReadBytes((int)entry.Size));
             }
         }
     }
     catch (Exception exception)
     {
         Exceptions.Add(exception);
     }
     return(new byte[0]);
 }
Beispiel #10
0
 public override void Parse(CBinaryReader br)
 {
     br.Seek((long)base.Address, SeekOrigin.Begin);
     br.Endian           = EndianType.BigEndian;
     this.MediaID        = br.ReadBytes(4);
     this.Version        = br.ReadUInt32();
     this.BaseVersion    = br.ReadUInt32();
     this.TitleID        = br.ReadBytes(4);
     this.Platform       = br.ReadByte();
     this.ExecutableType = br.ReadByte();
     this.DiscNumber     = br.ReadByte();
     this.DiscCount      = br.ReadByte();
 }
Beispiel #11
0
 public override void Parse(CBinaryReader br)
 {
     br.Seek(Address, SeekOrigin.Begin);
     br.Endian      = EndianType.BigEndian;
     MediaID        = br.ReadBytes(4);
     Version        = br.ReadUInt32();
     BaseVersion    = br.ReadUInt32();
     TitleID        = br.ReadBytes(4);
     Platform       = br.ReadByte();
     ExecutableType = br.ReadByte();
     DiscNumber     = br.ReadByte();
     DiscCount      = br.ReadByte();
 }
Beispiel #12
0
        public GDFDirTable(CBinaryReader File, GDFVolumeDescriptor Vol, uint Sector, uint Size)
        {
            this.Sector = Sector;
            this.Size   = Size;
            File.Seek((long)((Sector * Vol.SectorSize) + Vol.RootOffset), SeekOrigin.Begin);
            byte[]        buffer = File.ReadBytes((int)Size);
            MemoryStream  s      = new MemoryStream(buffer);
            CBinaryReader reader = new CBinaryReader(EndianType.LittleEndian, s);

            try
            {
                while (s.Position < Size)
                {
                    GDFDirEntry item = new GDFDirEntry {
                        SubTreeL = reader.ReadUInt16(),
                        SubTreeR = reader.ReadUInt16()
                    };
                    if ((item.SubTreeL != 0xffff) && (item.SubTreeR != 0xffff))
                    {
                        item.Sector     = reader.ReadUInt32();
                        item.Size       = reader.ReadUInt32();
                        item.Attributes = (GDFDirEntryAttrib)reader.ReadByte();
                        item.NameLength = reader.ReadByte();
                        item.Name       = Encoding.ASCII.GetString(buffer, (int)s.Position, item.NameLength);
                        s.Seek((long)item.NameLength, SeekOrigin.Current);
                        long num1 = s.Position % 4L;
                        if ((s.Position % 4L) != 0L)
                        {
                            s.Seek(4L - (s.Position % 4L), SeekOrigin.Current);
                        }
                        base.Add(item);
                    }
                }
            }
            catch (EndOfStreamException)
            {
                Console.WriteLine("EndOfStreamException while trying to read directory at sector {0} ({1} bytes)", Sector.ToString(), Size.ToString());
            }
            catch (Exception exception)
            {
                Console.WriteLine("Unhandled Exception {0} for directory at sector {1} -> {2}", exception.InnerException, Sector.ToString(), exception.Message);
            }
        }
Beispiel #13
0
 public XexHeader(CBinaryReader br)
 {
     Clear();
     try
     {
         br.Seek(0L, SeekOrigin.Begin);
         if (Encoding.ASCII.GetString(br.ReadBytes(4)) == "XEX2")
         {
             br.Seek(4L, SeekOrigin.Begin);
             Add(XexInfoFields.ModuleFlags, new XexModuleFlags(br.ReadUInt32()));
             br.Seek(8L, SeekOrigin.Begin);
             Add(XexInfoFields.CodeOffset, new XexCodeOffset(br.ReadUInt32()));
             br.Seek(0x10L, SeekOrigin.Begin);
             Add(XexInfoFields.CertifcateOffset, new XexCertifcateOffset(br.ReadUInt32()));
             br.Seek(20L, SeekOrigin.Begin);
             uint num = br.ReadUInt32();
             for (int i = 0; i < num; i++)
             {
                 uint num3 = BitConverter.ToUInt32(br.ReadBytes(4), 0);
                 if (num3 == BitConverter.ToUInt32(XexResourceInfo.Signature, 0))
                 {
                     Add(XexInfoFields.ResourceInfo, new XexResourceInfo(br.ReadUInt32()));
                 }
                 else if (num3 == BitConverter.ToUInt32(XexCompressionInfo.Signature, 0))
                 {
                     Add(XexInfoFields.CompressionInfo, new XexCompressionInfo(br.ReadUInt32()));
                 }
                 else if (num3 == BitConverter.ToUInt32(XexExecutionInfo.Signature, 0))
                 {
                     Add(XexInfoFields.ExecutionInfo, new XexExecutionInfo(br.ReadUInt32()));
                 }
                 else if (num3 == BitConverter.ToUInt32(XexBaseFileFormat.Signature, 0))
                 {
                     Add(XexInfoFields.BaseFileFormat, new XexBaseFileFormat(br.ReadUInt32()));
                 }
                 else if (num3 == BitConverter.ToUInt32(XexBaseFileTimestamp.Signature, 0))
                 {
                     Add(XexInfoFields.BaseFileTimestamp, new XexBaseFileTimestamp(br.ReadUInt32()));
                 }
                 else if (num3 == BitConverter.ToUInt32(XexOriginalName.Signature, 0))
                 {
                     Add(XexInfoFields.OriginalName, new XexOriginalName(br.ReadUInt32()));
                 }
                 else if (num3 == BitConverter.ToUInt32(XexRatingsInfo.Signature, 0))
                 {
                     Add(XexInfoFields.RatingsInfo, new XexRatingsInfo(br.ReadUInt32()));
                 }
                 else if (num3 == BitConverter.ToUInt32(XexModuleFlags.Signature, 0))
                 {
                     Add(XexInfoFields.SystemFlags, new XexModuleFlags(br.ReadUInt32()));
                 }
                 else
                 {
                     br.ReadUInt32();
                 }
             }
         }
     }
     catch (EndOfStreamException)
     {
         Console.WriteLine("EndOfStreamException when trying to read XEX file header.");
     }
 }