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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user