Example #1
0
 private FieldDefinitionResolver(uint rid, FieldRow row, MetadataSystem metadata, TypeDefinition declaringType)
 {
     _token         = new MetadataToken(MetadataTokenType.Field, rid);
     _row           = row;
     _metadata      = metadata;
     _declaringType = declaringType;
 }
Example #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CilRuntimeField"/> class.
 /// </summary>
 /// <param name="module">The module.</param>
 /// <param name="field">The field.</param>
 /// <param name="offset">The offset.</param>
 /// <param name="rva">The rva.</param>
 /// <param name="declaringType">Type of the declaring.</param>
 public CilRuntimeField(IMetadataModule module, ref FieldRow field, IntPtr offset, IntPtr rva, RuntimeType declaringType) : base(module, declaringType)
 {
     this.nameIdx    = field.NameStringIdx;
     this.signature  = field.SignatureBlobIdx;
     base.Attributes = field.Flags;
     base.RVA        = rva;
     //base.Offset = offset; ?
 }
Example #3
0
        public void FieldRow_WithSize2_Initializes2EmptyDots()
        {
            var fieldRow = new FieldRow(2);

            Assume.That(fieldRow[0], Is.Not.Null);
            Assume.That(fieldRow[1], Is.Not.Null);
            Assume.That(fieldRow[0], Is.EqualTo(fieldRow[1]));
        }
Example #4
0
        public static void ProcessTextFile(DataSourceData dataSourceData, MemoryStream stream)
        {
            dataSourceData.DataStoreType     = "text/csv";
            dataSourceData.DataStoreTabName  = "NA";
            dataSourceData.DataStoreLocation = "Unavailable";

            List <string> textLines = new List <string>( );

            using (StreamReader sr = new StreamReader(stream))
            {
                string line;
                while ((line = sr.ReadLine( )) != null)
                {
                    textLines.Add(line);
                }

                sr.Close( );
            }

            if (textLines.Any( ))
            {
                foreach (var textLine in textLines)
                {
                    string[] lineFields = textLine.Split(',');                        //Assume normal comma separated (csv)

                    if (lineFields.Any( ))
                    {
                        if (!dataSourceData.ColumnsNames.Any( ))
                        {
                            foreach (var value in lineFields)
                            {
                                dataSourceData.ColumnsNames.Add(value);
                            }

                            continue;
                        }

                        FieldRow fieldRow = new FieldRow( );
                        foreach (var value in lineFields)
                        {
                            fieldRow.Fields.Add(new Field
                            {
                                Value    = value,
                                Approved = false,
                                Category = Enums.Categories.Unknown,
                                Column   = dataSourceData.ColumnsNames[fieldRow.Fields.Count],
                                Row      = dataSourceData.FieldRows.Count
                            });
                        }

                        dataSourceData.FieldRows.Add(fieldRow);
                    }
                }
            }

            ProcessDataSourceData(dataSourceData);
        }
Example #5
0
        public void ThisWrite_WithRightIndex_InitializesDot()
        {
            var fieldRow = new FieldRow(2);

            fieldRow[0] = new Dot {
                Value = 10
            };

            Assume.That(fieldRow[0].Value, Is.EqualTo(10));
        }
Example #6
0
 public override void FromRawData(byte [] buff, int offs, int numRows)
 {
     for (int i = numRows; --i >= 0;)
     {
         Row row = new FieldRow(this);
         row.FromRawData(buff, offs);
         Add(row);
         offs += FieldRow.LogicalSize;
     }
 }
Example #7
0
        /// <summary>
        /// Reads the specified token.
        /// </summary>
        /// <param name="token">The token.</param>
        /// <param name="result">The result.</param>
        public void Read(TokenTypes token, out FieldRow result)
        {
            if ((token & TokenTypes.TableMask) != TokenTypes.Field)
            {
                throw new ArgumentException("Invalid token type for FieldRow.", "token");
            }

            using (BinaryReader reader = CreateReaderForToken(token))
            {
                result = new FieldRow((FieldAttributes)reader.ReadUInt16(), ReadIndexValue(reader, IndexType.StringHeap), ReadIndexValue(reader, IndexType.BlobHeap));
            }
        }
Example #8
0
        public static void ProcessJsonFile(DataSourceData dataSourceData, MemoryStream stream)
        {
            dataSourceData.DataStoreType     = "json";
            dataSourceData.DataStoreTabName  = "NA";
            dataSourceData.DataStoreLocation = "Unavailable";

            string text;

            using (StreamReader sr = new StreamReader(stream))
            {
                text = sr.ReadToEnd( );
                sr.Close( );
            }

            JObject jObject = JObject.Parse(text);

            var data = jObject.First;

            JArray jArray = JArray.Parse(data.First.ToString( ));

            IList <JsonDataBody> jsonDataBodies = jArray.ToObject <IList <JsonDataBody> >( );

            foreach (var jsonDataBody in jsonDataBodies)
            {
                var propertyInfos = jsonDataBody.GetType( ).GetProperties( );

                if (!dataSourceData.ColumnsNames.Any( ))
                {
                    foreach (var propertyInfo in propertyInfos)
                    {
                        dataSourceData.ColumnsNames.Add(propertyInfo.Name);
                    }
                }

                FieldRow fieldRow = new FieldRow( );
                foreach (var propertyInfo in propertyInfos)
                {
                    fieldRow.Fields.Add(new Field
                    {
                        Value    = propertyInfo.GetValue(jsonDataBody, null).ToString( ),
                        Approved = false,
                        Category = Enums.Categories.Unknown,
                        Column   = dataSourceData.ColumnsNames[fieldRow.Fields.Count],
                        Row      = dataSourceData.FieldRows.Count
                    });
                }

                dataSourceData.FieldRows.Add(fieldRow);

                ProcessDataSourceData(dataSourceData);
            }
        }
Example #9
0
        public static void ProcessExcelFile(DataSourceData dataSourceData, MemoryStream stream)
        {
            dataSourceData.DataStoreType     = "Excel";
            dataSourceData.DataStoreLocation = "Unavailable";

            using (XLWorkbook workbook = new XLWorkbook(stream))
            {
                IXLWorksheet worksheet = workbook.Worksheets.First( );
                dataSourceData.DataStoreTabName = worksheet.Name;

                IXLRange range = worksheet.RangeUsed( );

                if (range.RowsUsed( ).Any( ))
                {
                    foreach (var row in range.RowsUsed( ))
                    {
                        if (row.CellsUsed( ).Any( ))
                        {
                            if (!dataSourceData.ColumnsNames.Any( ))
                            {
                                foreach (var cell in row.CellsUsed( ))
                                {
                                    dataSourceData.ColumnsNames.Add(cell.Value.ToString( ).Trim( ));
                                }

                                continue;
                            }

                            FieldRow fieldRow = new FieldRow( );
                            foreach (var cell in row.CellsUsed( ))
                            {
                                fieldRow.Fields.Add(new Field
                                {
                                    Value    = cell.Value.ToString( ).Trim( ),
                                    Approved = false,
                                    Category = Enums.Categories.Unknown,
                                    Column   = dataSourceData.ColumnsNames[fieldRow.Fields.Count],
                                    Row      = dataSourceData.FieldRows.Count
                                });
                            }

                            dataSourceData.FieldRows.Add(fieldRow);
                        }
                    }
                }
            }

            ProcessDataSourceData(dataSourceData);
        }
        void ReadAllFields()
        {
            TypeDefTable tdefTable = m_tableReader.GetTypeDefTable();

            if (!m_tHeap.HasTable(FieldTable.RId))
            {
                m_fields = new FieldDefinition [0];
                return;
            }

            FieldTable fldTable = m_tableReader.GetFieldTable();

            m_fields = new FieldDefinition [fldTable.Rows.Count];

            for (int i = 0; i < m_typeDefs.Length; i++)
            {
                TypeDefinition dec     = m_typeDefs [i];
                GenericContext context = new GenericContext(dec);

                int index = i, next;

                if (index == tdefTable.Rows.Count - 1)
                {
                    next = fldTable.Rows.Count + 1;
                }
                else
                {
                    next = (int)(tdefTable [index + 1]).FieldList;
                }

                for (int j = (int)tdefTable [index].FieldList; j < next; j++)
                {
                    FieldRow        frow = fldTable [j - 1];
                    FieldSig        fsig = m_sigReader.GetFieldSig(frow.Signature);
                    FieldDefinition fdef = new FieldDefinition(
                        m_root.Streams.StringsHeap [frow.Name],
                        this.GetTypeRefFromSig(fsig.Type, context), frow.Flags);
                    fdef.MetadataToken = MetadataToken.FromMetadataRow(TokenType.Field, j - 1);

                    if (fsig.CustomMods.Length > 0)
                    {
                        fdef.FieldType = GetModifierType(fsig.CustomMods, fdef.FieldType);
                    }

                    dec.Fields.Add(fdef);
                    m_fields [j - 1] = fdef;
                }
            }
        }
