Skip to content

Commit 684bf68

Browse files
committed
refactor: 统一 Cargo workspace 与 Windows 依赖
将 applechu、applechu-macros 和 chu-abi 迁入 packages 目录,并把仓库根 Cargo.toml 改为三成员 workspace;集中管理版本、edition、license、共享依赖和 release profile,同时以 applechu 作为默认成员,保持根目录构建命令与 DLL 产物路径不变。 将应用直接依赖统一为 windows-sys 0.59,合并两套 feature 列表并移除 windows-sys-loader 别名;按 0.59 的指针句柄语义迁移 Win32 空句柄、模块句柄和 UART/IO 伪句柄转换。 新增统一的 opaque handle 转换边界与回归测试;workspace 33 项测试、Clippy、release PE32 构建和 x86 Miri strict-provenance 定向测试均通过。
1 parent beaf0a7 commit 684bf68

122 files changed

Lines changed: 216 additions & 160 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,34 @@
1-
[package]
2-
name = "applechu"
1+
[workspace]
2+
members = [
3+
"packages/applechu",
4+
"packages/applechu-macros",
5+
"packages/chu-abi",
6+
]
7+
default-members = ["packages/applechu"]
8+
resolver = "2"
9+
10+
[workspace.package]
311
version = "1.0.0"
412
edition = "2021"
513
license = "Apache-2.0"
614

7-
[lib]
8-
name = "winhttp"
9-
crate-type = ["cdylib"]
10-
11-
[dependencies]
12-
applechu-macros = { path = "applechu-macros" }
13-
chu-abi = { path = "chu-abi" }
15+
[workspace.dependencies]
16+
applechu-macros = { path = "packages/applechu-macros" }
17+
chu-abi = { path = "packages/chu-abi" }
18+
forward-dll = "0.1.11"
1419
linkme = "0.3.36"
15-
toml = "0.8"
1620
once_cell = "1"
21+
proc-macro2 = "1"
22+
quote = "1"
1723
retour = "0.4.0-alpha.4"
18-
windows-sys = { version = "0.52", features = [
19-
"Win32_Foundation",
20-
"Win32_Networking_WinSock",
24+
syn = { version = "2", features = ["full"] }
25+
toml = "0.8"
26+
windows-sys = { version = "0.59", features = [
2127
"Win32_Devices_Communication",
22-
"Win32_Security",
23-
"Win32_Storage_FileSystem",
24-
"Win32_System_IO",
25-
"Win32_System_Kernel",
26-
"Win32_System_LibraryLoader",
27-
"Win32_System_Memory",
28-
"Win32_System_ProcessStatus",
29-
"Win32_System_Pipes",
30-
"Win32_System_Threading",
31-
"Win32_UI_Input_KeyboardAndMouse",
32-
"Win32_UI_WindowsAndMessaging",
33-
] }
34-
windows-sys-loader = { package = "windows-sys", version = "0.59", features = [
3528
"Win32_Foundation",
3629
"Win32_Graphics_Gdi",
30+
"Win32_Networking_WinSock",
31+
"Win32_Security",
3732
"Win32_Security_Cryptography",
3833
"Win32_Storage_FileSystem",
3934
"Win32_System_Console",
@@ -42,17 +37,16 @@ windows-sys-loader = { package = "windows-sys", version = "0.59", features = [
4237
"Win32_System_Kernel",
4338
"Win32_System_LibraryLoader",
4439
"Win32_System_Memory",
40+
"Win32_System_Pipes",
4541
"Win32_System_ProcessStatus",
4642
"Win32_System_Registry",
4743
"Win32_System_SystemInformation",
4844
"Win32_System_Threading",
45+
"Win32_UI_Input_KeyboardAndMouse",
4946
"Win32_UI_Shell",
5047
"Win32_UI_WindowsAndMessaging",
5148
] }
5249

53-
[build-dependencies]
54-
forward-dll = "0.1.11"
55-
5650
[profile.release]
5751
lto = true
5852
opt-level = "s"

applechu-macros/Cargo.toml

Lines changed: 0 additions & 13 deletions
This file was deleted.

chu-abi/Cargo.toml

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "applechu-macros"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
7+
[lib]
8+
proc-macro = true
9+
10+
[dependencies]
11+
proc-macro2.workspace = true
12+
quote.workspace = true
13+
syn.workspace = true

packages/applechu/Cargo.toml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "applechu"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
readme = "../../README.md"
7+
8+
[lib]
9+
name = "winhttp"
10+
crate-type = ["cdylib"]
11+
12+
[dependencies]
13+
applechu-macros.workspace = true
14+
chu-abi.workspace = true
15+
linkme.workspace = true
16+
once_cell.workspace = true
17+
retour.workspace = true
18+
toml.workspace = true
19+
windows-sys.workspace = true
20+
21+
[build-dependencies]
22+
forward-dll.workspace = true
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl ExternalAimeIo {
7979
pub unsafe fn load(path: &str) -> Result<Self, String> {
8080
let wide = string_to_wide(path);
8181
let module = LoadLibraryW(wide.as_ptr());
82-
if module == 0 {
82+
if module.is_null() {
8383
return Err(format!("LoadLibraryW failed for {path}"));
8484
}
8585

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ unsafe fn aime_irp_handler(irp: &mut Irp) -> i32 {
240240
if !high_baudrate {
241241
uart::set_baud_rate(handle, 38_400);
242242
}
243-
irp.fd = handle as isize;
243+
irp.fd = crate::util::win32::handle_from_value(handle);
244244
AIME_FD.store(handle, Ordering::SeqCst);
245245
return 1;
246246
}
247247

248248
let my_fd = AIME_FD.load(Ordering::SeqCst);
249-
if my_fd == 0 || irp.fd as usize != my_fd {
249+
if my_fd == 0 || crate::util::win32::handle_value(irp.fd) != my_fd {
250250
return iohook::invoke_next(irp);
251251
}
252252

@@ -258,7 +258,7 @@ unsafe fn aime_irp_handler(irp: &mut Irp) -> i32 {
258258
IrpOp::Read => read_aime(irp),
259259
IrpOp::Write => write_aime(irp),
260260
IrpOp::Ioctl => uart::device_io_control(
261-
irp.fd as usize,
261+
crate::util::win32::handle_value(irp.fd),
262262
irp.ioctl,
263263
irp.ioctl_in,
264264
irp.ioctl_in_nbytes,

0 commit comments

Comments
 (0)