예제 #1
0
 private void WGH_MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (WGH_Core.currentMemoryInterface != null)
     {
         WGH_Core.RestoreTarget();
     }
 }
예제 #2
0
        private void btnInjectSelected_Click(object sender, EventArgs e)
        {
            if (WGH_Core.currentMemoryInterface == null)
            {
                MessageBox.Show("No target is loaded");
                return;
            }

            TerminateIfNeeded();

            StashKey sk = null;

            if (lbStashHistory.SelectedIndex != -1)
            {
                sk = (StashKey)lbStashHistory.SelectedItem;
            }
            else if (lbStockpile.SelectedIndex != -1)
            {
                sk = (StashKey)lbStockpile.SelectedItem;
            }

            if (sk != null)
            {
                WGH_Core.RestoreTarget();

                sk.Run();
                WGH_Executor.Execute();
            }
        }
예제 #3
0
        public static bool MergeStashkeys(List <StashKey> sks, bool _stashAfterOperation = true)
        {
            if (sks != null && sks.Count > 1)
            {
                BlastLayer bl = new BlastLayer();
                foreach (StashKey item in sks)
                {
                    bl.Layer.AddRange(item.BlastLayer.Layer);
                }

                StashKey newSk = new StashKey(WGH_Core.GetRandomKey(), bl);
                WGH_Core.ghForm.lbStashHistory.Items.Add(newSk);

                WGH_Core.ghForm.RefreshStashHistory();

                WGH_Core.RestoreTarget();
                newSk.Run();
                WGH_Executor.Execute();

                return(true);
            }
            else
            {
                MessageBox.Show("You need 2 or more items for Merging");
                return(false);
            }
        }
예제 #4
0
        public WGH_MainForm()
        {
            InitializeComponent();

            //Terrible ugly hack for the RefreshingListBox. Forgive my sins.
            //---------------------------------------------------------------
            var newListBox = new RefreshingListBox();

            newListBox.Anchor              = lbStockpile.Anchor;
            newListBox.BackColor           = lbStockpile.BackColor;
            newListBox.BorderStyle         = lbStockpile.BorderStyle;
            newListBox.Font                = lbStockpile.Font;
            newListBox.ForeColor           = lbStockpile.ForeColor;
            newListBox.FormattingEnabled   = lbStockpile.FormattingEnabled;
            newListBox.IntegralHeight      = lbStockpile.IntegralHeight;
            newListBox.ItemHeight          = lbStockpile.ItemHeight;
            newListBox.Location            = lbStockpile.Location;
            newListBox.Name                = lbStockpile.Name;
            newListBox.ScrollAlwaysVisible = lbStockpile.ScrollAlwaysVisible;
            newListBox.Size                = lbStockpile.Size;
            newListBox.TabIndex            = lbStockpile.TabIndex;
            newListBox.TabStop             = lbStockpile.TabStop;
            newListBox.Tag                   = lbStockpile.Tag;
            newListBox.SelectionMode         = lbStockpile.SelectionMode;
            newListBox.SelectedIndexChanged += new System.EventHandler(this.lbStockpile_SelectedIndexChanged);
            newListBox.MouseDown            += new System.Windows.Forms.MouseEventHandler(this.lbStockpile_MouseDown);
            Controls.Remove(lbStockpile);
            lbStockpile = newListBox;
            Controls.Add(lbStockpile);
            //---------------------------------------------------------------


            WGH_Core.Start(this);
        }
예제 #5
0
 public void btnSaveState_Click(object sender, EventArgs e)
 {
     //dolphinConn.connector.SendMessage("SAVESTATE");
     //This will send a NetCoreSimpleMessage
     WGH_Core.currentDolphinSavestate = WGH_Core.GetRandomKey();
     dolphinConn.connector.SendMessage("SAVESTATE", WGH_Core.currentDolphinSavestate);
     //If you want to send an advanced message or if you want to specify a filename for example
 }