Example #11
0
        private void BuildRows(FacilityModel model)
        {
            int             num1          = 1;
            List <FieldRow> fieldRowList1 = new List <FieldRow>();
            List <FieldRow> fieldRowList2 = fieldRowList1;
            FieldRow        fieldRow1     = new FieldRow();
            int             num2          = num1;
            int             num3          = 1;
            int             num4          = num2 + num3;

            fieldRow1.Iden = num2;
            string str1 = "工厂";

            fieldRow1.FieldName = str1;
            string str2 = "";

            fieldRow1.FieldValue = str2;
            fieldRowList2.Add(fieldRow1);
            List <FieldRow> fieldRowList3 = fieldRowList1;
            FieldRow        fieldRow2     = new FieldRow();
            int             num5          = num4;
            int             num6          = 1;
            int             num7          = num5 + num6;

            fieldRow2.Iden = num5;
            string str3 = "设备名称";

            fieldRow2.FieldName = str3;
            string mmName = model.MMName;

            fieldRow2.FieldValue = mmName;
            fieldRowList3.Add(fieldRow2);
            List <FieldRow> fieldRowList4 = fieldRowList1;
            FieldRow        fieldRow3     = new FieldRow();
            int             num8          = num7;
            int             num9          = 1;
            int             num10         = num8 + num9;

            fieldRow3.Iden = num8;
            string str4 = "设备IP地址";

            fieldRow3.FieldName = str4;
            string mmip = model.MMIP;

            fieldRow3.FieldValue = mmip;
            fieldRowList4.Add(fieldRow3);
            List <FieldRow> fieldRowList5 = fieldRowList1;
            FieldRow        fieldRow4     = new FieldRow();
            int             num11         = num10;
            int             num12         = 1;
            int             num13         = num11 + num12;

            fieldRow4.Iden = num11;
            string str5 = "设备PLC端口";

            fieldRow4.FieldName = str5;
            string mmPort = model.MMPort;

            fieldRow4.FieldValue = mmPort;
            fieldRowList5.Add(fieldRow4);
            List <FieldRow> fieldRowList6 = fieldRowList1;
            FieldRow        fieldRow5     = new FieldRow();
            int             num14         = num13;
            int             num15         = 1;
            int             num16         = num14 + num15;

            fieldRow5.Iden = num14;
            string str6 = "MMAddress";

            fieldRow5.FieldName = str6;
            string maAddress = model.MAAddress;

            fieldRow5.FieldValue = maAddress;
            fieldRowList6.Add(fieldRow5);
            List <FieldRow> fieldRowList7 = fieldRowList1;
            FieldRow        fieldRow6     = new FieldRow();
            int             num17         = num16;
            int             num18         = 1;
            int             num19         = num17 + num18;

            fieldRow6.Iden = num17;
            string str7 = "MMAddressNO";

            fieldRow6.FieldName = str7;
            string str8 = "";

            fieldRow6.FieldValue = str8;
            fieldRowList7.Add(fieldRow6);
            List <FieldRow> fieldRowList8 = fieldRowList1;
            FieldRow        fieldRow7     = new FieldRow();
            int             num20         = num19;
            int             num21         = 1;
            int             num22         = num20 + num21;

            fieldRow7.Iden = num20;
            string str9 = "设备启用";

            fieldRow7.FieldName = str9;
            string str10 = "";

            fieldRow7.FieldValue = str10;
            fieldRowList8.Add(fieldRow7);
            List <FieldRow> fieldRowList9 = fieldRowList1;
            FieldRow        fieldRow8     = new FieldRow();
            int             num23         = num22;
            int             num24         = 1;
            int             num25         = num23 + num24;

            fieldRow8.Iden = num23;
            string str11 = "设备清除报警地址";

            fieldRow8.FieldName = str11;
            string str12 = "";

            fieldRow8.FieldValue = str12;
            fieldRowList9.Add(fieldRow8);
            List <FieldRow> fieldRowList10 = fieldRowList1;
            FieldRow        fieldRow9      = new FieldRow();
            int             num26          = num25;
            int             num27          = 1;
            int             num28          = num26 + num27;

            fieldRow9.Iden = num26;
            string str13 = "设备重置地址";

            fieldRow9.FieldName = str13;
            string mmClearAddr = model.MMClearAddr;

            fieldRow9.FieldValue = mmClearAddr;
            fieldRowList10.Add(fieldRow9);
            this.dataGrid1.ItemsSource = fieldRowList1;
            List <FieldRow> fieldRowList11 = new List <FieldRow>();
            List <FieldRow> fieldRowList12 = fieldRowList11;
            FieldRow        fieldRow10     = new FieldRow();
            int             num29          = num28;
            int             num30          = 1;
            int             num31          = num29 + num30;

            fieldRow10.Iden = num29;
            string str14 = "PLC信号地址";

            fieldRow10.FieldName = str14;
            string str15 = "";

            fieldRow10.FieldValue = str15;
            fieldRowList12.Add(fieldRow10);
            List <FieldRow> fieldRowList13 = fieldRowList11;
            FieldRow        fieldRow11     = new FieldRow();
            int             num32          = num31;
            int             num33          = 1;
            int             num34          = num32 + num33;

            fieldRow11.Iden = num32;
            string str16 = "MMEndAddr";

            fieldRow11.FieldName = str16;
            string str17 = "";

            fieldRow11.FieldValue = str17;
            fieldRowList13.Add(fieldRow11);
            List <FieldRow> fieldRowList14 = fieldRowList11;
            FieldRow        fieldRow12     = new FieldRow();
            int             num35          = num34;
            int             num36          = 1;
            int             num37          = num35 + num36;

            fieldRow12.Iden = num35;
            string str18 = "MMCountAddr";

            fieldRow12.FieldName = str18;
            string str19 = "";

            fieldRow12.FieldValue = str19;
            fieldRowList14.Add(fieldRow12);
            List <FieldRow> fieldRowList15 = fieldRowList11;
            FieldRow        fieldRow13     = new FieldRow();
            int             num38          = num37;
            int             num39          = 1;
            int             num40          = num38 + num39;

            fieldRow13.Iden = num38;
            string str20 = "MMBadAddr";

            fieldRow13.FieldName = str20;
            string str21 = "";

            fieldRow13.FieldValue = str21;
            fieldRowList15.Add(fieldRow13);
            List <FieldRow> fieldRowList16 = fieldRowList11;
            FieldRow        fieldRow14     = new FieldRow();
            int             num41          = num40;
            int             num42          = 1;
            int             num43          = num41 + num42;

            fieldRow14.Iden = num41;
            string str22 = "MMRemark";

            fieldRow14.FieldName = str22;
            string str23 = "";

            fieldRow14.FieldValue = str23;
            fieldRowList16.Add(fieldRow14);
            List <FieldRow> fieldRowList17 = fieldRowList11;
            FieldRow        fieldRow15     = new FieldRow();
            int             num44          = num43;
            int             num45          = 1;
            int             num46          = num44 + num45;

            fieldRow15.Iden = num44;
            string str24 = "设备顺序号";

            fieldRow15.FieldName = str24;
            string str25 = "";

            fieldRow15.FieldValue = str25;
            fieldRowList17.Add(fieldRow15);
            List <FieldRow> fieldRowList18 = fieldRowList11;
            FieldRow        fieldRow16     = new FieldRow();
            int             num47          = num46;
            int             num48          = 1;
            int             num49          = num47 + num48;

            fieldRow16.Iden = num47;
            string str26 = "采集地址";

            fieldRow16.FieldName = str26;
            string str27 = "";

            fieldRow16.FieldValue = str27;
            fieldRowList18.Add(fieldRow16);
            List <FieldRow> fieldRowList19 = fieldRowList11;
            FieldRow        fieldRow17     = new FieldRow();
            int             num50          = num49;
            int             num51          = 1;
            int             num52          = num50 + num51;

            fieldRow17.Iden = num50;
            string str28 = "采集类型";

            fieldRow17.FieldName = str28;
            string str29 = "";

            fieldRow17.FieldValue = str29;
            fieldRowList19.Add(fieldRow17);
            List <FieldRow> fieldRowList20 = fieldRowList11;
            FieldRow        fieldRow18     = new FieldRow();
            int             num53          = num52;
            int             num54          = 1;
            int             num55          = num53 + num54;

            fieldRow18.Iden = num53;
            string str30 = "是否启用(数据采集)";

            fieldRow18.FieldName = str30;
            string str31 = "";

            fieldRow18.FieldValue = str31;
            fieldRowList20.Add(fieldRow18);
            List <FieldRow> fieldRowList21 = fieldRowList11;
            FieldRow        fieldRow19     = new FieldRow();
            int             num56          = num55;
            int             num57          = 1;
            int             num58          = num56 + num57;

            fieldRow19.Iden = num56;
            string str32 = "Remark";

            fieldRow19.FieldName = str32;
            string str33 = "";

            fieldRow19.FieldValue = str33;
            fieldRowList21.Add(fieldRow19);
            this.dataGrid2.ItemsSource = fieldRowList11;
        }
