using System; using System.Windows.Forms; namespace Injector { public partial class MainUI : Form { #region GUI stuff public void updateText() { tb_pathToFiles.Text = "exe: " + exePath + System.Environment.NewLine + System.Environment.NewLine + "dll:" + dllPath; } public int testME = 0; private Button Bn_FindDll; private Button bn_Inject; private TextBox tb_AppName; private Injector.targetControl.pictureBoxTarget pictureBoxTarget1; private System.ComponentModel.IContainer components; private TextBox tb_appID; private SplitContainer splitContainer2; private SplitContainer splitContainer1; public static string sApplication = String.Empty; private Button bnSelectExe; private Label label1; private CheckBox cb_overrideTarget; private TextBox tb_pathToFiles; private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainUI)); this.Bn_FindDll = new System.Windows.Forms.Button(); this.bn_Inject = new System.Windows.Forms.Button(); this.tb_AppName = new System.Windows.Forms.TextBox(); this.tb_appID = new System.Windows.Forms.TextBox(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.cb_overrideTarget = new System.Windows.Forms.CheckBox(); this.pictureBoxTarget1 = new Injector.targetControl.pictureBoxTarget(); this.tb_pathToFiles = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.bnSelectExe = new System.Windows.Forms.Button(); this.splitContainer2 = new System.Windows.Forms.SplitContainer(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.splitContainer2.Panel1.SuspendLayout(); this.splitContainer2.Panel2.SuspendLayout(); this.splitContainer2.SuspendLayout(); this.SuspendLayout(); // // Bn_FindDll // this.Bn_FindDll.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Bn_FindDll.Location = new System.Drawing.Point(12, 21); this.Bn_FindDll.Name = "Bn_FindDll"; this.Bn_FindDll.Size = new System.Drawing.Size(48, 25); this.Bn_FindDll.TabIndex = 0; this.Bn_FindDll.Text = "DLL"; this.Bn_FindDll.UseVisualStyleBackColor = true; this.Bn_FindDll.Click += new System.EventHandler(this.BtnBrowseDll_Click); // // bn_Inject // this.bn_Inject.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(204)))), ((int)(((byte)(204)))), ((int)(((byte)(204))))); this.bn_Inject.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.bn_Inject.ForeColor = System.Drawing.SystemColors.ActiveCaptionText; this.bn_Inject.Location = new System.Drawing.Point(7, 24); this.bn_Inject.Name = "bn_Inject"; this.bn_Inject.Size = new System.Drawing.Size(81, 43); this.bn_Inject.TabIndex = 1; this.bn_Inject.Text = "Inject"; this.bn_Inject.UseVisualStyleBackColor = false; this.bn_Inject.Click += new System.EventHandler(this.BtnInject_Click); // // tb_AppName // this.tb_AppName.Location = new System.Drawing.Point(8, 54); this.tb_AppName.Multiline = true; this.tb_AppName.Name = "tb_AppName"; this.tb_AppName.Size = new System.Drawing.Size(91, 35); this.tb_AppName.TabIndex = 2; this.tb_AppName.Text = "Target App(Drag Target)"; this.tb_AppName.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; // // tb_appID // this.tb_appID.BackColor = System.Drawing.SystemColors.WindowText; this.tb_appID.ForeColor = System.Drawing.SystemColors.Menu; this.tb_appID.Location = new System.Drawing.Point(59, 19); this.tb_appID.Name = "tb_appID"; this.tb_appID.Size = new System.Drawing.Size(40, 20); this.tb_appID.TabIndex = 19; this.tb_appID.Text = "000000"; this.tb_appID.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.tb_appID.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.tb_appID_KeyPress); // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; this.splitContainer1.Location = new System.Drawing.Point(0, 0); this.splitContainer1.Name = "splitContainer1"; // // splitContainer1.Panel1 // this.splitContainer1.Panel1.BackColor = System.Drawing.Color.Gray; this.splitContainer1.Panel1.Controls.Add(this.bn_Inject); // // splitContainer1.Panel2 // this.splitContainer1.Panel2.BackColor = System.Drawing.SystemColors.ActiveCaption; this.splitContainer1.Panel2.Controls.Add(this.cb_overrideTarget); this.splitContainer1.Panel2.Controls.Add(this.tb_AppName); this.splitContainer1.Panel2.Controls.Add(this.tb_appID); this.splitContainer1.Panel2.Controls.Add(this.pictureBoxTarget1); this.splitContainer1.Size = new System.Drawing.Size(206, 102); this.splitContainer1.SplitterDistance = 93; this.splitContainer1.TabIndex = 20; // // cb_overrideTarget // this.cb_overrideTarget.AutoSize = true; this.cb_overrideTarget.Location = new System.Drawing.Point(7, 0); this.cb_overrideTarget.Name = "cb_overrideTarget"; this.cb_overrideTarget.Size = new System.Drawing.Size(105, 17); this.cb_overrideTarget.TabIndex = 2; this.cb_overrideTarget.Text = "OverRide Target"; this.cb_overrideTarget.UseVisualStyleBackColor = true; this.cb_overrideTarget.CheckedChanged += new System.EventHandler(this.cb_overrideTarget_CheckedChanged); // // pictureBoxTarget1 // this.pictureBoxTarget1.Location = new System.Drawing.Point(21, 19); this.pictureBoxTarget1.Name = "pictureBoxTarget1"; this.pictureBoxTarget1.Size = new System.Drawing.Size(32, 29); this.pictureBoxTarget1.TabIndex = 18; // // tb_pathToFiles // this.tb_pathToFiles.Location = new System.Drawing.Point(12, 53); this.tb_pathToFiles.Multiline = true; this.tb_pathToFiles.Name = "tb_pathToFiles"; this.tb_pathToFiles.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.tb_pathToFiles.Size = new System.Drawing.Size(184, 47); this.tb_pathToFiles.TabIndex = 6; // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(50, 7); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(103, 13); this.label1.TabIndex = 5; this.label1.Text = "Select what to inject"; // // bnSelectExe // this.bnSelectExe.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.bnSelectExe.Location = new System.Drawing.Point(148, 22); this.bnSelectExe.Name = "bnSelectExe"; this.bnSelectExe.Size = new System.Drawing.Size(48, 25); this.bnSelectExe.TabIndex = 4; this.bnSelectExe.Text = "EXE"; this.bnSelectExe.UseVisualStyleBackColor = true; this.bnSelectExe.Click += new System.EventHandler(this.bnSelectExe_Click); // // splitContainer2 // this.splitContainer2.Location = new System.Drawing.Point(-1, 1); this.splitContainer2.Name = "splitContainer2"; this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal; // // splitContainer2.Panel1 // this.splitContainer2.Panel1.Controls.Add(this.splitContainer1); // // splitContainer2.Panel2 // this.splitContainer2.Panel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); this.splitContainer2.Panel2.Controls.Add(this.Bn_FindDll); this.splitContainer2.Panel2.Controls.Add(this.bnSelectExe); this.splitContainer2.Panel2.Controls.Add(this.tb_pathToFiles); this.splitContainer2.Panel2.Controls.Add(this.label1); this.splitContainer2.Size = new System.Drawing.Size(206, 209); this.splitContainer2.SplitterDistance = 102; this.splitContainer2.TabIndex = 21; // // MainUI // this.ClientSize = new System.Drawing.Size(206, 209); this.Controls.Add(this.splitContainer2); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Name = "MainUI"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.Text = "Injector"; this.Load += new System.EventHandler(this.MainUI_Load); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); this.splitContainer1.Panel2.PerformLayout(); this.splitContainer1.ResumeLayout(false); this.splitContainer2.Panel1.ResumeLayout(false); this.splitContainer2.Panel2.ResumeLayout(false); this.splitContainer2.Panel2.PerformLayout(); this.splitContainer2.ResumeLayout(false); this.ResumeLayout(false); } #endregion ---GUI stuff--- #region vars string dllPath = string.Empty; string exePath = string.Empty; System.Diagnostics.Process procTarget; #endregion ---vars--- #region con public MainUI() { InitializeComponent(); exePath = "slate.exe"; // exePath = System.Environment.CurrentDirectory + "\\slate.exe"; dllPath = "slater.dll"; // dllPath = System.Environment.CurrentDirectory + "\\slater.dll"; updateText(); } private void MainUI_Load(object sender, EventArgs e) { if (IntPtr.Size == 4) this.Text += "-32"; if (IntPtr.Size == 8) this.Text += "-64"; pictureBoxTarget1.myWindowTarget.targetApplicationEvent += new Injector.targetControl.TargetWindow.newTargetProcess(delegate(System.Diagnostics.Process procIN) { procTarget = procIN; string s = procIN.ProcessName; if (s.Contains(".")) s = s.Substring(0, s.LastIndexOf(".")); tb_AppName.Text = s; tb_appID.Text = procIN.Id.ToString(); }); } #endregion ---con--- #region GUI click private void BtnBrowseDll_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "Dynamic Link Library|*.dll"; ofd.FileOk += new System.ComponentModel.CancelEventHandler(dll_FileOk); ofd.ShowDialog(); } private void bnSelectExe_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "exe|*.exe"; ofd.FileOk += new System.ComponentModel.CancelEventHandler(exe_FileOk); ofd.ShowDialog(); } private void BtnInject_Click(object sender, EventArgs e) { try { copyFileToTargetDIR(); } catch { } if (!Inject.DoInject(tb_AppName.Text, exePath,false)) MessageBox.Show("inject 2 Fail #r6i76i"); if (!Inject.DoInject(tb_AppName.Text, dllPath, true)) MessageBox.Show("injecting Fail #89gh9fb"); this.Close(); } #endregion ---GUI click--- #region FileDialogs private void dll_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { OpenFileDialog ofd = (OpenFileDialog)sender; dllPath = ofd.FileName; updateText(); //now dispose of the object ofd.Dispose(); } private void exe_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { OpenFileDialog ofd = (OpenFileDialog)sender; exePath = ofd.FileName; updateText(); //now dispose of the object ofd.Dispose(); } #endregion ---FileDialogs--- #region copyFileToTargetDIR private void copyFileToTargetDIR() { string e = string.Empty; try { string targetPath = procTarget.MainModule.FileName; e += targetPath + "---"; targetPath = targetPath.Substring(0, targetPath.LastIndexOf("\\")); e += targetPath + "---"; string currenPath = System.Windows.Forms.Application.ExecutablePath.Substring(0, System.Windows.Forms.Application.ExecutablePath.LastIndexOf("\\")); e += currenPath + "---"; if (targetPath == currenPath) return; try { System.IO.File.Copy(dllPath, targetPath + "\\" + dllPath, true); System.IO.File.Copy(exePath, targetPath + "\\" + exePath, true); } catch { throw new System.Exception("Could not copy files #ohfsdsdf4"); } } catch (System.Exception e2) { throw new System.Exception("ERROR : " + e + " {#yoh9uijo9{{ " + e2.Message); } } #endregion ---copyFileToTargetDIR--- private void cb_overrideTarget_CheckedChanged(object sender, EventArgs e) { pictureBoxTarget1.myWindowTarget.overRideManagedCheck = cb_overrideTarget.Checked; } private void tb_appID_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == System.Environment.NewLine[0]) { try { System.Diagnostics.Process aProcess = System.Diagnostics.Process.GetProcessById(int.Parse(tb_appID.Text)); pictureBoxTarget1.myWindowTarget.CheckApp(aProcess, true); e.Handled = true; } catch { System.Windows.Forms.MessageBox.Show("sorry PID:" + tb_appID.Text + " not found"); } } } } }