示例#1
0
 public MainPresenter(IMainView viewBook)
 {
     _view          = viewBook;
     _bookModel     = new BookModel();
     _magazineModel = new MagazineModel();
     _libraryMapper = new LibraryMapper();
 }
示例#2
0
文件: X86Tests.cs 项目: okandok/Lunar
        public void TestMap(string dllName)
        {
            var libraryMapper = new LibraryMapper(_process, Path.Combine(_testBinaryDirectory, dllName));

            libraryMapper.MapLibrary();

            Assert.NotEqual(libraryMapper.DllBaseAddress, IntPtr.Zero);
        }
示例#3
0
        public void TestMap()
        {
            var libraryMapper = new LibraryMapper(_process, _dllPath);

            libraryMapper.MapLibrary();

            Assert.NotEqual(libraryMapper.DllBaseAddress, IntPtr.Zero);
        }
示例#4
0
        private void InjectManualMap(string dllPath)
        {
            var flags = MappingFlags.DiscardHeaders;

            var mapper = new LibraryMapper(ProcessMemoryManager.Process, dllPath, flags);

            mapper.MapLibrary();
        }
示例#5
0
        public void TestUnmap()
        {
            LibraryMapper.MapLibrary();

            LibraryMapper.UnmapLibrary();

            Assert.Equal(LibraryMapper.DllBaseAddress, IntPtr.Zero);
        }
示例#6
0
文件: X64Tests.cs 项目: unkmc/Lunar
        public void TestMapTlsCallBack()
        {
            var libraryMapper = new LibraryMapper(_process, Path.Combine(_testBinaryDirectory, "TlsCallBack.dll"));

            libraryMapper.MapLibrary();

            Assert.NotEqual(libraryMapper.DllBaseAddress, IntPtr.Zero);
        }
示例#7
0
        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);
        }
示例#8
0
文件: X64Tests.cs 项目: unkmc/Lunar
        public void TestUnmapException()
        {
            var libraryMapper = new LibraryMapper(_process, Path.Combine(_testBinaryDirectory, "Exception.dll"));

            libraryMapper.MapLibrary();

            libraryMapper.UnmapLibrary();

            Assert.Equal(libraryMapper.DllBaseAddress, IntPtr.Zero);
        }
示例#9
0
        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);
        }
示例#10
0
        protected MappingTester(string processFilePath, string dllFilePath)
        {
            var processStartInfo = new ProcessStartInfo {
                CreateNoWindow = true, FileName = processFilePath, UseShellExecute = true, WindowStyle = ProcessWindowStyle.Hidden
            };

            _process = new Process {
                StartInfo = processStartInfo
            };

            _process.Start();

            _process.WaitForInputIdle();

            LibraryMapper = new LibraryMapper(_process, dllFilePath);
        }
示例#11
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            dynamic ProcessHandler = null;
            dynamic ProcessID      = null;

            using (PowerShell PowerShellInst = PowerShell.Create())
            {
                string path = PathToPS1Script;
                if (!string.IsNullOrEmpty(path))
                {
                    string script = File.ReadAllText(path).Replace("###File###", PathToExe).Replace("###Path###", PathToExe.Replace("GenshinImpact.exe", ""));
                    PowerShellInst.AddScript(script);
                }

                Collection <PSObject> PSOutput = PowerShellInst.Invoke();

                ProcessHandler = PSOutput[2].Properties["hProcess"];
                ProcessID      = PSOutput[2].Properties["dwProcessID"];
            }

            if (ProcessHandler != null)
            {
                Process            Genshin = Process.GetProcesses().ToList().Find((p) => p.ProcessName == "GenshinImpact");
                LibraryMapper      lm      = new LibraryMapper(Genshin, "Resources\\HelloWorldDLL.dll", MappingFlags.DiscardHeaders);
                DllInjectionResult result  = D11_1NJ3CT0R.D11_1NJ3CT3("GenshinImpact", "Resources\\HelloWorldDLL.dll");
                if (result == DllInjectionResult.Success)
                {
                    Process p = Process.GetProcessById(ProcessID);
                    if (p.Id == ProcessID)
                    {
                        ProcessExtensions.Resume(p);
                    }
                }
                else
                {
                    MessageBox.Show("ERROR INJECTING: " + result.ToString());
                }
            }
        }
示例#12
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);
        }