feat: inspect windows browser process identity

This commit is contained in:
QiuSW
2026-07-22 14:59:57 +08:00
parent 23be05210b
commit d6f6bb0f2c
8 changed files with 370 additions and 3 deletions
+1 -1
View File
@@ -15,7 +15,7 @@
| ID | 任务 | 依赖 | 状态 |
| --- | --- | --- | --- |
| T-101 | 实现启动、registry、Wait 和 profile 占用检测 | T-003 | DONE |
| T-102 | 实现 Windows 进程身份查询和外部实例保守识别 | T-101 | TODO |
| T-102 | 实现 Windows 进程身份查询和外部实例保守识别 | T-101 | DONE |
| T-103 | 实现优雅关闭、强制关闭和 Job Object 进程树 | T-102 | TODO |
| T-104 | Chrome/Edge 双实例、异常退出和权限失败 smoke | T-103 | TODO |
+2 -2
View File
@@ -4,10 +4,10 @@
- 日期:2026-07-22
- 阶段:文档与交互原型准备
- 代码:已建立 Go module `chub`、`cmd/chub` 入口、logging 测试基座、浏览器 domain/application 合约、Chrome/Edge 参数/发现模块和启动 registry,T-001 至 T-003、T-101 已完成
- 代码:已建立 Go module `chub`、`cmd/chub` 入口、logging 测试基座、浏览器 domain/application 合约、Chrome/Edge 参数/发现模块、启动 registry 和 Windows 身份/占用检查,T-001 至 T-003、T-101、T-102 已完成
- UI:尚未实现;P0 页面需要先制作 HTML 原型
- 浏览器核心:设计参考来自 `D:\OPC\shop_helm\internal\platform\chrome`,尚未复制或接入本项目
- blocker:无;下一个任务为 T-102
- blocker:无;下一个任务为 T-103
## 当前目录
+36
View File
@@ -0,0 +1,36 @@
---
id: T-102
title: 实现 Windows 进程身份查询和外部实例保守识别
phase: 1
deps: [T-101]
status: DONE
created: 2026-07-22
owner: codex
---
## 需求与背景
Chub 重启后不能只依赖本进程 registry 判断 profile 状态;需要读取 Windows 进程和 Chromium profile 的系统证据,同时避免误认或误关闭外部进程。
## 方案与边界
- Windows 使用 `QueryFullProcessImageNameW` 查询 executable,使用进程句柄和 `WaitForSingleObject` 判断存活。
- 使用 `Chrome_MessageWindow` + user data dir 识别 Chrome/Edge profile singleton。
- 使用 lockfile sharing violation 作为占用证据;stale lock 和 stale PID 只记录来源,不转化为可关闭实例。
- executable 名称必须与浏览器类型匹配;无法确认时返回 unknown source。
- 非 Windows 编译为明确 unsupported 降级。
## 验收要点
- 当前测试进程可读取 executable 和 alive 状态。
- Chrome/Edge executable 类型匹配校验通过。
- 外部 profile 检查不会只凭历史 PID 直接授权关闭。
- `go test ./...`、`go vet ./...` 通过。
## 执行记录
- 状态:DONE
- 变更:新增跨平台 identity port、Windows Win32 实现、message window/lockfile profile inspector 和非 Windows 降级。
- 验证:`gofmt`、`go test ./...`、`go vet ./...` 均通过;包含真实 Windows 当前进程查询。
- 阻塞:无。
- 残余风险:真实 Chrome/Edge profile lock 占用仍需 T-104 用临时 profile smoke 验证。