Example #12
0
        private void BaseCraftDetailPage_Loaded(object sender, RoutedEventArgs e)
        {
            int             num1          = 1;
            List <FieldRow> fieldRowList1 = new List <FieldRow>();
            List <FieldRow> fieldRowList2 = fieldRowList1;
            FieldRow        fieldRow1     = new FieldRow();
            int             num2          = num1;
            int             num3          = 1;
            int             num4          = num2 + num3;

            fieldRow1.Iden = num2;
            string str1 = "工厂";

            fieldRow1.FieldName = str1;
            string str2 = "";

            fieldRow1.FieldValue = str2;
            fieldRowList2.Add(fieldRow1);
            List <FieldRow> fieldRowList3 = fieldRowList1;
            FieldRow        fieldRow2     = new FieldRow();
            int             num5          = num4;
            int             num6          = 1;
            int             num7          = num5 + num6;

            fieldRow2.Iden = num5;
            string str3 = "设备名称";

            fieldRow2.FieldName = str3;
            string str4 = "";

            fieldRow2.FieldValue = str4;
            fieldRowList3.Add(fieldRow2);
            List <FieldRow> fieldRowList4 = fieldRowList1;
            FieldRow        fieldRow3     = new FieldRow();
            int             num8          = num7;
            int             num9          = 1;
            int             num10         = num8 + num9;

            fieldRow3.Iden = num8;
            string str5 = "设备IP地址";

            fieldRow3.FieldName = str5;
            string str6 = "";

            fieldRow3.FieldValue = str6;
            fieldRowList4.Add(fieldRow3);
            List <FieldRow> fieldRowList5 = fieldRowList1;
            FieldRow        fieldRow4     = new FieldRow();
            int             num11         = num10;
            int             num12         = 1;
            int             num13         = num11 + num12;

            fieldRow4.Iden = num11;
            string str7 = "设备PLC端口";

            fieldRow4.FieldName = str7;
            string str8 = "";

            fieldRow4.FieldValue = str8;
            fieldRowList5.Add(fieldRow4);
            List <FieldRow> fieldRowList6 = fieldRowList1;
            FieldRow        fieldRow5     = new FieldRow();
            int             num14         = num13;
            int             num15         = 1;
            int             num16         = num14 + num15;

            fieldRow5.Iden = num14;
            string str9 = "MMAddress";

            fieldRow5.FieldName = str9;
            string str10 = "";

            fieldRow5.FieldValue = str10;
            fieldRowList6.Add(fieldRow5);
            List <FieldRow> fieldRowList7 = fieldRowList1;
            FieldRow        fieldRow6     = new FieldRow();
            int             num17         = num16;
            int             num18         = 1;
            int             num19         = num17 + num18;

            fieldRow6.Iden = num17;
            string str11 = "MMAddressNO";

            fieldRow6.FieldName = str11;
            string str12 = "";

            fieldRow6.FieldValue = str12;
            fieldRowList7.Add(fieldRow6);
            List <FieldRow> fieldRowList8 = fieldRowList1;
            FieldRow        fieldRow7     = new FieldRow();
            int             num20         = num19;
            int             num21         = 1;
            int             num22         = num20 + num21;

            fieldRow7.Iden = num20;
            string str13 = "设备启用";

            fieldRow7.FieldName = str13;
            string str14 = "";

            fieldRow7.FieldValue = str14;
            fieldRowList8.Add(fieldRow7);
            List <FieldRow> fieldRowList9 = fieldRowList1;
            FieldRow        fieldRow8     = new FieldRow();
            int             num23         = num22;
            int             num24         = 1;
            int             num25         = num23 + num24;

            fieldRow8.Iden = num23;
            string str15 = "设备清除报警地址";

            fieldRow8.FieldName = str15;
            string str16 = "";

            fieldRow8.FieldValue = str16;
            fieldRowList9.Add(fieldRow8);
            List <FieldRow> fieldRowList10 = fieldRowList1;
            FieldRow        fieldRow9      = new FieldRow();
            int             num26          = num25;
            int             num27          = 1;
            int             num28          = num26 + num27;

            fieldRow9.Iden = num26;
            string str17 = "设备重置地址";

            fieldRow9.FieldName = str17;
            string str18 = "";

            fieldRow9.FieldValue = str18;
            fieldRowList10.Add(fieldRow9);
            this.dataGrid1.ItemsSource = fieldRowList1;
            List <FieldRow> fieldRowList11 = new List <FieldRow>();
            List <FieldRow> fieldRowList12 = fieldRowList11;
            FieldRow        fieldRow10     = new FieldRow();
            int             num29          = num28;
            int             num30          = 1;
            int             num31          = num29 + num30;

            fieldRow10.Iden = num29;
            string str19 = "PLC信号地址";

            fieldRow10.FieldName = str19;
            string str20 = "";

            fieldRow10.FieldValue = str20;
            fieldRowList12.Add(fieldRow10);
            List <FieldRow> fieldRowList13 = fieldRowList11;
            FieldRow        fieldRow11     = new FieldRow();
            int             num32          = num31;
            int             num33          = 1;
            int             num34          = num32 + num33;

            fieldRow11.Iden = num32;
            string str21 = "MMEndAddr";

            fieldRow11.FieldName = str21;
            string str22 = "";

            fieldRow11.FieldValue = str22;
            fieldRowList13.Add(fieldRow11);
            List <FieldRow> fieldRowList14 = fieldRowList11;
            FieldRow        fieldRow12     = new FieldRow();
            int             num35          = num34;
            int             num36          = 1;
            int             num37          = num35 + num36;

            fieldRow12.Iden = num35;
            string str23 = "MMCountAddr";

            fieldRow12.FieldName = str23;
            string str24 = "";

            fieldRow12.FieldValue = str24;
            fieldRowList14.Add(fieldRow12);
            List <FieldRow> fieldRowList15 = fieldRowList11;
            FieldRow        fieldRow13     = new FieldRow();
            int             num38          = num37;
            int             num39          = 1;
            int             num40          = num38 + num39;

            fieldRow13.Iden = num38;
            string str25 = "MMBadAddr";

            fieldRow13.FieldName = str25;
            string str26 = "";

            fieldRow13.FieldValue = str26;
            fieldRowList15.Add(fieldRow13);
            List <FieldRow> fieldRowList16 = fieldRowList11;
            FieldRow        fieldRow14     = new FieldRow();
            int             num41          = num40;
            int             num42          = 1;
            int             num43          = num41 + num42;

            fieldRow14.Iden = num41;
            string str27 = "MMRemark";

            fieldRow14.FieldName = str27;
            string str28 = "";

            fieldRow14.FieldValue = str28;
            fieldRowList16.Add(fieldRow14);
            List <FieldRow> fieldRowList17 = fieldRowList11;
            FieldRow        fieldRow15     = new FieldRow();
            int             num44          = num43;
            int             num45          = 1;
            int             num46          = num44 + num45;

            fieldRow15.Iden = num44;
            string str29 = "设备顺序号";

            fieldRow15.FieldName = str29;
            string str30 = "";

            fieldRow15.FieldValue = str30;
            fieldRowList17.Add(fieldRow15);
            List <FieldRow> fieldRowList18 = fieldRowList11;
            FieldRow        fieldRow16     = new FieldRow();
            int             num47          = num46;
            int             num48          = 1;
            int             num49          = num47 + num48;

            fieldRow16.Iden = num47;
            string str31 = "采集地址";

            fieldRow16.FieldName = str31;
            string str32 = "";

            fieldRow16.FieldValue = str32;
            fieldRowList18.Add(fieldRow16);
            List <FieldRow> fieldRowList19 = fieldRowList11;
            FieldRow        fieldRow17     = new FieldRow();
            int             num50          = num49;
            int             num51          = 1;
            int             num52          = num50 + num51;

            fieldRow17.Iden = num50;
            string str33 = "采集类型";

            fieldRow17.FieldName = str33;
            string str34 = "";

            fieldRow17.FieldValue = str34;
            fieldRowList19.Add(fieldRow17);
            List <FieldRow> fieldRowList20 = fieldRowList11;
            FieldRow        fieldRow18     = new FieldRow();
            int             num53          = num52;
            int             num54          = 1;
            int             num55          = num53 + num54;

            fieldRow18.Iden = num53;
            string str35 = "是否启用(数据采集)";

            fieldRow18.FieldName = str35;
            string str36 = "";

            fieldRow18.FieldValue = str36;
            fieldRowList20.Add(fieldRow18);
            List <FieldRow> fieldRowList21 = fieldRowList11;
            FieldRow        fieldRow19     = new FieldRow();
            int             num56          = num55;
            int             num57          = 1;
            int             num58          = num56 + num57;

            fieldRow19.Iden = num56;
            string str37 = "Remark";

            fieldRow19.FieldName = str37;
            string str38 = "";

            fieldRow19.FieldValue = str38;
            fieldRowList21.Add(fieldRow19);
            this.dataGrid2.ItemsSource   = fieldRowList11;
            this.ddlFacility.ItemsSource = (LocalApi.Execute(new FacilityListRequest()
            {
                CraftDID = this.CraftDID
            })).Facilities;
        }