예제 #6
0
        public void BlastTarget(int times = 1, bool untilFound = false, bool stashBlastLayer = true)
        {
            if (WGH_Core.currentMemoryInterface is ProcessInterface)
            {
                (WGH_Core.currentMemoryInterface as ProcessInterface).RefreshSize();
            }


            if (WGH_Core.currentMemoryInterface == null)
            {
                MessageBox.Show("No target is loaded");
                return;
            }

            TerminateIfNeeded();

            if (WGH_Core.currentMemoryInterface == null)
            {
                return;
            }


            WGH_Core.RestoreTarget();

            for (int i = 0; i < times; i++)
            {
                var bl = WGH_Core.Blast();

                if (bl != null)
                {
                    WGH_Core.currentStashkey = new StashKey(WGH_Core.GetRandomKey(), bl);

                    if (stashBlastLayer)
                    {
                        DontLoadSelectedStash = true;
                        lbStashHistory.Items.Add(WGH_Core.currentStashkey);
                        lbStashHistory.ClearSelected();
                        lbStashHistory.SelectedIndex = lbStashHistory.Items.Count - 1;
                        lbStockpile.ClearSelected();
                    }

                    if (untilFound)
                    {
                        break;
                    }
                }
            }
            WGH_Executor.Execute();
        }
