-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExportsPropertyPage.cs
73 lines (65 loc) · 2.27 KB
/
ExportsPropertyPage.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using SharpShell.SharpPropertySheet;
using System;
using System.Linq;
using System.Windows.Forms;
namespace DLLTab
{
public partial class ExportsPropertyPage : SharpPropertyPage
{
private readonly PeNet.Header.Pe.ExportFunction[] _exports;
private readonly int _exportCount;
public ExportsPropertyPage(PeNet.Header.Pe.ExportFunction[] exports)
{
_exports = exports;
_exportCount = _exports.Count();
Log($"Found {_exportCount} exports");
InitializeComponent();
PageTitle = "Exports";
// https://stackoverflow.com/a/42389596
lv
.GetType()
.GetProperty("DoubleBuffered",
System.Reflection.BindingFlags.Instance |
System.Reflection.BindingFlags.NonPublic)
.SetValue(lv, true, null);
}
protected override void OnPropertyPageInitialised(SharpPropertySheet parent)
{
foreach (var export in _exports)
{
_ = lv.Items.Add(ExportAsItem(export));
}
numLbl.Text = $"{_exportCount} exports found";
}
private static ListViewItem ExportAsItem(PeNet.Header.Pe.ExportFunction export)
{
return new ListViewItem(
new string[]
{
export.Ordinal.ToString(),
export.Name,
export.Address.ToString()
});
}
private void OnSearchBoxEdit(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(searchBox.Text))
{
numLbl.Text = $"{_exportCount} exports found";
return;
}
var query = searchBox.Text.ToLower();
lv.Items.Clear();
foreach (var export in _exports)
{
if (export.Name.ToLower().Contains(query) ||
export.Ordinal.ToString().Contains(query) ||
export.Address.ToString().Contains(query))
{
lv.Items.Add(ExportAsItem(export));
}
}
numLbl.Text = $"{lv.Items.Count} export(s) found matching '{query}'";
}
}
}