示例#1
0
        protected override void OnModelUpdated()
        {
            view.Clear();
            if (Model != null)
            {
                for (int i = 0; i < 0x10; i++)
                {
                    var dir     = Model.Image.ImageNTHeaders.OptionalHeader.DataDirectories[i];
                    var section = Model.Image.ToImageSectionHeader(dir.VirtualAddress);

                    GridView.Cell sectionCell;
                    if (dir.VirtualAddress != 0 && section == null)
                    {
                        sectionCell = new GridView.Cell("Invalid", back: ControlPaint.Light(Color.Red));
                    }
                    else if (section != null)
                    {
                        sectionCell = new GridView.Cell(section.DisplayName, back: SystemColors.ControlLight);
                    }
                    else
                    {
                        sectionCell = new GridView.Cell("", back: SystemColors.ControlLight);
                    }

                    view.AddRow(DirectoryNames[i], dir.VirtualAddress, dir.Size, sectionCell, ctxMenu);
                }
            }
        }
示例#2
0
        public static void PopulateGridView(MDTableHeapView view, GridView gridView, MDRowModel row)
        {
            var reader = getReader(row.Parent.Tables, row.Parent.MDTable, row.Rid);

            var beginPos = reader.Position;

            gridView.Clear();
            foreach (var column in row.Parent.MDTable.Columns)
            {
                reader.Position = beginPos + column.Offset;
                var offset = (uint)row.Parent.MDTable.StartOffset + (uint)reader.Position;

                object value    = null;
                uint   rawValue = 0;
                switch (column.Size)
                {
                case 1:
                    byte u1 = reader.ReadByte();
                    value    = u1;
                    rawValue = u1;
                    break;

                case 2:
                    ushort u2 = reader.ReadUInt16();
                    value    = u2;
                    rawValue = u2;
                    break;

                case 4:
                    uint u4 = reader.ReadUInt32();
                    value    = u4;
                    rawValue = u4;
                    break;

                default:
                    throw new Exception("Unexpected column size.");
                }

                var desc    = GetDescription(row.Parent.MetaData, row.Parent.MDTable, column, rawValue);
                var ctxMenu = GetContextMenu(view, row, row.Parent.MetaData, column.ColumnSize);
                var cell    = new GridView.Cell(desc,
                                                back: desc == InvalidValue ? ControlPaint.Light(Color.Red) : SystemColors.ControlLight);
                gridView.AddRow(column.Name, column.ColumnSize.ToString(), offset, value, cell, ctxMenu);
            }
        }