Exemplo n.º 1
0
        void ReadInitialValues()
        {
            if (!m_tHeap.HasTable(FieldRVATable.RId))
            {
                return;
            }

            FieldRVATable frTable = m_tableReader.GetFieldRVATable();

            for (int i = 0; i < frTable.Rows.Count; i++)
            {
                FieldRVARow     frRow = frTable [i];
                FieldDefinition field = GetFieldDefAt(frRow.Field);
                field.RVA = frRow.RVA;
                SetInitialValue(field);
            }
        }
        void PatchFields()
        {
            FieldRVATable fieldRvaTable = (FieldRVATable)stripped_tables [FieldRVATable.RId];

            if (fieldRvaTable == null)
            {
                return;
            }

            for (int i = 0; i < fieldRvaTable.Rows.Count; i++)
            {
                FieldRVARow fieldRvaRow = fieldRvaTable [i];

                MetadataToken fieldToken = new MetadataToken(TokenType.Field, fieldRvaRow.Field);

                FieldDefinition field = (FieldDefinition)assembly.MainModule.LookupByToken(fieldToken);

                fieldRvaRow.RVA = metadata_writer.GetDataCursor();
                metadata_writer.AddData(field.InitialValue.Length + 3 & (~3));
                metadata_writer.AddFieldInitData(field.InitialValue);
            }
        }