-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainForm.cs
More file actions
629 lines (516 loc) · 25.7 KB
/
MainForm.cs
File metadata and controls
629 lines (516 loc) · 25.7 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
using MetroSuite;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Windows.Forms;
public partial class MainForm : MetroForm
{
[DllImport("kernel32.dll")]
private static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr GetModuleHandle(string lpModuleName);
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
private static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
private static extern IntPtr VirtualAllocEx(IntPtr hProcess, IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);
[DllImport("kernel32.dll")]
private static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, uint lpNumberOfBytesWritten);
[DllImport("kernel32.dll")]
private static extern IntPtr CreateRemoteThread(IntPtr hProcess, IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
[DllImport("ntdll.dll", SetLastError = true)]
private static extern IntPtr NtWriteVirtualMemory(IntPtr ProcessHandle, IntPtr BaseAddress, byte[] Buffer, UInt32 NumberOfBytesToWrite, ref UInt32 NumberOfBytesWritten);
[DllImport("ntdll.dll", SetLastError = true)]
private static extern IntPtr ZwWriteVirtualMemory(IntPtr ProcessHandle, IntPtr BaseAddress, byte[] Buffer, UInt32 NumberOfBytesToWrite, ref UInt32 NumberOfBytesWritten);
[DllImport("ntdll.dll", SetLastError = true)]
private static extern IntPtr RtlCreateUserThread(IntPtr processHandle, IntPtr threadSecurity, bool createSuspended, Int32 stackZeroBits, IntPtr stackReserved, IntPtr stackCommit, IntPtr startAddress, IntPtr parameter, ref IntPtr threadHandle, IntPtr clientId);
[DllImport("ntdll.dll", SetLastError = true)]
private static extern IntPtr NtCreateThreadEx(ref IntPtr threadHandle, UInt32 desiredAccess, IntPtr objectAttributes, IntPtr processHandle, IntPtr startAddress, IntPtr parameter, bool inCreateSuspended, Int32 stackZeroBits, Int32 sizeOfStack, Int32 maximumStackSize, IntPtr attributeList);
[DllImport("ntdll.dll", SetLastError = true)]
public static extern int NtQueueApcThread(IntPtr ThreadHandle, IntPtr ApcRoutine, IntPtr ApcArgument1, IntPtr ApcArgument2, IntPtr ApcArgument3);
[DllImport("ntdll.dll", SetLastError = true)]
public static extern int NtQueueApcThreadEx(IntPtr ThreadHandle, IntPtr UserApcReserveHandle, IntPtr ApcRoutine, IntPtr ApcArgument1, IntPtr ApcArgument2, IntPtr ApcArgument3);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr OpenThread(uint dwDesiredAccess, bool bInheritHandle,uint dwThreadId);
[DllImport("kernel32.dll")]
public static extern bool CloseHandle(IntPtr hObject);
[DllImport("ntdll.dll", SetLastError = true)]
private static extern int NtAllocateVirtualMemory(IntPtr ProcessHandle, ref IntPtr BaseAddress, IntPtr ZeroBits, ref ulong RegionSize, uint AllocationType, uint Protect);
[DllImport("ntdll.dll")]
private static extern int NtCreateSection(out IntPtr SectionHandle, uint DesiredAccess, IntPtr ObjectAttributes, ref long MaximumSize, uint SectionPageProtection, uint AllocationAttributes, IntPtr FileHandle);
[DllImport("ntdll.dll")]
private static extern int NtMapViewOfSection(IntPtr SectionHandle, IntPtr ProcessHandle, out IntPtr BaseAddress, IntPtr ZeroBits, IntPtr CommitSize, out long SectionOffset, out ulong ViewSize, uint InheritDisposition, uint AllocationType, uint Win32Protect);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr CreateFileMapping( IntPtr hFile, IntPtr lpFileMappingAttributes, uint flProtect, uint dwMaximumSizeHigh, uint dwMaximumSizeLow, string lpName);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern IntPtr MapViewOfFile(IntPtr hFileMappingObject, uint dwDesiredAccess, uint dwFileOffsetHigh, uint dwFileOffsetLow, UIntPtr dwNumberOfBytesToMap);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool UnmapViewOfFile(IntPtr lpBaseAddress);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool DuplicateHandle(IntPtr hSourceProcessHandle, IntPtr hSourceHandle, IntPtr hTargetProcessHandle, out IntPtr lpTargetHandle, uint dwDesiredAccess, bool bInheritHandle, uint dwOptions);
[DllImport("ntdll.dll")]
private static extern uint NtUnmapViewOfSection(IntPtr hProc, IntPtr baseAddr);
[DllImport("kernelbase.dll", SetLastError = true)]
private static extern IntPtr VirtualAlloc2(IntPtr processHandle, IntPtr baseAddress, UIntPtr size, AllocationType allocationType, MemoryProtection protection, IntPtr extendedParameters, IntPtr parameterCount);
[DllImport("ManualMapper.dll", EntryPoint = "ManualMapDLL", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern int ManualMapDLL(uint processID, string dllPath);
[DllImport("ThreadHijacker.dll", EntryPoint = "ThreadHijack", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
private static extern int ThreadHijack(uint processID, string dllPath);
[DllImport("ntdll.dll", SetLastError = true)]
private static extern int NtOpenProcess(out IntPtr ProcessHandle, UInt32 DesiredAccess, ref OBJECT_ATTRIBUTES ObjectAttributes, ref CLIENT_ID ClientId);
[DllImport("ntdll.dll", SetLastError = true)]
private static extern uint NtOpenThread(out IntPtr ThreadHandle, uint DesiredAccess, ref OBJECT_ATTRIBUTES ObjectAttributes, ref CLIENT_ID ClientId);
[DllImport("ntdll.dll", SetLastError = true)]
private static extern int NtClose(IntPtr Handle);
[Flags]
public enum AllocationType : uint
{
MEM_COMMIT = 0x1000,
MEM_RESERVE = 0x2000
}
[Flags]
public enum MemoryProtection : uint
{
PAGE_READWRITE = 0x04
}
[StructLayout(LayoutKind.Sequential)]
public struct CLIENT_ID
{
public IntPtr UniqueProcess;
public IntPtr UniqueThread;
}
[StructLayout(LayoutKind.Sequential)]
public struct OBJECT_ATTRIBUTES
{
public UInt32 Length;
public IntPtr RootDirectory;
public IntPtr ObjectName;
public UInt32 Attributes;
public IntPtr SecurityDescriptor;
public IntPtr SecurityQualityOfService;
}
private const uint MEM_COMMIT = 0x00001000;
private const uint MEM_RESERVE = 0x00002000;
private const uint PAGE_READWRITE = 4;
private const uint SECTION_ALL_ACCESS = 0x10000000;
private const uint SEC_COMMIT = 0x8000000;
private const uint ViewShare = 1;
private const uint FILE_MAP_WRITE = 0x0002;
private const uint STATUS_SUCCESS = 0x00000000;
private List<InjectorProcess> _injectorProcesses;
public MainForm()
{
InitializeComponent();
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
CheckForIllegalCrossThreadCalls = false;
_injectorProcesses = new List<InjectorProcess>();
RefreshProcesses();
SearchProcess("");
Thread checkerThread = new Thread(CheckerThread);
checkerThread.Priority = ThreadPriority.Highest;
checkerThread.Start();
guna2ComboBox1.SelectedIndex = 1;
guna2ComboBox2.SelectedIndex = 4;
guna2ComboBox3.SelectedIndex = 0;
guna2ComboBox4.SelectedIndex = 3;
guna2ComboBox5.SelectedIndex = 2;
guna2ComboBox6.SelectedIndex = 1;
}
public static void InitializeObjectAttributes(ref OBJECT_ATTRIBUTES attributes, UInt32 attributesValue)
{
attributes.Length = (uint)Marshal.SizeOf(attributes);
attributes.RootDirectory = IntPtr.Zero;
attributes.ObjectName = IntPtr.Zero;
attributes.Attributes = attributesValue;
attributes.SecurityDescriptor = IntPtr.Zero;
attributes.SecurityQualityOfService = IntPtr.Zero;
}
public IntPtr OpenProcessNt(int processId, UInt32 desiredAccess)
{
CLIENT_ID cid = new CLIENT_ID
{
UniqueProcess = new IntPtr(processId),
UniqueThread = IntPtr.Zero
};
OBJECT_ATTRIBUTES objAttr = new OBJECT_ATTRIBUTES();
InitializeObjectAttributes(ref objAttr, 0);
IntPtr hProcess = IntPtr.Zero;
int status = NtOpenProcess(out hProcess, desiredAccess, ref objAttr, ref cid);
if (status != STATUS_SUCCESS)
{
return IntPtr.Zero;
}
return hProcess;
}
public bool CloseHandleNt(IntPtr handle)
{
if (handle == IntPtr.Zero)
{
return true;
}
int status = NtClose(handle);
return status == STATUS_SUCCESS;
}
public IntPtr NtOpenThreadReplacement(int targetProcessId, int targetThreadId, uint desiredAccess)
{
IntPtr hThread = IntPtr.Zero;
CLIENT_ID clientId = new CLIENT_ID
{
UniqueProcess = new IntPtr(targetProcessId),
UniqueThread = new IntPtr(targetThreadId)
};
OBJECT_ATTRIBUTES objAttributes = new OBJECT_ATTRIBUTES
{
Length = (uint) Marshal.SizeOf(typeof(OBJECT_ATTRIBUTES)),
};
uint status = NtOpenThread(out hThread, desiredAccess, ref objAttributes, ref clientId);
if (status != STATUS_SUCCESS || hThread == IntPtr.Zero)
{
return IntPtr.Zero;
}
return hThread;
}
public void CheckerThread()
{
while (true)
{
try
{
Thread.Sleep(100);
bool canBeInjected = Utils.CanBeInjected(listView1, guna2TextBox2.Text);
guna2Button3.Invoke(new Action(() =>
{
guna2Button3.Enabled = canBeInjected;
}));
}
catch
{
}
}
}
public void RefreshProcesses()
{
_injectorProcesses.Clear();
foreach (Process process in Process.GetProcesses())
{
try
{
_injectorProcesses.Add(new InjectorProcess((uint)process.Id, process.ProcessName));
}
catch
{
}
}
}
public void SearchProcess(string query)
{
query = query.ToLower().Replace(" ", "");
listView1.Items.Clear();
foreach (InjectorProcess injectorProcess in _injectorProcesses)
{
string formatted = injectorProcess.ProcessId.ToString() + injectorProcess.ProcessName.ToLower();
formatted = formatted.ToLower().Replace(" ", "");
if (query.Contains(formatted) || formatted.Contains(query))
{
ListViewItem listViewItem = new ListViewItem(injectorProcess.ProcessId.ToString());
listViewItem.SubItems.Add(injectorProcess.ProcessName);
listView1.Items.Add(listViewItem);
}
}
}
private void guna2TextBox1_TextChanged(object sender, EventArgs e)
{
SearchProcess(guna2TextBox1.Text);
}
private void guna2Button1_Click(object sender, EventArgs e)
{
RefreshProcesses();
SearchProcess(guna2TextBox1.Text);
}
private void guna2Button4_Click(object sender, EventArgs e)
{
Process.Start("https://github.com/ZygoteCode/TrueInjector/");
}
private void guna2Button2_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog().Equals(DialogResult.OK))
{
guna2TextBox2.Text = openFileDialog1.FileName;
}
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
Process.GetCurrentProcess().Kill();
}
private void guna2Button3_Click(object sender, EventArgs e)
{
if (!Utils.CanBeInjected(listView1, guna2TextBox2.Text))
{
MessageBox.Show("An error occurred.", "TrueInjector", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
if (guna2ComboBox3.SelectedIndex == 0)
{
uint processId = uint.Parse(listView1.SelectedItems[0].Text);
IntPtr processHandle = IntPtr.Zero;
if (guna2ComboBox6.SelectedIndex == 0)
{
processHandle = OpenProcess(0x001F0FFF, false, (int)processId);
}
else if (guna2ComboBox6.SelectedIndex == 1)
{
processHandle = OpenProcessNt((int)processId, 0x001F0FFF);
}
string dllPath = guna2TextBox2.Text;
byte[] dllBytes = guna2ComboBox1.SelectedIndex == 0 ?
Encoding.ASCII.GetBytes(dllPath + "\0") :
Encoding.Unicode.GetBytes(dllPath + "\0");
uint dllSize = (uint)dllBytes.Length;
IntPtr remoteThread = new IntPtr(0);
IntPtr loadLibraryAddress = IntPtr.Zero;
switch (guna2ComboBox1.SelectedIndex)
{
case 0:
loadLibraryAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryA");
break;
case 1:
loadLibraryAddress = GetProcAddress(GetModuleHandle("kernel32.dll"), "LoadLibraryW");
break;
}
IntPtr allocatedMemoryAddress = IntPtr.Zero;
bool memoryAlreadyFilled = false;
if (guna2ComboBox4.SelectedIndex == 3)
{
long maxSize = dllSize;
IntPtr sectionHandle;
int status = NtCreateSection(out sectionHandle, SECTION_ALL_ACCESS, IntPtr.Zero, ref maxSize, PAGE_READWRITE, SEC_COMMIT, IntPtr.Zero);
IntPtr localBase;
long offset = 0;
ulong viewSize = 0;
status = NtMapViewOfSection(sectionHandle, (IntPtr)(-1), out localBase, IntPtr.Zero, IntPtr.Zero, out offset, out viewSize, ViewShare, 0, PAGE_READWRITE);
Marshal.Copy(dllBytes, 0, localBase, dllBytes.Length);
IntPtr remoteBase;
offset = 0;
viewSize = 0;
status = NtMapViewOfSection(sectionHandle, processHandle, out remoteBase, IntPtr.Zero, IntPtr.Zero, out offset, out viewSize, ViewShare, 0, PAGE_READWRITE);
allocatedMemoryAddress = remoteBase;
memoryAlreadyFilled = true;
NtUnmapViewOfSection((IntPtr)(-1), localBase);
if (guna2ComboBox6.SelectedIndex == 0)
{
CloseHandle(sectionHandle);
}
else if (guna2ComboBox6.SelectedIndex == 1)
{
CloseHandleNt(sectionHandle);
}
}
else if (guna2ComboBox4.SelectedIndex == 4)
{
IntPtr hSection = CreateFileMapping(new IntPtr(-1), IntPtr.Zero, PAGE_READWRITE, 0, dllSize, null);
IntPtr localView = MapViewOfFile(hSection, FILE_MAP_WRITE, 0, 0, (UIntPtr)dllSize);
Marshal.Copy(dllBytes, 0, localView, dllBytes.Length);
long offset = 0;
ulong viewSize = 0;
IntPtr remoteBase;
int status = NtMapViewOfSection(hSection, processHandle, out remoteBase, IntPtr.Zero, IntPtr.Zero, out offset, out viewSize, ViewShare, 0, PAGE_READWRITE);
allocatedMemoryAddress = remoteBase;
memoryAlreadyFilled = true;
UnmapViewOfFile(localView);
if (guna2ComboBox6.SelectedIndex == 0)
{
CloseHandle(hSection);
}
else if (guna2ComboBox6.SelectedIndex == 1)
{
CloseHandleNt(hSection);
}
}
else
{
if (guna2ComboBox5.SelectedIndex == 0)
{
allocatedMemoryAddress = VirtualAllocEx(processHandle, IntPtr.Zero, dllSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
}
else if (guna2ComboBox5.SelectedIndex == 1)
{
ulong newDllSize = (ulong)dllSize;
NtAllocateVirtualMemory(processHandle, ref allocatedMemoryAddress, IntPtr.Zero, ref newDllSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
}
else if (guna2ComboBox5.SelectedIndex == 2)
{
long maxSize = dllSize;
IntPtr sectionHandle;
int status = NtCreateSection(out sectionHandle, SECTION_ALL_ACCESS, IntPtr.Zero, ref maxSize, PAGE_READWRITE, SEC_COMMIT, IntPtr.Zero);
IntPtr localBase;
long offset = 0;
ulong viewSize = 0;
status = NtMapViewOfSection(sectionHandle, (IntPtr)(-1), out localBase, IntPtr.Zero, IntPtr.Zero, out offset, out viewSize, ViewShare, 0, PAGE_READWRITE);
Marshal.Copy(dllBytes, 0, localBase, dllBytes.Length);
IntPtr remoteBase;
offset = 0;
viewSize = 0;
status = NtMapViewOfSection(sectionHandle, processHandle, out remoteBase, IntPtr.Zero, IntPtr.Zero, out offset, out viewSize, ViewShare, 0, PAGE_READWRITE);
allocatedMemoryAddress = remoteBase;
if (guna2ComboBox6.SelectedIndex == 0)
{
CloseHandle(sectionHandle);
}
else if (guna2ComboBox6.SelectedIndex == 1)
{
CloseHandleNt(sectionHandle);
}
}
else if (guna2ComboBox5.SelectedIndex == 3)
{
IntPtr hSection = CreateFileMapping(new IntPtr(-1), IntPtr.Zero, PAGE_READWRITE, 0, dllSize, null);
IntPtr localView = MapViewOfFile(hSection, FILE_MAP_WRITE, 0, 0, (UIntPtr)dllSize);
Marshal.Copy(dllBytes, 0, localView, dllBytes.Length);
long offset = 0;
ulong viewSize = 0;
IntPtr remoteBase;
int status = NtMapViewOfSection(hSection, processHandle, out remoteBase, IntPtr.Zero, IntPtr.Zero, out offset, out viewSize, ViewShare, 0, PAGE_READWRITE);
allocatedMemoryAddress = remoteBase;
UnmapViewOfFile(localView);
if (guna2ComboBox6.SelectedIndex == 0)
{
CloseHandle(hSection);
}
else if (guna2ComboBox6.SelectedIndex == 1)
{
CloseHandleNt(hSection);
}
}
else if (guna2ComboBox5.SelectedIndex == 4)
{
allocatedMemoryAddress = VirtualAlloc2(processHandle, IntPtr.Zero, (UIntPtr)dllSize, AllocationType.MEM_RESERVE | AllocationType.MEM_COMMIT, MemoryProtection.PAGE_READWRITE, IntPtr.Zero, IntPtr.Zero);
}
}
if (!memoryAlreadyFilled)
{
if (guna2ComboBox4.SelectedIndex == 0)
{
WriteProcessMemory(processHandle, allocatedMemoryAddress, dllBytes, dllSize, 0);
}
else if (guna2ComboBox4.SelectedIndex == 1)
{
uint bytesWritten = 0;
NtWriteVirtualMemory(processHandle, allocatedMemoryAddress, dllBytes, dllSize, ref bytesWritten);
}
else if (guna2ComboBox4.SelectedIndex == 2)
{
uint bytesWritten = 0;
ZwWriteVirtualMemory(processHandle, allocatedMemoryAddress, dllBytes, dllSize, ref bytesWritten);
}
}
switch (guna2ComboBox2.SelectedIndex)
{
case 0:
CreateRemoteThread(processHandle, IntPtr.Zero, 0, loadLibraryAddress, allocatedMemoryAddress, 0, IntPtr.Zero);
break;
case 1:
RtlCreateUserThread(processHandle, IntPtr.Zero, false, 0, IntPtr.Zero, IntPtr.Zero, loadLibraryAddress, allocatedMemoryAddress, ref remoteThread, IntPtr.Zero);
break;
case 2:
NtCreateThreadEx(ref remoteThread, 0x1FFFFF, IntPtr.Zero, processHandle, loadLibraryAddress, allocatedMemoryAddress, false, 0, 0, 0, IntPtr.Zero);
break;
case 3:
foreach (ProcessThread t in Process.GetProcessById((int) processId).Threads)
{
IntPtr hThread = IntPtr.Zero;
if (guna2ComboBox6.SelectedIndex == 0)
{
hThread = OpenThread(0x0010, false, (uint)t.Id);
}
else if (guna2ComboBox6.SelectedIndex == 1)
{
hThread = NtOpenThreadReplacement((int) processId, t.Id, 0x0010);
}
if (hThread == IntPtr.Zero)
{
continue;
}
int status = NtQueueApcThread(hThread, loadLibraryAddress, allocatedMemoryAddress, IntPtr.Zero, IntPtr.Zero);
if (guna2ComboBox6.SelectedIndex == 0)
{
CloseHandle(hThread);
}
else if (guna2ComboBox6.SelectedIndex == 1)
{
CloseHandleNt(hThread);
}
}
break;
case 4:
foreach (ProcessThread t in Process.GetProcessById((int)processId).Threads)
{
IntPtr hThread = IntPtr.Zero;
if (guna2ComboBox6.SelectedIndex == 0)
{
hThread = OpenThread(0x1FFFFF, false, (uint)t.Id);
}
else if (guna2ComboBox6.SelectedIndex == 1)
{
hThread = NtOpenThreadReplacement((int)processId, t.Id, 0x1FFFFF);
}
if (hThread == IntPtr.Zero)
{
continue;
}
int status = NtQueueApcThreadEx(hThread, IntPtr.Zero, loadLibraryAddress, allocatedMemoryAddress, IntPtr.Zero, IntPtr.Zero);
if (guna2ComboBox6.SelectedIndex == 0)
{
CloseHandle(hThread);
}
else if (guna2ComboBox6.SelectedIndex == 1)
{
CloseHandleNt(hThread);
}
}
break;
}
if (guna2ComboBox6.SelectedIndex == 0)
{
CloseHandle(processHandle);
}
else if (guna2ComboBox6.SelectedIndex == 1)
{
CloseHandleNt(processHandle);
}
}
else if (guna2ComboBox3.SelectedIndex == 1)
{
uint processId = uint.Parse(listView1.SelectedItems[0].Text);
new Thread(() => ManualMapDLL(processId, guna2TextBox2.Text)).Start();
}
else if (guna2ComboBox3.SelectedIndex == 2)
{
uint processId = uint.Parse(listView1.SelectedItems[0].Text);
new Thread(() => ThreadHijack(processId, guna2TextBox2.Text)).Start();
}
else if (guna2ComboBox3.SelectedIndex == 3)
{
uint processId = uint.Parse(listView1.SelectedItems[0].Text);
new Thread(() => NativeLoader.InjectLdrLoadDll((int)processId, guna2TextBox2.Text)).Start();
}
MessageBox.Show("Succesfully injected!", "TrueInjector", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch
{
MessageBox.Show("An error occurred.", "TrueInjector", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void guna2ComboBox3_SelectedIndexChanged(object sender, EventArgs e)
{
bool enabled = guna2ComboBox3.SelectedIndex == 0;
guna2ComboBox1.Enabled = enabled;
guna2ComboBox2.Enabled = enabled;
guna2ComboBox4.Enabled = enabled;
guna2ComboBox5.Enabled = enabled;
guna2ComboBox6.Enabled = enabled;
}
}