12 using System.Collections.Generic;
13 using System.ComponentModel;
18 using System.Windows.Forms;
26 InitializeComponent();
30 textBox_FileAccessFlags.Text = filterRule.
AccessFlag.ToString();
32 textBox_SelectedEvents.Text = filterRule.
EventType.ToString();
40 textBox_MonitorIO.Text = filterRule.
MonitorIO.ToString();
41 textBox_ControlIO.Text = filterRule.
ControlIO.ToString();
45 groupBox_AccessControl.Visible =
false;
54 private void SetCheckBoxValue()
57 uint accessFlags = uint.Parse(textBox_FileAccessFlags.Text);
59 if ((accessFlags & (uint)FilterAPI.AccessFlag.FILE_ENCRYPTION_RULE) > 0 && textBox_PassPhrase.Text.Length > 0 )
61 checkBox_Encryption.Checked =
true;
62 textBox_PassPhrase.ReadOnly =
false;
66 checkBox_Encryption.Checked =
false;
69 if ((accessFlags & (uint)FilterAPI.AccessFlag.ALLOW_FILE_ACCESS_FROM_NETWORK) > 0)
71 checkBox_AllowRemoteAccess.Checked =
true;
75 checkBox_AllowRemoteAccess.Checked =
false;
78 if ((accessFlags & (uint)FilterAPI.AccessFlag.ALLOW_FILE_DELETE) > 0)
80 checkBox_AllowDelete.Checked =
true;
84 checkBox_AllowDelete.Checked =
false;
87 if ((accessFlags & (uint)FilterAPI.AccessFlag.ALLOW_FILE_RENAME) > 0)
89 checkBox_AllowRename.Checked =
true;
93 checkBox_AllowRename.Checked =
false;
96 if ((accessFlags & (uint)FilterAPI.AccessFlag.ALLOW_WRITE_ACCESS) > 0
97 && (accessFlags & (uint)FilterAPI.AccessFlag.ALLOW_SET_INFORMATION) > 0)
99 checkBox_AllowChange.Checked =
true;
103 checkBox_AllowChange.Checked =
false;
106 if ((accessFlags & (uint)FilterAPI.AccessFlag.ALLOW_OPEN_WITH_CREATE_OR_OVERWRITE_ACCESS) > 0)
108 checkBox_AllowNewFileCreation.Checked =
true;
112 checkBox_AllowNewFileCreation.Checked =
false;
117 private void button_FileAccessFlags_Click(
object sender, EventArgs e)
121 if (optionForm.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
123 textBox_FileAccessFlags.Text = optionForm.
AccessFlags.ToString();
129 private void button_SaveFilter_Click(
object sender, EventArgs e)
131 if (textBox_IncludeFilterMask.Text.Trim().Length == 0)
133 MessageBoxHelper.PrepToCenterMessageBoxOnForm(
this);
134 MessageBox.Show(
"The include filter mask can't be empty.",
"Add Filter Rule", MessageBoxButtons.OK, MessageBoxIcon.Error);
139 string encryptionPassPhrase =
string.Empty;
140 uint accessFlags = uint.Parse(textBox_FileAccessFlags.Text);
142 if (checkBox_Encryption.Checked)
144 encryptionPassPhrase = textBox_PassPhrase.Text;
147 accessFlags = accessFlags|(uint)FilterAPI.AccessFlag.FILE_ENCRYPTION_RULE;
150 if (textBox_HiddenFilterMask.Text.Trim().Length > 0)
153 accessFlags = accessFlags | (uint)FilterAPI.AccessFlag.HIDE_FILES_IN_DIRECTORY_BROWSING;
168 filterRule.
EventType = uint.Parse(textBox_SelectedEvents.Text);
169 filterRule.
MonitorIO = uint.Parse(textBox_MonitorIO.Text);
170 filterRule.
ControlIO = uint.Parse(textBox_ControlIO.Text);
176 private void checkBox_Encryption_CheckedChanged(
object sender, EventArgs e)
178 uint accessFlags = uint.Parse(textBox_FileAccessFlags.Text);
180 if (checkBox_Encryption.Checked)
182 textBox_PassPhrase.ReadOnly =
false;
183 accessFlags = accessFlags | ((uint)FilterAPI.AccessFlag.FILE_ENCRYPTION_RULE);
187 textBox_PassPhrase.ReadOnly =
true;
188 accessFlags = accessFlags & ((uint)~FilterAPI.AccessFlag.FILE_ENCRYPTION_RULE);
191 textBox_FileAccessFlags.Text = accessFlags.ToString();
194 private void checkBox_AllowDelete_CheckedChanged(
object sender, EventArgs e)
197 uint accessFlags = uint.Parse(textBox_FileAccessFlags.Text);
199 if (!checkBox_AllowDelete.Checked)
201 accessFlags = accessFlags & ((uint)~FilterAPI.AccessFlag.ALLOW_FILE_DELETE);
205 accessFlags = accessFlags | ((uint)FilterAPI.AccessFlag.ALLOW_FILE_DELETE);
208 textBox_FileAccessFlags.Text = accessFlags.ToString();
211 private void checkBox_AllowChange_CheckedChanged(
object sender, EventArgs e)
213 uint accessFlags = uint.Parse(textBox_FileAccessFlags.Text);
214 if (!checkBox_AllowChange.Checked)
216 accessFlags = accessFlags & ((uint)~FilterAPI.AccessFlag.ALLOW_WRITE_ACCESS) & ((uint)~FilterAPI.AccessFlag.ALLOW_SET_INFORMATION);
220 accessFlags = accessFlags | ((uint)FilterAPI.AccessFlag.ALLOW_WRITE_ACCESS) | ((uint)FilterAPI.AccessFlag.ALLOW_SET_INFORMATION);
223 textBox_FileAccessFlags.Text = accessFlags.ToString();
226 private void checkBox_AllowRename_CheckedChanged(
object sender, EventArgs e)
228 uint accessFlags = uint.Parse(textBox_FileAccessFlags.Text);
230 if (!checkBox_AllowRename.Checked)
232 accessFlags = accessFlags & ((uint)~FilterAPI.AccessFlag.ALLOW_FILE_RENAME);
236 accessFlags = accessFlags | ((uint)FilterAPI.AccessFlag.ALLOW_FILE_RENAME);
239 textBox_FileAccessFlags.Text = accessFlags.ToString();
242 private void checkBox_AllowRemoteAccess_CheckedChanged(
object sender, EventArgs e)
244 uint accessFlags = uint.Parse(textBox_FileAccessFlags.Text);
246 if (!checkBox_AllowRemoteAccess.Checked)
248 accessFlags = accessFlags & ((uint)~FilterAPI.AccessFlag.ALLOW_FILE_ACCESS_FROM_NETWORK);
252 accessFlags = accessFlags | ((uint)FilterAPI.AccessFlag.ALLOW_FILE_ACCESS_FROM_NETWORK);
255 textBox_FileAccessFlags.Text = accessFlags.ToString();
258 private void checkBox_AllowNewFileCreation_CheckedChanged(
object sender, EventArgs e)
260 uint accessFlags = uint.Parse(textBox_FileAccessFlags.Text);
262 if (!checkBox_AllowNewFileCreation.Checked)
264 accessFlags = accessFlags & ((uint)~FilterAPI.AccessFlag.ALLOW_OPEN_WITH_CREATE_OR_OVERWRITE_ACCESS);
268 accessFlags = accessFlags | ((uint)FilterAPI.AccessFlag.ALLOW_OPEN_WITH_CREATE_OR_OVERWRITE_ACCESS);
271 textBox_FileAccessFlags.Text = accessFlags.ToString();
274 private void checkBox_DisplayPassword_CheckedChanged(
object sender, EventArgs e)
276 if (checkBox_DisplayPassword.Checked)
278 textBox_PassPhrase.UseSystemPasswordChar =
false;
282 textBox_PassPhrase.UseSystemPasswordChar =
true;
286 private void button_SelectIncludePID_Click(
object sender, EventArgs e)
291 if (optionForm.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
293 textBox_IncludePID.Text = optionForm.
ProcessId;
297 private void button_SelectExcludePID_Click(
object sender, EventArgs e)
302 if (optionForm.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
304 textBox_ExcludePID.Text = optionForm.
ProcessId;
308 private void button_SelectedEvents_Click(
object sender, EventArgs e)
312 if (optionForm.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
318 private void button_RegisterMonitorIO_Click(
object sender, EventArgs e)
322 if (optionForm.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
328 private void button_RegisterControlIO_Click(
object sender, EventArgs e)
332 if (optionForm.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
string ExcludeProcessNames
static bool AddFilterRule(FilterRule newRule)
uint EventType
The register the file I/O events
string IncludeProcessNames
uint ControlIO
register control I/O requests, the filter driver will block and wait for the response.
string HiddenFileFilterMasks
static FilterAPI.FilterType filterType
string ExcludeFileFilterMasks
uint MonitorIO
register monitor I/O requests
string EncryptionPassPhrase
string IncludeFileFilterMask