private void ExecuteEjectCommand(object parameter)
        {
            IntPtr handle = Native.OpenProcess(ProcessAccessRights.PROCESS_ALL_ACCESS, false, SelectedAssembly.ProcessId);

            if (handle == IntPtr.Zero) {
                Status = "Failed to open process";
                return;
            }

            IsExecuting = true;
            Status = "Ejecting " + SelectedAssembly.Name;

            ProcessUtils.GetMonoModule(handle, out IntPtr mono);

            using (Injector injector = new Injector(handle, mono)) {
                try {
                    injector.Eject(SelectedAssembly.Address, EjectNamespace, EjectClassName, EjectMethodName);
                    InjectedAssemblies.Remove(SelectedAssembly);
                    Status = "Ejection successful";
                } catch (InjectorException ie) {
                    Status = "Ejection failed: " + ie.Message;
                } catch (Exception e) {
                    Status = "Ejection failed (unknown error): " + e.Message;
                }
            }

            IsExecuting = false;
        }
        private void ExecuteInjectCommand(object parameter)
        {
            IntPtr handle = Native.OpenProcess(ProcessAccessRights.PROCESS_ALL_ACCESS, false, SelectedProcess.Id);

            if (handle == IntPtr.Zero)
            {
                Status = "Failed to open process";
                return;
            }

            byte[] file;

            try
            {
                file = File.ReadAllBytes(AssemblyPath);
            }
            catch (IOException)
            {
                Status = "Failed to read the file " + AssemblyPath;
                return;
            }

            IsExecuting = true;
            Status      = "Injecting " + Path.GetFileName(AssemblyPath);

            using (Injector injector = new Injector(handle, SelectedProcess.MonoModule))
            {
                try
                {
                    IntPtr asm = injector.Inject(file, InjectNamespace, InjectClassName, InjectMethodName);
                    InjectedAssemblies.Add(new InjectedAssembly
                    {
                        ProcessId = SelectedProcess.Id,
                        Address   = asm,
                        Name      = Path.GetFileName(AssemblyPath),
                        Is64Bit   = injector.Is64Bit
                    });
                    Status = "Injection successful";
                }
                catch (InjectorException ie)
                {
                    Status = "Injection failed: " + ie.Message;
                }
                catch (Exception e)
                {
                    Status = "Injection failed (unknown error): " + e.Message;
                }
            }

            IsExecuting = false;
        }