fix: cancel owned prewrite PCB at the license selector

This commit is contained in:
阿白叔 committed 2026-11-25 17:54:01 +08:00
1 parent d45a29503d
commit e4fc37a291
2 files changed
+59

No files matched your search

+27
View File
@@ -76,6 +76,20 @@ def _tip_target(snapshot):
return target if target is not None and target.class_name == 'Button' else None
def _startup_license_cancel(snapshot):
if snapshot.window_class != '#32770' or snapshot.title:
return None
controls = snapshot.controls
buttons = {(c.control_id, c.name) for c in controls if c.class_name == 'Button' and c.enabled}
expected = {(5225, 'Select the desired product license'), (1, 'OK'), (2, 'Cancel')}
if (buttons not in (expected, expected | {(57670, '')})
or not any(c.control_id == 1522 and c.class_name == 'GXWND' for c in controls)):
return None
options = [c for c in controls if c.control_id == 2 and c.class_name == 'Button'
and c.name == 'Cancel' and c.enabled]
return options[0] if len(options) == 1 else None
def _database_log_declined(root, pcb_pid):
"""The supervisor can dismiss this exact failed-open question before cleanup."""
from dataclasses import fields
@@ -228,6 +242,7 @@ def close_failed_startup(job, pcb_pid, *, baseline_pids=(), emit=lambda **event:
cancelled_open = _database_log_declined(root, pcb_pid)
decline_owner = None
dismissed_tips = set()
license_cancelled = False
close_handle = None
close_identity = None
close_frame = None
@@ -346,6 +361,18 @@ def close_failed_startup(job, pcb_pid, *, baseline_pids=(), emit=lambda **event:
break
if dismissed:
continue # Prove the Tip disappeared; it does not prove a cancelled open.
if cancelled_prewrite and not license_cancelled:
visible = [w for w in windows if win32gui.GetClassName(w) not in (
'UAC_InputIndicatorOverlayWnd', 'UAC Input Indicator')]
if len(visible) == 1 and win32gui.GetClassName(visible[0]) == '#32770':
prompt = _startup_snapshot(visible[0], pcb_pid)
cancel = _startup_license_cancel(prompt)
if cancel is not None and _startup_snapshot(visible[0], pcb_pid) == prompt:
cleanup_post(cancel.handle, win32con.BM_CLICK)
license_cancelled = True
emit(stage='startup_license_cancelled', pcb_pid=pcb_pid, hwnd=visible[0],
control_id=cancel.control_id)
continue
if declined_hwnd is None:
for hwnd in windows:
if win32gui.GetClassName(hwnd) != '#32770':