1

Fix: blocked processes still measured for game-mem detection

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.
This commit is contained in:
2026-06-22 17:41:10 +03:00
parent 565b751195
commit ea914101bb
+19 -3
View File
@@ -421,14 +421,13 @@ func main() {
if p.PID == myPID || p.PID == 0 { if p.PID == myPID || p.PID == 0 {
continue continue
} }
if _, ok := blocked[p.PID]; ok {
continue
}
h, err := openProc(p.PID, ProcessQueryLimitedInformation) h, err := openProc(p.PID, ProcessQueryLimitedInformation)
if err != nil { if err != nil {
if _, ok := blocked[p.PID]; !ok {
blocked[p.PID] = p.Name blocked[p.PID] = p.Name
logf("BLOCK %s (PID %d): %v (added to exclusion list)", p.Name, p.PID, err) logf("BLOCK %s (PID %d): %v (added to exclusion list)", p.Name, p.PID, err)
}
continue continue
} }
@@ -437,7 +436,9 @@ func main() {
r, _, e := procGetMemInfo.Call(uintptr(h), uintptr(unsafe.Pointer(&m)), uintptr(unsafe.Sizeof(m))) r, _, e := procGetMemInfo.Call(uintptr(h), uintptr(unsafe.Pointer(&m)), uintptr(unsafe.Sizeof(m)))
if r == 0 { if r == 0 {
closeH(h) closeH(h)
if _, ok := blocked[p.PID]; !ok {
logf("GetProcessMemoryInfo(%d) error: %v", p.PID, e) logf("GetProcessMemoryInfo(%d) error: %v", p.PID, e)
}
continue continue
} }
closeH(h) closeH(h)
@@ -457,9 +458,17 @@ func main() {
for _, pr := range procList { for _, pr := range procList {
p := pr.info p := pr.info
rssBytes := pr.rss rssBytes := pr.rss
isBlocked := false
if _, ok := blocked[p.PID]; ok {
isBlocked = true
}
if _, ok := gameProcs[p.PID]; ok { if _, ok := gameProcs[p.PID]; ok {
if hasGame { 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) h, err := openProc(p.PID, ProcessQueryLimitedInformation)
if err != nil { if err != nil {
continue continue
@@ -491,6 +500,9 @@ func main() {
} }
if hasGame { if hasGame {
if isBlocked {
continue
}
h, err := openProc(p.PID, ProcessQueryLimitedInformation) h, err := openProc(p.PID, ProcessQueryLimitedInformation)
if err != nil { if err != nil {
continue continue
@@ -522,6 +534,10 @@ func main() {
continue continue
} }
if isBlocked {
continue
}
if _, ok := promoted[p.PID]; ok { if _, ok := promoted[p.PID]; ok {
continue continue
} }