public XeXHeader(MemoryStream file) { MyBinaryReader reader; try { reader = new MyBinaryReader(file, EndianType.BigEndian); reader.BaseStream.Seek(0L, SeekOrigin.Begin); if (Encoding.ASCII.GetString(reader.ReadBytes(4)) == "XEX2") { reader.BaseStream.Seek(20L, SeekOrigin.Begin); uint headerCount = reader.ReadUInt32(); byte[] infoArray = new byte[] { 0, 4, 0, 6 }; for (int i = 0; i < headerCount; i++) { byte[] headerIdArray = reader.ReadBytes(4); uint headerId = BitConverter.ToUInt32(headerIdArray, 0); if (headerId == BitConverter.ToUInt32(infoArray, 0)) { uint dataAddress = reader.ReadUInt32(); reader.BaseStream.Seek((long)dataAddress, SeekOrigin.Begin); this.mediaId = reader.ReadBytes(4); this.version = reader.ReadUInt32(); this.baseVersion = reader.ReadUInt32(); this.titleId = reader.ReadBytes(4); this.platform = reader.ReadByte(); this.executableType = reader.ReadByte(); this.discNumber = reader.ReadByte(); this.discCount = reader.ReadByte(); break; } else { reader.ReadUInt32(); } } } else { throw new Exception("Extracted file is not XEX file"); } } catch (Exception ex) { throw ex; } reader.Close(); }