private bool SanityChecks() { int comboBoxCount = -1; if (Process_Name_Textbox.Text == String.Empty || Process_Name_Textbox.Text.Length < 0) { MetroMessageBox.Show(this, "No Process selected", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error, 100); return(false); } if (Globals.Dll_list.Count == 0) { MetroMessageBox.Show(this, "No DLL found", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error, 100); return(false); } Inject_Method_Combobox.Invoke(new MethodInvoker(() => comboBoxCount = Inject_Method_Combobox.SelectedIndex)); if (comboBoxCount < 0) { MetroMessageBox.Show(this, "Select an injection method first", string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error, 100); return(false); } return(true); }
private void autoInjectCheckbox_CheckedChanged(object sender, EventArgs e) { if (this.autoInjectThread == null) { this.threadInterrupt.Reset(); this.autoInjectThread = new Thread(() => { while (!this.threadInterrupt.WaitOne(0)) { // prevent checkbox from being toggled while sanitychecks might display error message autoInjectCheckbox.Invoke(new MethodInvoker(() => autoInjectCheckbox.Enabled = false)); if (SanityChecks()) { if (UpdateSelectedProcess() && Globals.Selected_Process.Id != Globals.Last_Pid) { int injectionMethod = -1; Inject_Method_Combobox.Invoke(new MethodInvoker(() => injectionMethod = Inject_Method_Combobox.SelectedIndex)); switch (injectionMethod) { case 0: Task.Factory.StartNew(() => Memory_manager.Inject(Memory.Method.Standard)); continue; case 1: Task.Factory.StartNew(() => Memory_manager.Inject(Memory.Method.ManualMap)); continue; case 2: Task.Factory.StartNew(() => Memory_manager.Inject(Memory.Method.ThreadHijacking)); continue; default: throw new Exception("gj m8 you broke the matrix"); } } } else { autoInjectCheckbox.Invoke(new MethodInvoker(() => autoInjectCheckbox.Checked = false)); } // reenable chechbox autoInjectCheckbox.Invoke(new MethodInvoker(() => autoInjectCheckbox.Enabled = true)); Thread.Sleep(500); } this.autoInjectThread = null; }); this.autoInjectThread.IsBackground = true; this.autoInjectThread.Start(); } else { threadInterrupt.Set(); } }