Esempio n. 1
0
        private async void button4_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                await WriteToFile("# Hosts reset by AdBlockerWP");

                StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
                RPCManager    RPC   = new RPCManager();
                RPC.Start();
                CSilentInstallerRuntime NrsCopy = new CSilentInstallerRuntime();
                bool didFinish = NrsCopy.NRSCopyFile(local.Path + "\\DataFolder\\hosts.txt", "C:\\Windows\\System32\\DRIVERS\\ETC\\HOSTS");
                if (didFinish == bool.Parse("true"))
                {
                    progress.Items.Add("Finished unblocking ads...");
                }
                else
                {
                    progress.Items.Add("Error writing to hosts file... (Are you interop-unlocked?)...");
                }
            }
            catch
            {
                MessageBox.Show("You must be Interop-Unlocked with all Capabilities unlocked as well to use this app!", "Not unlocked!", MessageBoxButton.OK);
            }
        }
Esempio n. 2
0
 private void saveBtn_Click(object sender, RoutedEventArgs e)
 {
     //await WriteToFile(hostsText.Text);
     StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
     RPCManager RPC = new RPCManager();
     RPC.Start();
     CSilentInstallerRuntime NrsCopy = new CSilentInstallerRuntime();
     bool didFinish = NrsCopy.NRSCopyFile(local.Path + "\\DataFolder\\hosts.txt", "C:\\Windows\\System32\\DRIVERS\\ETC\\HOSTS");
     if (didFinish == bool.Parse("true"))
     {
         MessageBox.Show("Hosts file saved!", "Saved!", MessageBoxButton.OK);
         NavigationService.GoBack();
     }
     else
     {
         MessageBox.Show("Could not save Hosts File....", "Uh-Oh!", MessageBoxButton.OK);
     }
 }
Esempio n. 3
0
        private void saveBtn_Click(object sender, RoutedEventArgs e)
        {
            //await WriteToFile(hostsText.Text);
            StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
            RPCManager    RPC   = new RPCManager();

            RPC.Start();
            CSilentInstallerRuntime NrsCopy = new CSilentInstallerRuntime();
            bool didFinish = NrsCopy.NRSCopyFile(local.Path + "\\DataFolder\\hosts.txt", "C:\\Windows\\System32\\DRIVERS\\ETC\\HOSTS");

            if (didFinish == bool.Parse("true"))
            {
                MessageBox.Show("Hosts file saved!", "Saved!", MessageBoxButton.OK);
                NavigationService.GoBack();
            }
            else
            {
                MessageBox.Show("Could not save Hosts File....", "Uh-Oh!", MessageBoxButton.OK);
            }
        }
Esempio n. 4
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                progress.Items.Clear();
                progress.Items.Add("Downloading config now....");
                //progress.Items.Add("Downloading first hosts file...");
                //string host1 = await GetString("https://adaway.org/hosts.txt");
                //if (host1.Contains("Response status code"))
                //{
                //    host1 = "";
                //    progress.Items.Add("Error with first file...");
                //}
                //progress.Items.Add("Downloading second hosts file...");
                //string host2 = await GetString("https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts");
                //if (host2.Contains("Response status code"))
                //{
                //    host2 = "";
                //    progress.Items.Add("Error with second file...");
                //}
                StringBuilder UserHosts = new StringBuilder();
                StorageFolder userList  = Windows.Storage.ApplicationData.Current.LocalFolder;
                int           counter   = 0;
                string        line;
                // Read the file and display it line by line.
                System.IO.StreamReader file =
                    new System.IO.StreamReader(userList.Path + "\\DataFolder\\userList.txt");
                while ((line = file.ReadLine()) != null)
                {
                    progress.Items.Add("Downloading " + line);
                    string tempLines = await GetString(line);

                    if (tempLines.Contains("Response status code"))
                    {
                        tempLines = "";
                        progress.Items.Add("Error encountered while downloading " + line);
                    }
                    UserHosts.Append(tempLines).AppendLine();
                    counter++;
                }

                file.Close();

                await WriteToFile(UserHosts.ToString());

                string readFile1 = await ReadFile();

                StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
                //StorageFolder hosts = "C:\\Windows\\System32\\DRIVERS\\etc";
                //NRSCopyFile(local.Path.ToString + "DataFolder\hosts.txt", "\Windows\System32\DRIVERS\etc\HOSTS");
                //File.Copy(local.Path + "\\DataFolder\\hosts.txt", "C:\\Windows\\System32\\DRIVERS\\ETC\\HOSTS",true);
                RPCManager RPC = new RPCManager();
                RPC.Start();
                CSilentInstallerRuntime NrsCopy = new CSilentInstallerRuntime();
                bool didFinish = NrsCopy.NRSCopyFile(local.Path + "\\DataFolder\\hosts.txt", "C:\\Windows\\System32\\DRIVERS\\ETC\\HOSTS");
                if (didFinish == bool.Parse("true"))
                {
                    String report = "Downloaded " + counter + " URLs";
                    progress.Items.Add(report);
                    progress.Items.Add("FINISHED!");
                }
                else
                {
                    progress.Items.Add("ERROR while coping to HOSTS (Are you Interop/Cap Unlocked?)");
                }

                //MessageBox.Show("Here is your new hosts file:" + Environment.NewLine + readFile1, "Finished", MessageBoxButton.OK);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButton.OK);
                progress.Items.Add("Errors during compilation:");
                progress.Items.Add(ex.Message);
            }
        }
