Пример #1
0
        private async Task GetProcess()
        {
            Process[] processes = Process.GetProcesses();
            Process?  proc      = null;

            // Search for ffxiv process
            if (this.EnableProcess)
            {
                foreach (Process process in processes)
                {
                    if (process.ProcessName.ToLower().Contains("ffxiv_dx11"))
                    {
                        proc = process;
                    }
                }
            }

            // if no process, open the process selector GUI
            if (proc == null)
            {
                await Dispatch.MainThread();

                if (App.Current == null)
                {
                    return;
                }

                App.Current.MainWindow.Topmost = false;

                proc = ProcessSelector.FindProcess();

                if (SettingsService.Exists)
                {
                    App.Current.MainWindow.Topmost = SettingsService.Current.AlwaysOnTop;
                }

                await Dispatch.NonUiThread();
            }

            // if still no process, shutdown.
            if (proc == null)
            {
                await Dispatch.MainThread();

                App.Current.MainWindow.Close();
                App.Current.Shutdown();

                return;
            }

            this.OpenProcess(proc);
            await AddressService.Scan();

            IsProcessAlive = true;
        }
Пример #2
0
        private async Task <Process> OnSelectProcess()
        {
            return(await App.Current.Dispatcher.InvokeAsync <Process>(() =>
            {
                Process proc = ProcessSelector.FindProcess();

                if (proc == null)
                {
                    Application.Current.Shutdown();
                }

                return proc;
            }));
        }
Пример #3
0
        private async Task GetProcess()
        {
            Process[] processes = Process.GetProcesses();
            Process?  proc      = null;

            // Search for ffxiv process
            foreach (Process process in processes)
            {
                if (process.ProcessName.ToLower().Contains("ffxiv_dx11"))
                {
                    proc = process;
                }
            }

            // if no process, open the process selector GUI
            if (proc == null)
            {
                proc = await App.Current.Dispatcher.InvokeAsync <Process?>(() =>
                {
                    App.Current.MainWindow.Topmost = false;

                    Process?proc = ProcessSelector.FindProcess();

                    if (proc == null)
                    {
                        App.Current.Shutdown();
                    }

                    App.Current.MainWindow.Topmost = SettingsService.Current.AlwaysOnTop;

                    return(proc);
                });
            }

            // if still no process, shutdown.
            if (proc == null)
            {
                throw new Exception("Unable to locate FFXIV process");
            }

            this.OpenProcess(proc);
            await AddressService.Scan();

            IsProcessAlive = true;
        }
 private void _selectProcessButton_Click(object sender, EventArgs e)
 {
     using (var processSelector = new ProcessSelector(AppStateSingleton.Instance().GetRecentProcessesList()))
     {
         var result = processSelector.ShowDialog(this);
         if (result == DialogResult.Cancel)
         {
             return;
         }
         _selectedProcess = processSelector.SelectedProcess;
         DisplayProcessInfoForInjection();
         // pre-select the dll if there's no dll selected
         if (string.IsNullOrEmpty(_dllFilenameTextBox.Text))
         {
             _dllFilenameTextBox.Text = AppStateSingleton.Instance().GetDllNameForSelectedProcess(_selectedProcess?.MainModule?.ModuleName) ?? string.Empty;
         }
     }
 }
Пример #5
0
        private async Task GetProcess()
        {
            Process?proc = null;

            await Dispatch.MainThread();

            if (App.Current == null)
            {
                return;
            }

            App.Current.MainWindow.Topmost = false;

            proc = ProcessSelector.FindProcess();

            if (SettingsService.Exists)
            {
                App.Current.MainWindow.Topmost = SettingsService.Current.AlwaysOnTop;
            }

            await Dispatch.NonUiThread();

            // if still no process, shutdown.
            if (proc == null)
            {
                await Dispatch.MainThread();

                App.Current.MainWindow.Close();
                App.Current.Shutdown();

                return;
            }

            this.OpenProcess(proc);
            await AddressService.Scan();

            IsProcessAlive = true;
        }
Пример #6
0
        public Task Initialize()
        {
            Instance      = this;
            this.isActive = true;
            this.memoryTypeLookup.Clear();

            // Gets all Memory types (Like IntMemory, FloatMemory) and puts them in the lookup
            foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                foreach (Type type in asm.GetTypes())
                {
                    if (type.IsAbstract || type.IsInterface)
                    {
                        continue;
                    }

                    if (typeof(MemoryBase).IsAssignableFrom(type))
                    {
                        if (type.BaseType.IsGenericType)
                        {
                            Type[] generics = type.BaseType.GetGenericArguments();
                            if (generics.Length == 1)
                            {
                                this.memoryTypeLookup.Add(generics[0], type);
                            }
                        }
                    }
                }
            }

#if NO_GAME
            this.Process = new DummyProcess();
#else
            this.Process = new WinProcess();
#endif

            while (!this.ProcessIsAlive)
            {
                try
                {
                    Process[] processes = System.Diagnostics.Process.GetProcesses();
                    Process   proc      = null;
                    foreach (Process process in processes)
                    {
                        if (process.ProcessName.ToLower().Contains("ffxiv_dx11"))
                        {
                            if (proc != null)
                            {
                                throw new Exception("Multiple processes found");
                            }

                            proc = process;
                        }
                    }

                    if (proc == null)
                    {
                        throw new Exception("No process found");
                    }

                    this.Process.OpenProcess(proc);
                    this.ProcessIsAlive = true;
                }
                catch (Exception)
                {
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        Process proc = ProcessSelector.FindProcess();

                        if (proc == null)
                        {
                            App.Current.Shutdown();
                            return;
                        }

                        try
                        {
                            this.Process.OpenProcess(proc);
                            this.ProcessIsAlive = true;
                        }
                        catch (Exception ex)
                        {
                            Log.Write(ex);
                        }
                    });
                }
            }

            return(Task.CompletedTask);
        }