/// <summary> /// An instance capable of injecting a DLL into a remote process /// </summary> public Injector(string processName, byte[] dllBytes, InjectionMethod injectionMethod, InjectionFlags injectionFlags = InjectionFlags.None) { if (injectionMethod == InjectionMethod.ManualMap) { _injectionMethod = new ManualMap(dllBytes, GetProcess(processName), injectionFlags); } else { var dllPath = CreateTemporaryDll(dllBytes); switch (injectionMethod) { case InjectionMethod.CreateThread: { _injectionMethod = new CreateThread(dllPath, GetProcess(processName), injectionFlags); break; } case InjectionMethod.HijackThread: { _injectionMethod = new HijackThread(dllPath, GetProcess(processName), injectionFlags); break; } } } }
/// <summary> /// An instance capable of injecting a DLL into a remote process /// </summary> public Injector(int processId, string dllPath, InjectionMethod injectionMethod, InjectionFlags injectionFlags = InjectionFlags.None) { if (injectionFlags.HasFlag(InjectionFlags.RandomiseDllName)) { dllPath = CreateTemporaryDll(File.ReadAllBytes(dllPath)); } switch (injectionMethod) { case InjectionMethod.CreateThread: { _injectionMethod = new CreateThread(dllPath, GetProcess(processId), injectionFlags); break; } case InjectionMethod.HijackThread: { _injectionMethod = new HijackThread(dllPath, GetProcess(processId), injectionFlags); break; } case InjectionMethod.ManualMap: { _injectionMethod = new ManualMap(dllPath, GetProcess(processId), injectionFlags); break; } } }
/// <summary> /// Provides the ability to inject a DLL into a process /// </summary> public Injector(string processName, byte[] dllBytes, InjectionMethod injectionMethod, InjectionFlags injectionFlags = InjectionFlags.None) { if (injectionMethod == InjectionMethod.ManualMap) { _injectionBase = new ManualMap(dllBytes, GetProcess(processName), injectionMethod, injectionFlags); } else if (injectionMethod == InjectionMethod.CreateThread || injectionMethod == InjectionMethod.HijackThread) { _injectionBase = new LdrLoadDll(CreateTemporaryDll(dllBytes), GetProcess(processName), injectionMethod, injectionFlags); } else { throw new ArgumentException("The injection method provided was invalid"); } }
/// <summary> /// Provides the ability to inject a DLL into a process /// </summary> public Injector(string processName, string dllPath, InjectionMethod injectionMethod, InjectionFlags injectionFlags = InjectionFlags.None) { if (injectionFlags.HasFlag(InjectionFlags.RandomiseDllName)) { dllPath = CreateTemporaryDll(File.ReadAllBytes(dllPath)); } if (injectionMethod == InjectionMethod.ManualMap) { _injectionBase = new ManualMap(dllPath, GetProcess(processName), injectionMethod, injectionFlags); } else if (injectionMethod == InjectionMethod.CreateThread || injectionMethod == InjectionMethod.HijackThread) { _injectionBase = new LdrLoadDll(dllPath, GetProcess(processName), injectionMethod, injectionFlags); } else { throw new ArgumentException("The injection method provided was invalid"); } }