示例#1
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);
                            }
                        }
                        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
                            {
                                Inject32Bit("Grim Dawn.exe", dll32Bit);
                            }
                        }
                    }
                }
            }
        }
示例#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 dll = Path.Combine(Directory.GetCurrentDirectory(), arguments.DllName);

            if (!File.Exists(dll))
            {
                Logger.FatalFormat("Could not find {1} at \"{0}\"", dll, arguments.DllName);
            }
            else
            {
                foreach (uint pid in pids)
                {
                    if (!_previouslyInjected.Contains(pid))
                    {
                        //DllInjector.adjustDebugPriv(pid);
                        IntPtr remoteModuleHandle = DllInjector.NewInject(pid, dll);
                        if (remoteModuleHandle == IntPtr.Zero)
                        {
                            if (!_dontLog.Contains(pid))
                            {
                                Logger.WarnFormat("Could not inject dll into process {0}, if this is a recurring issue, try running as administrator.", pid);
                                worker.ReportProgress(INJECTION_ERROR, "Could not inject dll into process " + pid);
                            }
                        }
                        else
                        {
                            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.");
                                    ExceptionReporter.ReportIssue("InjectionVerifier reports injection failed into PID " + pid);
                                    worker.ReportProgress(INJECTION_ERROR, string.Format("InjectionVerifier reports injection failed into PID {0}, try running as administrator.", pid));
                                }


                                _dontLog.Add(pid);
                            }
                            else
                            {
                                Logger.Info("InjectionVerifier reports injection succeeded.");
                                _previouslyInjected.Add(pid);
                                _pidModuleHandleMap[pid] = remoteModuleHandle;
                            }
                        }
                    }
                }
            }
        }