-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainFrame.cs
More file actions
86 lines (72 loc) · 2.89 KB
/
Copy pathMainFrame.cs
File metadata and controls
86 lines (72 loc) · 2.89 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
using WinSysInfo.MiniFileParser.Model;
using WinSysInfo.MiniFileParser.Process;
using System.Reflection;
namespace WinSysInfo.MiniFileParser.GUI
{
public partial class MainFrame : Form
{
FileLoader loader;
public MainFrame()
{
InitializeComponent();
}
private void OnClickFileOpenMenuItem(object sender, EventArgs e)
{
OpenFileDialog openFileDlg = new OpenFileDialog();
openFileDlg.Title = "Choose Windows File";
openFileDlg.Multiselect = false;
openFileDlg.Filter = "Win EXE (*.exe)|*.exe";
DialogResult dlgResult = openFileDlg.ShowDialog();
if(dlgResult == DialogResult.OK | dlgResult == DialogResult.Yes)
{
loader = new FileLoader(openFileDlg.FileName);
loader.Read();
LoadTreeView();
}
}
private void LoadTreeView()
{
treeViewFile.Nodes.Clear();
foreach (KeyValuePair<EnumPEStructureId, object> kv in
(Dictionary<EnumPEStructureId, object>)loader.DataStore.FileData)
{
TreeNode parent = new TreeNode(kv.Key.ToString());
treeViewFile.Nodes.Add(parent);
}
treeViewFile.SelectedNode = treeViewFile.Nodes[0];
}
private void OnSelectedNode(object sender, TreeViewEventArgs e)
{
listViewDetails.Items.Clear();
EnumPEStructureId enumVal = (EnumPEStructureId)Enum.Parse(typeof(EnumPEStructureId), e.Node.Text);
object objData = loader.DataStore.FileData[enumVal];
if (objData == null) return;
Type type = objData.GetType();
if ((type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Dictionary<,>)) ||
(type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>)))
return;
PropertyInfo DataPi = type.GetProperty("Data");
object rawObjData = DataPi.GetValue(objData);
foreach (var f in DataPi.PropertyType.GetFields().Where(f => f.IsPublic))
{
if(f.FieldType.IsArray == true)
{
Array array = f.GetValue(rawObjData) as Array;
string data = string.Empty;
for (int indx = 0; indx < array.Length; ++indx) data += array.GetValue(indx);
listViewDetails.Items.Add(
new ListViewItem(new string[] { f.Name, data }));
}
else
{
listViewDetails.Items.Add(
new ListViewItem(new string[] { f.Name, f.GetValue(rawObjData).ToString() }));
}
}
}
}
}