예제 #7
0
        /*
         * private void btnCorrupt_Click(object sender, EventArgs e)
         * {
         *  BlastLayer bl = new BlastLayer();
         *
         *  foreach (var item in lbBlastLayer.Items)
         *  {
         *      BlastUnit bu = (item as BlastUnit);
         *      if (bu.IsEnabled)
         *          bl.Layer.Add(bu);
         *  }
         *
         *  WGH_Core.RestoreTarget();
         *  bl.Apply();
         * }*/

        private void btnSendToStash_Click(object sender, EventArgs e)
        {
            StashKey newSk = (StashKey)sk.Clone();

            newSk.Key   = WGH_Core.GetRandomKey();
            newSk.Alias = null;

            WGH_Core.ghForm.DontLoadSelectedStash = true;
            WGH_Core.ghForm.lbStashHistory.Items.Add(newSk);
            WGH_Core.ghForm.RefreshStashHistory();
            //  WGH_Core.ghForm.lbStashHistory.Items.Add(WGH_Core.currentStashkey);
            WGH_Core.ghForm.lbStockpile.ClearSelected();
            WGH_Core.ghForm.lbStashHistory.ClearSelected();
            WGH_Core.ghForm.lbStashHistory.SelectedIndex = WGH_Core.ghForm.lbStashHistory.Items.Count - 1;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
예제 #8
0
        private void btnLoadCorrupt_Click(object sender, EventArgs e)
        {
            BlastLayer bl = new BlastLayer();

            foreach (var item in lbBlastLayer.Items)
            {
                BlastUnit bu = (item as BlastUnit);
                if (bu.IsEnabled)
                {
                    bl.Layer.Add(bu);
                }
            }

            StashKey newSk = (StashKey)sk.Clone();

            newSk.BlastLayer = bl;
            WGH_Core.RestoreTarget();
            newSk.Run();
            WGH_Executor.Execute();
        }
예제 #9
0
        private void btnRerollInject_Click(object sender, EventArgs e)
        {
            if (WGH_Core.currentMemoryInterface == null)
            {
                MessageBox.Show("No target is loaded");
                return;
            }

            TerminateIfNeeded();

            StashKey sk = null;


            if (lbStashHistory.SelectedIndex != -1)
            {
                sk = (StashKey)lbStashHistory.SelectedItem;
            }
            else if (lbStockpile.SelectedIndex != -1)
            {
                sk = (StashKey)lbStockpile.SelectedItem;
            }

            if (sk != null)
            {
                StashKey newSk = (StashKey)sk.Clone();
                newSk.Key   = WGH_Core.GetRandomKey();
                newSk.Alias = null;

                WGH_Core.ghForm.DontLoadSelectedStash = true;
                WGH_Core.ghForm.lbStashHistory.Items.Add(newSk);
                WGH_Core.ghForm.lbStashHistory.ClearSelected();
                WGH_Core.ghForm.lbStashHistory.SelectedIndex = WGH_Core.ghForm.lbStashHistory.Items.Count - 1;
                WGH_Core.ghForm.lbStockpile.ClearSelected();


                //TODO: Refactor this properly instead of as a hacky mess
                foreach (BlastUnit bu in newSk.BlastLayer.Layer)
                {
                    var bb = (bu as BlastByte);
                    var bv = (bu as BlastVector);
                    //BAD HACK. USE THIS TO DECTECT IF VECTOR. SORRY I DIDN'T KNOW WHERE TO REFACTOR THIS -NARRY
                    if (bb != null)
                    {
                        if (bb.Type == BlastByteType.SET)
                        {
                            bb.Value = WGH_Core.RND.Next(0, 255);
                        }
                        else if (bb.Type == BlastByteType.ADD || bb.Type == BlastByteType.SUBSTRACT)
                        {
                            int result = WGH_Core.RND.Next(1, 3);
                            switch (result)
                            {
                            case 1:
                                bb.Type = BlastByteType.ADD;
                                break;

                            case 2:
                                bb.Type = BlastByteType.SUBSTRACT;
                                break;
                            }
                        }
                    }
                    if (bv != null)
                    {
                        bv.Values = WGH_VectorEngine.getRandomConstant(WGH_VectorEngine.valueList);
                    }
                }

                WGH_Core.RestoreTarget();

                newSk.Run();
                WGH_Executor.Execute();
            }
        }
예제 #10
0
        private void btnBrowseTarget_Click(object sender, EventArgs e)
        {
            WGH_Core.LoadTarget();

            if (WGH_Core.currentMemoryInterface != null)
            {
                var mi = WGH_Core.currentMemoryInterface;

                if (mi.lastMemorySize != null)
                {
                    if (mi.lastMemorySize >= int.MaxValue)
                    {
                        tbStartingAddress.Visible = false;
                        tbBlastRange.Visible      = false;
                    }
                    else
                    {
                        tbStartingAddress.Visible = true;
                        tbBlastRange.Visible      = true;
                    }


                    if (tbStartingAddress.Visible && tbStartingAddress.Value > mi.lastMemorySize && tbStartingAddress.Maximum > mi.lastMemorySize)
                    {
                        tbStartingAddress.Value = (int)mi.lastMemorySize;
                    }

                    nmStartingAddress.Maximum = (long)mi.lastMemorySize;

                    if (tbBlastRange.Visible && tbBlastRange.Value > mi.lastMemorySize && tbBlastRange.Maximum > mi.lastMemorySize)
                    {
                        tbBlastRange.Value = (int)mi.lastMemorySize;
                    }

                    nmBlastRange.Maximum = (long)mi.lastMemorySize;

                    if (tbStartingAddress.Visible)
                    {
                        tbStartingAddress.Maximum = (int)mi.lastMemorySize;
                        tbBlastRange.Maximum      = (int)mi.lastMemorySize;
                    }

                    WGH_Core.lastBlastLayerBackup = new BlastLayer();
                }


                if (mi is ProcessInterface)
                {
                    cbTerminateOnReExec.Visible    = false;
                    cbWriteCopyMode.Visible        = false;
                    rbExecuteWith.Visible          = false;
                    rbExecuteScript.Visible        = false;
                    rbExecuteOtherProgram.Visible  = false;
                    rbExecuteCorruptedFile.Visible = false;
                    rbNoExecution.Visible          = false;
                    btnEditExec.Visible            = false;
                    lbExecution.Visible            = false;
                    cbInjectOnSelect.Visible       = false;

                    WGH_Core.acForm.Visible = true;
                }
                else
                {
                    cbTerminateOnReExec.Visible    = true;
                    cbWriteCopyMode.Visible        = true;
                    rbExecuteWith.Visible          = true;
                    rbExecuteScript.Visible        = true;
                    rbExecuteOtherProgram.Visible  = true;
                    rbExecuteCorruptedFile.Visible = true;
                    rbNoExecution.Visible          = true;
                    btnEditExec.Visible            = true;
                    lbExecution.Visible            = true;
                    cbInjectOnSelect.Visible       = true;

                    WGH_Core.acForm.Visible = false;
                }
            }


            lbStashHistory.Items.Clear();
            lbStockpile.Items.Clear();
        }
예제 #11
0
        public static void LoadTarget()
        {
            if (WGH_Core.ghForm.rbTargetFile.Checked)
            {
                OpenFileDialog OpenFileDialog1;
                OpenFileDialog1 = new OpenFileDialog();

                OpenFileDialog1.Title            = "Open File";
                OpenFileDialog1.Filter           = "files|*.*";
                OpenFileDialog1.RestoreDirectory = true;
                if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    if (OpenFileDialog1.FileName.ToString().Contains('^'))
                    {
                        MessageBox.Show("You can't use a file that contains the character ^ ");
                        return;
                    }

                    currentTargetId       = "File|" + OpenFileDialog1.FileName.ToString();
                    currentTargetFullName = OpenFileDialog1.FileName.ToString();
                }
                else
                {
                    return;
                }

                //Disable caching of the previously loaded file if it was enabled
                if (ghForm.btnEnableCaching.Text == "Disable caching on current target")
                {
                    ghForm.btnEnableCaching.PerformClick();
                }

                if (currentMemoryInterface != null && (currentTargetType == "Dolphin" || currentTargetType == "File" || currentTargetType == "MultipleFiles"))
                {
                    WGH_Core.RestoreTarget();
                    currentMemoryInterface.stream?.Dispose();
                }

                currentTargetType = "File";
                var fi = new FileInterface(currentTargetId);
                currentTargetName = fi.ShortFilename;

                currentMemoryInterface = fi;
                ghForm.lbTarget.Text   = currentTargetId + "|MemorySize:" + fi.lastMemorySize.ToString();
            }
            else if (WGH_Core.ghForm.rbTargetMultipleFiles.Checked)
            {
                if (smForm != null)
                {
                    smForm.Close();
                }

                smForm = new WGH_SelectMultipleForm();

                if (smForm.ShowDialog() != DialogResult.OK)
                {
                    WGH_Core.currentMemoryInterface = null;
                    return;
                }

                currentTargetType = "MultipleFiles";
                var mfi = (MultipleFileInterface)WGH_Core.currentMemoryInterface;
                currentTargetName    = mfi.ShortFilename;
                ghForm.lbTarget.Text = mfi.ShortFilename + "|MemorySize:" + mfi.lastMemorySize.ToString();
            }
            else if (WGH_Core.ghForm.rbTargetProcess.Checked)
            {
                if (hpForm != null)
                {
                    hpForm.Close();
                }

                hpForm = new WGH_HookProcessForm();

                if (hpForm.ShowDialog() != DialogResult.OK)
                {
                    WGH_Core.currentMemoryInterface = null;
                    return;
                }

                currentTargetType = "Process";
                var mfi = (ProcessInterface)WGH_Core.currentMemoryInterface;
                currentTargetName    = mfi.ProcessName;
                ghForm.lbTarget.Text = mfi.ProcessName + "|MemorySize:" + mfi.lastMemorySize.ToString();
            }
            if (WGH_Core.ghForm.rbTargetDolphin.Checked)
            {
                OpenFileDialog OpenFileDialog1;
                OpenFileDialog1 = new OpenFileDialog();

                OpenFileDialog1.Title            = "Open File";
                OpenFileDialog1.Filter           = "Dolphin Savestates|*.state;*.s01;*.s02;*.s03;*.s04;*.s05;*.s06;*.s07;*.s08;*.s09;*.sav|All Files|*.*";
                OpenFileDialog1.RestoreDirectory = true;
                if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    if (OpenFileDialog1.FileName.ToString().Contains('^'))
                    {
                        MessageBox.Show("You can't use a file that contains the character ^ ");
                    }

                    currentTargetId       = "Dolphin|" + OpenFileDialog1.FileName.ToString();
                    currentTargetFullName = OpenFileDialog1.FileName.ToString();
                }
                else
                {
                    return;
                }

                //Disable caching of the previously loaded file if it was enabled
                if (ghForm.btnEnableCaching.Text == "Disable caching on current target")
                {
                    ghForm.btnEnableCaching.PerformClick();
                }

                if (currentMemoryInterface != null && (currentTargetType == "Dolphin" || currentTargetType == "File" || currentTargetType == "MultipleFiles"))
                {
                    WGH_Core.RestoreTarget();
                    currentMemoryInterface.stream?.Dispose();
                }


                currentTargetType = "Dolphin";
                var di = new DolphinInterface(currentTargetId);
                currentTargetName = di.ShortFilename;

                currentMemoryInterface  = di;
                ghForm.lbTarget.Text    = currentTargetId + "|MemorySize:" + di.lastMemorySize.ToString();
                currentDolphinSavestate = di.getCorruptFilename();

                //Cache the new file
                ghForm.btnEnableCaching.PerformClick();

                //Update the savestate info.
                if (WGH_Core.ssForm != null)
                {
                    WGH_Core.ssForm.GetSavestateInfo();
                }
            }

            /*
             * else if (WGH_Core.ghForm.rbTargetDolphin.Checked)
             * {
             *
             *  currentTargetType = "Dolphin";
             *  //var mfi = (DolphinInterface)WGH_Core.currentMemoryInterface;
             *  WGH_Core.currentMemoryInterface = new DolphinInterface("Test");
             *  currentTargetName = "Dolphin";
             *  ghForm.lbTarget.Text = currentTargetName + "|MemorySize:" + WGH_Core.currentMemoryInterface.lastMemorySize.ToString();
             * }*/
        }