void OnNodeSelected(object sender, TreeViewEventArgs e) { gridView.Clear(); var node = (DataTreeNodeX)treeView.SelectedNode; if (node.Model is MDTableModel) { var mdTable = ((MDTableModel)node.Model).MDTable; hexView.SetHighLights(GetHighLights(mdTable.Table)); if (followInHex) { var tbls = Model.Stream; var begin = mdTable.StartOffset - tbls.StartOffset; var end = mdTable.EndOffset - tbls.StartOffset; hexView.Select(begin, end); } } else if (node.Model is MDRowModel) { var rowModel = (MDRowModel)node.Model; var mdTable = rowModel.Parent.MDTable; var rid = rowModel.Rid; var rowHL = GetHighLights(mdTable.Table); rowHL = (HexViewer.HighLight[])rowHL.Clone(); var row = rowHL[rid]; row = new HexViewer.HighLight(Color.Blue, row.Start, row.End); rowHL[rid] = row; hexView.SetHighLights(rowHL); RowInfoPopulator.PopulateGridView(this, gridView, rowModel); if (followInHex) { hexView.Select(row.Start, row.End); } } else { hexView.ClearHighLight(); } }
protected override void OnModelUpdated() { gridView.Clear(); if (Model != null) { hexView.ClearHighLight(); var tbls = Model.Stream; var ranges = new List <Tuple <uint, uint> >(); uint relBase = (uint)tbls.StartOffset; uint offset = 0; gridView.AddRow("Reserved1", ranges.IncrementOffset(relBase, ref offset, 4), tbls.Reserved1); gridView.AddRow("MajorVersion", ranges.IncrementOffset(relBase, ref offset, 1), (byte)(tbls.Version >> 8)); gridView.AddRow("MinorVersion", ranges.IncrementOffset(relBase, ref offset, 1), (byte)tbls.Version); gridView.AddRow("Flags", ranges.IncrementOffset(relBase, ref offset, 1), tbls.Flags); gridView.AddRow("Log2Rid", ranges.IncrementOffset(relBase, ref offset, 1), tbls.Log2Rid); gridView.AddRow("MaskValid", ranges.IncrementOffset(relBase, ref offset, 8), tbls.ValidMask); gridView.AddRow("MaskSorted", ranges.IncrementOffset(relBase, ref offset, 8), tbls.SortedMask); var rowSizeBegin = offset; var numTbls = Math.Min(Utils.GetNumOfSetBits(tbls.ValidMask), 0x3f); var rowSizeEnd = rowSizeBegin + numTbls * 4; hexView.AddHighLight(new HexViewer.HighLight(Color.Green, rowSizeBegin, rowSizeEnd)); if (tbls.HasExtraData) { gridView.AddRow("ExtraData (!)", ranges.IncrementOffset(relBase, ref rowSizeEnd, 4), tbls.ExtraData); } hexView.AddHighLights(ranges, Color.Red, Color.Blue); hexView.Stream = tbls.GetClonedImageStream(); } else { hexView.Stream = null; } }
void PopulateMDHeader() { hexView.ClearHighLight(); var header = Model.MetaData.MetaDataHeader; var ranges = new List <Tuple <uint, uint> >(); uint relBase = (uint)header.StartOffset; uint offset = 0; hdrGridView.AddRow("Signature", ranges.IncrementOffset(relBase, ref offset, 4), header.Signature); hdrGridView.AddRow("MajorVersion", ranges.IncrementOffset(relBase, ref offset, 2), header.MajorVersion); hdrGridView.AddRow("MinorVersion", ranges.IncrementOffset(relBase, ref offset, 2), header.MinorVersion); hdrGridView.AddRow("Reserved", ranges.IncrementOffset(relBase, ref offset, 4), header.Reserved1); hdrGridView.AddRow("VersionLength", ranges.IncrementOffset(relBase, ref offset, 4), header.StringLength); hdrGridView.AddRow("VersionString", ranges.IncrementOffset(relBase, ref offset, header.StringLength), header.VersionString); hdrGridView.AddRow("Flags", ranges.IncrementOffset(relBase, ref offset, 1), header.Flags); hdrGridView.AddRow("Reserved", ranges.IncrementOffset(relBase, ref offset, 1), header.Reserved2); hdrGridView.AddRow("NumberOfStreams", ranges.IncrementOffset(relBase, ref offset, 2), header.Streams); hexView.AddHighLights(ranges, Color.Red, Color.Blue); }