Esempio n. 5
0
        private async void button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                progress.Items.Clear();
                progress.Items.Add("Downloading config now....");
                //progress.Items.Add("Downloading first hosts file...");
                //string host1 = await GetString("https://adaway.org/hosts.txt");
                //if (host1.Contains("Response status code"))
                //{
                //    host1 = "";
                //    progress.Items.Add("Error with first file...");
                //}
                //progress.Items.Add("Downloading second hosts file...");
                //string host2 = await GetString("https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts");
                //if (host2.Contains("Response status code"))
                //{
                //    host2 = "";
                //    progress.Items.Add("Error with second file...");
                //}
                StringBuilder UserHosts = new StringBuilder();
                StorageFolder userList = Windows.Storage.ApplicationData.Current.LocalFolder;
                int counter = 0;
                string line;
                // Read the file and display it line by line.
                System.IO.StreamReader file =
                   new System.IO.StreamReader(userList.Path + "\\DataFolder\\userList.txt");
                while ((line = file.ReadLine()) != null)
                {
                    progress.Items.Add("Downloading " + line);
                    string tempLines = await GetString(line);
                    if (tempLines.Contains("Response status code"))
                    {
                        tempLines = "";
                        progress.Items.Add("Error encountered while downloading " + line);
                    }
                    UserHosts.Append(tempLines).AppendLine();
                    counter++;
                }

                file.Close();

                await WriteToFile(UserHosts.ToString());
                string readFile1 = await ReadFile();
                StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
                //StorageFolder hosts = "C:\\Windows\\System32\\DRIVERS\\etc";
                //NRSCopyFile(local.Path.ToString + "DataFolder\hosts.txt", "\Windows\System32\DRIVERS\etc\HOSTS");
                //File.Copy(local.Path + "\\DataFolder\\hosts.txt", "C:\\Windows\\System32\\DRIVERS\\ETC\\HOSTS",true);
                RPCManager RPC = new RPCManager();
                RPC.Start();
                CSilentInstallerRuntime NrsCopy = new CSilentInstallerRuntime();
                bool didFinish = NrsCopy.NRSCopyFile(local.Path + "\\DataFolder\\hosts.txt", "C:\\Windows\\System32\\DRIVERS\\ETC\\HOSTS");
                if(didFinish == bool.Parse("true"))
                {
                    String report = "Downloaded " + counter + " URLs";
                    progress.Items.Add(report);
                    progress.Items.Add("FINISHED!");
                } else
                {
                    progress.Items.Add("ERROR while coping to HOSTS (Are you Interop/Cap Unlocked?)");
                }
               
                //MessageBox.Show("Here is your new hosts file:" + Environment.NewLine + readFile1, "Finished", MessageBoxButton.OK);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR",MessageBoxButton.OK);
                progress.Items.Add("Errors during compilation:");
                progress.Items.Add(ex.Message);
            }
        }
Esempio n. 6
0
 private async void button4_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         await WriteToFile("# Hosts reset by AdBlockerWP");
         StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
         RPCManager RPC = new RPCManager();
         RPC.Start();
         CSilentInstallerRuntime NrsCopy = new CSilentInstallerRuntime();
         bool didFinish = NrsCopy.NRSCopyFile(local.Path + "\\DataFolder\\hosts.txt", "C:\\Windows\\System32\\DRIVERS\\ETC\\HOSTS");
         if (didFinish == bool.Parse("true"))
         {
             progress.Items.Add("Finished unblocking ads...");
         }
         else
         {
             progress.Items.Add("Error writing to hosts file... (Are you interop-unlocked?)...");
         }
     }
     catch
     {
         MessageBox.Show("You must be Interop-Unlocked with all Capabilities unlocked as well to use this app!", "Not unlocked!", MessageBoxButton.OK);
     }
 }