Beispiel #1
0
        private void PopulateWindow()
        {
            FormBorderStyle = FormBorderStyle.FixedSingle;
            MaximizeBox     = false;
            Text            = "RotMG Tool";
            Size            = new Size(600, 400);
            Font            = new Font("Segoe UI", 9);
            Shown          += OnShown;

            // log box

            logBox             = new RichTextBox();
            logBox.BackColor   = Color.White;
            logBox.ForeColor   = Color.Black;
            logBox.BorderStyle = BorderStyle.None;
            logBox.Cursor      = Cursors.Default;
            logBox.ReadOnly    = true;
            logBox.Dock        = DockStyle.Fill;
            Controls.Add(logBox);

            // status bar
            var status = new StatusStrip();

            status.RenderMode = ToolStripRenderMode.ManagerRenderMode;
            status.Dock       = DockStyle.Bottom;
            status.SizingGrip = false;
            Controls.Add(status);

            proxyLink        = new ToolStripStatusLabel();
            proxyLink.IsLink = true;
            var ctxMenu = new ContextMenuStrip
            {
                Items =
                {
                    new ToolStripMenuItem("Copy AGC Loader link...", null, (sender, e) =>
                    {
                        string link = new Uri(new Uri(proxyLink.Text),"/RotMG").AbsoluteUri;
                        Clipboard.SetText(link);
                        AppendLog("Link copyed to clipboard.");
                    })
                }
            };

            proxyLink.MouseUp += (sender, e) =>
            {
                if (e.Button == MouseButtons.Right)
                {
                    ctxMenu.Show(MousePosition);
                }
                else if (e.Button == MouseButtons.Left)
                {
                    Process.Start(proxyLink.Text);
                }
            };
            status.Items.Add(proxyLink);

            // tool bar

            var toolBar = new ToolStrip();

            toolBar.Items.Add(new ToolStripButton("Clear Log", null, (sender, e) => { logBox.Clear(); }));
            toolBar.Items.Add(new ToolStripButton("Reload word list", null, (sender, e) =>
            {
                Filter.LoadWordList();
                AppendLog("Word list reloaded.");
            }));
            toolBar.Items.Add(new ToolStripButton("Reload settings", null, (sender, e) =>
            {
                Settings = new SimpleSettings();
                AppendLog("Settings reloaded.");
            }));
            windowDropDown = new ToolStripDropDownButton("Info Windows", null);
            toolBar.Items.Add(windowDropDown);

            toolBar.Dock = DockStyle.Top;
            Controls.Add(toolBar);
            toolBar.PerformLayout();
        }
Beispiel #2
0
        private void Initialize()
        {
            AppendLog("RotMG Tool initializing...");

            try
            {
                Settings = new SimpleSettings();
                string packetFile = Path.Combine(Program.RootDirectory, "packets.dat");
                if (File.Exists(packetFile))
                {
                    PacketTable = PacketTable.Load(File.ReadAllText(packetFile));
                }
                AppendLog("Settings loaded.");
            }
            catch (Exception ex)
            {
                AppendLog("Error when loading settings: " + ex.Message);
                return;
            }

            //new System.Threading.Thread(DoCheckUpdate) { IsBackground = true }.Start();

            AppendLog("Retrieving server list...");
            var doc =
                XDocument.Load("http://realmofthemadgodhrd.appspot.com/char/list?guid=" +
                               Guid.NewGuid().ToString().Replace("-", "").ToUpper());
            byte id = 1;

            Servers = doc.XPathSelectElements("//Server").Select(srv => new RemoteServer
            {
                Name     = srv.Element("Name").Value,
                DNS      = srv.Element("DNS").Value,
                Loopback = new IPAddress(new byte[] { 127, 0, 0, id++ })
            }).ToArray();
            AppendLog("Server list retrieved, total {0} servers.", Servers.Length);


            if (!InitializeComponent("Spam Filter", () =>
            {
                Filter = new SpamFilter(this);
                Filter.LoadWordList();
            }))
            {
                return;
            }

            if (!InitializeComponent("Handlers", () =>
            {
                Commands = new CommandManager();
                Hooks = new HookManager();
                Invoke(new Action(() => Windows = new WindowManager(this, windowDropDown)));
            }))
            {
                return;
            }

            AppendLog("If you see any firewall warning, allow this program to pass!");

            if (!InitializeComponent("Web Proxy", () =>
            {
                WebProxy = new HttpProxy(this);
                WebProxy.Start();
                BeginInvoke(new Action(() => { proxyLink.Text = new Uri(WebProxy.ProxyUrl).AbsoluteUri; }));
            }))
            {
                return;
            }

            if (!InitializeComponent("Socket Proxy", () =>
            {
                SocketProxy = new SocketProxy(this);
                SocketProxy.Start();
            }))
            {
                return;
            }

            if (!InitializeComponent("Policy Server", () =>
            {
                PolicyServer = new PolicyServer();
                if (!PolicyServer.Start())
                {
                    throw new Exception("Cannot start policy server! Try start as adminstrator/sudo!");
                }
            }))
            {
                return;
            }

            new HttpHandler(this).Attach();
            new SocketHandler(this).Attach();
            BeginInvoke(new Action(() => timer.Start()));

            AppendLog("RotMG Tool initialized.");
        }