static public bool SkipUacEnable(string taskName, bool is_enable) { try { TaskScheduler.TaskScheduler service = new TaskScheduler.TaskScheduler(); service.Connect(); ITaskFolder folder = service.GetFolder(@"\"); // root if (is_enable) { string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location; string appPath = Path.GetDirectoryName(exePath); ITaskDefinition task = service.NewTask(0); task.RegistrationInfo.Author = "WuMgr"; task.Principal.RunLevel = _TASK_RUNLEVEL.TASK_RUNLEVEL_HIGHEST; task.Settings.AllowHardTerminate = false; task.Settings.StartWhenAvailable = false; task.Settings.DisallowStartIfOnBatteries = false; task.Settings.StopIfGoingOnBatteries = false; task.Settings.MultipleInstances = _TASK_INSTANCES_POLICY.TASK_INSTANCES_PARALLEL; task.Settings.ExecutionTimeLimit = "PT0S"; IExecAction action = (IExecAction)task.Actions.Create(_TASK_ACTION_TYPE.TASK_ACTION_EXEC); action.Path = exePath; action.WorkingDirectory = appPath; action.Arguments = "-NoUAC $(Arg0)"; IRegisteredTask registered_task = folder.RegisterTaskDefinition(taskName, task, (int)_TASK_CREATION.TASK_CREATE_OR_UPDATE, null, null, _TASK_LOGON_TYPE.TASK_LOGON_INTERACTIVE_TOKEN); if (registered_task == null) { return(false); } // Note: if we run as UWP we need to adjust the file permissions for this workaround to work if (UwpFunc.IsRunningAsUwp()) { if (!FileOps.TakeOwn(exePath)) { return(false); } FileSecurity ac = File.GetAccessControl(exePath); ac.AddAccessRule(new FileSystemAccessRule(new SecurityIdentifier(FileOps.SID_Worls), FileSystemRights.ReadAndExecute, AccessControlType.Allow)); File.SetAccessControl(exePath, ac); } } else { folder.DeleteTask(taskName, 0); } } catch (Exception err) { AppLog.Line("Enable SkipUAC Error {0}", err.ToString()); return(false); } return(true); }
public DnsLogList() { InitializeComponent(); this.txtDnsFilter.LabelText = Translate.fmt("lbl_text_filter"); this.dnsGrid.Columns[1].Header = Translate.fmt("lbl_name"); this.dnsGrid.Columns[2].Header = Translate.fmt("lbl_host_name"); this.dnsGrid.Columns[3].Header = Translate.fmt("lbl_last_seen"); this.dnsGrid.Columns[4].Header = Translate.fmt("lbl_seen_count"); this.dnsGrid.Columns[5].Header = Translate.fmt("lbl_con_count"); this.dnsGrid.Columns[6].Header = Translate.fmt("lbl_uploaded"); this.dnsGrid.Columns[7].Header = Translate.fmt("lbl_downloaded"); this.dnsGrid.Columns[8].Header = Translate.fmt("lbl_program"); dnsGridExt = new DataGridExt(dnsGrid); dnsGridExt.Restore(App.GetConfig("GUI", "dnsGrid_Columns", "")); LogList = new ObservableCollection <DnsItem>(); dnsGrid.ItemsSource = LogList; textFilter = App.GetConfig("GUI", "DnsFilter", ""); txtDnsFilter.Text = textFilter; UwpFunc.AddBinding(dnsGrid, new KeyGesture(Key.F, ModifierKeys.Control), (s, e) => { this.txtDnsFilter.Focus(); }); CheckLogEntries(); }
public NetworkSocketList() { InitializeComponent(); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_all"), FirewallPage.FilterPreset.Socket.Any); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_web"), FirewallPage.FilterPreset.Socket.Web).Background = new SolidColorBrush(Colors.DodgerBlue); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_tcp"), FirewallPage.FilterPreset.Socket.TCP).Background = new SolidColorBrush(Colors.Turquoise); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_client"), FirewallPage.FilterPreset.Socket.Client).Background = new SolidColorBrush(Colors.Gold); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_server"), FirewallPage.FilterPreset.Socket.Server).Background = new SolidColorBrush(Colors.DarkOrange); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_udp"), FirewallPage.FilterPreset.Socket.UDP).Background = new SolidColorBrush(Colors.Violet); //WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_raw"), FirewallPage.FilterPreset.Socket.Raw); this.txtSockFilter.LabelText = Translate.fmt("lbl_text_filter"); //this.chkNoINet.ToolTip = Translate.fmt("str_no_inet"); //this.chkNoLAN.ToolTip = Translate.fmt("str_no_lan"); //this.chkNoMulti.ToolTip = Translate.fmt("str_no_multi"); //this.chkNoLocal.ToolTip = Translate.fmt("str_no_local"); this.socksGrid.Columns[1].Header = Translate.fmt("lbl_name"); this.socksGrid.Columns[2].Header = Translate.fmt("lbl_time_stamp"); this.socksGrid.Columns[3].Header = Translate.fmt("lbl_state"); this.socksGrid.Columns[4].Header = Translate.fmt("lbl_protocol"); this.socksGrid.Columns[5].Header = Translate.fmt("lbl_remote_ip"); this.socksGrid.Columns[6].Header = Translate.fmt("lbl_remote_port"); this.socksGrid.Columns[7].Header = Translate.fmt("lbl_local_ip"); this.socksGrid.Columns[8].Header = Translate.fmt("lbl_local_port"); this.socksGrid.Columns[9].Header = Translate.fmt("lbl_access"); this.socksGrid.Columns[10].Header = Translate.fmt("lbl_upload"); this.socksGrid.Columns[11].Header = Translate.fmt("lbl_download"); this.socksGrid.Columns[12].Header = Translate.fmt("lbl_uploaded"); this.socksGrid.Columns[13].Header = Translate.fmt("lbl_downloaded"); this.socksGrid.Columns[14].Header = Translate.fmt("lbl_program"); socksGridExt = new DataGridExt(socksGrid); socksGridExt.Restore(App.GetConfig("GUI", "socksGrid_Columns", "")); SocketList = new ObservableCollection <SocketItem>(); socksGrid.ItemsSource = SocketList; UwpFunc.AddBinding(socksGrid, new KeyGesture(Key.F, ModifierKeys.Control), (s, e) => { this.txtSockFilter.Focus(); }); //UwpFunc.AddBinding(socksGrid, new KeyGesture(Key.Delete), btnRemoveRule_Click); try { textFilter = App.GetConfig("NetSocks", "Filter", ""); txtSockFilter.Text = textFilter; WpfFunc.CmbSelect(sockType, ((FirewallPage.FilterPreset.Socket)App.GetConfigInt("NetSocks", "Types", 0)).ToString()); //this.chkNoLocal.IsChecked = App.GetConfigInt("NetSocks", "NoLocal", 0) == 1; //this.chkNoMulti.IsChecked = App.GetConfigInt("NetSocks", "NoMulti", 0) == 1; //this.chkNoLAN.IsChecked = App.GetConfigInt("NetSocks", "NoLan", 0) == 1; //this.chkNoINet.IsChecked = App.GetConfigInt("NetSocks", "NoINet", 0) == 1; } catch { } CheckSockets(); }
public void SetPage(FirewallPage page) { menuAdd.Click += page.btnAdd_Click; menuAddSub.Click += page.btnAddSub_Click; menuRemove.Click += page.btnRemove_Click; menuMerge.Click += page.btnMerge_Click; menuSplit.Click += page.btnSplit_Click; foreach (MenuItem item in menuAccess.Items) { item.Click += page.btnSetAccess_Click; } menuNotify.Click += page.ChkNotify_Click; menuRename.Click += page.BtnRename_Click; menuSetIcon.Click += page.BtnIcon_Click; menuCategory.Click += page.BtnCategory_Click; UwpFunc.AddBinding(treeView, new KeyGesture(Key.Delete), page.btnRemove_Click); }
public FirewallRuleList() { InitializeComponent(); /*this.grpRules.Header = Translate.fmt("grp_firewall"); * this.grpRuleTools.Header = Translate.fmt("grp_tools"); * this.grpRuleView.Header = Translate.fmt("grp_view"); * * this.btnCreateRule.Content = Translate.fmt("btn_mk_rule"); * this.btnEnableRule.Content = Translate.fmt("btn_enable_rule"); * this.btnDisableRule.Content = Translate.fmt("btn_disable_rule"); * this.btnRemoveRule.Content = Translate.fmt("btn_remove_rule"); * this.btnBlockRule.Content = Translate.fmt("btn_block_rule"); * this.btnAllowRule.Content = Translate.fmt("btn_allow_rule"); * this.btnEditRule.Content = Translate.fmt("btn_edit_rule"); * this.btnCloneRule.Content = Translate.fmt("btn_clone_rule");*/ //this.chkNoDisabled.Content = Translate.fmt("chk_hide_disabled"); //this.lblFilterRules.Content = Translate.fmt("lbl_filter_rules"); //this.lblFilter.Content = Translate.fmt("lbl_filter"); this.txtRuleFilter.LabelText = Translate.fmt("lbl_text_filter"); this.cmbAll.Content = Translate.fmt("str_all_actions"); this.cmbAllow.Content = Translate.fmt("str_allow"); this.cmbBlock.Content = Translate.fmt("str_block"); this.cmbBooth.Content = Translate.fmt("str_all_rules"); this.cmbIn.Content = Translate.fmt("str_inbound"); this.cmbOut.Content = Translate.fmt("str_outbound"); this.chkNoDisabled.ToolTip = Translate.fmt("str_no_disabled"); int i = 0; this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_name"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_group"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_index"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_status"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_count"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_profiles"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_action"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_direction"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_protocol"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_remote_ip"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_local_ip"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_remote_port"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_local_port"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_icmp"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_interfaces"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_edge"); this.rulesGrid.Columns[++i].Header = Translate.fmt("lbl_program"); RulesList = new ObservableCollection <RuleItem>(); rulesGrid.ItemsSource = RulesList; var contextMenu = new ContextMenu(); WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_mk_rule"), btnCreateRule_Click, TryFindResource("Icon_Plus")); contextMenu.Items.Add(new Separator()); menuEnableRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_enable_rule"), btnEnableRule_Click, TryFindResource("Icon_Enable")); menuDisableRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_disable_rule"), btnDisableRule_Click, TryFindResource("Icon_Disable")); contextMenu.Items.Add(new Separator()); menuBlockRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_block_rule"), btnBlockRule_Click, TryFindResource("Icon_Deny")); menuAllowRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_allow_rule"), btnAllowRule_Click, TryFindResource("Icon_Check")); contextMenu.Items.Add(new Separator()); menuRemoveRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_remove_rule"), btnRemoveRule_Click, TryFindResource("Icon_Remove")); menuEditRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_edit_rule"), btnEditRule_Click, TryFindResource("Icon_Edit")); menuCloneRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_clone_rule"), btnCloneRule_Click, TryFindResource("Icon_Clone")); contextMenu.Items.Add(new Separator()); menuApproveRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_approve_rule"), btnApproveRule_Click, TryFindResource("Icon_Approve")); menuRestoreRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_restore_rule"), btnRestoreRule_Click, TryFindResource("Icon_Undo")); menuRedoRule = WpfFunc.AddMenu(contextMenu, Translate.fmt("btn_redo_rule"), btnRedoRule_Click, TryFindResource("Icon_Redo")); rulesGrid.ContextMenu = contextMenu; rulesGridExt = new DataGridExt(rulesGrid); rulesGridExt.Restore(App.GetConfig("GUI", "rulesGrid_Columns", "")); UwpFunc.AddBinding(rulesGrid, new KeyGesture(Key.F, ModifierKeys.Control), (s, e) => { this.txtRuleFilter.Focus(); }); UwpFunc.AddBinding(rulesGrid, new KeyGesture(Key.Delete), btnRemoveRule_Click); try { textFilter = App.GetConfig("FwRules", "Filter", ""); txtRuleFilter.Text = textFilter; cmbAction.SelectedIndex = App.GetConfigInt("FwRules", "Actions", 0); cmbDirection.SelectedIndex = App.GetConfigInt("FwRules", "Directions", 0); this.chkNoDisabled.IsChecked = App.GetConfigInt("FwRules", "NoDisabled", 0) == 1; } catch { } CheckRules(); }
public FirewallLogList() { InitializeComponent(); //this.grpLog.Header = Translate.fmt("gtp_con_log"); /*this.grpLogTools.Header = Translate.fmt("grp_tools"); * this.grpLogView.Header = Translate.fmt("grp_view"); * * this.btnMkRule.Content = Translate.fmt("btn_mk_rule"); * this.btnClearLog.Content = Translate.fmt("btn_clear_log"); * this.lblShowCons.Content = Translate.fmt("lbl_show_cons"); * this.chkNoLocal.Content = Translate.fmt("chk_hide_local"); * this.chkNoLAN.Content = Translate.fmt("chk_hide_lan"); * this.lblFilterCons.Content = Translate.fmt("lbl_filter_cons");*/ this.txtConFilter.LabelText = Translate.fmt("lbl_text_filter"); this.cmbAll.Content = Translate.fmt("str_all_events"); this.cmbAllow.Content = Translate.fmt("str_allowed"); this.cmbBlock.Content = Translate.fmt("str_blocked"); this.chkNoINet.ToolTip = Translate.fmt("str_no_inet"); this.chkNoLAN.ToolTip = Translate.fmt("str_no_lan"); this.chkNoMulti.ToolTip = Translate.fmt("str_no_multi"); this.chkNoLocal.ToolTip = Translate.fmt("str_no_local"); this.logGrid.Columns[1].Header = Translate.fmt("lbl_name"); this.logGrid.Columns[2].Header = Translate.fmt("lbl_time_stamp"); this.logGrid.Columns[3].Header = Translate.fmt("lbl_action"); this.logGrid.Columns[4].Header = Translate.fmt("lbl_direction"); this.logGrid.Columns[5].Header = Translate.fmt("lbl_protocol"); this.logGrid.Columns[6].Header = Translate.fmt("lbl_remote_ip"); this.logGrid.Columns[7].Header = Translate.fmt("lbl_remote_port"); this.logGrid.Columns[8].Header = Translate.fmt("lbl_local_ip"); this.logGrid.Columns[9].Header = Translate.fmt("lbl_local_port"); this.logGrid.Columns[10].Header = Translate.fmt("lbl_program"); LogList = new ObservableCollection <LogItem>(); logGrid.ItemsSource = LogList; logGridExt = new DataGridExt(logGrid); logGridExt.Restore(App.GetConfig("FwLog", "Columns", "")); UwpFunc.AddBinding(logGrid, new KeyGesture(Key.F, ModifierKeys.Control), (s, e) => { this.txtConFilter.Focus(); }); try { textFilter = App.GetConfig("FwLog", "Filter", ""); txtConFilter.Text = textFilter; cmbConTypes.SelectedIndex = App.GetConfigInt("FwLog", "Events", 0); //this.chkAllowed.IsChecked = App.GetConfigInt("FwLog", "ShowAllowed", 1) == 1; //this.chkBlocked.IsChecked = App.GetConfigInt("FwLog", "ShowBlocked", 1) == 1; this.chkNoLocal.IsChecked = App.GetConfigInt("FwLog", "NoLocal", 0) == 1; this.chkNoMulti.IsChecked = App.GetConfigInt("FwLog", "NoMulti", 0) == 1; this.chkNoLAN.IsChecked = App.GetConfigInt("FwLog", "NoLan", 0) == 1; this.chkNoINet.IsChecked = App.GetConfigInt("FwLog", "NoINet", 0) == 1; } catch { } //mConLimit = App.engine.programs.MaxLogLength * 10; // todo logLimit = App.GetConfigInt("GUI", "LogLimit", 1000); CheckLogLines(); }
public FirewallLogList() { InitializeComponent(); //this.grpLog.Header = Translate.fmt("gtp_con_log"); /*this.grpLogTools.Header = Translate.fmt("grp_tools"); * this.grpLogView.Header = Translate.fmt("grp_view"); * * this.btnMkRule.Content = Translate.fmt("btn_mk_rule"); * this.btnClearLog.Content = Translate.fmt("btn_clear_log"); * this.lblShowCons.Content = Translate.fmt("lbl_show_cons"); * this.chkNoLocal.Content = Translate.fmt("chk_hide_local"); * this.chkNoLAN.Content = Translate.fmt("chk_hide_lan"); * this.lblFilterCons.Content = Translate.fmt("lbl_filter_cons");*/ this.txtConFilter.LabelText = Translate.fmt("lbl_text_filter"); this.cmbAll.Content = Translate.fmt("str_all_events"); this.cmbAllow.Content = Translate.fmt("str_allowed"); this.cmbBlock.Content = Translate.fmt("str_blocked"); this.chkNoINet.ToolTip = Translate.fmt("str_no_inet"); this.chkNoLAN.ToolTip = Translate.fmt("str_no_lan"); this.chkNoMulti.ToolTip = Translate.fmt("str_no_multi"); this.chkNoLocal.ToolTip = Translate.fmt("str_no_local"); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_protocols_any"), FirewallPage.FilterPreset.Socket.Any); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_web"), FirewallPage.FilterPreset.Socket.Web).Background = new SolidColorBrush(Colors.DodgerBlue); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_tcp"), FirewallPage.FilterPreset.Socket.TCP).Background = new SolidColorBrush(Colors.Turquoise); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_client"), FirewallPage.FilterPreset.Socket.Client).Background = new SolidColorBrush(Colors.Gold); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_server"), FirewallPage.FilterPreset.Socket.Server).Background = new SolidColorBrush(Colors.DarkOrange); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_sockets_udp"), FirewallPage.FilterPreset.Socket.UDP).Background = new SolidColorBrush(Colors.Violet); WpfFunc.CmbAdd(sockType, Translate.fmt("filter_protocols_other"), FirewallPage.FilterPreset.Socket.Other).Background = new SolidColorBrush(Colors.LightGray); int i = 0; this.logGrid.Columns[++i].Header = Translate.fmt("lbl_name"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_time_stamp"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_action"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_direction"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_protocol"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_remote_ip"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_remote_port"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_local_ip"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_local_port"); this.logGrid.Columns[++i].Header = Translate.fmt("lbl_program"); LogList = new ObservableCollection <LogItem>(); logGrid.ItemsSource = LogList; logGridExt = new DataGridExt(logGrid); logGridExt.Restore(App.GetConfig("FwLog", "Columns", "")); UwpFunc.AddBinding(logGrid, new KeyGesture(Key.F, ModifierKeys.Control), (s, e) => { this.txtConFilter.Focus(); }); try { textFilter = App.GetConfig("FwLog", "Filter", ""); txtConFilter.Text = textFilter; cmbConTypes.SelectedIndex = App.GetConfigInt("FwLog", "Events", 0); WpfFunc.CmbSelect(sockType, ((FirewallPage.FilterPreset.Socket)App.GetConfigInt("FwLog", "Types", 0)).ToString()); //this.chkAllowed.IsChecked = App.GetConfigInt("FwLog", "ShowAllowed", 1) == 1; //this.chkBlocked.IsChecked = App.GetConfigInt("FwLog", "ShowBlocked", 1) == 1; this.chkNoLocal.IsChecked = App.GetConfigInt("FwLog", "NoLocal", 0) == 1; this.chkNoMulti.IsChecked = App.GetConfigInt("FwLog", "NoMulti", 0) == 1; this.chkNoLAN.IsChecked = App.GetConfigInt("FwLog", "NoLan", 0) == 1; this.chkNoINet.IsChecked = App.GetConfigInt("FwLog", "NoINet", 0) == 1; } catch { } //mConLimit = App.engine.programs.MaxLogLength * 10; // todo logLimit = App.GetConfigInt("GUI", "LogLimit", 1000); CheckLogLines(); }