-
Notifications
You must be signed in to change notification settings - Fork 2
/
SearchingForProcessForm.cs
68 lines (61 loc) · 2 KB
/
SearchingForProcessForm.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Threading;
namespace UmbraInjector
{
public partial class SearchingForProcessForm : Form
{
public SearchingForProcessForm()
{
InitializeComponent();
isProcessRunning.Start();
}
private void IsProcessRunning_Tick(object sender, EventArgs e)
{
Process[] getProcess = Process.GetProcessesByName("Risk of Rain 2");
if (getProcess.Length != 0)
{
isProcessRunning.Stop();
Inject(false);
Application.Exit();
}
}
public static string GetDLLName()
{
string dllName = "";
var currentFiles = Directory.GetFiles("Data/UmbraMenu/");
foreach (string fileName in currentFiles)
{
if (dllName.Contains(Program.currentVersion))
{
break;
}
string temp = fileName.Replace("Data/UmbraMenu/", "");
if (temp.EndsWith(".dll") && temp.Contains("Umbra"))
{
dllName = temp;
}
}
return dllName;
}
public static void Inject(bool alreadyOpen)
{
if (!alreadyOpen)
{
Thread.Sleep(15000);
}
Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.FileName = "cmd.exe";
startInfo.Arguments = $"/C cd Data&smi.exe inject -p \"Risk of Rain 2\" -a UmbraMenu/{GetDLLName()} -n UmbraMenu -c Loader -m Load";
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();
Thread.Sleep(1000);
Environment.Exit(0);
}
}
}