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).
Add safe CpuSelection affinity apply path
Introduce a structured CpuSelection affinity apply path that tries CPU Sets first and falls back to legacy ProcessorAffinity only when the selection is safely representable as a non-zero single-group <64 mask.
- Add structured AffinityApplyResult fields and error codes
- Add CpuSelectionAffinityApplier with CPU Sets-first behavior
- Add ProcessService overload for CpuSelection affinity apply
- Block unsafe legacy fallback for multi-group and CPU >=64 selections
- Preserve existing legacy SetProcessorAffinity(long) behavior
- Add audit coverage for CpuSelection apply success/failure paths
- Add tests for safe fallback, blocked fallback, access denied, process exit and invalid selection
No UI, preset generator, profile migration, registry/IFEO, priority guardrail, versioning or tag changes.
Replaces the project's license from GNU GPL v3 to the GNU Affero General Public License v3: updated LICENSE (full AGPL text) and updated license headers across source files. Adds InternalsVisibleTo("ThreadPilot.Core.Tests") (plus using System.Runtime.CompilerServices) in AssemblyInfo to allow test access to internal types. Also introduces Services/TaskSafety.cs and two new test files under Tests/ThreadPilot.Core.Tests to cover task safety. These changes apply the AGPLv3 terms and enable internal API access for unit tests.