示例#1
0
 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
 static void Main()
 {
     if (ME3Server.IsRunningAsAdmin())
     {
         string[] commandlineargs = System.Environment.GetCommandLineArgs();
         ME3Server.silentStart = commandlineargs.Contains("-silentstart", StringComparer.InvariantCultureIgnoreCase);
         ME3Server.silentExit  = commandlineargs.Contains("-silentexit", StringComparer.InvariantCultureIgnoreCase);
         if (commandlineargs.Contains("-deactivateonly", StringComparer.InvariantCultureIgnoreCase))
         {
             Frontend.DeactivateRedirection();
         }
         else
         {
             Application.EnableVisualStyles();
             Application.SetCompatibleTextRenderingDefault(false);
             Application.Run(new Frontend());
             //Application.Run(new GUI_PacketEditor());
             //Application.Run(new GUI_ProfileCreator());
         }
     }
     else
     {
         MessageBox.Show("This program requires administrator rights.", "ME3Server_WV", MessageBoxButtons.OK, MessageBoxIcon.Stop);
     }
 }
示例#3
0
 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));
         }
     }
 }
示例#4
0
 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");
     }
 }
示例#5
0
        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);
            }
        }
示例#6
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);
     }
 }
示例#7
0
 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");
     }
 }
示例#8
0
        public static PlayerFileProfile GetFromFile(string path)
        {
            PlayerFileProfile res = new PlayerFileProfile();

            string[] lines = File.ReadAllLines(path);
            foreach (string line in lines)
            {
                string[] parts = line.Split('=');
                if (parts.Length == 2)
                {
                    switch (parts[0].Trim())
                    {
                    case "PID":
                        res.PID = ME3Server.ConvertHex(parts[1].Trim());
                        break;

                    case "UID":
                        res.UID = ME3Server.ConvertHex(parts[1].Trim());
                        break;

                    case "AUTH":
                        res.AUTH = parts[1].Trim();
                        break;

                    case "AUTH2":
                        res.AUTH2 = parts[1].Trim();
                        break;

                    case "DSNM":
                        res.NAME = parts[1].Trim();
                        break;
                    }
                }
            }
            return(res);
        }
示例#9
0
        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));
                }
            }
        }
示例#10
0
 private void GUI_Log_FormClosing(object sender, FormClosingEventArgs e)
 {
     ME3Server.Stop();
 }
示例#11
0
 private void GUI_Log_Load(object sender, EventArgs e)
 {
     Logger.box = rtb1;
     ME3Server.Start();
 }
示例#12
0
 private void Frontend_Shown(object sender, EventArgs e)
 {
     ME3Server.Start();
 }
示例#13
0
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode t = e.Node;

            if (t != null && t.Name != "")
            {
                int       n   = Convert.ToInt32(t.Name);
                Blaze.Tdf tdf = inlist[n];
                string    s;
                switch (tdf.Type)
                {
                case 0:
                    Blaze.TdfInteger ti = (Blaze.TdfInteger)tdf;
                    rtb1.Text = "0x" + ti.Value.ToString("X");
                    if (ti.Label == "IP  ")
                    {
                        rtb1.Text += Environment.NewLine + "(" + ME3Server.GetStringFromIP(ti.Value) + ")";
                    }
                    break;

                case 1:
                    rtb1.Text = ((Blaze.TdfString)tdf).Value.ToString();
                    break;

                case 2:
                    rtb1.Text  = "Length: " + ((Blaze.TdfBlob)tdf).Data.Length.ToString();
                    rtb1.Text += Environment.NewLine + Blaze.HexDump(((Blaze.TdfBlob)tdf).Data);
                    break;

                case 4:
                    Blaze.TdfList l = (Blaze.TdfList)tdf;
                    s = "";
                    for (int i = 0; i < l.Count; i++)
                    {
                        switch (l.SubType)
                        {
                        case 0:
                            s += "{" + ((List <long>)l.List)[i] + "} ";
                            break;

                        case 1:
                            s += "{" + ((List <string>)l.List)[i] + "} ";
                            break;

                        case 9:
                            Blaze.TrippleVal t2 = ((List <Blaze.TrippleVal>)l.List)[i];
                            s += "{" + t2.v1.ToString("X") + "; " + t2.v2.ToString("X") + "; " + t2.v3.ToString("X") + "} ";
                            break;
                        }
                    }
                    rtb1.Text = s;
                    break;

                case 5:
                    s = "";
                    Blaze.TdfDoubleList ll = (Blaze.TdfDoubleList)tdf;
                    for (int i = 0; i < ll.Count; i++)
                    {
                        s += "{";
                        switch (ll.SubType1)
                        {
                        case 0:
                            List <long> l1 = (List <long>)ll.List1;
                            s += l1[i].ToString("X");
                            break;

                        case 1:
                            List <string> l2 = (List <string>)ll.List1;
                            s += l2[i];
                            break;

                        case 0xA:
                            List <float> lf1 = (List <float>)ll.List1;
                            s += lf1[i].ToString();
                            break;

                        default:
                            s += "(see List1[" + i + "])";
                            break;
                        }
                        s += " ; ";
                        switch (ll.SubType2)
                        {
                        case 0:
                            List <long> l1 = (List <long>)ll.List2;
                            s += l1[i].ToString("X");
                            break;

                        case 1:
                            List <string> l2 = (List <string>)ll.List2;
                            s += l2[i];
                            break;

                        case 0xA:
                            List <float> lf1 = (List <float>)ll.List2;
                            s += lf1[i].ToString();
                            break;

                        default:
                            s += "(see List2[" + i + "])";
                            break;
                        }
                        s += "}\n";
                    }
                    rtb1.Text = s;
                    break;

                case 6:
                    rtb1.Text = "Type: 0x" + ((Blaze.TdfUnion)tdf).UnionType.ToString("X2");
                    break;

                case 7:
                    Blaze.TdfIntegerList til = (Blaze.TdfIntegerList)tdf;
                    s = "";
                    for (int i = 0; i < til.Count; i++)
                    {
                        s += til.List[i].ToString("X");
                        if (i < til.Count - 1)
                        {
                            s += "; ";
                        }
                    }
                    rtb1.Text = s;
                    break;

                case 8:
                    Blaze.TdfDoubleVal dval = (Blaze.TdfDoubleVal)tdf;
                    rtb1.Text = "0x" + dval.Value.v1.ToString("X") + " 0x" + dval.Value.v2.ToString("X");
                    break;

                case 9:
                    Blaze.TdfTrippleVal tval = (Blaze.TdfTrippleVal)tdf;
                    rtb1.Text = "0x" + tval.Value.v1.ToString("X") + " 0x" + tval.Value.v2.ToString("X") + " 0x" + tval.Value.v3.ToString("X");
                    break;

                default:
                    rtb1.Text = "";
                    break;
                }
            }
        }