Esempio n. 1
0
        private void UpdateProcess(Process proc)
        {
            bool showDX9MsgBox = false;

            _processLock.EnterWriteLock();
            try
            {
                if (processHandle != IntPtr.Zero)
                {
                    CloseProcessHandle();
                }

                if (proc == null || proc.HasExited)
                {
                    return;
                }

                if (proc.ProcessName == "ffxiv")
                {
                    if (!hasLoggedDx9)
                    {
                        hasLoggedDx9  = true;
                        showDX9MsgBox = true;
                        logger.Log(LogLevel.Error, "{0}", "不支持 DX9 模式启动的游戏,请参考 https://www.yuque.com/ffcafe/act/dx11/ 解决");
                    }
                    return;
                }
                else if (proc.ProcessName != "ffxiv_dx11")
                {
                    logger.Log(LogLevel.Error, "{0}", "Unknown ffxiv process.");
                    return;
                }
                try
                {
                    process       = proc;
                    processHandle = NativeMethods.OpenProcess(ProcessAccessFlags.VirtualMemoryRead, false, proc.Id);
                    logger.Log(LogLevel.Info, "游戏进程:{0},来源:解析插件订阅", proc.Id);
                }
                catch (Exception e)
                {
                    logger.Log(LogLevel.Error, "Failed to open FFXIV process: {0}", e);
                    process       = null;
                    processHandle = IntPtr.Zero;
                }
            }
            finally
            {
                _processLock.ExitWriteLock();
                if (showDX9MsgBox)
                {
                    MessageBox.Show("现在 ACT 的部分功能不支持 DX9 启动的游戏。\r\n请在游戏启动器器设置里选择以 DX11 模式运行游戏。", "兼容提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            OnProcessChange?.Invoke(this, null);
        }
Esempio n. 2
0
        public bool IsValid()
        {
            if (this.process != null && this.process.HasExited)
            {
                this.process = null;
                OnProcessChange.Invoke(this.process);
            }
            if (this.process != null)
            {
                return(true);
            }
            this.process = FindProcess();
            if (this.process == null)
            {
                return(false);
            }

            OnProcessChange.Invoke(this.process);
            return(true);
        }
Esempio n. 3
0
        public bool IsValid()
        {
            if (process != null && process.HasExited)
            {
                CloseProcessHandle();
                OnProcessChange?.Invoke(this, null);
            }

            if (processHandle != IntPtr.Zero)
            {
                return(true);
            }

            FindProcess();
            if (processHandle == IntPtr.Zero || process == null || process.HasExited)
            {
                return(false);
            }

            OnProcessChange?.Invoke(this, null);
            return(true);
        }
Esempio n. 4
0
        private void UpdateProcess(Process proc)
        {
            if (processHandle != IntPtr.Zero)
            {
                CloseProcessHandle();
            }

            if (proc == null || proc.HasExited)
            {
                return;
            }

            if (proc.ProcessName == "ffxiv")
            {
                logger.Log(LogLevel.Error, "{0}", "DX9 is not supported.");
                return;
            }
            else if (proc.ProcessName != "ffxiv_dx11")
            {
                logger.Log(LogLevel.Error, "{0}", "Unknown ffxiv process.");
                return;
            }

            try {
                process       = proc;
                processHandle = NativeMethods.OpenProcess(ProcessAccessFlags.VirtualMemoryRead, false, proc.Id);
            } catch (Exception e)
            {
                logger.Log(LogLevel.Error, "Failed to open FFXIV process: {0}", e);

                process       = null;
                processHandle = IntPtr.Zero;
            }

            OnProcessChange?.Invoke(this, null);
        }
Esempio n. 5
0
        public bool IsValid()
        {
            bool hasChangedProcess = false;

            _processLock.EnterWriteLock();
            try
            {
                if (process != null && process.HasExited)
                {
                    CloseProcessHandle();
                    hasChangedProcess = true;
                }

                if (processHandle != IntPtr.Zero)
                {
                    return(true);
                }

                FindProcess();

                if (processHandle == IntPtr.Zero || process == null || process.HasExited)
                {
                    return(false);
                }
                hasChangedProcess = true;
                return(true);
            }
            finally
            {
                _processLock.ExitWriteLock();
                if (hasChangedProcess)
                {
                    OnProcessChange?.Invoke(this, null);
                }
            }
        }