Der echte CoinPoker-Client exponiert je Tisch eine Win32-Named-Pipe (dieselbe PBNamedPipe.dll, die auf dem Mac /tmp/<Raum> als AF_UNIX-Socket anlegt). Unsere Seite wird darum auf Named Pipes umgeschrieben; Rahmen, Umschlag und Byte- Reihenfolge bleiben unveraendert. - client/winpipe.py: Named-Pipe-Transport als Socket-Ersatz (Rohr mit connect/recv/sendall/settimeout/spitzeln/close inkl. ERROR_PIPE_BUSY-Retry; Lauscher mit overlapped ConnectNamedPipe und Frist; namen() mit Deckel+Entdopplung). - client/winproc.py: Prozess-Fund via Get-CimInstance (Win32_Process.CommandLine) und TerminateProcess ueber kernel32 - statt ps/kill. - client/pipe.py: Windows-Zweig fuer pfad/namen/verbinden/erreichbar/raeume/ bruecken_namen; AF_UNIX-Pfad unveraendert. - hand/mittler.py: herrichten haelt eine Pipe-Instanz vor (das Spiel verbindet sich dagegen); annehmen/_fremde_annehmen nehmen ueber Lauscher-Instanzen an (je Verbinder eine frische, gleiche Sonden-Logik); zu schliesst die Instanz ohne Socket-Datei; spiele() liest WMI; SPIEL_MARKE in Mac/Win getrennt. - betrieb/nur_uebung: harte Uebungssperre fuer die Windows-Bringup. Offline bewiesen: ein Named-Pipe-Loopback (fake Bruecke an <raum>, fake Spiel an <raum>-mitte) treibt den echten Mittler durch herrichten/klinken/annehmen/ lauf und reicht Rahmen byteweise in beide Richtungen durch. mittler_spec (25) und mittler_schutz_spec (7) gruen. Was erst am lebenden Tisch geht: Unity- Kommandozeile gegen MUSTER, Lobby-Anmelde-/Doppelgaenger-Timing, Lese-Pfad (Windows-main.log hat ein anderes Format). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
70 lines
2.5 KiB
Python
70 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""Prozess-Fund unter Windows - der Ersatz fuer `ps -eo pid,command` / `kill -9`.
|
|
|
|
Auf dem Mac liest der Betrieb die Prozessliste mit `ps` und findet so die Tischprozesse
|
|
(`CoinPoker Game.app/.../CoinPoker`) samt ihrer Startargumente (`pipeName=`, `roomName=`,
|
|
`tableSize=`). Unter Windows gibt es kein `ps`; die Kommandozeile liefert WMI
|
|
(`Win32_Process.CommandLine`) ueber CIM. `wmic` ist auf aktuellen Windows weg, darum PowerShell
|
|
`Get-CimInstance`. `toeten` beendet ueber kernel32 (kein Shell-Aufruf).
|
|
|
|
prozesse() -> [(pid, kommandozeile)] toeten(pid)
|
|
python3 client/winproc.py CoinPoker # zeigt die Treffer
|
|
"""
|
|
import ctypes
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
|
|
_PS = ("Get-CimInstance Win32_Process {filt} | "
|
|
"Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress")
|
|
|
|
|
|
def prozesse(name=None):
|
|
"""Alle Prozesse als (pid, kommandozeile). `name` filtert auf einen Exe-Namen
|
|
(z.B. 'CoinPoker.exe') - das ist viel schneller, als alles zu holen."""
|
|
filt = f"-Filter \"Name='{name}'\"" if name else ""
|
|
befehl = _PS.format(filt=filt)
|
|
try:
|
|
roh = subprocess.run(["powershell", "-NoProfile", "-NonInteractive", "-Command", befehl],
|
|
capture_output=True, text=True, timeout=15).stdout.strip()
|
|
except (OSError, subprocess.TimeoutExpired):
|
|
return []
|
|
if not roh:
|
|
return []
|
|
try:
|
|
daten = json.loads(roh)
|
|
except ValueError:
|
|
return []
|
|
if isinstance(daten, dict): # ConvertTo-Json gibt bei EINEM Treffer kein Array
|
|
daten = [daten]
|
|
raus = []
|
|
for e in daten:
|
|
pid = e.get("ProcessId")
|
|
if isinstance(pid, int):
|
|
raus.append((pid, e.get("CommandLine") or ""))
|
|
return raus
|
|
|
|
|
|
def toeten(pid):
|
|
"""Prozess beenden (TerminateProcess) - ohne Shell, ohne Fenster."""
|
|
PROCESS_TERMINATE = 0x0001
|
|
k = ctypes.windll.kernel32
|
|
k.OpenProcess.restype = ctypes.c_void_p
|
|
k.OpenProcess.argtypes = [ctypes.c_ulong, ctypes.c_int, ctypes.c_ulong]
|
|
k.TerminateProcess.argtypes = [ctypes.c_void_p, ctypes.c_uint]
|
|
k.CloseHandle.argtypes = [ctypes.c_void_p]
|
|
h = k.OpenProcess(PROCESS_TERMINATE, False, int(pid))
|
|
if not h:
|
|
return False
|
|
try:
|
|
return bool(k.TerminateProcess(h, 1))
|
|
finally:
|
|
k.CloseHandle(h)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
nadel = sys.argv[1] if len(sys.argv) > 1 else None
|
|
for pid, cmd in prozesse("CoinPoker.exe"):
|
|
if not nadel or nadel.lower() in cmd.lower():
|
|
print(pid, cmd[:160])
|