One double-click kit (scripts/m0/run_m0.bat) that measures the gaming PC and packs the results into a single zip: - PC info (GPU, driver, RAM, disks, monitors) - Windows checks with the user: bot browser window hidden from Alt+Tab but listed in Discord's share picker and still drawing while covered; Discord pop-out stream window identification and occlusion; installed games, anti-cheat services and the borderless game detector - MeloTTS, CosyVoice2 and Fun-CosyVoice3 Korean synthesis speed - faster-whisper large-v3-turbo: final/partial latency, CER, wake-word hint, batched decoding for several speakers - Strata LLM (fast and recommended presets): TTFT by context length, decode speed, tool calls, picture reading per quality tier, Korean answers, parallel requests, VRAM give-back and restart/switch timings uv and Python, per-stage venvs, models and Strata all live inside the work folder. Results are scrubbed of user/computer names and home paths. Verified on Linux GPU (LLM client against Ollama, STT, MeloTTS, CosyVoice2/3) and on the Windows 11 CI VM (window checks, game scan, MeloTTS/CosyVoice2/STT installs, Strata install and plan). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
404 lines
19 KiB
Python
404 lines
19 KiB
Python
"""Stage: Windows checks that need the user at the PC.
|
|
|
|
botwin bot browser window: hidden from Alt+Tab/taskbar but still listed in
|
|
Discord's screen-share picker, and still drawing while covered
|
|
discord a popped-out Discord stream window: how to recognise it, and
|
|
whether Discord stops drawing it while it is covered
|
|
games installed games and anti-cheat, and the borderless-window detector
|
|
on a game the user starts
|
|
|
|
Privacy: window titles of other programs are not stored. The Discord pop-out
|
|
title is stored only if the user agrees (it can contain a friend's name).
|
|
Game names and exe names are stored; folders are reduced to the launcher name.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
import re
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
from m0lib.common import IS_WINDOWS, StageResult, ask, say, stage_args, step, wait_enter # noqa: E402
|
|
|
|
TEST_TITLE = "Jarvis 브라우저 테스트"
|
|
|
|
ANTICHEAT_PROCS = {
|
|
"vgc.exe": "Vanguard", "vgtray.exe": "Vanguard",
|
|
"easyanticheat.exe": "Easy Anti-Cheat", "easyanticheat_eos.exe": "Easy Anti-Cheat (EOS)",
|
|
"beservice.exe": "BattlEye", "beservice_x64.exe": "BattlEye",
|
|
"faceit.exe": "FACEIT", "faceitservice.exe": "FACEIT",
|
|
"gamemon.des": "nProtect GameGuard", "gamemon64.des": "nProtect GameGuard", "npggnt.des": "nProtect GameGuard",
|
|
"xxd-0.xem": "XIGNCODE3", "x3.xem": "XIGNCODE3",
|
|
"sguard64.exe": "ACE (Tencent)", "sguardsvc64.exe": "ACE (Tencent)", "ace-tray.exe": "ACE (Tencent)",
|
|
"eaanticheat.gameservice.exe": "EA AntiCheat", "eaanticheat.gameservicelauncher.exe": "EA AntiCheat",
|
|
"pnkbstra.exe": "PunkBuster", "pnkbstrb.exe": "PunkBuster",
|
|
"ricochet": "Ricochet",
|
|
}
|
|
ANTICHEAT_SERVICES = ["vgc", "vgk", "EasyAntiCheat", "EasyAntiCheat_EOS", "BEService", "BEDaisy", "FACEIT",
|
|
"FACEITService", "npggsvc", "xhunter1", "ACE-BASE", "AntiCheatExpert Service", "ACE-GAME",
|
|
"EAAntiCheatService", "PnkBstrA", "mhyprot3", "zksvc", "atvi-randgrid_sr"]
|
|
RIOT_GAME_EXES = {"valorant-win64-shipping.exe": "VALORANT", "league of legends.exe": "League of Legends"}
|
|
ANTICHEAT_MARKERS = {"easyanticheat": "Easy Anti-Cheat", "battleye": "BattlEye", "gameguard": "nProtect GameGuard",
|
|
"xigncode": "XIGNCODE3", "anticheatexpert": "ACE (Tencent)", "eaanticheat": "EA AntiCheat"}
|
|
|
|
|
|
def html_page(path: Path) -> Path:
|
|
path.write_text(f"""<!doctype html><html><head><meta charset="utf-8"><title>{TEST_TITLE}</title>
|
|
<style>body{{margin:0;font:64px sans-serif;display:flex;align-items:center;justify-content:center;height:100vh}}</style>
|
|
</head><body><div id="t"></div><script>
|
|
function f(){{const d=new Date();document.getElementById('t').textContent=d.toLocaleTimeString()+'.'+String(d.getMilliseconds()).padStart(3,'0');
|
|
document.body.style.background='hsl('+(d.getTime()/20%360)+',60%,80%)';}}setInterval(f,50);f();
|
|
</script></body></html>""", encoding="utf-8")
|
|
return path
|
|
|
|
|
|
def find_browser() -> str | None:
|
|
cands = [os.path.expandvars(p) for p in (
|
|
r"%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe",
|
|
r"%ProgramFiles%\Microsoft\Edge\Application\msedge.exe",
|
|
r"%ProgramFiles%\Google\Chrome\Application\chrome.exe",
|
|
r"%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe")]
|
|
return next((p for p in cands if os.path.exists(p)), None)
|
|
|
|
|
|
class Cover:
|
|
"""An opaque always-on-top window placed exactly over another window."""
|
|
|
|
def __init__(self, rect: list[int]):
|
|
import tkinter as tk
|
|
self.root = tk.Tk()
|
|
self.root.overrideredirect(True)
|
|
self.root.attributes("-topmost", True)
|
|
self.root.configure(bg="#202020")
|
|
left, top, right, bottom = rect
|
|
pad = 20
|
|
self.root.geometry(f"{right - left + 2 * pad}x{bottom - top + 2 * pad}+{left - pad}+{top - pad}")
|
|
tk.Label(self.root, text="M0 가림 테스트 중 (몇 초 뒤 사라집니다)", fg="white", bg="#202020",
|
|
font=("Malgun Gothic", 20)).pack(expand=True)
|
|
self.pump(0.5)
|
|
|
|
def pump(self, seconds: float) -> None:
|
|
end = time.time() + seconds
|
|
while time.time() < end:
|
|
self.root.update()
|
|
time.sleep(0.02)
|
|
|
|
def close(self) -> None:
|
|
self.root.destroy()
|
|
|
|
|
|
def frames(hwnd: int, seconds: float, cover: Cover | None = None, interval: float = 0.25) -> dict:
|
|
from m0lib import winwin as w
|
|
hashes, black = [], 0
|
|
end = time.time() + seconds
|
|
while time.time() < end:
|
|
h, is_black = w.capture_hash(hwnd)
|
|
hashes.append(h)
|
|
black += int(is_black)
|
|
if cover:
|
|
cover.pump(interval)
|
|
else:
|
|
time.sleep(interval)
|
|
distinct = len({h for h in hashes if h})
|
|
return {"captures": len(hashes), "distinct": distinct, "black": black,
|
|
"drawing": distinct >= max(2, len(hashes) // 3)}
|
|
|
|
|
|
# --------------------------------------------------------------------------
|
|
|
|
def check_botwin(r: StageResult, work: Path) -> None:
|
|
from m0lib import winwin as w
|
|
step("1/3 봇용 크롬창: Alt+Tab 숨김과 디스코드 화면공유 목록")
|
|
res: dict = {}
|
|
r["botwin"] = res
|
|
browser = find_browser()
|
|
if not browser:
|
|
r.error("botwin", "Edge/Chrome을 찾지 못했습니다")
|
|
return
|
|
res["browser"] = os.path.basename(browser)
|
|
page = html_page(work / "m0_clock.html")
|
|
profile = work / "browser_test_profile"
|
|
proc = subprocess.Popen([browser, f"--user-data-dir={profile}", "--no-first-run", "--no-default-browser-check",
|
|
"--disable-backgrounding-occluded-windows", "--disable-renderer-backgrounding",
|
|
"--disable-background-timer-throttling", "--window-size=900,600",
|
|
"--window-position=200,200", f"--app={page.as_uri()}"])
|
|
try:
|
|
hwnd = None
|
|
for _ in range(60):
|
|
time.sleep(0.5)
|
|
for win in w.top_windows():
|
|
if TEST_TITLE in win["title"] and win["class"].startswith("Chrome_WidgetWin"):
|
|
hwnd = win["hwnd"]
|
|
break
|
|
if hwnd:
|
|
break
|
|
if not hwnd:
|
|
r.error("botwin", "테스트 창을 찾지 못했습니다")
|
|
return
|
|
res["visible_normal"] = frames(hwnd, 3)
|
|
say(f"\n '{TEST_TITLE}' 창(시계가 움직이는 창)을 띄웠습니다.")
|
|
say(" 디스코드에서 '화면 공유' 버튼을 누르고 '창'(애플리케이션) 목록을 열어 보세요. 확인만 하고 공유는 취소하셔도 됩니다.")
|
|
res["discord_list_normal"] = ask(f" 일반 창 상태: 목록에 '{TEST_TITLE}'가 보이나요? (s=디스코드 없음/건너뛰기)",
|
|
"yns", "s")
|
|
|
|
w.set_tool_window(hwnd)
|
|
time.sleep(2)
|
|
info = w.window_info(hwnd)
|
|
res["toolwindow_style_kept"] = bool(info["exstyle"] & w.WS_EX_TOOLWINDOW)
|
|
say("\n 같은 창을 '도구 창' 속성으로 바꾸고 맨 뒤로 보냈습니다.")
|
|
res["alt_tab_hidden"] = ask(" Alt+Tab을 눌러 보세요. 목록에서 이 창이 빠졌나요?", "yn")
|
|
res["taskbar_hidden"] = ask(" 작업 표시줄에서도 이 창 아이콘이 빠졌나요?", "yn")
|
|
res["win_tab_hidden"] = ask(" Win+Tab(작업 보기)에서도 빠졌나요?", "yn")
|
|
say(" 디스코드 '화면 공유 → 창' 목록을 닫았다가 다시 열어 보세요.")
|
|
res["discord_list_toolwindow"] = ask(f" 도구 창 상태: 목록에 '{TEST_TITLE}'가 아직 보이나요? (s=건너뛰기)",
|
|
"yns", "s")
|
|
if res["discord_list_toolwindow"] == "y":
|
|
say(" 그 창을 실제로 화면공유해 보세요(나만 있는 채널도 괜찮습니다). 공유를 시작했으면 Enter.")
|
|
if wait_enter(" (건너뛰려면 s 입력 후 Enter)") != "s":
|
|
cover = Cover(info["rect"])
|
|
try:
|
|
res["covered_capture"] = frames(hwnd, 6, cover)
|
|
finally:
|
|
cover.close()
|
|
res["discord_preview_moving_while_covered"] = ask(
|
|
" 방금 창이 가려져 있는 동안 디스코드 화면공유 미리보기의 시계가 계속 움직였나요?", "yns", "s")
|
|
if "covered_capture" not in res:
|
|
cover = Cover(info["rect"])
|
|
try:
|
|
res["covered_capture"] = frames(hwnd, 4, cover)
|
|
finally:
|
|
cover.close()
|
|
say(f" 가려졌을 때 창 그리기 계속: {'예' if res['covered_capture']['drawing'] else '아니요'}")
|
|
finally:
|
|
w.kill_tree(proc.pid)
|
|
w.kill_by_cmdline(profile.name)
|
|
|
|
|
|
def check_discord(r: StageResult) -> None:
|
|
from m0lib import winwin as w
|
|
step("2/3 디스코드 화면공유 창 분리(팝아웃)")
|
|
res: dict = {}
|
|
r["discord"] = res
|
|
procs = w.processes()
|
|
pids = {pid for pid, name in procs.items() if name == "discord.exe"}
|
|
res["discord_running"] = bool(pids)
|
|
if not pids:
|
|
say(" 디스코드가 실행 중이 아니라 건너뜁니다.")
|
|
return
|
|
|
|
def dwins() -> dict[int, dict]:
|
|
return {x["hwnd"]: x for x in w.top_windows() if x["pid"] in pids and x["title"]}
|
|
|
|
before = dwins()
|
|
say(" 친구(또는 다른 기기의 내 계정)의 화면공유를 시청하고, 시청 화면 오른쪽 위의 '창 분리(팝아웃)' 버튼을 눌러 주세요.")
|
|
say(" 화면에 계속 움직이는 내용(영상 등)이 나오면 더 정확합니다.")
|
|
if wait_enter(" 분리된 창이 떴으면 Enter, 지금 할 수 없으면 s 입력 후 Enter:") == "s":
|
|
res["skipped"] = True
|
|
return
|
|
time.sleep(1)
|
|
after = dwins()
|
|
new = [x for h, x in after.items() if h not in before]
|
|
res["new_windows"] = len(new)
|
|
if not new:
|
|
# Already popped out before we looked: take the smaller Discord windows.
|
|
new = sorted(after.values(), key=lambda x: (x["rect"][2] - x["rect"][0]) * (x["rect"][3] - x["rect"][1]))[:-1]
|
|
res["note"] = "no new window; used existing smaller Discord windows"
|
|
if not new:
|
|
r.error("discord", "분리된 창을 찾지 못했습니다")
|
|
return
|
|
pop = new[0]
|
|
say(f" 찾은 창 제목: {pop['title']}")
|
|
res["title_has_streamer_name"] = ask(" 이 제목에 화면공유한 사람 이름이 들어 있나요?", "yn")
|
|
keep = ask(" 이 제목을 결과 파일에 넣어도 될까요? (이름이 들어 있을 수 있습니다)", "yn", "n")
|
|
res["title"] = pop["title"] if keep == "y" else re.sub(r"\w", "x", pop["title"])
|
|
res["class"] = pop["class"]
|
|
res["size"] = [pop["rect"][2] - pop["rect"][0], pop["rect"][3] - pop["rect"][1]]
|
|
res["main_window_titles_masked"] = [re.sub(r"\w", "x", x["title"]) for x in after.values() if x is not pop]
|
|
say(" 분리된 창이 다른 창에 가려지지 않게 화면에 보이도록 두세요. 5초 동안 확인합니다.")
|
|
time.sleep(2)
|
|
res["visible_capture"] = frames(pop["hwnd"], 5)
|
|
cover = Cover(pop["rect"])
|
|
try:
|
|
res["covered_capture"] = frames(pop["hwnd"], 6, cover)
|
|
finally:
|
|
cover.close()
|
|
res["visible_capture_after"] = frames(pop["hwnd"], 3)
|
|
say(f" 보일 때 그리기: {'예' if res['visible_capture']['drawing'] else '아니요'}, "
|
|
f"가려졌을 때 그리기: {'예' if res['covered_capture']['drawing'] else '아니요'}")
|
|
|
|
|
|
def _steam_games() -> list[dict]:
|
|
import winreg
|
|
out = []
|
|
try:
|
|
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Valve\Steam") as k:
|
|
steam = Path(winreg.QueryValueEx(k, "SteamPath")[0])
|
|
except OSError:
|
|
return out
|
|
libs = {steam}
|
|
vdf = steam / "steamapps" / "libraryfolders.vdf"
|
|
if vdf.exists():
|
|
for m in re.finditer(r'"path"\s+"([^"]+)"', vdf.read_text(encoding="utf-8", errors="replace")):
|
|
libs.add(Path(m.group(1).replace("\\\\", "\\")))
|
|
for lib in libs:
|
|
for acf in (lib / "steamapps").glob("appmanifest_*.acf"):
|
|
t = acf.read_text(encoding="utf-8", errors="replace")
|
|
name = re.search(r'"name"\s+"([^"]+)"', t)
|
|
inst = re.search(r'"installdir"\s+"([^"]+)"', t)
|
|
if name and inst:
|
|
out.append({"launcher": "Steam", "name": name.group(1),
|
|
"dir": lib / "steamapps" / "common" / inst.group(1)})
|
|
return out
|
|
|
|
|
|
def _epic_games() -> list[dict]:
|
|
out = []
|
|
man = Path(os.environ.get("ProgramData", r"C:\ProgramData")) / "Epic" / "EpicGamesLauncher" / "Data" / "Manifests"
|
|
for item in man.glob("*.item"):
|
|
try:
|
|
d = json.loads(item.read_text(encoding="utf-8", errors="replace"))
|
|
out.append({"launcher": "Epic", "name": d.get("DisplayName"), "dir": Path(d.get("InstallLocation", ""))})
|
|
except Exception:
|
|
continue
|
|
return out
|
|
|
|
|
|
def _riot_games() -> list[dict]:
|
|
out = []
|
|
meta = Path(os.environ.get("ProgramData", r"C:\ProgramData")) / "Riot Games" / "Metadata"
|
|
for yaml in meta.glob("*/*.product_settings.yaml"):
|
|
t = yaml.read_text(encoding="utf-8", errors="replace")
|
|
m = re.search(r'product_install_full_path:\s*"?([^"\n]+)', t)
|
|
out.append({"launcher": "Riot", "name": yaml.parent.name.split(".")[0],
|
|
"dir": Path(m.group(1).strip()) if m else Path("")})
|
|
return out
|
|
|
|
|
|
def _anticheat_in_dir(d: Path, budget: int = 4000) -> list[str]:
|
|
found: set[str] = set()
|
|
if not d or not d.is_dir():
|
|
return []
|
|
seen = 0
|
|
for root, dirs, files in os.walk(d):
|
|
depth = len(Path(root).relative_to(d).parts)
|
|
if depth >= 3:
|
|
dirs[:] = []
|
|
for n in dirs + files:
|
|
seen += 1
|
|
low = n.lower()
|
|
for marker, label in ANTICHEAT_MARKERS.items():
|
|
if marker in low:
|
|
found.add(label)
|
|
if low.startswith("beservice") or low == "be":
|
|
found.add("BattlEye")
|
|
if seen > budget:
|
|
break
|
|
return sorted(found)
|
|
|
|
|
|
def _sample_foreground(w) -> dict:
|
|
fg = w.foreground()
|
|
if not fg:
|
|
return {}
|
|
mon = w.monitor_rect(fg["hwnd"])
|
|
path = w.proc_path(fg["pid"]) or ""
|
|
exe = os.path.basename(path).lower()
|
|
gpu = w.gpu_3d_by_pid()
|
|
low_path = path.lower()
|
|
launcher = next((n for key, n in (("steamapps", "Steam"), ("epic games", "Epic"), ("riot games", "Riot"),
|
|
("battle.net", "Battle.net"), ("nexon", "Nexon")) if key in low_path), None)
|
|
covers = fg["rect"][0] <= mon[0] and fg["rect"][1] <= mon[1] and fg["rect"][2] >= mon[2] and \
|
|
fg["rect"][3] >= mon[3]
|
|
no_frame = not (fg["style"] & w.WS_CAPTION) and not (fg["style"] & w.WS_THICKFRAME)
|
|
gpu_3d = gpu.get(fg["pid"], 0.0)
|
|
return {"exe": exe, "class": fg["class"], "covers_monitor": covers, "no_caption_or_border": no_frame,
|
|
"popup_style": bool(fg["style"] & w.WS_POPUP), "gpu_3d_percent": gpu_3d,
|
|
"top_gpu_3d": sorted(((v, (w.proc_path(p) and os.path.basename(w.proc_path(p)).lower()) or str(p))
|
|
for p, v in gpu.items() if v > 1), reverse=True)[:5],
|
|
"notification_state": w.notification_state(), "launcher_folder": launcher,
|
|
"rect": fg["rect"], "monitor": mon,
|
|
"detector_verdict": bool(covers and no_frame and gpu_3d >= 10) or w.notification_state() == "d3d_fullscreen"
|
|
or launcher is not None}
|
|
|
|
|
|
def check_games(r: StageResult) -> None:
|
|
from m0lib import winwin as w
|
|
step("3/3 게임과 안티치트 감지")
|
|
res: dict = {}
|
|
r["games"] = res
|
|
say(" 설치된 게임과 안티치트를 찾는 중 (게임 파일 이름만 보고, 내용은 읽지 않습니다)")
|
|
games = []
|
|
for fn in (_steam_games, _epic_games, _riot_games):
|
|
try:
|
|
games += fn()
|
|
except Exception as e:
|
|
r.error(fn.__name__, e)
|
|
res["installed"] = [{"launcher": g["launcher"], "name": g["name"], "anticheat_files": _anticheat_in_dir(g["dir"])}
|
|
for g in games]
|
|
res["anticheat_services"] = w.services_states(ANTICHEAT_SERVICES)
|
|
running = w.processes()
|
|
res["anticheat_running_now"] = sorted({ANTICHEAT_PROCS[n] for n in running.values() if n in ANTICHEAT_PROCS})
|
|
say(f" 설치된 게임 {len(games)}개, 안티치트 서비스/드라이버 {len(res['anticheat_services'])}개")
|
|
|
|
samples = []
|
|
labels = [("game", "게임을 하나 켜 주세요. 테두리 없는 창 모드(borderless)면 가장 좋습니다."),
|
|
("anticheat_game", "안티치트가 있는 게임(예: 발로란트, 배틀그라운드)이 있으면 켜 주세요."),
|
|
("not_game", "게임이 아닌 경우도 봅니다. 브라우저에서 영상을 전체화면으로 틀어 주세요.")]
|
|
for kind, guide in labels:
|
|
say(f"\n {guide}")
|
|
if wait_enter(" 준비되면 Enter (건너뛰려면 s 입력 후 Enter). Enter 뒤 15초 안에 그 화면으로 전환해 주세요:") == "s":
|
|
continue
|
|
for left in range(15, 0, -5):
|
|
say(f" {left}초 뒤 확인합니다...")
|
|
time.sleep(5)
|
|
rows = []
|
|
for _ in range(3):
|
|
rows.append(_sample_foreground(w))
|
|
time.sleep(1)
|
|
procs = w.processes()
|
|
anti = sorted({ANTICHEAT_PROCS[n] for n in procs.values() if n in ANTICHEAT_PROCS})
|
|
riot = sorted({RIOT_GAME_EXES[n] for n in procs.values() if n in RIOT_GAME_EXES})
|
|
try:
|
|
import winsound
|
|
winsound.MessageBeep()
|
|
except Exception:
|
|
pass
|
|
samples.append({"kind": kind, "samples": rows, "anticheat_running": anti, "riot_games_running": riot})
|
|
say(f" 확인 끝(삑 소리). 앞 창: {rows[-1].get('exe')}, 게임 판정: {rows[-1].get('detector_verdict')}, "
|
|
f"안티치트: {', '.join(anti) or '없음'}")
|
|
if kind != "not_game":
|
|
samples[-1]["user_says_mode"] = ask(" 그 게임의 화면 모드는? b=테두리 없는 창, f=전체화면, w=창 모드", "bfw", "b")
|
|
res["live"] = samples
|
|
|
|
|
|
def main() -> int:
|
|
out, work, opts = stage_args()
|
|
r = StageResult("winchecks", out)
|
|
if not IS_WINDOWS:
|
|
r.error("winchecks", "Windows가 아니라서 건너뜁니다")
|
|
r.save("skipped")
|
|
return 0
|
|
from m0lib import winwin as w
|
|
w.dpi_aware()
|
|
only = set(opts.get("only", "botwin,discord,games").split(","))
|
|
for name, fn in (("botwin", lambda: check_botwin(r, work)), ("discord", lambda: check_discord(r)),
|
|
("games", lambda: check_games(r))):
|
|
if name not in only:
|
|
continue
|
|
try:
|
|
fn()
|
|
except Exception as e:
|
|
r.error(name, e)
|
|
r.save()
|
|
r.save("ok" if not r["errors"] else "partial")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|