Ejemplo n.º 1
0
        public static Assembly Load(byte[] raw)
        {
            var r      = new BinaryReader(new MemoryStream(raw));
            var result = new Assembly();

            var magic = r.ReadInt32();

            if (magic == 0xA33)
            {
                // Load Sections
                var count = r.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    var sect = new AssemblySection();
                    sect.Name = r.ReadString();

                    var rawCount = r.ReadInt32();
                    sect.Raw = r.ReadBytes(rawCount);

                    result.Sections.Add(sect);
                }
            }
            else
            {
                throw new Exception("Unknown Assembly Format");
            }

            r.Close();

            return(result);
        }
Ejemplo n.º 2
0
        public AssemblySection CreateSection(AssemblySections section)
        {
            var s = new AssemblySection();

            s.Name = Enum.GetName(typeof(AssemblySections), section);

            if (!Sections.Where(_ => _.Name == s.Name).Any())
            {
                Sections.Add(s);
            }

            return(s);
        }