-
Notifications
You must be signed in to change notification settings - Fork 2
/
OptionSelector.cs
93 lines (75 loc) · 2.41 KB
/
OptionSelector.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace RegistryReader
{
public partial class OptionSelector : Form
{
public OptionSelector()
{
InitializeComponent();
MaximumSize = MinimumSize = Size;
btnDone.Click += BtnDone_Click;
btnSys.Click += BtnSys_Click;
chkLive.CheckedChanged += ChkLive_CheckedChanged;
}
private void BtnSys_Click(object sender, EventArgs e)
{
GetHivePath();
}
private void ChkLive_CheckedChanged(object sender, EventArgs e)
{
if (chkLive.Checked)
{
string path = GetSystemHive();
txtPath.Text = path;
}
else
{
txtPath.Clear();
}
}
private void BtnDone_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
public string SystemHive { get { return txtPath.Text; } }
public string NTUserDat { get; private set; }
public bool LiveSystem { get { return chkLive.Checked; } }
private string GetHivePath()
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Title = "Open Hive File";
ofd.InitialDirectory = @"C:\";
ofd.Multiselect = false;
if (ofd.ShowDialog() == DialogResult.OK)
{
txtPath.Text = ofd.FileName;
return ofd.FileName;
}
else return null;
}
private string GetSystemHive()
{
string timestamp = DateTime.Now.Subtract(DateTime.MinValue).TotalSeconds.ToString();
string savePath = Path.Combine(Environment.CurrentDirectory, timestamp);
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C reg save HKLM\\SYSTEM " + "\"" + savePath + "\"";
startInfo.Verb = "runas";
Process p = Process.Start(startInfo);
while (!p.HasExited) ;
}
catch
{
savePath = null;
}
return savePath;
}
}
}