Ejemplo n.º 1
0
        public static SMDH Read(Stream s)
        {
            if (!s.CanSeek)
            {
                throw new ArgumentException("Stream can't Seek", nameof(s));
            }

            var smdh = new SMDH(true);

            using (var br = new BinaryReader(s, Encoding.ASCII, true))
            {
                var flag = br.ReadUInt32() == BitConverter.ToUInt32(MAGIC, 0);
                if (!flag)
                {
                    throw new InvalidDataException("Not a SMDH File");
                }

                smdh.Version    = br.ReadInt16();
                smdh.Reserved_1 = br.ReadInt16();

                smdh.AppTitles = new AppTitle[16];
                for (int i = 0; i < 16; i++)
                {
                    smdh.AppTitles[i] = AppTitle.Read(s);
                }

                smdh.Settings = AppSettings.Read(s);

                smdh.Reserved_2 = br.ReadInt64();
                smdh.SmallIcon.Read(s);
                smdh.LargeIcon.Read(s);
            }
            return(smdh);
        }
Ejemplo n.º 2
0
 public SMDH() : this(true)
 {
     Version = 0;
     Reserved_1 = 0;
     Reserved_2 = 0;
     for (int i = 0; i < 16; i++)
         AppTitles[i] = new AppTitle();
     Settings = new AppSettings();
 }
Ejemplo n.º 3
0
 public static void Write(AppTitle title, Stream s)
 {
     using (var bw = new BinaryWriter(s, Encoding.ASCII, true))
     {
         bw.WriteFixedSizeString(title.ShortDesc, Encoding.Unicode, 0x80);
         bw.WriteFixedSizeString(title.LongDesc, Encoding.Unicode, 0x100);
         bw.WriteFixedSizeString(title.Publisher, Encoding.Unicode, 0x80);
     }
 }
Ejemplo n.º 4
0
        public static void Write(AppTitle title, Stream s)
        {
            using (var bw = new BinaryWriter(s, Encoding.ASCII, true))
            {
                bw.WriteFixedSizeString(title.ShortDesc, Encoding.Unicode, 0x80);

                bw.WriteFixedSizeString(title.LongDesc, Encoding.Unicode, 0x100);
                bw.WriteFixedSizeString(title.Publisher, Encoding.Unicode, 0x80);
            }
        }
Ejemplo n.º 5
0
 public SMDH() : this(true)
 {
     Version    = 0;
     Reserved_1 = 0;
     Reserved_2 = 0;
     for (int i = 0; i < 16; i++)
     {
         AppTitles[i] = new AppTitle();
     }
     Settings = new AppSettings();
 }
Ejemplo n.º 6
0
        public static void Write(SMDH smdh, Stream s)
        {
            using (var bw = new BinaryWriter(s, Encoding.ASCII, true))
            {
                bw.Write(MAGIC);
                bw.Write(smdh.Version);
                bw.Write(smdh.Reserved_1);

                for (int i = 0; i < 16; i++)
                {
                    AppTitle.Write(smdh.AppTitles[i], s);
                }

                AppSettings.Write(smdh.Settings, s);
                bw.Write(smdh.Reserved_2);
                bw.Write(smdh.SmallIcon.Data);
                bw.Write(smdh.LargeIcon.Data);
            }
        }