From ea914101bbdc3d3ecec8aaa75728715cbcc822e4 Mon Sep 17 00:00:00 2001 From: lzrdblzzrd Date: Mon, 22 Jun 2026 17:41:10 +0300 Subject: [PATCH] Fix: blocked processes still measured for game-mem detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, when SetPriorityClass failed for a process (e.g. anti-cheat), it was added to 'blocked' and completely skipped in future scans — including RSS measurement. This meant a game that started below game-mem threshold and got blocked before reaching it would never trigger game mode. Now pass 1 measures RSS for ALL processes (including blocked ones) and adds them to gameProcs if they exceed game-mem. Pass 2 skips priority changes for blocked processes but still tracks them as game processes. In game mode, blocked game procs log 'tracked as game (blocked)' instead of trying SetPriorityClass again. --- main.go | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index c306a88..9c906a5 100644 --- a/main.go +++ b/main.go @@ -421,14 +421,13 @@ func main() { if p.PID == myPID || p.PID == 0 { continue } - if _, ok := blocked[p.PID]; ok { - continue - } h, err := openProc(p.PID, ProcessQueryLimitedInformation) if err != nil { - blocked[p.PID] = p.Name - logf("BLOCK %s (PID %d): %v (added to exclusion list)", p.Name, p.PID, err) + if _, ok := blocked[p.PID]; !ok { + blocked[p.PID] = p.Name + logf("BLOCK %s (PID %d): %v (added to exclusion list)", p.Name, p.PID, err) + } continue } @@ -437,7 +436,9 @@ func main() { r, _, e := procGetMemInfo.Call(uintptr(h), uintptr(unsafe.Pointer(&m)), uintptr(unsafe.Sizeof(m))) if r == 0 { closeH(h) - logf("GetProcessMemoryInfo(%d) error: %v", p.PID, e) + if _, ok := blocked[p.PID]; !ok { + logf("GetProcessMemoryInfo(%d) error: %v", p.PID, e) + } continue } closeH(h) @@ -457,9 +458,17 @@ func main() { for _, pr := range procList { p := pr.info rssBytes := pr.rss + isBlocked := false + if _, ok := blocked[p.PID]; ok { + isBlocked = true + } if _, ok := gameProcs[p.PID]; ok { if hasGame { + if isBlocked { + logf("GAME %s (PID %d) RSS=%s — tracked as game (blocked)", p.Name, p.PID, formatMemSize(rssBytes)) + continue + } h, err := openProc(p.PID, ProcessQueryLimitedInformation) if err != nil { continue @@ -491,6 +500,9 @@ func main() { } if hasGame { + if isBlocked { + continue + } h, err := openProc(p.PID, ProcessQueryLimitedInformation) if err != nil { continue @@ -522,6 +534,10 @@ func main() { continue } + if isBlocked { + continue + } + if _, ok := promoted[p.PID]; ok { continue }