用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/publieople/hermes-config-kit --skill windows-rust-native命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Manage AstrBot knowledge bases — create, upload, retrieve, delete via WebUI or REST API. Use when adding documents to an AstrBot bot's RAG knowledge base, troubleshooting embedding issues, or automating KB updates.
Integrate Hermes Agent with external desktop applications, IDEs, and AI tools — mapping their integration interfaces (custom API endpoints, MCP support, terminal hooks) to Hermes' built-in capabilities (API Server, MCP Server Mode, CLI spawning). Use when asked to "connect Hermes to X" or "make Hermes work with Y" for any third-party app.
国内量化交易系统搭建 — 行情终端 vs 量化系统辨析、券商通道瓶颈、开源框架选型、老式行情软件逆向分析
基于 SOC 职业分类
正在显示 SKILL.md
| name | windows-rust-native |
| description | 写直接调 Win32/COM 的 Rust 代码前加载(windows crate、注册表、任务计划、签名)。 |
| category | software-development |
| tags | ["windows","rust","win32","com","winreg","wintrust","task-scheduler","cross-compile","ci"] |
直接调 Win32 API / COM 的 Rust 代码。不覆盖 Tauri(见 tauri-v2-development)。
windows crate 的 Win32_* feature 使用# Cargo.toml — 平台依赖放 target 段,Linux 编译不拉 Windows 库
[dependencies]
serde = "1"
[target.'cfg(windows)'.dependencies]
winreg = "0.56"
windows = { version = "0.62", features = [...] }
#[cfg(windows)] 门控的模块在 Linux 上编译时整个跳过 → 纯逻辑(规则引擎、快照、模型)在 Linux 跑单测,Windows 代码只真机验证。
rustup target add x86_64-pc-windows-msvc
cargo check --target x86_64-pc-windows-msvc -p <crate> # 验证 API 用法对错
cargo clippy --target x86_64-pc-windows-msvc --workspace --all-targets
关键限制:cargo check 不需要链接器,能验证所有 API 签名用法。但 bin(非 lib)cargo build 需要 link.exe — WSL 没有 MSVC 链接器,报 linker link.exe not found。所以本地只跑 cargo check,真链接靠 CI 的 windows runner。
详细坑位表见 references/windows-crate-0.62-pitfalls.md。高频要点:
CoCreateInstance(&CLSID_X, None, CLSCTX_INPROC_SERVER) 返回强类型接口,直接 .Method() 调用windows_core::Result<T>,用 .map_err(|e| ...)? 处理unsafe { } 块(赋值给 union 字段不需要 unsafe,调用方法需要)| 函数 | 0.62 签名 | 注意 |
|---|---|---|
ShellExecuteW | 6 参数(hwnd, operation, file, params, dir, nShowCmd) | 不是 SHELLEXECUTEINFOW 结构体版本 |
WinVerifyTrust | (HWND, *mut GUID, *mut c_void) | pwvtdata 是 *mut c_void,要 cast |
SHGetFolderPathW | (Option<HWND>, i32, Option<HANDLE>, u32, &mut [u16;260]) | 缓冲固定 260 |
SHGetFolderPathW csidl | i32,CSIDL_FLAG_CREATE 是 0x8000 | |
CloseHandle | 在 Win32::Foundation | 不在 Threading |
IRegisteredTaskCollection 用 Count() + get_Item(&VARIANT),不是 for 循环。
IActionCollection::Count 是 (&mut i32) 指针形式,get_Item(i32) 直接传值。
Win32_System_TaskScheduler + Win32_System_Com + Win32_System_Variant + Win32_System_OleWin32_Security_WinTrust + Win32_Security_Cryptography(WINTRUST_DATA 结构体 gate 在这)Win32_UI_Shell + Win32_FoundationWin32_UI_WindowsAndMessagingWin32_System_Threadingtest-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- run: cargo test --workspace
- run: cargo clippy --workspace --all-targets -- -D warnings
核心价值:交叉编译只验证"能编译",真机跑才验证"真的能跑"。本会话 CI 抓到一个交叉编译完全看不出的空指针解引用(WINTRUST_DATA union 初始化)——*data.Anonymous.pFile = x 在真机直接 STATUS_STACK_BUFFER_OVERRUN,改成 data.Anonymous.pFile = &mut x 才过。Windows 代码必须配真机 CI,别信交叉编译。
核心坑:GUI/CLI 是普通权限,helper 是管理员(ShellExecuteW runas)。管理员进程的 %APPDATA% 解析到 C:\Windows\System32\config\systemprofile\AppData\Roaming,与普通用户的 C:\Users\<name>\AppData\Roaming 不同。请求/结果文件和快照目录如果用 %APPDATA%,GUI 写了 helper 读不到。
修法:统一用 %ProgramData%\BootKeeper(std::env::var("ProgramData"))。ProgramData 是所有用户和管理员都能读写的系统共享目录。预留 BOOTKEEPER_DATA 环境变量覆盖以兼容测试/定制。
fn data_root() -> PathBuf {
if let Ok(p) = std::env::var("BOOTKEEPER_DATA") { return PathBuf::from(p); }
let base = std::env::var("ProgramData").unwrap_or("C:\\ProgramData".into());
PathBuf::from(base).join("BootKeeper")
}
核心坑:枚举器存 HKCU\...\Run 作为 location(显示缩写),写操作解这个 location 找 registry key 时把 ...\ 当字面量剥掉 → 打开 HKCU\Run 而非 HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run → 值查找 NotFound → 禁用/启用/删除静默失败。
修法:枚举器的 location 字段存真实路径 HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run(或 HKLM 等价)。parse_hive_and_key 只做 hive 剥离 + 真实路径解析,不依赖 ...\ 缩略。所有 CLI/GUI/MCP 的默认位置同步改为真实路径。写完必须加集成测试:真注册表写值 → 禁用 → 再枚举找 .disabled → 启用 → 验证往返。
use windows::Win32::System::Services::{
OpenSCManagerW, EnumServicesStatusW, OpenServiceW, QueryServiceConfigW,
SERVICE_WIN32, SERVICE_STATE_ALL, SERVICE_AUTO_START,
SC_MANAGER_ENUMERATE_SERVICE, CloseServiceHandle,
};
要点:
EnumServicesStatusW 8 个参数:scm, service_type (SERVICE_WIN32), state (SERVICE_STATE_ALL), buf ptr, buf size, &mut needed, &mut count, resume (None)QueryServiceConfigW 同理:两次调用模式(None→获取大小,Some→填数据)scm 不是 &scm,svc 不是 &svc)"Win32_System_Services" featurereferences/windows-crate-0.62-pitfalls.md — windows crate 0.62 完整坑位(COM 接口形态、feature gate、类型签名、注册表 UTF-16LE 解码)