Example #1
0
        private void BtnOK_Click(object sender, RoutedEventArgs e)
        {
            bool Restart = false;

            if (chkAutoStart.IsChecked == true)
            {
                App.SetConfig("Startup", "Tray", true);
                App.TrayIcon.Visible = true;

                App.AutoStart(true);
                if (chkService.IsChecked == true)
                {
                    Priv10Service.Install();
                    App.Log.SetupEventLog(App.Key);
                    Restart = true;
                }
            }
            if (chkNoUAC.IsChecked == true)
            {
                AdminFunc.SkipUacEnable(App.Key, true);
            }

            if (chkUseFW.IsChecked == true)
            {
                App.SetConfig("Firewall", "Enabled", 1);

                FirewallManager.FilteringModes Mode = FirewallManager.FilteringModes.WhiteList;
                App.SetConfig("Firewall", "Mode", Mode.ToString());
                App.client.SetFilteringMode(Mode);

                FirewallMonitor.Auditing audit = FirewallMonitor.Auditing.All;
                App.SetConfig("Firewall", "AuditPol", audit.ToString());
                App.client.SetAuditPolicy(audit);

                App.SetConfig("Firewall", "NotifyConnections", chkNotifyFW.IsChecked == true ? 1 : 0);

                if (!App.client.IsConnected())
                {
                    App.StartEngine();
                    App.client.Connect();
                }
            }

            App.SetConfig("Startup", "ShowSetup", 0);
            if (Restart)
            {
                App.Restart();
            }
            this.DialogResult = true;
        }
