Skip to content

Commit 2a1dcdb

Browse files
committed
Many improvements made
1 parent 065d7dd commit 2a1dcdb

11 files changed

Lines changed: 844 additions & 38 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.

.vs/TrueInjector/v18/.suo

-4.5 KB
Binary file not shown.

.vs/TrueInjector/v18/DocumentLayout.backup.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
"WorkspaceRootPath": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\",
44
"Documents": [
55
{
6-
"AbsoluteMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
6+
"AbsoluteMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|c:\\users\\nmjuk\\desktop\\computer\\github repositories\\trueinjector\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
77
"RelativeMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|solutionrelative:mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
88
},
99
{
1010
"AbsoluteMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
1111
"RelativeMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|solutionrelative:mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form"
1212
},
1313
{
14-
"AbsoluteMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|c:\\users\\nmjuk\\desktop\\computer\\github repositories\\trueinjector\\nativeloader.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
15-
"RelativeMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|solutionrelative:nativeloader.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
14+
"AbsoluteMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|c:\\users\\nmjuk\\desktop\\computer\\github repositories\\trueinjector\\utils.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
15+
"RelativeMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|solutionrelative:utils.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
1616
}
1717
],
1818
"DocumentGroupContainers": [
@@ -27,14 +27,14 @@
2727
{
2828
"$type": "Document",
2929
"DocumentIndex": 2,
30-
"Title": "NativeLoader.cs",
31-
"DocumentMoniker": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\NativeLoader.cs",
32-
"RelativeDocumentMoniker": "NativeLoader.cs",
33-
"ToolTip": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\NativeLoader.cs",
34-
"RelativeToolTip": "NativeLoader.cs",
35-
"ViewState": "AgIAAEMAAAAAAAAAAAAowHoAAAAzAAAAAAAAAA==",
30+
"Title": "Utils.cs",
31+
"DocumentMoniker": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\Utils.cs",
32+
"RelativeDocumentMoniker": "Utils.cs",
33+
"ToolTip": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\Utils.cs",
34+
"RelativeToolTip": "Utils.cs",
35+
"ViewState": "AgIAADYAAAAAAAAAAAAowAcAAAAAAAAAAAAAAA==",
3636
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
37-
"WhenOpened": "2025-12-13T12:21:24.265Z",
37+
"WhenOpened": "2026-04-26T14:51:20.033Z",
3838
"EditorCaption": ""
3939
},
4040
{
@@ -45,7 +45,7 @@
4545
"RelativeDocumentMoniker": "MainForm.cs",
4646
"ToolTip": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\MainForm.cs",
4747
"RelativeToolTip": "MainForm.cs",
48-
"ViewState": "AgIAAKMAAAAAAAAAAAAswLQAAAAkAAAAAAAAAA==",
48+
"ViewState": "AgIAAKwBAAAAAAAAAAAQwMwBAAA8AAAAAAAAAA==",
4949
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
5050
"WhenOpened": "2025-12-12T20:35:06.078Z",
5151
"EditorCaption": ""

.vs/TrueInjector/v18/DocumentLayout.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
"Version": 1,
33
"WorkspaceRootPath": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\",
44
"Documents": [
5-
{
6-
"AbsoluteMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
7-
"RelativeMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|solutionrelative:mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
8-
},
95
{
106
"AbsoluteMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form",
117
"RelativeMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|solutionrelative:mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}|Form"
128
},
139
{
14-
"AbsoluteMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|c:\\users\\nmjuk\\desktop\\computer\\github repositories\\trueinjector\\nativeloader.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
15-
"RelativeMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|solutionrelative:nativeloader.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
10+
"AbsoluteMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|c:\\users\\nmjuk\\desktop\\computer\\github repositories\\trueinjector\\utils.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
11+
"RelativeMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|solutionrelative:utils.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
12+
},
13+
{
14+
"AbsoluteMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|c:\\users\\nmjuk\\desktop\\computer\\github repositories\\trueinjector\\mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
15+
"RelativeMoniker": "D:0:0:{70170C8D-34C6-4F30-85A5-DABE0FC0199F}|TrueInjector.csproj|solutionrelative:mainform.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
1616
}
1717
],
1818
"DocumentGroupContainers": [
@@ -22,37 +22,37 @@
2222
"DocumentGroups": [
2323
{
2424
"DockedWidth": 200,
25-
"SelectedChildIndex": 1,
25+
"SelectedChildIndex": 2,
2626
"Children": [
2727
{
2828
"$type": "Document",
29-
"DocumentIndex": 2,
30-
"Title": "NativeLoader.cs",
31-
"DocumentMoniker": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\NativeLoader.cs",
32-
"RelativeDocumentMoniker": "NativeLoader.cs",
33-
"ToolTip": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\NativeLoader.cs",
34-
"RelativeToolTip": "NativeLoader.cs",
35-
"ViewState": "AgIAAEMAAAAAAAAAAAAowHoAAAAzAAAAAAAAAA==",
29+
"DocumentIndex": 1,
30+
"Title": "Utils.cs",
31+
"DocumentMoniker": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\Utils.cs",
32+
"RelativeDocumentMoniker": "Utils.cs",
33+
"ToolTip": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\Utils.cs",
34+
"RelativeToolTip": "Utils.cs",
35+
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAYAAAAbAAAAAAAAAA==",
3636
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
37-
"WhenOpened": "2025-12-13T12:21:24.265Z",
37+
"WhenOpened": "2026-04-26T14:51:20.033Z",
3838
"EditorCaption": ""
3939
},
4040
{
4141
"$type": "Document",
42-
"DocumentIndex": 0,
42+
"DocumentIndex": 2,
4343
"Title": "MainForm.cs",
4444
"DocumentMoniker": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\MainForm.cs",
4545
"RelativeDocumentMoniker": "MainForm.cs",
4646
"ToolTip": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\MainForm.cs",
4747
"RelativeToolTip": "MainForm.cs",
48-
"ViewState": "AgIAAIYAAAAAAAAAAAAkwLQAAAAkAAAAAAAAAA==",
48+
"ViewState": "AgIAAKwBAAAAAAAAAAAQwLkBAABDAAAAAAAAAA==",
4949
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
5050
"WhenOpened": "2025-12-12T20:35:06.078Z",
5151
"EditorCaption": ""
5252
},
5353
{
5454
"$type": "Document",
55-
"DocumentIndex": 1,
55+
"DocumentIndex": 0,
5656
"Title": "MainForm.cs [Progettazione]",
5757
"DocumentMoniker": "C:\\Users\\nmjuk\\Desktop\\Computer\\GitHub Repositories\\TrueInjector\\MainForm.cs",
5858
"RelativeDocumentMoniker": "MainForm.cs",

MainForm.Designer.cs

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MainForm.cs

Lines changed: 117 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Diagnostics;
5+
using System.IO;
56
using System.Runtime.InteropServices;
67
using System.Text;
78
using System.Threading;
@@ -134,6 +135,9 @@ public struct OBJECT_ATTRIBUTES
134135
private const uint STATUS_SUCCESS = 0x00000000;
135136

136137
private List<InjectorProcess> _injectorProcesses;
138+
private ProtoRandom.ProtoRandom _random;
139+
string rootDir = Environment.GetFolderPath(Environment.SpecialFolder.System).Substring(0, 1) + ":";
140+
char[] characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".ToCharArray();
137141

138142
public MainForm()
139143
{
@@ -159,6 +163,8 @@ public MainForm()
159163
guna2ComboBox4.SelectedIndex = 3;
160164
guna2ComboBox5.SelectedIndex = 2;
161165
guna2ComboBox6.SelectedIndex = 1;
166+
167+
_random = new ProtoRandom.ProtoRandom(2);
162168
}
163169

164170
public void CheckForProcessStartup()
@@ -178,7 +184,12 @@ public void CheckForProcessStartup()
178184
{
179185
if (process.ProcessName.ToLower().Trim().Equals(guna2TextBox1.Text.ToLower().Trim()))
180186
{
181-
Inject((uint) process.Id);
187+
if (Utils.CanBeInjected(process.Id, guna2TextBox2.Text))
188+
{
189+
Inject((uint)process.Id, false);
190+
Process.GetCurrentProcess().Kill();
191+
return;
192+
}
182193
}
183194
}
184195
catch
@@ -264,7 +275,7 @@ public void CheckerThread()
264275
try
265276
{
266277
Thread.Sleep(100);
267-
bool canBeInjected = Utils.CanBeInjected(listView1, guna2TextBox2.Text);
278+
bool canBeInjected = Utils.CanBeInjected2(listView1, guna2TextBox2.Text);
268279

269280
guna2Button3.Invoke(new Action(() =>
270281
{
@@ -343,7 +354,71 @@ private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
343354
Process.GetCurrentProcess().Kill();
344355
}
345356

346-
public void Inject(uint processId)
357+
public int FindBytes(byte[] src, byte[] find)
358+
{
359+
int index = -1;
360+
int matchIndex = 0;
361+
362+
for (int i = 0; i < src.Length; i++)
363+
{
364+
if (src[i] == find[matchIndex])
365+
{
366+
if (matchIndex == (find.Length - 1))
367+
{
368+
index = i - matchIndex;
369+
break;
370+
}
371+
372+
matchIndex++;
373+
}
374+
else if (src[i] == find[0])
375+
{
376+
matchIndex = 1;
377+
}
378+
else
379+
{
380+
matchIndex = 0;
381+
}
382+
}
383+
384+
return index;
385+
}
386+
387+
public byte[] ReplaceBytes(byte[] src, byte[] search, byte[] repl)
388+
{
389+
byte[] dst = null;
390+
int index = FindBytes(src, search);
391+
392+
if (index >= 0)
393+
{
394+
dst = new byte[src.Length - search.Length + repl.Length];
395+
396+
Buffer.BlockCopy(src, 0, dst, 0, index);
397+
Buffer.BlockCopy(repl, 0, dst, index, repl.Length);
398+
Buffer.BlockCopy(src, index + search.Length, dst, index + repl.Length, src.Length - (index + search.Length));
399+
}
400+
401+
return dst;
402+
}
403+
404+
public static byte[] Combine(byte[] first, byte[] second)
405+
{
406+
byte[] ret = new byte[first.Length + second.Length];
407+
408+
Buffer.BlockCopy(first, 0, ret, 0, first.Length);
409+
Buffer.BlockCopy(second, 0, ret, first.Length, second.Length);
410+
411+
return ret;
412+
}
413+
414+
public static void HideFile(string file)
415+
{
416+
System.IO.File.SetAttributes(file, System.IO.FileAttributes.Hidden);
417+
System.IO.FileInfo info = new System.IO.FileInfo(file);
418+
info.IsReadOnly = true;
419+
}
420+
421+
public void Inject(uint processId, bool showMessageBox)
347422
{
348423
try
349424
{
@@ -362,6 +437,35 @@ public void Inject(uint processId)
362437

363438
string dllPath = guna2TextBox2.Text;
364439

440+
if (guna2CheckBox2.Checked)
441+
{
442+
byte[] dllContent = File.ReadAllBytes(dllPath);
443+
444+
byte[] bytesToReplace = Encoding.UTF8.GetBytes("This program cannot be run in DOS mode.");
445+
dllContent = ReplaceBytes(dllContent, bytesToReplace, _random.GetRandomBytes(bytesToReplace.Length));
446+
447+
if (!Directory.Exists(rootDir + "\\Temp"))
448+
{
449+
Directory.CreateDirectory(rootDir + "\\Temp");
450+
}
451+
452+
string folderName = _random.GetRandomString(characters, _random.GetRandomInt32(12, 64));
453+
454+
if (Directory.Exists(rootDir + "\\Temp\\" + folderName))
455+
{
456+
Directory.Delete(rootDir + "\\Temp\\" + folderName);
457+
}
458+
459+
Directory.CreateDirectory(rootDir + "\\Temp\\" + folderName);
460+
dllPath = rootDir + "\\Temp\\" + folderName + "\\" + _random.GetRandomString(characters, _random.GetRandomInt32(6, 32)) + ".dll";
461+
File.WriteAllBytes(dllPath, dllContent);
462+
}
463+
464+
if (guna2CheckBox4.Checked)
465+
{
466+
HideFile(dllPath);
467+
}
468+
365469
byte[] dllBytes = guna2ComboBox1.SelectedIndex == 0 ?
366470
Encoding.ASCII.GetBytes(dllPath + "\0") :
367471
Encoding.Unicode.GetBytes(dllPath + "\0");
@@ -631,26 +735,31 @@ public void Inject(uint processId)
631735
new Thread(() => NativeLoader.InjectLdrLoadDll((int)processId, guna2TextBox2.Text)).Start();
632736
}
633737

634-
MessageBox.Show("Succesfully injected!", "TrueInjector", MessageBoxButtons.OK, MessageBoxIcon.Information);
738+
if (showMessageBox)
739+
{
740+
MessageBox.Show("Succesfully injected!", "TrueInjector", MessageBoxButtons.OK, MessageBoxIcon.Information);
741+
}
635742
}
636743
catch
637744
{
638-
MessageBox.Show("An error occurred.", "TrueInjector", MessageBoxButtons.OK, MessageBoxIcon.Error);
639-
745+
if (showMessageBox)
746+
{
747+
MessageBox.Show("An error occurred.", "TrueInjector", MessageBoxButtons.OK, MessageBoxIcon.Error);
748+
}
640749
}
641750
}
642751

643752
private void guna2Button3_Click(object sender, EventArgs e)
644753
{
645-
if (!Utils.CanBeInjected(listView1, guna2TextBox2.Text))
754+
if (!Utils.CanBeInjected2(listView1, guna2TextBox2.Text))
646755
{
647756
MessageBox.Show("An error occurred.", "TrueInjector", MessageBoxButtons.OK, MessageBoxIcon.Error);
648757
return;
649758
}
650759

651760
try
652761
{
653-
Inject(uint.Parse(listView1.SelectedItems[0].Text));
762+
Inject(uint.Parse(listView1.SelectedItems[0].Text), true);
654763
}
655764
catch
656765
{

0 commit comments

Comments
 (0)