コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="worker"></param>
        /// <param name="arguments"></param>
        private void Process(BackgroundWorker worker, RunArguments arguments)
        {
            Thread.Sleep(1200);

            HashSet <uint> pids = FindProcesses(arguments);

            if (pids.Count == 0 && _previouslyInjected.Count == 0)
            {
                worker.ReportProgress(NoProcessFoundOnStartup, null);
            }
            else if (pids.Count == 0)
            {
                worker.ReportProgress(NoProcessFound, null);
            }

            string dll = Path.Combine(Directory.GetCurrentDirectory(), arguments.DllName);

            if (!File.Exists(dll))
            {
                Logger.Fatal($"Could not find {arguments.DllName} at \"{dll}\"");
                return;
            }

            foreach (uint pid in pids)
            {
                if (_previouslyInjected.Contains(pid))
                {
                    continue;
                }

                IntPtr remoteModuleHandle = DllInjector.NewInject(pid, dll);
                if (remoteModuleHandle == IntPtr.Zero)
                {
                    if (!_dontLog.Contains(pid))
                    {
                        Logger.Warn($"Could not inject dll into process {pid}, if this is a recurring issue, try running as administrator.");
                        worker.ReportProgress(InjectionError, $"Could not inject dll into process {pid}");
                    }

                    continue;
                }

                if (!_dontLog.Contains(pid))
                {
                    Logger.Info("Injected dll into process " + pid);
                }

                if (!InjectionVerifier.VerifyInjection(pid, arguments.DllName))
                {
                    if (!_dontLog.Contains(pid))
                    {
                        Logger.Warn("InjectionVerifier reports injection failed.");
                        worker.ReportProgress(InjectionError, $"InjectionVerifier reports injection failed into PID {pid}, try running as administrator.");
                    }

                    _dontLog.Add(pid);

                    continue;
                }

                Logger.Info("InjectionVerifier reports injection succeeded.");
                _previouslyInjected.Add(pid);
                _pidModuleHandleMap[pid] = remoteModuleHandle;
            }
        }
コード例 #2
0
        private void Process(BackgroundWorker worker, RunArguments arguments)
        {
            System.Threading.Thread.Sleep(1200);

            HashSet <uint> pids = FindProcesses(arguments);


            if (pids.Count == 0 && _previouslyInjected.Count == 0)
            {
                worker.ReportProgress(NO_PROCESS_FOUND_ON_STARTUP, null);
            }
            else if (pids.Count == 0)
            {
                worker.ReportProgress(NO_PROCESS_FOUND, null);
            }



            string dll32Bit = Path.Combine(Directory.GetCurrentDirectory(), arguments.DllName.Replace(".dll", "_x86.dll"));
            string dll64Bit = Path.Combine(Directory.GetCurrentDirectory(), arguments.DllName.Replace(".dll", "_x64.dll"));

            if (!File.Exists(dll32Bit))
            {
                Logger.FatalFormat("Could not find {1} at \"{0}\"", dll32Bit, arguments.DllName);
            }
            else if (!File.Exists(dll64Bit))
            {
                Logger.FatalFormat("Could not find {1} at \"{0}\"", dll64Bit, arguments.DllName);
            }
            else
            {
                foreach (uint pid in pids)
                {
                    if (!_previouslyInjected.Contains(pid))
                    {
                        if (Is64Bit((int)pid))
                        {
                            if (InjectionVerifier.VerifyInjection(pid, dll64Bit))
                            {
                                Logger.Info($"DLL already injected into target process, skipping injection into {pid}");
                                _dontLog.Add(pid);
                                _previouslyInjected.Add(pid);
                            }
                            else
                            {
                                Inject64Bit("Grim Dawn.exe", dll64Bit);

                                if (!InjectionVerifier.VerifyInjection(pid, dll64Bit))
                                {
                                    worker.ReportProgress(INJECTION_ERROR, null);
                                }
                            }
                        }
                        else
                        {
                            if (InjectionVerifier.VerifyInjection(pid, dll32Bit))
                            {
                                Logger.Info($"DLL already injected into target process, skipping injection into {pid}");
                                _dontLog.Add(pid);
                                _previouslyInjected.Add(pid);
                            }
                            else
                            {
                                //DllInjector.NewInject(pid, dll32Bit);
                                Inject32Bit("Grim Dawn.exe", dll32Bit);


                                if (!InjectionVerifier.VerifyInjection(pid, dll32Bit))
                                {
                                    worker.ReportProgress(INJECTION_ERROR, null);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
        private void Process(BackgroundWorker worker, RunArguments arguments)
        {
            System.Threading.Thread.Sleep(1200);

            HashSet <uint> pids = FindProcesses(arguments);


            if (pids.Count == 0 && _previouslyInjected.Count == 0)
            {
                worker.ReportProgress(NO_PROCESS_FOUND_ON_STARTUP, null);
            }
            else if (pids.Count == 0)
            {
                worker.ReportProgress(NO_PROCESS_FOUND, null);
            }



            string dll64Bit = Path.Combine(Directory.GetCurrentDirectory(), arguments.DllName.Replace(".dll", "_x64.dll"));

            if (!File.Exists(dll64Bit))
            {
                Logger.FatalFormat("Could not find {1} at \"{0}\"", dll64Bit, arguments.DllName);
            }
            else
            {
                foreach (uint pid in pids)
                {
                    if (!_previouslyInjected.Contains(pid))
                    {
                        if (Is64Bit((int)pid, worker))
                        {
                            if (InjectionVerifier.VerifyInjection(pid, dll64Bit))
                            {
                                Logger.Info($"DLL already injected into target process, skipping injection into {pid}");
                                _dontLog.Add(pid);
                                _previouslyInjected.Add(pid);
                            }
                            else
                            {
                                Inject64Bit("Grim Dawn.exe", dll64Bit, _injectionMethods.GetInjectionMethod());

                                if (!InjectionVerifier.VerifyInjection(pid, dll64Bit))
                                {
                                    Logger.Error($"Error injecting DLL into Grim Dawn. Injection method {_injectionMethods.GetInjectionMethod()}, switching to injetion method {_injectionMethods.GetNextInjectionMethod()}");
                                    _injectionMethods.SwitchInjectionMethod();


                                    worker.ReportProgress(INJECTION_ERROR, null);
                                }
                            }
                        }
                        else
                        {
                            Logger.Fatal("This version of Item Assistant does not support 32bit Grim Dawn");
                            worker.ReportProgress(INJECTION_ERROR_32BIT, null);
                        }
                    }
                    else
                    {
                        worker.ReportProgress(STILL_RUNNING, null);
                    }
                }
            }
        }