Example #2
0
        private void chkService_Click(object sender, RoutedEventArgs e)
        {
            if (bHold)
            {
                return;
            }

            if (!AdminFunc.IsAdministrator())
            {
                if (MessageBox.Show(Translate.fmt("msg_admin_prompt", App.Title), App.Title, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    App.Restart(true);
                }
                return;
            }

            if (chkService.IsChecked == true)
            {
                if (App.EngineProc != null)
                {
                    App.StopEngine();
                }

                Priv10Service.Install(true);
                App.Log.SetupEventLog(App.Key);
                App.client.Connect();
            }
            else
            {
                App.client.Close();

                Priv10Service.Terminate();
                Priv10Service.Uninstall();

                if (App.EngineProc == null && App.GetConfigInt("Firewall", "Enabled", 0) != 0)
                {
                    App.StartEngine();
                    App.client.Connect();
                }
            }


            App.MainWnd.UpdateEnabled();
        }
Example #3
0
        public void OnShow()
        {
            string running = Translate.fmt("lbl_run_as", Translate.fmt(AdminFunc.IsAdministrator() ? "str_admin" : "str_user"));

            if (Priv10Service.IsInstalled())
            {
                running += Translate.fmt("lbl_run_svc");
            }
            lblRunning.Content = running;

            lblFirewallInfo.Content = Translate.fmt((App.GetConfigInt("Firewall", "Enabled", 0) != 0) ? "str_enabled" : "str_disabled");
            // filterming mode
            // current profile
            lblRuleGuardInfo.Content = Translate.fmt(App.client.IsFirewallGuard() ? "str_enabled" : "str_disabled");
            // changed rules

            lblTweakGuardInfo.Content = Translate.fmt(App.GetConfigInt("TweakGuard", "AutoCheck", 1) != 0 ? "str_enabled" : "str_disabled");
            // mode
            // changed tweaks
        }
Example #4
0
        public void Refresh()
        {
            bHold = true;

            chkTray.IsChecked      = App.GetConfigInt("Startup", "Tray", 1) != 0;
            chkAutoStart.IsChecked = App.IsAutoStart();
            chkService.IsChecked   = Priv10Service.IsInstalled();
            chkNoUAC.IsChecked     = AdminFunc.IsSkipUac(App.Key);

            chkTweakCheck.IsChecked = App.GetConfigInt("TweakGuard", "AutoCheck", 1) != 0;
            chkTweakFix.IsEnabled   = chkTweakCheck.IsChecked == true;
            chkTweakFix.IsChecked   = App.GetConfigInt("TweakGuard", "AutoFix", 0) != 0;

            chkUseFW.IsChecked = App.GetConfigInt("Firewall", "Enabled", 0) != 0;

            if (App.client.IsConnected())
            {
                var mode = App.client.GetFilteringMode();

                radWhitelist.IsChecked = mode == FirewallManager.FilteringModes.WhiteList;
                radBlacklist.IsChecked = mode == FirewallManager.FilteringModes.BlackList;
                radDisabled.IsChecked  = mode == FirewallManager.FilteringModes.NoFiltering;

                var pol = App.client.GetAuditPolicy();
                switch (pol)
                {
                case FirewallMonitor.Auditing.All: cmbAudit.SelectedItem = lblAuditAll; break;

                case FirewallMonitor.Auditing.Blocked: cmbAudit.SelectedItem = lblAuditBlock; break;

                default: cmbAudit.SelectedItem = lblAuditNone; break;
                }

                chkGuardFW.IsEnabled = chkUseFW.IsChecked == true;
                chkGuardFW.IsChecked = App.client.IsFirewallGuard();

                chkEnableDNS.IsChecked = App.GetConfigInt("DnsProxy", "Enabled", 0) != 0;
            }
            else
            {
                chkUseFW.IsEnabled = false;

                radWhitelist.IsEnabled = false;
                radBlacklist.IsEnabled = false;
                radDisabled.IsEnabled  = false;
                cmbAudit.IsEnabled     = false;

                chkGuardFW.IsEnabled = false;

                chkEnableDNS.IsEnabled = false;
            }

            var fix_mode = App.GetConfigInt("Firewall", "GuardMode", 0);

            radFix.IsChecked     = fix_mode == (int)FirewallGuard.Mode.Fix;
            radDisable.IsChecked = fix_mode == (int)FirewallGuard.Mode.Disable;
            radAlert.IsChecked   = fix_mode == (int)FirewallGuard.Mode.Alert;

            radFix.IsEnabled = radDisable.IsEnabled = radAlert.IsEnabled = (chkGuardFW.IsChecked != false && chkGuardFW.IsEnabled);


            chkNotifyFW.IsEnabled = chkUseFW.IsChecked == true;
            chkNotifyFW.IsChecked = App.GetConfigInt("Firewall", "NotifyConnections", 1) != 0;

            chkDnsInspector.IsChecked = App.GetConfigInt("DnsInspector", "Enabled", 0) != 0;

            chkReverseDNS.IsChecked = App.GetConfigInt("DnsInspector", "UseReverseDNS", 0) != 0;

            // DNS
            chkLocalDNS.IsChecked = App.GetConfigInt("DnsProxy", "SetLocal", 0) != 0;
            string UpstreamDNS = App.GetConfig("DNSProxy", "UpstreamDNS", "8.8.8.8");

            if (!WpfFunc.CmbSelect(cmbRootDNS, UpstreamDNS))
            {
                cmbRootDNS.Text = UpstreamDNS;
            }
            CheckDNS();

            //this.btnBackup.IsEnabled = this.btnRestore.IsEnabled = !App.isPortable;

            bHold = false;
        }
Example #5
0
        public static void Main(string[] args)
        {
            App.args = args;

            HasConsole = WinConsole.Initialize(TestArg("-console"));

            if (TestArg("-dbg_wait"))
            {
                MessageBox.Show("Waiting for debugger. (press ok when attached)");
            }

            if (TestArg("-dbg_log"))
            {
                AppDomain.CurrentDomain.FirstChanceException += FirstChanceExceptionHandler;
            }

            StartModes startMode = StartModes.Normal; // Normal GUI Mode

            if (TestArg("-svc"))
            {
                startMode = StartModes.Service;
            }
            else if (TestArg("-engine"))
            {
                startMode = StartModes.Engine;
            }

            Log = new AppLog(Key);
            AppLog.ExceptionLogID    = (long)Priv10Logger.EventIDs.Exception;
            AppLog.ExceptionCategory = (short)Priv10Logger.EventFlags.DebugEvents;

            // When running as worker we need the windows event log
            if (!Log.UsingEventLog())
            {
                Log.SetupEventLog(Key);
            }

            // load current version
            exePath = Process.GetCurrentProcess().MainModule.FileName; //System.Reflection.Assembly.GetExecutingAssembly().Location;
            //*FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(exePath);
            //Version = fvi.FileMajorPart + "." + fvi.FileMinorPart;
            //if (fvi.FileBuildPart != 0)
            //    Version += "." + fvi.FileBuildPart;
            //if (fvi.FilePrivatePart != 0)
            //    Version += (char)('a' + (fvi.FilePrivatePart - 1));
            appPath = Path.GetDirectoryName(exePath);

            dataPath = appPath + @"\Data";
            if (File.Exists(GetINIPath())) // if an ini exists in the app path, its considdered to be a portable run
            {
                isPortable = true;

                AppLog.Debug("Portable Mode");
            }
            else
            {
                string progData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                if (progData == null)
                {
                    progData = @"C:\ProgramData";
                }

                dataPath = progData + "\\" + Key;
            }

            AppLog.Debug("Config Directory: {0}", dataPath);

            if (!Directory.Exists(dataPath))
            {
                Directory.CreateDirectory(dataPath);
            }
            if (AdminFunc.IsAdministrator())
            {
                FileOps.SetAnyDirSec(dataPath);
            }

            Priv10Logger.LogInfo("PrivateWin10 Service Process Started, Mode {0}.", startMode.ToString());

            // setup custom assembly resolution for x86/x64 synamic compatybility
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveHandler;

            // is the process starting as a service/worker?
            if (startMode != StartModes.Normal)
            {
                engine = new Priv10Engine();
                if (startMode == StartModes.Service)
                {
                    using (Priv10Service svc = new Priv10Service())
                        ServiceBase.Run(svc);
                }
                else
                {
                    engine.Run();
                }
                return;
            }
        }