Exemple #1
0
        /// <summary>
        /// Writes a <c>AssemblyRefProcessor</c> table
        /// </summary>
        /// <param name="writer">Writer</param>
        /// <param name="metadata">Metadata</param>
        /// <param name="table">Table</param>
        public static void Write(this DataWriter writer, Metadata metadata, MDTable <RawAssemblyRefProcessorRow> table)
        {
            var columns  = table.TableInfo.Columns;
            var columns1 = columns[1];

            for (int i = 0; i < table.Rows; i++)
            {
                var row = table[(uint)i + 1];
                writer.WriteUInt32(row.Processor);
                columns1.Write24(writer, row.AssemblyRef);
            }
        }
Exemple #2
0
        /// <summary>
        /// Writes a <c>FieldRVA</c> table
        /// </summary>
        /// <param name="writer">Writer</param>
        /// <param name="metadata">Metadata</param>
        /// <param name="table">Table</param>
        public static void Write(this DataWriter writer, Metadata metadata, MDTable <RawFieldRVARow> table)
        {
            var columns  = table.TableInfo.Columns;
            var columns1 = columns[1];

            for (int i = 0; i < table.Rows; i++)
            {
                var row = table[(uint)i + 1];
                writer.WriteUInt32(row.RVA);
                columns1.Write24(writer, row.Field);
            }
        }
        void WriteArrayValue(SZArraySig arrayType, IList <CAArgument> args)
        {
            if (arrayType is null)
            {
                helper.Error("Custom attribute: Array type is null");
                return;
            }

            if (args is null)
            {
                writer.WriteUInt32(uint.MaxValue);
            }
            else
            {
                writer.WriteUInt32((uint)args.Count);
                var arrayElementType = FixTypeSig(arrayType.Next);
                for (int i = 0; i < args.Count; i++)
                {
                    WriteValue(arrayElementType, args[i]);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Writes a <c>Assembly</c> table
        /// </summary>
        /// <param name="writer">Writer</param>
        /// <param name="metadata">Metadata</param>
        /// <param name="table">Table</param>
        public static void Write(this DataWriter writer, Metadata metadata, MDTable <RawAssemblyRow> table)
        {
            var columns     = table.TableInfo.Columns;
            var columns6    = columns[6];
            var columns7    = columns[7];
            var columns8    = columns[8];
            var stringsHeap = metadata.StringsHeap;

            for (int i = 0; i < table.Rows; i++)
            {
                var row = table[(uint)i + 1];
                writer.WriteUInt32(row.HashAlgId);
                writer.WriteUInt16(row.MajorVersion);
                writer.WriteUInt16(row.MinorVersion);
                writer.WriteUInt16(row.BuildNumber);
                writer.WriteUInt16(row.RevisionNumber);
                writer.WriteUInt32(row.Flags);
                columns6.Write24(writer, row.PublicKey);
                columns7.Write24(writer, stringsHeap.GetOffset(row.Name));
                columns8.Write24(writer, stringsHeap.GetOffset(row.Locale));
            }
        }
Exemple #5
0
        /// <summary>
        /// Writes a <c>ClassLayout</c> table
        /// </summary>
        /// <param name="writer">Writer</param>
        /// <param name="metadata">Metadata</param>
        /// <param name="table">Table</param>
        public static void Write(this DataWriter writer, Metadata metadata, MDTable <RawClassLayoutRow> table)
        {
            var columns  = table.TableInfo.Columns;
            var columns2 = columns[2];

            for (int i = 0; i < table.Rows; i++)
            {
                var row = table[(uint)i + 1];
                writer.WriteUInt16(row.PackingSize);
                writer.WriteUInt32(row.ClassSize);
                columns2.Write24(writer, row.Parent);
            }
        }
Exemple #6
0
        /// <summary>
        /// Writes a <c>File</c> table
        /// </summary>
        /// <param name="writer">Writer</param>
        /// <param name="metadata">Metadata</param>
        /// <param name="table">Table</param>
        public static void Write(this DataWriter writer, Metadata metadata, MDTable <RawFileRow> table)
        {
            var columns     = table.TableInfo.Columns;
            var columns1    = columns[1];
            var columns2    = columns[2];
            var stringsHeap = metadata.StringsHeap;

            for (int i = 0; i < table.Rows; i++)
            {
                var row = table[(uint)i + 1];
                writer.WriteUInt32(row.Flags);
                columns1.Write24(writer, stringsHeap.GetOffset(row.Name));
                columns2.Write24(writer, row.HashValue);
            }
        }
Exemple #7
0
        /// <summary>
        /// Writes a <c>Method</c> table
        /// </summary>
        /// <param name="writer">Writer</param>
        /// <param name="metadata">Metadata</param>
        /// <param name="table">Table</param>
        public static void Write(this DataWriter writer, Metadata metadata, MDTable <RawMethodRow> table)
        {
            var columns     = table.TableInfo.Columns;
            var columns3    = columns[3];
            var columns4    = columns[4];
            var columns5    = columns[5];
            var stringsHeap = metadata.StringsHeap;

            for (int i = 0; i < table.Rows; i++)
            {
                var row = table[(uint)i + 1];
                writer.WriteUInt32(row.RVA);
                writer.WriteUInt16(row.ImplFlags);
                writer.WriteUInt16(row.Flags);
                columns3.Write24(writer, stringsHeap.GetOffset(row.Name));
                columns4.Write24(writer, row.Signature);
                columns5.Write24(writer, row.ParamList);
            }
        }
Exemple #8
0
        /// <summary>
        /// Writes a <c>TypeDef</c> table
        /// </summary>
        /// <param name="writer">Writer</param>
        /// <param name="metadata">Metadata</param>
        /// <param name="table">Table</param>
        public static void Write(this DataWriter writer, Metadata metadata, MDTable <RawTypeDefRow> table)
        {
            var columns     = table.TableInfo.Columns;
            var columns1    = columns[1];
            var columns2    = columns[2];
            var columns3    = columns[3];
            var columns4    = columns[4];
            var columns5    = columns[5];
            var stringsHeap = metadata.StringsHeap;

            for (int i = 0; i < table.Rows; i++)
            {
                var row = table[(uint)i + 1];
                writer.WriteUInt32(row.Flags);
                columns1.Write24(writer, stringsHeap.GetOffset(row.Name));
                columns2.Write24(writer, stringsHeap.GetOffset(row.Namespace));
                columns3.Write24(writer, row.Extends);
                columns4.Write24(writer, row.FieldList);
                columns5.Write24(writer, row.MethodList);
            }
        }