public void TestUnmap() { LibraryMapper.MapLibrary(); LibraryMapper.UnmapLibrary(); Assert.Equal(LibraryMapper.DllBaseAddress, IntPtr.Zero); }
public void TestMap(string dllName) { var libraryMapper = new LibraryMapper(_process, Path.Combine(_testBinaryDirectoryPath, dllName)); libraryMapper.MapLibrary(); Assert.NotEqual(libraryMapper.DllBaseAddress, IntPtr.Zero); }
public void TestMapTlsCallBack() { var libraryMapper = new LibraryMapper(_process, Path.Combine(_testBinaryDirectory, "TlsCallBack.dll")); libraryMapper.MapLibrary(); Assert.NotEqual(libraryMapper.DllBaseAddress, IntPtr.Zero); }
public void TestMap() { var libraryMapper = new LibraryMapper(_process, _dllPath); libraryMapper.MapLibrary(); Assert.NotEqual(libraryMapper.DllBaseAddress, IntPtr.Zero); }
private void InjectManualMap(string dllPath) { var flags = MappingFlags.DiscardHeaders; var mapper = new LibraryMapper(ProcessMemoryManager.Process, dllPath, flags); mapper.MapLibrary(); ProcessMemoryManager.Process.Dispose(); }
public void TestMapTlsCallBack() { var libraryFilePath = Path.Combine(Path.GetFullPath(@"..\..\..\TestLibraries\x64"), "TlsCallBack.dll"); var libraryMapper = new LibraryMapper(_process, libraryFilePath); libraryMapper.MapLibrary(); Assert.NotEqual(libraryMapper.DllBaseAddress, IntPtr.Zero); }
public void TestUnmapException() { var libraryMapper = new LibraryMapper(_process, Path.Combine(_testBinaryDirectory, "Exception.dll")); libraryMapper.MapLibrary(); libraryMapper.UnmapLibrary(); Assert.Equal(libraryMapper.DllBaseAddress, IntPtr.Zero); }
public void TestUnmapException() { var libraryFilePath = Path.Combine(Path.GetFullPath(@"..\..\..\TestLibraries\x64"), "Exception.dll"); var libraryMapper = new LibraryMapper(_process, libraryFilePath); libraryMapper.MapLibrary(); libraryMapper.UnmapLibrary(); Assert.Equal(libraryMapper.DllBaseAddress, IntPtr.Zero); }
public static Status Inject(Config config) { if (config.EraseHeaders) { switch (config.InjectionMethod) { case "[BLEAK] CreateThread": try { var Injekt = new Injector(config.ProcessName, config.DllPath, InjectionMethod.CreateThread); Injekt.EjectDll(); } catch (Exception ex) { MessageBox.Show($"Eject failed using Bleak-CreateThread.\nError:\n{ex}", "BleakInjector"); break; } Status.EraseHeadersOutcome = true; break; case "[BLEAK] HijackThread": try { var Injekt2 = new Injector(config.ProcessName, config.DllPath, InjectionMethod.HijackThread); Injekt2.EjectDll(); } catch (Exception ex) { MessageBox.Show($"Inject failed using Bleak-HijackThread.\nError:\n{ex}", "BleakInjector"); break; } Status.EraseHeadersOutcome = true; break; case "[BLEAK] ManualMap": try { var Injekt3 = new Injector(config.ProcessName, config.DllPath, InjectionMethod.ManualMap); Injekt3.EjectDll(); } catch (Exception ex) { MessageBox.Show($"Inject failed using Bleak-ManualMap.\nError:\n{ex}", "BleakInjector"); break; } Status.EraseHeadersOutcome = true; break; case "BasicInjector": MessageBox.Show("This inject type dosen't support Eject.", "BleakInjector"); break; case "[RI] Injector": MessageBox.Show("This inject type dosen't support Eject.", "BleakInjector"); break; case "[LUNAR] Injector": try { foreach (Process proc in Process.GetProcessesByName(config.ProcessName)) { var LibMapper = new LibraryMapper(proc, config.DllPath); LibMapper.UnmapLibrary(); } } catch (Exception ex) { MessageBox.Show($"Inject failed using Lunar.\nError:\n{ex}", "BleakInjector"); break; } Status.EraseHeadersOutcome = true; break; } } else { switch (config.InjectionMethod) { case "[BLEAK] CreateThread": try { var Injekt = new Injector(config.ProcessName, config.DllPath, InjectionMethod.CreateThread); if (Injekt.InjectDll() != IntPtr.Zero) { Injekt.Dispose(); Status.InjectionOutcome = true; } else { MessageBox.Show("Inject failed using Bleak-CreateThread.\nError: Unknown.", "BleakInjector"); } } catch (Exception ex) { MessageBox.Show($"Inject failed using Bleak-CreateThread.\nError:\n{ex}", "BleakInjector"); } break; case "[BLEAK] HijackThread": try { var Injekt2 = new Injector(config.ProcessName, config.DllPath, InjectionMethod.HijackThread); if (Injekt2.InjectDll() != IntPtr.Zero) { Injekt2.Dispose(); Status.InjectionOutcome = true; } else { MessageBox.Show("Inject failed using Bleak-HijackThread.\nError: Unknown.", "BleakInjector"); } } catch (Exception ex) { MessageBox.Show($"Inject failed using Bleak-HijackThread.\nError:\n{ex}", "BleakInjector"); } break; case "[BLEAK] ManualMap": try { var Injekt3 = new Injector(config.ProcessName, config.DllPath, InjectionMethod.ManualMap); if (Injekt3.InjectDll() != IntPtr.Zero) { Injekt3.Dispose(); Status.InjectionOutcome = true; } else { MessageBox.Show("Inject failed using Bleak-ManualMap.\nError: Unknown.", "BleakInjector"); } } catch (Exception ex) { MessageBox.Show($"Inject failed using Bleak-ManualMap.\nError:\n{ex}", "BleakInjector"); } break; case "BasicInjector": try { if (DllInjector.BasicInject(config.ProcessName, config.DllPath) == DllInjectionResult.Success) { Status.InjectionOutcome = true; } else { if (DllInjector.BasicInject(config.ProcessName, config.DllPath) == DllInjectionResult.DllNotFound) { MessageBox.Show("Inject failed using BasicInjector.\nError: Dll not found.", "BleakInjector"); } else if (DllInjector.BasicInject(config.ProcessName, config.DllPath) == DllInjectionResult.GameProcessNotFound) { MessageBox.Show("Inject failed using BasicInjector.\nError: Target process isn't running.", "BleakInjector"); } else if (DllInjector.BasicInject(config.ProcessName, config.DllPath) == DllInjectionResult.InjectionFailed) { MessageBox.Show("Inject failed using BasicInjector.\nError: Unknown.", "BleakInjector"); } } } catch (Exception ex) { MessageBox.Show($"Inject failed using BasicInjector.\nError:\n{ex}", "BleakInjector"); } break; case "[RI] Injector": try { foreach (Process proc in Process.GetProcessesByName(config.ProcessName)) { var Injecc = new Reloaded.Injector.Injector(proc); if (Injecc.Inject(config.DllPath) != 0) { break; } else { MessageBox.Show("Inject failed using Reloaded Injector.\nError: Unknown.", "BleakInjector"); } Injecc.Dispose(); } } catch (Exception ex) { MessageBox.Show($"Inject failed using Reloaded Injector.\nError:\n{ex}", "BleakInjector"); break; } Status.InjectionOutcome = true; break; case "[LUNAR] Injector": try { foreach (Process proc in Process.GetProcessesByName(config.ProcessName)) { var LibMapper = new LibraryMapper(proc, config.DllPath); LibMapper.MapLibrary(); } } catch (Exception ex) { MessageBox.Show($"Inject failed using Lunar.\nError:\n{ex}", "BleakInjector"); break; } Status.InjectionOutcome = true; break; } if (config.CloseAfterInject) { Environment.Exit(0); } } return(Status); }