Example #13
0
 public FieldMetadata ResolveField(FieldRow row)
 {
     return(new FieldMetadata(this.Assembly, row));
 }
Example #14
0
        void IMetadataProvider.Read(TokenTypes token, out FieldRow result)
        {
            TableHeap theap = (TableHeap)_streams[(int)HeapType.Tables];

            theap.Read(token, out result);
        }
 public virtual void VisitFieldRow(FieldRow row)
 {
 }
Example #16
0
 public FieldMetadata(AssemblyMetadata assembly, FieldRow row) :
     base(assembly)
 {
     this.fieldRow  = row;            //fieldRow;
     this.signature = new FieldSignature(assembly, row);
 }
Example #17
0
 public FieldRowExt(IMetadataProvider metadata, FieldRow row)
     : base(metadata)
 {
     this.row = row;
 }
Example #18
0
        public static FieldDefinition Resolve(uint rid, FieldRow row, MetadataSystem metadata, TypeDefinition declaringType)
        {
            var resolver = new FieldDefinitionResolver(rid, row, metadata, declaringType);

            return(new FieldDefinition(resolver));
        }
Example #19
0
        public FieldSignature(AssemblyMetadata assembly, FieldRow fieldRow) :
            base(assembly)
        {
            this.Field = fieldRow;

            int pos = (int)fieldRow.Signature - 1;

            byte [] blob      = assembly.BlobHeap;
            int     cmodCount = 0;
            int     savedPos  = 0;
            int     cmodIndex = 0;

            // The first byte must be FIELD (0x6)

            Diagnostics.Assert(blob [pos++] == 0x6,
                               "FieldSignature.ctor(): blob signature is not FIELD (0x6)");

            //if (blob [pos] != 0x6) {
            //	throw new Exception ("Invalid signature type for field"); // explode
            //}

            // First determine the amount of cmods we have

            savedPos = pos;

            while (true)
            {
                ElementType type = (ElementType)DecompressValue(blob, ref pos);

                if (type == ElementType.CModReqD || type == ElementType.CModOpt)
                {
                    ++cmodCount;
                }
                else
                {
                    break;
                }
            }

            this.CustomModifiers = new SigCustomModifier [cmodCount];
            pos = savedPos;

            while (true)
            {
                ElementType type = (ElementType)DecompressValue(blob, ref pos);

                if (type == ElementType.CModReqD || type == ElementType.CModOpt)
                {
                    CustomModifiers [cmodIndex++] =
                        new SigCustomModifier(type, DecompressValue(blob, ref pos));
                }
                else
                {
                    // now for the "Type"

                    switch (type)
                    {
                    case ElementType.Class:
                        this.Type = new SigClassType(type, DecompressValue(blob, ref pos));
                        break;

                    case ElementType.ValueType:
                        this.Type = new SigClassType(type, DecompressValue(blob, ref pos));
                        break;

                    case ElementType.Boolean:
                    case ElementType.Char:
                    case ElementType.I1:
                    case ElementType.U1:
                    case ElementType.I2:
                    case ElementType.U2:
                    case ElementType.I4:
                    case ElementType.U4:
                    case ElementType.I8:
                    case ElementType.U8:
                    case ElementType.R4:
                    case ElementType.R8:
                    case ElementType.I:
                    case ElementType.U:
                    case ElementType.Object:
                    case ElementType.String:
                        this.Type = new SigType(type);
                        break;

                    default:
                        //throw new NotSupportedException (); // explode
                        break;
                    }

                    // hereby ends this thousand-year journey
                    break;
                }
            }

            ++pos;
        }
 public virtual void VisitFieldRow(FieldRow row)
 {
 }
