private void ControllerOnGameProcessUpdated(bool fromView, HashSet <uint> pids)
        {
            lock (this)
            {
                if (!_isStarted)
                {
                    return;
                }

                var oldCtx = new HashSet <uint>(_processContexts.Keys);
                oldCtx.ExceptWith(pids);

                foreach (var pid in oldCtx)
                {
                    if (_processContexts.TryRemove(pid, out var ctx))
                    {
                        ctx.Stop();
                    }
                }

                foreach (var pid in pids)
                {
                    _processContexts.AddOrUpdate(pid, _pid =>
                    {
                        var ctx = new ProcessContext(_pid);
                        ctx.Start();
                        return(ctx);
                    }, (_, _ctx) => _ctx);
                }
            }
        }
Beispiel #2
0
        private void ControllerOnGameProcessUpdated(bool fromView, HashSet <ProcessInfo> processes)
        {
            lock (this)
            {
                if (!_isStarted)
                {
                    return;
                }

                var oldCtx = new HashSet <uint>(_processContexts.Keys);
                oldCtx.ExceptWith(processes.Select(it => it.Pid));

                foreach (var pid in oldCtx)
                {
                    if (_processContexts.TryRemove(pid, out var ctx))
                    {
                        ctx.Stop();
                    }
                }

                // Check network parse mode
                var targetMonitorType = DetermineMonitorType();
                if (targetMonitorType != _currentMonitorType)
                {
                    _currentMonitorType = targetMonitorType;

                    // Stop all existing monitors since the parse mode has changed
                    foreach (var context in _processContexts.Values)
                    {
                        context.Stop();
                    }
                    _processContexts.Clear();

                    Logger.Info($"Parse mode = {targetMonitorType}.");
                }

                foreach (var process in processes)
                {
                    _processContexts.AddOrUpdate(process.Pid, _pid =>
                    {
                        var ctx = new ProcessContext(process, _currentMonitorType);
                        ctx.OnPingOpCodeDetected += code =>
                        {
                            Logger.Info($"IPC Ping OpCode detected for pid={_pid}: {code}");
                        };
                        ctx.Start();
                        return(ctx);
                    }, (_, _ctx) => _ctx);
                }
            }
        }
Beispiel #3
0
        private void ControllerOnGameProcessUpdated(bool fromView, HashSet <uint> pids)
        {
            lock (this)
            {
                if (!_isStarted)
                {
                    return;
                }

                var oldCtx = new HashSet <uint>(_processContexts.Keys);
                oldCtx.ExceptWith(pids);

                foreach (var pid in oldCtx)
                {
                    if (_processContexts.TryRemove(pid, out var ctx))
                    {
                        ctx.Stop();
                    }
                }

                // Check network parse mode
                var targetMonitorType = DetermineMonitorType();
                if (targetMonitorType != _currentMonitorType)
                {
                    _currentMonitorType = targetMonitorType;

                    // Stop all existing monitors since the parse mode has changed
                    foreach (var context in _processContexts.Values)
                    {
                        context.Stop();
                    }
                    _processContexts.Clear();

                    _plugin.Controller.NotifyLogMessageAppend(false, $"Parse mode = {targetMonitorType}.");
                }

                foreach (var pid in pids)
                {
                    _processContexts.AddOrUpdate(pid, _pid =>
                    {
                        var ctx = new ProcessContext(_pid, _currentMonitorType);
                        ctx.OnPingOpCodeDetected += code =>
                        {
                            _plugin.Controller.NotifyLogMessageAppend(false, $"IPC Ping OpCode detected for pid={_pid}: 0x{code:x4}");
                        };
                        ctx.Start();
                        return(ctx);
                    }, (_, _ctx) => _ctx);
                }
            }
        }
Beispiel #4
0
 public void Start()
 {
     _processHandler.OnCommandStarting();
     _processContext.Start();
     _processHandler.OnCommandCompleted();
 }