-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportsPropertyPage.cs
More file actions
72 lines (64 loc) · 2.24 KB
/
ImportsPropertyPage.cs
File metadata and controls
72 lines (64 loc) · 2.24 KB
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
using SharpShell.SharpPropertySheet;
using System;
using System.Linq;
using System.Windows.Forms;
namespace DLLTab
{
public partial class ImportsPropertyPage : SharpPropertyPage
{
private readonly PeNet.Header.Pe.ImportFunction[] _imports;
private readonly int _importCount = 0;
public ImportsPropertyPage(PeNet.Header.Pe.ImportFunction[] imports)
{
_imports = imports;
_importCount = _imports.Count();
Log($"Found {_importCount} imports");
InitializeComponent();
PageTitle = "Imports";
// 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 import in _imports)
{
_ = lv.Items.Add(ImportAsItem(import));
}
numLbl.Text = $"{_importCount} imports found";
}
private static ListViewItem ImportAsItem(PeNet.Header.Pe.ImportFunction import)
{
return new ListViewItem(
new string[]
{
import.Name,
import.DLL,
import.IATOffset.ToString()
});
}
private void OnSearchBoxEdit(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(searchBox.Text))
{
numLbl.Text = $"{_importCount} imports found";
return;
}
var query = searchBox.Text.ToLower();
lv.Items.Clear();
foreach (var import in _imports)
{
if (import.Name.ToLower().Contains(query) ||
import.DLL.ToLower().Contains(query) ||
import.IATOffset.ToString().Contains(query))
{
lv.Items.Add(ImportAsItem(import));
}
}
numLbl.Text = $"{lv.Items.Count} import(s) found matching '{query}'";
}
}
}