コード例 #1
0
        public static Status Inject(Config config)
        {
            // Inject using specified method

            switch (config.InjectionMethod)
            {
            case "[BLEAK] CreateThread":

                if (Injector.CreateRemoteThread(config.DllPath, config.ProcessName))
                {
                    Status.InjectionOutcome = true;
                }

                break;

            case "[BLEAK] HijackThread":

                if (Injector.RtlCreateUserThread(config.DllPath, config.ProcessName))
                {
                    Status.InjectionOutcome = true;
                }

                break;

            case "[BLEAK] ManualMap":

                if (Injector.SetThreadContext(config.DllPath, config.ProcessName))
                {
                    Status.InjectionOutcome = true;
                }

                break;

            case "BasicInjector":
                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");
                    }
                }
                break;

            case "[RI] Injector":
                Process[] proc   = Process.GetProcessesByName(config.ProcessName);
                var       Injecc = new Reloaded.Injector.Injector(proc[0]);
                Injecc.Inject(config.DllPath);
                Status.InjectionOutcome = true;
                break;
            }

            // Erase headers if EraseHeaders is checked

            if (config.EraseHeaders)
            {
                if (Injector.EraseHeaders(config.DllPath, config.ProcessName))
                {
                    Status.EraseHeadersOutcome = true;
                }
            }

            // Close the program if CloseAfterInject is checked

            if (config.CloseAfterInject)
            {
                Application.Exit();
            }

            return(Status);
        }
コード例 #2
0
        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);
        }