604642598f
During a session the game was looked up twice every 3 s (identity + CPU time, each a GetProcessById and the identity a full process snapshot for SessionId), and every 15 s a model was built for every process on the machine to find a few listed background names. - The game is held open for the session (Process + Exited): its exit ends the session at once, under the same lock as the tick; CPU time for the load sampling is read from the same handle. The identity is re-checked through the held handle, which also pins the PID. - The handle is verified with one wait before the exit wait is registered, so a handle without SYNCHRONIZE (anti-cheat) falls into the polling fallback instead of failing on the runtime's wait thread. A denied or protected game keeps the previous polling. - The rescan filters the GetProcesses snapshot by listed name before any model is built; exact paths are still checked afterwards. - Session id read with ProcessIdToSessionId instead of Process.SessionId (a full snapshot per listed background process every 15 s). Ownership, journal and restore unchanged. +8 tests (903/903).
66 lines
2.3 KiB
C#
66 lines
2.3 KiB
C#
namespace ThreadPilot.Services
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Diagnostics;
|
|
using System.Threading.Tasks;
|
|
using ThreadPilot.Models;
|
|
|
|
public interface IProcessService
|
|
{
|
|
Task<ObservableCollection<ProcessModel>> GetProcessesAsync();
|
|
|
|
Task SetProcessorAffinity(ProcessModel process, long affinityMask);
|
|
|
|
Task<AffinityApplyResult> SetProcessorAffinity(ProcessModel process, CpuSelection selection);
|
|
|
|
Task SetProcessPriority(ProcessModel process, ProcessPriorityClass priority);
|
|
|
|
Task SetProcessPriority(ProcessModel process, ProcessPriorityClass priority, ProcessPriorityWriteSource source);
|
|
|
|
Task<bool> SaveProcessProfile(string profileName, ProcessModel process);
|
|
|
|
Task<bool> LoadProcessProfile(string profileName, ProcessModel process);
|
|
|
|
Task RefreshProcessInfo(ProcessModel process);
|
|
|
|
Task<IReadOnlyList<int>?> GetCpuAssignmentLogicalProcessorIndexesAsync(
|
|
ProcessModel process,
|
|
CpuAssignmentMode mode);
|
|
|
|
Task<ProcessModel?> GetProcessByIdAsync(int processId);
|
|
|
|
Task<IEnumerable<ProcessModel>> GetProcessesByNameAsync(string executableName);
|
|
|
|
Task<bool> IsProcessRunningAsync(string executableName);
|
|
|
|
/// <summary>Models only for processes whose snapshot name (no ".exe") passes <paramref name="nameFilter"/>, so the rest cost no queries.</summary>
|
|
Task<IEnumerable<ProcessModel>> GetProcessesWithPathsAsync(Func<string, bool> nameFilter);
|
|
|
|
Task<ObservableCollection<ProcessModel>> GetActiveApplicationsAsync();
|
|
|
|
ProcessModel CreateProcessModel(Process process);
|
|
|
|
Task<bool> IsProcessStillRunning(ProcessModel process);
|
|
|
|
Task<bool> SetRegistryPriorityAsync(ProcessModel process, bool enable, ProcessPriorityClass priority);
|
|
|
|
void SetUseCpuSets(bool useCpuSets);
|
|
|
|
bool GetUseCpuSets();
|
|
|
|
Task<bool> ClearProcessCpuSetAsync(ProcessModel process);
|
|
|
|
Task ClearAllAppliedMasksAsync();
|
|
|
|
Task ResetAllProcessPrioritiesAsync();
|
|
|
|
void TrackAppliedMask(int processId, string maskId);
|
|
|
|
void TrackPriorityChange(int processId, ProcessPriorityClass originalPriority);
|
|
|
|
void UntrackProcess(int processId);
|
|
}
|
|
}
|