コード例 #1
0
ファイル: Frontend.cs プロジェクト: hatstand0/ME3PSE
 public static bool IsRedirectionActive()
 {
     try
     {
         int           count = 0;
         List <string> r     = new List <string>(File.ReadAllLines(loc + "conf\\redirect.txt"));
         List <string> h     = new List <string>(File.ReadAllLines(sysdir + @"drivers\etc\hosts"));
         foreach (string url in r)
         {
             for (int i = (h.Count - 1); i >= 0; i--)
             {
                 if (h[i].EndsWith(url) && !h[i].StartsWith("#"))
                 {
                     count++;
                 }
             }
         }
         if (count > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.Print("IsRedirectionActive | Error:\n" + ME3Server.GetExceptionMessage(ex));
         return(false);
     }
 }
コード例 #2
0
ファイル: Frontend.cs プロジェクト: hatstand0/ME3PSE
 public static void DeactivateRedirection(bool bShowMsg = true)
 {
     try
     {
         List <string> r = new List <string>(File.ReadAllLines(loc + "conf\\redirect.txt"));
         List <string> h = new List <string>(File.ReadAllLines(sysdir + @"drivers\etc\hosts"));
         foreach (string url in r)
         {
             for (int i = (h.Count - 1); i >= 0; i--)
             {
                 if (h[i].EndsWith(url) && !h[i].StartsWith("#"))
                 {
                     h.RemoveAt(i);
                 }
             }
         }
         File.WriteAllLines(sysdir + @"drivers\etc\hosts", h);
         if (bShowMsg)
         {
             MessageBox.Show("Done.", "Deactivate Redirection");
         }
     }
     catch (Exception ex)
     {
         if (bShowMsg)
         {
             MessageBox.Show("Error:\n" + ME3Server.GetExceptionMessage(ex), "Deactivate Redirection");
         }
         else
         {
             System.Diagnostics.Debug.Print("DeactivateRedirection | " + ME3Server.GetExceptionMessage(ex));
         }
     }
 }
コード例 #3
0
ファイル: Frontend.cs プロジェクト: hatstand0/ME3PSE
 private void showContentToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         MessageBox.Show(File.ReadAllText(sysdir + @"drivers\etc\hosts"), "Show Content");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error:\n" + ME3Server.GetExceptionMessage(ex), "Show Content");
     }
 }
コード例 #4
0
ファイル: Frontend.cs プロジェクト: hatstand0/ME3PSE
        private void importPlayerSettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool activePlayer = false;

            foreach (Player.PlayerInfo p in Player.AllPlayers)
            {
                activePlayer |= p.isActive;
            }
            if (!activePlayer)
            {
                MessageBox.Show("You must be already connected through PSE before using this function.", "Import player settings");
                return;
            }

            OpenFileDialog o = new OpenFileDialog();

            o.Filter = "*.txt|*.txt";
            if (o.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            try
            {
                List <string> Lines = new List <string>(System.IO.File.ReadAllLines(o.FileName));
                if (Lines.Count < 6)
                {
                    Logger.Log("[Import player settings] Invalid player file (number of lines)", Color.Red);
                    return;
                }
                Lines.RemoveRange(0, 5);
                List <string> keys   = new List <string>();
                List <string> values = new List <string>();
                foreach (string line in Lines)
                {
                    string[] s = line.Split(Char.Parse("="));
                    if (s.Length != 2)
                    {
                        Logger.Log("[Import player settings] Invalid player file (line split)", Color.Red);
                        return;
                    }
                    keys.Add(s[0]);
                    values.Add(s[1]);
                }
                ME3Server.importKeys   = keys;
                ME3Server.importValues = values;
            }
            catch (Exception ex)
            {
                Logger.Log("[Import player settings] " + ME3Server.GetExceptionMessage(ex), Color.Red);
            }
        }
コード例 #5
0
 public static bool EnableSSL3Server()
 {
     try
     {
         Registry.SetValue(ssl3serverpath, "Enabled", 1, RegistryValueKind.DWord);
         return(true);
     }
     catch (Exception ex)
     {
         Logger.Log("[EnableSSL3Server]\n" + ME3Server.GetExceptionMessage(ex), Color.Red);
         return(false);
     }
 }
コード例 #6
0
ファイル: Frontend.cs プロジェクト: hatstand0/ME3PSE
 public static void ActivateRedirection(string hostIP)
 {
     DeactivateRedirection(false);
     try
     {
         List <string> r = new List <string>(File.ReadAllLines(loc + "conf\\redirect.txt"));
         List <string> h = new List <string>(File.ReadAllLines(sysdir + @"drivers\etc\hosts"));
         foreach (string url in r)
         {
             string s = hostIP + " " + url;
             if (!h.Contains(s))
             {
                 h.Add(s);
             }
         }
         File.WriteAllLines(sysdir + @"drivers\etc\hosts", h);
         MessageBox.Show("Done.", "Activate Redirection");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error:\n" + ME3Server.GetExceptionMessage(ex), "Activate Redirection");
     }
 }
コード例 #7
0
ファイル: Frontend.cs プロジェクト: hatstand0/ME3PSE
        public static void PatchGame()
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "masseffect3.exe|masseffect3.exe";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    string path = Path.GetDirectoryName(d.FileName);
                    File.Copy(loc + "patch\\binkw32.dll", path + "\\binkw32.dll", true);
                    File.Copy(loc + "patch\\binkw23.dll", path + "\\binkw23.dll", true);
                    if (File.Exists(loc + "patch\\MassEffect3.exe"))
                    {
                        File.Copy(loc + "patch\\MassEffect3.exe", path + "\\MassEffect3.exe", true);
                    }
                    MessageBox.Show("Done.");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error:\n" + ME3Server.GetExceptionMessage(ex));
                }
            }
        }