CNWei 5e69a6a980 refactor: 迁移 winapi 到 windows-sys,修复配置解析漏洞
- 依赖替换为 windows-sys 0.61,main.rs 全面适配新 API
  - 配置解析错误显式传播:env/args 类型错误、数组空洞、非法键不再静默
  吞错
  - 修正空环境变量与空参数语义,补充 UTF-8 与路径拼接校验
  - require 容错移至 Rust 侧,模块加载失败记录日志并跳过
  - 新增配置解析与运行时单元测试(19 个)
2026-08-14 20:09:34 +08:00
2021-01-21 23:05:19 +08:00
2021-01-21 23:05:19 +08:00
2021-01-21 23:05:19 +08:00
2021-01-21 23:05:19 +08:00
2021-01-21 23:05:19 +08:00

rshim

rshim is the shim program written in rust.

Why this exist?

There are several versions of shim:

  1. the official shim.cs was written in c# and required an instantiation of a .NET command line app every time it was started therefore is slower than directly executing. And it dose not handle Ctrl+C event correctly.

  2. shim.c is ok with performance and Ctrl+C event handling,but sometimes suffer memory violation (randomly exited with return code 3221226356).

  3. shim.cpp didn't work on my machine, calling it with any executable result in an infinite recursion of creating subprocess until eating all memory for unknown subtle reason.

rshim :

  1. less probability with bug and undefined behavior.
  2. properly handle variety errors.
  3. friendly error message.
  4. properly handle Ctrl+C events.
  5. properly handle utf-8 with or without bom in shim file.

Installation

First install rust

cargo build --release

Close any running process with existed shim. then

./repshims.bat

Executable Size

Without crt-static enabled: around 200kb

With crt-static enabled: around 300kb

Description
shim written in rust
Readme 356 KiB
Languages
Rust 95.1%
Batchfile 4.9%