Example #21
0
        static void ReadPeInfo2(String dll, Boolean showDllName, Boolean pauseOnDir)
        {
            if (showDllName)
            {
                Console.WriteLine("Reading file: {0}", dll);
            }

            using (PEFile info = new PEFile(StreamLoader.FromFile(dll)))
            {
                if (info.Header.IsValid)               //Проверка на валидность загруженного файла
                {
                    foreach (var section in info.Sections)
                    {
                        Utils.ConsoleWriteMembers(section);
                    }

                    if (info.Header.SymbolTable != null)
                    {
                        Utils.ConsoleWriteMembers(info.Header.SymbolTable.Value);
                    }

                    if (!info.Resource.IsEmpty)
                    {
                        Console.WriteLine("===Resources===");
                        Int32 directoriesCount = 0;

                        foreach (var dir in info.Resource)
                        {
                            directoriesCount++;
                            //Console.WriteLine("dir: {0}", dir.NameAddress);
                            Console.WriteLine("Resource dir: {0}", dir.Name);
                            foreach (var dir1 in dir)
                            {
                                Console.WriteLine("----- {0}", dir1.Name);
                                foreach (var dir2 in dir1)
                                {
                                    Console.WriteLine("-------- {0}", dir2.Name);
                                    if (dir2.DirectoryEntry.IsDataEntry)
                                    {
                                        switch (dir.DirectoryEntry.NameType)
                                        {
                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_VERSION:
                                            var version1    = new AlphaOmega.Debug.NTDirectory.Resources.ResourceVersion(dir2);
                                            var strFileInfo = version1.GetFileInfo();
                                            Utils.ConsoleWriteMembers(version1.FileInfo.Value);

                                            //WinNT.StringFileInfo fInfo = NativeMethods.BytesToStructure<WinNT.StringFileInfo>(bytesV, ptr);
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_STRING:
                                            var strings = new AlphaOmega.Debug.NTDirectory.Resources.ResourceString(dir2);
                                            foreach (var entry in strings)
                                            {
                                                Utils.ConsoleWriteMembers(entry);
                                            }
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_ACCELERATOR:
                                            var    acc     = new AlphaOmega.Debug.NTDirectory.Resources.ResourceAccelerator(dir2).ToArray();
                                            String testAcc = String.Empty;
                                            foreach (var a in acc)
                                            {
                                                Utils.ConsoleWriteMembers(a);
                                            }
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_MANIFEST:
                                            Byte[] bytesM = dir2.GetData();                                            //http://msdn.microsoft.com/ru-ru/library/eew13bza.aspx
                                            String xml    = System.Text.Encoding.GetEncoding((Int32)dir2.DataEntry.Value.CodePage).GetString(bytesM);
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_MESSAGETABLE:
                                            var messageTable = new AlphaOmega.Debug.NTDirectory.Resources.ResourceMessageTable(dir2);
                                            foreach (var entry in messageTable)
                                            {
                                                Utils.ConsoleWriteMembers(entry);
                                            }
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_MENU:
                                            var resMenu = new AlphaOmega.Debug.NTDirectory.Resources.ResourceMenu(dir2);
                                            foreach (var entry in resMenu.GetMenuTemplate())
                                            {
                                                Utils.ConsoleWriteMembers(entry);
                                            }
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_TOOLBAR:
                                            var resToolbar = new AlphaOmega.Debug.NTDirectory.Resources.ResourceToolBar(dir2);
                                            Utils.ConsoleWriteMembers(resToolbar.Header);

                                            foreach (var entry in resToolbar.GetToolBarTemplate())
                                            {
                                                Utils.ConsoleWriteMembers(entry);
                                            }
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_FONTDIR:
                                            var resFontDir = new AlphaOmega.Debug.NTDirectory.Resources.ResourceFontDir(dir2);
                                            foreach (var fontItem in resFontDir)
                                            {
                                                Utils.ConsoleWriteMembers(fontItem);
                                            }
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_FONT:
                                            var resFont = new AlphaOmega.Debug.NTDirectory.Resources.ResourceFont(dir2);
                                            Utils.ConsoleWriteMembers(resFont.Font);
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_BITMAP:
                                            //TODO:
                                            // http://www.vbdotnetforums.com/graphics-gdi/49563-i-need-help-converting-bitmap-dib-intptr.html
                                            // http://snipplr.com/view/36593/
                                            // http://www.codeproject.com/Articles/16268/DIB-to-System-Bitmap
                                            // http://ebersys.blogspot.com/2009/06/how-to-convert-dib-to-bitmap.html
                                            // http://hecgeek.blogspot.com/2007/04/converting-from-dib-to.html
                                            // http://objectmix.com/dotnet/101391-dib-bitmap-system-drawing-bitmap.html
                                            var resBitmap = new AlphaOmega.Debug.NTDirectory.Resources.ResourceBitmap(dir2);
                                            try
                                            {
                                                Utils.ConsoleWriteMembers(resBitmap.Header);
                                            } catch (ArgumentOutOfRangeException exc)
                                            {
                                                Console.WriteLine("!!!ArgumentOutOfRangeException (Corrupt bitmap): {0}", exc.Message);
                                                Console.ReadKey();
                                            }
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_ICON:
                                            var resIcon = new AlphaOmega.Debug.NTDirectory.Resources.ResourceIcon(dir2);

                                            /*WinGdi.ICONDIR icoHeader = new WinGdi.ICONDIR() { idReserved = 0, idType = 1, idCount = 1 };
                                             * List<Byte> bytes = new List<Byte>();
                                             * bytes.AddRange(PinnedBufferReader.StructureToArray<WinGdi.ICONDIR>(icoHeader));
                                             *
                                             * var resHeader=resIcon.Header;
                                             * Byte[] payload = resIcon.Directory.GetData().Skip(Marshal.SizeOf(typeof(WinGdi.GRPICONDIRENTRY))).ToArray();
                                             * WinGdi.ICONDIRENTRY icoEntry = new WinGdi.ICONDIRENTRY()
                                             * {
                                             *      bWidth = resHeader.bWidth,
                                             *      bHeight = resHeader.bHeight,
                                             *      bColorCount = resHeader.bColorCount,
                                             *      bReserved = resHeader.bReserved,
                                             *      wPlanes = resHeader.wPlanes,
                                             *      wBitCount = resHeader.wBitCount,
                                             *      dwBytesInRes = (UInt32)payload.Length,
                                             *      dwImageOffset = (UInt32)(Marshal.SizeOf(typeof(WinGdi.ICONDIR)) + Marshal.SizeOf(typeof(WinGdi.ICONDIRENTRY))),
                                             * };
                                             * bytes.AddRange(PinnedBufferReader.StructureToArray<WinGdi.ICONDIRENTRY>(icoEntry));
                                             * bytes.AddRange(payload);
                                             * File.WriteAllBytes(@"C:\Visual Studio Projects\C++\DBaseTool\DBaseTool_src\res\RT_ICON.ico", bytes.ToArray());*/
                                            Utils.ConsoleWriteMembers(resIcon.Header);
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_DLGINIT:
                                            var dlgInit = new AlphaOmega.Debug.NTDirectory.Resources.ResourceDialogInit(dir2);
                                            foreach (var initData in dlgInit)
                                            {
                                                Utils.ConsoleWriteMembers(initData);
                                            }
                                            break;

                                        case WinNT.Resource.RESOURCE_DIRECTORY_TYPE.RT_DIALOG:
                                            var dialog = new AlphaOmega.Debug.NTDirectory.Resources.ResourceDialog(dir2);
                                            try
                                            {
                                                var template = dialog.GetDialogTemplate();
                                                foreach (var ctrl in template.Controls)
                                                {
                                                    if (ctrl.CX < 0 || ctrl.CY < 0 || ctrl.X < 0 || ctrl.Y < 0)
                                                    {
                                                        Console.WriteLine("???Invalid position? ({0}) CX: {1} CY: {2} X: {3} Y: {4}", template.Title, ctrl.CX, ctrl.CY, ctrl.X, ctrl.Y);
                                                        Console.ReadKey();
                                                    }
                                                    else
                                                    {
                                                        Utils.ConsoleWriteMembers(ctrl);
                                                    }
                                                }
                                            } catch (IndexOutOfRangeException exc)
                                            {
                                                Console.WriteLine("!!!IndexOutOfRangeException (Corrupt dialog): {0}", exc.Message);
                                                Console.ReadKey();
                                            } catch (ArgumentException exc)
                                            {
                                                Console.WriteLine("!!!ArgumentException (Corrupt dialog): {0}", exc.Message);
                                                Console.ReadKey();
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        Console.WriteLine("Total dirs: {0}", directoriesCount);
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }

                    if (info.ComDescriptor != null)
                    {                    //.NET Framework
                        if (info.ComDescriptor.Resources != null)
                        {
                            if (info.ComDescriptor.Resources.Header.IsValid)
                            {
                                foreach (var item in info.ComDescriptor.Resources)
                                {
                                    Console.WriteLine("Resource Item: {0}", item.Name);
                                    if (item.CanRead)
                                    {
                                        foreach (var row in item)
                                        {
                                            Console.WriteLine("\tResource row: {0} {1}", row.Name, row.Type);
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("\t---Some object---");
                                    }
                                }
                            }
                            else
                            {
                                Console.WriteLine("INVALID. MetaData Address: {0} Resources Address: {1}", info.ComDescriptor.MetaData.Directory.VirtualAddress, info.ComDescriptor.Resources.Directory.VirtualAddress);
                                Console.ReadKey();
                            }
                        }

                        var meta = info.ComDescriptor.MetaData;
                        Utils.ConsoleWriteMembers("MetaData", meta.Header.Value);

                        foreach (var header in meta)
                        {
                            Console.WriteLine(Utils.GetReflectedMembers(header.Header));
                            switch (header.Header.Type)
                            {
                            case Cor.StreamHeaderType.StreamTable:
                                var table = (StreamTables)header;

                                Console.WriteLine(Utils.GetReflectedMembers(table.StreamTableHeader));

                                Array enums = Enum.GetValues(typeof(Cor.MetaTableType));
                                foreach (Cor.MetaTableType type in enums)
                                {
                                    //Пробежка по всем именованным таблицам
                                    PropertyInfo property = table.GetType().GetProperty(type.ToString(), BindingFlags.Instance | BindingFlags.Public);
                                    foreach (var row in ((IEnumerable)property.GetValue(table, null)))
                                    {
                                        switch (type)
                                        {
                                        case Cor.MetaTableType.NestedClass:
                                        {
                                            NestedClassRow nestedClassRow = (NestedClassRow)row;
                                            TypeDefRow     parentTypeRow  = nestedClassRow.EnclosingClass;
                                            TypeDefRow     childTypeRow   = nestedClassRow.NestedClass;
                                            String         typeName       = parentTypeRow.TypeNamespace + "." + parentTypeRow.TypeName + " {\r\n";
                                            typeName += "\tclass " + childTypeRow.TypeName + " {...}\r\n";
                                            typeName += "}";
                                            Console.WriteLine("{0}: {1}", type, typeName);
                                        }
                                        break;

                                        case Cor.MetaTableType.FieldRVA:
                                        {
                                            FieldRVARow fieldRVARow = (FieldRVARow)row;
                                            FieldRow    fieldRow    = fieldRVARow.Field;
                                            String      fieldName   = fieldRow.Name + " -> 0x" + fieldRVARow.RVA.ToString("X8");
                                            Console.WriteLine("{0}: {1}", type, fieldName);
                                        }
                                        break;

                                        case Cor.MetaTableType.ImplMap:
                                        {
                                            ImplMapRow   implMapRow = (ImplMapRow)row;
                                            ModuleRefRow moduleRow  = implMapRow.ImportScope;
                                            String       moduleName = moduleRow.Name + "-> " + implMapRow.ImportName;
                                            Console.WriteLine("{0}: {1}", type, moduleName);
                                        }
                                        break;

                                        case Cor.MetaTableType.MethodImpl:
                                        {
                                            MethodImplRow methodImplRow = (MethodImplRow)row;
                                            TypeDefRow    typeRow       = methodImplRow.Class;
                                            String        typeName      = typeRow.TypeNamespace + "." + typeRow.TypeName;
                                            Console.WriteLine("{0}: {1}", type, typeName);
                                        }
                                        break;

                                        case Cor.MetaTableType.PropertyMap:
                                        {
                                            PropertyMapRow propertyMapRow = (PropertyMapRow)row;
                                            TypeDefRow     typeRow        = propertyMapRow.Parent;
                                            String         typeName       = typeRow.TypeNamespace + "." + typeRow.TypeName + " {\r\n";
                                            foreach (PropertyRow propertyRow in propertyMapRow.Properties)
                                            {
                                                typeName += "\t" + propertyRow.Name + ";\r\n";
                                            }
                                            typeName += "}";
                                            Console.WriteLine("{0}: {1}", type, typeName);
                                        }
                                        break;

                                        case Cor.MetaTableType.EventMap:
                                        {                                                //TODO: Не тестировано
                                            EventMapRow eventMapRow = (EventMapRow)row;
                                            TypeDefRow  typeRow     = eventMapRow.Parent;
                                            String      typeName    = typeRow.TypeNamespace + "." + typeRow.TypeName + " {\r\n";
                                            foreach (EventRow eventRow in eventMapRow.EventList)
                                            {
                                                typeName += "\tevent " + eventRow.Name + ";\r\n";
                                            }
                                            typeName += "}";
                                            Console.WriteLine("{0}: {1}", type, typeName);
                                        }
                                        break;

                                        case Cor.MetaTableType.FieldLayout:
                                        {
                                            FieldLayoutRow fieldLayoutRow = (FieldLayoutRow)row;
                                            FieldRow       fieldRow       = fieldLayoutRow.Field;
                                            String         fieldName      = fieldRow.Name;
                                            Console.WriteLine("{0}: {1}", type, fieldName);
                                        }
                                        break;

                                        case Cor.MetaTableType.ClassLayout:
                                        {
                                            ClassLayoutRow classLayoutRow = (ClassLayoutRow)row;
                                            TypeDefRow     typeRow        = classLayoutRow.Parent;
                                            String         typeName       = typeRow.TypeNamespace + "." + typeRow.TypeName;
                                            Console.WriteLine("{0}: {1}", type, typeName);
                                        }
                                        break;

                                        case Cor.MetaTableType.InterfaceImpl:
                                        {
                                            InterfaceImplRow interfaceRow = (InterfaceImplRow)row;
                                            TypeDefRow       typeRow      = interfaceRow.Class;
                                            String           typeName     = typeRow.TypeNamespace + "." + typeRow.TypeName;
                                            Console.WriteLine("{0}: {1}", type, typeName);
                                        }
                                        break;

                                        case Cor.MetaTableType.TypeDef:
                                        {
                                            TypeDefRow typeRow  = (TypeDefRow)row;
                                            String     typeName = typeRow.TypeNamespace + "." + typeRow.TypeName + " {\r\n";
                                            foreach (var fieldRow in typeRow.FieldList)
                                            {
                                                typeName += "\t" + fieldRow.Name + ";\r\n";
                                            }
                                            foreach (var methodRow in typeRow.MethodList)
                                            {
                                                typeName += "\t" + methodRow.Name + "(";
                                                foreach (var paramRow in methodRow.ParamList)
                                                {
                                                    typeName += paramRow.Name + ", ";
                                                }
                                                typeName = typeName.TrimEnd(',', '"', ' ') + ");\r\n";
                                            }
                                            typeName += "}";
                                            Console.WriteLine("{0}: {1}", type, typeName);
                                        }
                                        break;

                                        case Cor.MetaTableType.MethodDef:
                                        {
                                            MethodDefRow methodRow  = (MethodDefRow)row;
                                            String       methodName = methodRow.Name + "(";
                                            foreach (var paramRow in methodRow.ParamList)
                                            {
                                                methodName += paramRow.Name + ", ";
                                            }
                                            methodName = methodName.TrimEnd(',', '"', ' ') + ")";
                                            Console.WriteLine("{0}: {1}", type, methodName);

                                            //TODO: Быстрый набросок чтения тела метода
                                            UInt32 methodLength = 0;

                                            UInt32 rva   = methodRow.RVA;
                                            Byte   flags = info.Header.PtrToStructure <Byte>(rva);
                                            rva += sizeof(Byte);
                                            Boolean CorILMethod_FatFormat  = (UInt16)(flags & 0x3) == 0x3;
                                            Boolean CorILMethod_TinyFormat = (UInt16)(flags & 0x2) == 0x2;
                                            Boolean CorILMethod_MoreSects  = (UInt16)(flags & 0x8) == 0x8;
                                            Boolean CorILMethod_InitLocals = (UInt16)(flags & 0x10) == 0x10;

                                            if (CorILMethod_FatFormat)
                                            {
                                                Byte flags2 = info.Header.PtrToStructure <Byte>(rva);
                                                rva += sizeof(Byte);

                                                Byte   headerSize = Convert.ToByte((flags2 >> 4) * 4);
                                                UInt16 maxStack   = info.Header.PtrToStructure <UInt16>(rva);
                                                rva += sizeof(UInt16);

                                                methodLength = info.Header.PtrToStructure <UInt32>(rva);
                                                rva         += sizeof(UInt32);

                                                UInt32 localVarSigTok = info.Header.PtrToStructure <UInt32>(rva);
                                                rva += sizeof(UInt32);
                                            }
                                            else
                                            {
                                                methodLength = ((UInt32)flags >> 2);
                                            }

                                            try
                                            {
                                                Byte[] methodBody  = info.Header.ReadBytes(rva, methodLength);
                                                Byte[] methodBody2 = methodRow.Body.GetMethodBody();

                                                for (Int32 loop = 0; loop < methodLength; loop++)
                                                {
                                                    if (methodBody[loop] != methodBody2[loop])
                                                    {
                                                        throw new ArgumentException("Method not equals");
                                                    }
                                                }
                                            } catch (Exception exc)
                                            {
                                                Console.WriteLine("!!!Error while reading method body!!!");
                                                Console.WriteLine(exc.Message);
                                                Console.ReadLine();
                                            }
                                        }
                                        break;

                                        default:
                                            Utils.ConsoleWriteMembers(row);
                                            break;
                                        }
                                    }

                                    //Пробежка по всем таблицам
                                    MetaTable moduleTable = table[type];

                                    Console.WriteLine(String.Format("==MetaTableType.{0} Contents:", type));
                                    foreach (MetaRow row in moduleTable.Rows)
                                    {
                                        StringBuilder result = new StringBuilder();
                                        foreach (MetaCell cell in row)
                                        {
                                            result.AppendFormat("{0}:\t{1}", cell.Column.Name, cell.Value);
                                        }
                                        result.AppendLine();
                                        Console.WriteLine(result.ToString());
                                    }
                                    Console.WriteLine(String.Format("==MetaTableType.{0} End", type));
                                }
                                break;

                            case Cor.StreamHeaderType.Guid:
                                var    gHeap = (GuidHeap)header;
                                Guid[] guids = gHeap.Data.ToArray();
                                break;

                            case Cor.StreamHeaderType.Blob:
                                var      bHeap = (BlobHeap)header;
                                Byte[][] bytes = bHeap.Data.ToArray();
                                break;

                            case Cor.StreamHeaderType.String:
                                var      sHeap   = (StringHeap)header;
                                String[] strings = sHeap.Data.ToArray();
                                break;

                            case Cor.StreamHeaderType.UnicodeSting:
                                var      usHeap    = (USHeap)header;
                                String[] usStrings = usHeap.DataString;
                                break;
                            }
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }

                    if (!info.ExceptionTable.IsEmpty)
                    {                    //TODO: Ошибка при чтении
                        Console.WriteLine("===Exception Table===");
                        try
                        {
                            foreach (var entry in info.ExceptionTable)
                            {
                                Utils.ConsoleWriteMembers(entry);
                            }
                        } catch (ArgumentOutOfRangeException exc)
                        {
                            Console.WriteLine("Exception: " + exc.Message);
                            Console.WriteLine("========================");
                            Console.WriteLine(exc.StackTrace);
                            Console.ReadKey();
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }
                    if (!info.Iat.IsEmpty)
                    {
                        Console.WriteLine("===Import Address Table===");
                        foreach (UInt32 addr in info.Iat)
                        {
                            Console.WriteLine("Addr: {0:X8}", addr);
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }

                    if (!info.Tls.IsEmpty)
                    {
                        Console.WriteLine("===Thread Local Storage===");
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }
                    if (!info.Certificate.IsEmpty)
                    {
                        try
                        {
                            var cert = info.Certificate.Certificate.Value;
                            var x509 = info.Certificate.X509;
                            Console.WriteLine("===Security===");
                            Utils.ConsoleWriteMembers(cert);
                            Console.WriteLine("Certificate: {0}", x509 == null ? "NULL" : x509.ToString());
                        } catch (ArgumentOutOfRangeException exc)
                        {
                            Console.WriteLine("!!!OverflowException (Corrupted section): {0}", exc.Message);
                            Console.ReadKey();
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }

                    if (!info.DelayImport.IsEmpty)
                    {
                        Console.WriteLine("===Delay Import===");
                        foreach (var module in info.DelayImport)
                        {
                            Console.WriteLine(String.Format("Module Name: {0}\tCount: {1}", module.ModuleName, module.Count()));
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }

                    if (!info.Relocations.IsEmpty)
                    {                    //File contains relocation table
                        Console.WriteLine("===Relocations===");
                        foreach (var block in info.Relocations)
                        {
                            Utils.ConsoleWriteMembers(block.Block);
                            foreach (var section in block)
                            {
                                Utils.ConsoleWriteMembers(section);

                                /*if(!Enum.IsDefined(typeof(WinNT.IMAGE_REL_BASED), section.Type))
                                 * {
                                 *      Console.WriteLine(String.Format("Enum {0} not defined", section.Type));
                                 *      Console.ReadKey();
                                 * }*/
                            }
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }

                    if (!info.Debug.IsEmpty)
                    {                    //В файле есть инормация для дебага
                        Console.WriteLine("===Debug info===");
                        foreach (var debug in info.Debug)
                        {
                            Utils.ConsoleWriteMembers(debug);
                        }
                        var pdb7 = info.Debug.Pdb7CodeView;
                        if (pdb7.HasValue)
                        {
                            Utils.ConsoleWriteMembers(pdb7.Value);
                        }
                        var pdb2 = info.Debug.Pdb2CodeView;
                        if (pdb2.HasValue)
                        {
                            Utils.ConsoleWriteMembers(pdb2.Value);
                        }
                        var misc = info.Debug.Misc;
                        if (misc.HasValue)
                        {
                            Utils.ConsoleWriteMembers(misc.Value);
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }

                    if (!info.LoadConfig.IsEmpty)
                    {
                        Console.WriteLine("===Load Config===");
                        if (info.LoadConfig.Directory32.HasValue)
                        {
                            var directory = info.LoadConfig.Directory32.Value;
                            Utils.ConsoleWriteMembers(directory);
                        }
                        else if (info.LoadConfig.Directory64.HasValue)
                        {
                            var directory = info.LoadConfig.Directory64.Value;
                            Utils.ConsoleWriteMembers(directory);
                        }
                        else
                        {
                            throw new NotImplementedException();
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }

                    if (!info.BoundImport.IsEmpty)
                    {
                        Console.WriteLine("===Bound Import===");
                        Console.WriteLine("ModuleName: {0}", info.BoundImport.ModuleName);
                        foreach (var ffRef in info.BoundImport)
                        {
                            Utils.ConsoleWriteMembers(ffRef);
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }

                    if (!info.Export.IsEmpty)
                    {                    //В файле есть информация о экспортируемых функциях
                        Console.WriteLine("===Export Functions===");
                        Console.WriteLine("Module name: {0}", info.Export.DllName);

                        foreach (var func in info.Export.GetExportFunctions())
                        {
                            Utils.ConsoleWriteMembers(func);
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }

                    if (!info.Import.IsEmpty)
                    {                    //В файле есть информация о импортиуемых модулях
                        Console.WriteLine("===Import Modules===");
                        foreach (var module in info.Import)
                        {
                            Console.WriteLine("Module name: {0}", module.ModuleName);
                            foreach (var func in module)
                            {
                                Utils.ConsoleWriteMembers(func);
                            }
                        }
                        if (pauseOnDir)
                        {
                            Console.ReadKey();
                        }
                    }
                }
            }
        }
Example #22
0
        /// <summary>
        /// Loads all fields defined in the module.
        /// </summary>
        /// <param name="declaringType">The type, which declared the method.</param>
        /// <param name="first">The first field token to load.</param>
        /// <param name="last">The last field token to load (non-inclusive.)</param>
        private void LoadFields(RuntimeType declaringType, Token first, Token last)
        {
            Token maxRVA      = GetMaxTokenValue(TableType.FieldRVA);
            Token maxLayout   = GetMaxTokenValue(TableType.FieldLayout);
            Token tokenRva    = new Token(TableType.FieldRVA, 1);
            Token tokenLayout = new Token(TableType.FieldLayout, 1);

            FieldRVARow    fieldRVA    = (maxRVA.RID != 0) ? metadataProvider.ReadFieldRVARow(tokenRva) : new FieldRVARow();
            FieldLayoutRow fieldLayout = (maxLayout.RID != 0) ? metadataProvider.ReadFieldLayoutRow(tokenLayout) : new FieldLayoutRow();

            foreach (Token token in first.Upto(last.PreviousRow))
            {
                FieldRow fieldRow = metadataProvider.ReadFieldRow(token);
                uint     rva      = 0;
                uint     layout   = 0;

                // Static fields have an optional RVA, non-static may have a layout assigned
                if ((fieldRow.Flags & FieldAttributes.HasFieldRVA) == FieldAttributes.HasFieldRVA)
                {
                    // Move to the RVA of this field
                    while (fieldRVA.Field.RID < token.RID && tokenRva.RID <= maxRVA.RID)
                    {
                        fieldRVA = metadataProvider.ReadFieldRVARow(tokenRva);
                        tokenRva = tokenRva.NextRow;
                    }

                    // Does this field have an RVA?
                    if (token == fieldRVA.Field && tokenRva.RID <= maxRVA.RID)
                    {
                        rva      = fieldRVA.Rva;
                        tokenRva = tokenRva.NextRow;
                        if (tokenRva.RID < maxRVA.RID)
                        {
                            fieldRVA = metadataProvider.ReadFieldRVARow(tokenRva);
                        }
                    }
                }

                if ((fieldRow.Flags & FieldAttributes.HasDefault) == FieldAttributes.HasDefault)
                {
                    // FIXME: Has a default value.
                    //Debug.Assert(false);
                }

                // Layout only exists for non-static fields
                if ((fieldRow.Flags & FieldAttributes.Static) != FieldAttributes.Static)
                {
                    // Move to the layout of this field
                    while (fieldLayout.Field.RID < token.RID && tokenLayout.RID <= maxLayout.RID)
                    {
                        fieldLayout = metadataProvider.ReadFieldLayoutRow(tokenLayout);
                        tokenLayout = tokenLayout.NextRow;
                    }

                    // Does this field have layout?
                    if (token == fieldLayout.Field && tokenLayout.RID <= maxLayout.RID)
                    {
                        layout      = fieldLayout.Offset;
                        tokenLayout = tokenLayout.NextRow;
                        if (tokenLayout.RID < maxLayout.RID)
                        {
                            fieldLayout = metadataProvider.ReadFieldLayoutRow(tokenLayout);
                        }
                    }
                }

                // Load the field metadata
                CilRuntimeField field = new CilRuntimeField(
                    this,
                    GetString(fieldRow.Name),
                    GetFieldSignature(fieldRow.Signature),
                    token,
                    layout,
                    rva,
                    declaringType,
                    fieldRow.Flags
                    );

                declaringType.Fields.Add(field);
                fields[token.RID - 1] = field;
            }

            /* FIXME:
             * Load FieldMarshal tables
             * as needed afterwards. All Generics have been loaded, fields can receive
             * their signature in the load method above.
             */
        }
Example #23
0
        public void ThisRead_WithWrongIndex_ThrowsArgumentOutOfRangeException()
        {
            var fieldRow = new FieldRow(2);

            Assert.Throws <ArgumentOutOfRangeException>(() => { var dot = fieldRow[-1]; });
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            AlarmRecordGetResponse recordGetResponse = LocalApi.GetAlarmRecord(new AlarmRecordGetRequest()
            {
                AlarmRecordDID = this.AlarmRecordDID
            });

            if (recordGetResponse.AlarmRecord == null)
            {
                return;
            }
            this.model = recordGetResponse.AlarmRecord;
            List <FieldRow> fieldRowList1 = new List <FieldRow>();
            List <FieldRow> fieldRowList2 = fieldRowList1;
            FieldRow        fieldRow1     = new FieldRow();

            fieldRow1.FieldName = "报警编号";
            string string1 = this.model.RuleDID.ToString();

            fieldRow1.FieldValue = string1;
            fieldRowList2.Add(fieldRow1);
            List <FieldRow> fieldRowList3 = fieldRowList1;
            FieldRow        fieldRow2     = new FieldRow();

            fieldRow2.FieldName = "报警时间";
            string string2 = this.model.AlarmTime.ToString("yyyy-MM-dd HH:mm:ss");

            fieldRow2.FieldValue = string2;
            fieldRowList3.Add(fieldRow2);
            List <FieldRow> fieldRowList4 = fieldRowList1;
            FieldRow        fieldRow3     = new FieldRow();

            fieldRow3.FieldName = "报警内容";
            string alarmContent = this.model.AlarmContent;

            fieldRow3.FieldValue = alarmContent;
            fieldRowList4.Add(fieldRow3);
            List <FieldRow> fieldRowList5 = fieldRowList1;
            FieldRow        fieldRow4     = new FieldRow();

            fieldRow4.FieldName = "报警部件";
            string unitName = this.model.UnitName;

            fieldRow4.FieldValue = unitName;
            fieldRowList5.Add(fieldRow4);
            List <FieldRow> fieldRowList6 = fieldRowList1;
            FieldRow        fieldRow5     = new FieldRow();

            fieldRow5.FieldName = "所在工位";
            string facilityName = this.model.FacilityName;

            fieldRow5.FieldValue = facilityName;
            fieldRowList6.Add(fieldRow5);
            fieldRowList1.Add(new FieldRow()
            {
                FieldName  = "报警类型",
                FieldValue = ""
            });
            List <FieldRow> fieldRowList7 = fieldRowList1;
            FieldRow        fieldRow6     = new FieldRow();

            fieldRow6.FieldName = "异常原因";
            string alarmReason = this.model.AlarmReason;

            fieldRow6.FieldValue = alarmReason;
            fieldRowList7.Add(fieldRow6);
            List <FieldRow> fieldRowList8 = fieldRowList1;
            FieldRow        fieldRow7     = new FieldRow();

            fieldRow7.FieldName = "解决方案";
            string solutionText = this.model.SolutionText;

            fieldRow7.FieldValue = solutionText;
            fieldRowList8.Add(fieldRow7);
            List <FieldRow> fieldRowList9 = fieldRowList1;
            FieldRow        fieldRow8     = new FieldRow();

            fieldRow8.FieldName = "报警地址";
            string address = this.model.Address;

            fieldRow8.FieldValue = address;
            fieldRowList9.Add(fieldRow8);
            List <FieldRow> fieldRowList10 = fieldRowList1;
            FieldRow        fieldRow9      = new FieldRow();

            fieldRow9.FieldName = "恢复时间";
            string string3 = this.model.DisposeTime.Value.ToString("yyyy-MM-dd HH:mm:ss");

            fieldRow9.FieldValue = string3;
            fieldRowList10.Add(fieldRow9);
            List <FieldRow> fieldRowList11 = fieldRowList1;
            FieldRow        fieldRow10     = new FieldRow();

            fieldRow10.FieldName = "处理人";
            string handler = this.model.Handler;

            fieldRow10.FieldValue = handler;
            fieldRowList11.Add(fieldRow10);
            foreach (AlarmFieldValue fieldValue in this.model.FieldValues)
            {
                fieldRowList1.Add(new FieldRow()
                {
                    FieldName  = fieldValue.FieldDescription,
                    FieldValue = fieldValue.FieldValue
                });
            }
            //string urlstring = "C:/" + this.model.AlarmLocationImagePath;
            string urlstring = System.Environment.CurrentDirectory + this.model.AlarmLocationImagePath;

            if (System.IO.File.Exists(urlstring))
            {
                this.imgAlarmLocation.Source = new BitmapImage(new Uri(urlstring, UriKind.Absolute));
            }
            else
            {
                urlstring = urlstring = urlstring = System.Environment.CurrentDirectory + "/ErrorPic/Error.jpg";
            }
            this.imgAlarmLocation.Source = new BitmapImage(new Uri(urlstring, UriKind.Absolute));

            this.dataGrid.ItemsSource = fieldRowList1;
        }
        public void Map_FieldValueListWithSameReferenceParent_ReferenceMaintainedInMapping()
        {
            var target = new AutoMapperEntityMapper(new Mapper(MappingConfigurationProvider));

            var fieldRow = new FieldRow {
                FieldId = 234, Name = "Field1", Description = "The first field"
            };
            var domainIdentity1Row = new DomainIdentityRow {
                DomainIdentityId = 134, FirstName = "Tom", LastName = "Bomb", UniqueIdentifier = "*****@*****.**"
            };
            var domainIdentity2Row = new DomainIdentityRow {
                DomainIdentityId = 765, FirstName = "Tim", LastName = "Bo", UniqueIdentifier = "*****@*****.**"
            };

            var fieldValueRows = new List <FieldValueRow>
            {
                new FieldValueRow
                {
                    Field            = fieldRow,
                    FieldId          = fieldRow.FieldId,
                    FieldValueId     = 93453,
                    LastModifiedTime = DateTimeOffset.Now,
                    LastModifiedBy   = domainIdentity1Row,
                    LastModifiedByDomainIdentifierId = domainIdentity1Row.DomainIdentityId
                },
                new FieldValueRow
                {
                    Field            = fieldRow,
                    FieldId          = fieldRow.FieldId,
                    FieldValueId     = 93454,
                    LastModifiedTime = DateTimeOffset.Now,
                    LastModifiedBy   = domainIdentity1Row,
                    LastModifiedByDomainIdentifierId = domainIdentity1Row.DomainIdentityId
                },
                new FieldValueRow
                {
                    Field            = fieldRow,
                    FieldId          = fieldRow.FieldId,
                    FieldValueId     = 93455,
                    LastModifiedTime = DateTimeOffset.Now,
                    LastModifiedBy   = domainIdentity2Row,
                    LastModifiedByDomainIdentifierId = domainIdentity2Row.DomainIdentityId
                },
                new FieldValueRow
                {
                    Field            = fieldRow,
                    FieldId          = fieldRow.FieldId,
                    FieldValueId     = 93456,
                    LastModifiedTime = DateTimeOffset.Now,
                    LastModifiedBy   = domainIdentity2Row,
                    LastModifiedByDomainIdentifierId = domainIdentity2Row.DomainIdentityId
                },
                new FieldValueRow
                {
                    Field            = fieldRow,
                    FieldId          = fieldRow.FieldId,
                    FieldValueId     = 93457,
                    LastModifiedTime = DateTimeOffset.Now,
                    LastModifiedBy   = domainIdentity2Row,
                    LastModifiedByDomainIdentifierId = domainIdentity2Row.DomainIdentityId
                },
            };

            var values = new List <FieldValue>();

            Trace.WriteLine("test");

            foreach (var row in fieldValueRows)
            {
                values.Add(target.Map <FieldValue>(row));
            }

            var firstField = values.First().Field;

            foreach (var value in values)
            {
                Assert.AreSame(firstField, value.Field);
            }
        }