-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathConstructors.cs
49 lines (39 loc) · 1.49 KB
/
Constructors.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
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace Com.Xenthrax.DllInjector
{
public partial class DllInjector : IDisposable
{
public DllInjector(string ProcessName, bool FreeOnDispose = false)
{
if (string.IsNullOrEmpty(ProcessName))
throw new ArgumentNullException("ProcessName");
this.FreeOnDispose = FreeOnDispose;
this.Process = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(ProcessName)).FirstOrDefault();
if (this.Process == null)
throw new ArgumentException("Process does not exist", "ProcessName");
if (IntPtr.Size < this.PointerSize)
throw new ArgumentException("Process' architecture is incompatible with DllInjector's");
}
public DllInjector(int ProcessId, bool FreeOnDispose = false)
{
this.FreeOnDispose = FreeOnDispose;
this.Process = Process.GetProcessById(ProcessId);
if (this.Process == null)
throw new ArgumentException("Process does not exist", "ProcessId");
if (IntPtr.Size < this.PointerSize)
throw new ArgumentException("Process' architecture is incompatible with DllInjector's");
}
public DllInjector(Process Process, bool FreeOnDispose = false)
{
if (Process == null)
throw new ArgumentNullException("Processs");
this.FreeOnDispose = FreeOnDispose;
this.Process = Process;
if (IntPtr.Size < this.PointerSize)
throw new ArgumentException("Process' architecture is incompatible with DllInjector's");
}
}
}