From fe06c96070bbc8a48fc07f3bf78795b272dd9d64 Mon Sep 17 00:00:00 2001 From: wj32 Date: Sun, 23 Nov 2008 03:11:28 +0000 Subject: [PATCH] fixes for symbols, give listview tooltips git-svn-id: svn://svn.code.sf.net/p/processhacker/code@123 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- .../Forms/ThreadWindow.Designer.cs | 2 + trunk/ProcessHacker/Symbols/Symbols.cs | 38 ++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/trunk/ProcessHacker/Forms/ThreadWindow.Designer.cs b/trunk/ProcessHacker/Forms/ThreadWindow.Designer.cs index 0a3032ff7..602f1ea14 100644 --- a/trunk/ProcessHacker/Forms/ThreadWindow.Designer.cs +++ b/trunk/ProcessHacker/Forms/ThreadWindow.Designer.cs @@ -118,8 +118,10 @@ this.columnHeader3, this.columnHeader4}); this.listViewCallStack.FullRowSelect = true; + this.listViewCallStack.HideSelection = false; this.listViewCallStack.Location = new System.Drawing.Point(6, 19); this.listViewCallStack.Name = "listViewCallStack"; + this.listViewCallStack.ShowItemToolTips = true; this.listViewCallStack.Size = new System.Drawing.Size(363, 232); this.listViewCallStack.TabIndex = 0; this.listViewCallStack.UseCompatibleStateImageBehavior = false; diff --git a/trunk/ProcessHacker/Symbols/Symbols.cs b/trunk/ProcessHacker/Symbols/Symbols.cs index 37c8d3133..d8159922e 100644 --- a/trunk/ProcessHacker/Symbols/Symbols.cs +++ b/trunk/ProcessHacker/Symbols/Symbols.cs @@ -33,11 +33,13 @@ namespace ProcessHacker { private static List> _libraryLookup; private static Dictionary>> _symbols; + private static Dictionary _librarySizes; static Symbols() { _libraryLookup = new List>(); _symbols = new Dictionary>>(); + _librarySizes = new Dictionary(); } public static void LoadSymbolsFromLibrary(string path) @@ -77,38 +79,44 @@ namespace ProcessHacker PEFile file = new PEFile(realPath); List> list = new List>(); + uint size = 0; + + foreach (SectionHeader sh in file.Sections) + size += sh.VirtualSize; + + _librarySizes.Add(realPath, size); if (file.ExportData == null) { // no symbols, but we can still display a module name in a lookup _libraryLookup.Add(new KeyValuePair(imageBase, realPath)); _symbols.Add(realPath, new List>()); - - return; } - - for (int i = 0; i < file.ExportData.ExportNameTable.Count; i++) + else { - string name = file.ExportData.ExportNameTable[i]; + for (int i = 0; i < file.ExportData.ExportNameTable.Count; i++) + { + string name = file.ExportData.ExportNameTable[i]; - list.Add(new KeyValuePair(imageBase + - (int)file.ExportData.ExportAddressTable[file.ExportData.ExportOrdinalTable[i]].ExportRVA, name)); + list.Add(new KeyValuePair(imageBase + + (int)file.ExportData.ExportAddressTable[file.ExportData.ExportOrdinalTable[i]].ExportRVA, name)); + } + + _libraryLookup.Add(new KeyValuePair(imageBase, realPath)); + _symbols.Add(realPath, list); } // sort the list list.Sort(new Comparison>( delegate(KeyValuePair kvp1, KeyValuePair kvp2) { - return kvp2.Key.CompareTo(kvp1.Key); + return ((uint)kvp2.Key).CompareTo((uint)kvp1.Key); })); - _libraryLookup.Add(new KeyValuePair(imageBase, realPath)); - _symbols.Add(realPath, list); - _libraryLookup.Sort(new Comparison>( delegate(KeyValuePair kvp1, KeyValuePair kvp2) { - return kvp2.Key.CompareTo(kvp1.Key); + return ((uint)kvp2.Key).CompareTo((uint)kvp1.Key); })); } @@ -117,7 +125,9 @@ namespace ProcessHacker // go through each loaded library foreach (KeyValuePair kvp in _libraryLookup) { - if (address >= kvp.Key) + uint size = _librarySizes[kvp.Value]; + + if ((uint)address >= (uint)kvp.Key && (uint)address < ((uint)kvp.Key + size)) { List> symbolList = _symbols[kvp.Value]; FileInfo fi = new FileInfo(kvp.Value); @@ -125,7 +135,7 @@ namespace ProcessHacker // go through each symbol foreach (KeyValuePair kvps in symbolList) { - if (address >= kvps.Key) + if ((uint)address >= (uint)kvps.Key) { // we found a function name return string.Format("{0}!{1}+0x{2:x}",