From bae957dd09916d860dc681a3db53904950d6c53a Mon Sep 17 00:00:00 2001 From: Ladi Prosek Date: Mon, 4 Aug 2025 14:02:48 +0200 Subject: [PATCH 1/5] Add stubs for __CxxFrameHandler4 and __GSHandlerCheck_EH4 --- crates/wdk-sys/src/lib.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/wdk-sys/src/lib.rs b/crates/wdk-sys/src/lib.rs index f7d387bbb..078945f88 100644 --- a/crates/wdk-sys/src/lib.rs +++ b/crates/wdk-sys/src/lib.rs @@ -120,7 +120,7 @@ mod macros; #[no_mangle] pub static _fltused: () = (); -// FIXME: Is there any way to avoid this stub? See https://github.com/rust-lang/rust/issues/101134 +// FIXME: Is there any way to avoid these stubs? See https://github.com/rust-lang/rust/issues/101134 #[cfg(panic = "abort")] #[allow(missing_docs)] #[allow(clippy::missing_const_for_fn)] // const extern is not yet supported: https://github.com/rust-lang/rust/issues/64926 @@ -129,6 +129,27 @@ pub extern "system" fn __CxxFrameHandler3() -> i32 { 0 } +#[cfg(panic = "abort")] +#[allow(missing_docs)] +#[allow(clippy::missing_const_for_fn)] // const extern is not yet supported: https://github.com/rust-lang/rust/issues/64926 +#[no_mangle] +pub extern "system" fn __CxxFrameHandler4() -> i32 { + // This is a stub for the C++ exception handling frame handler. It's never called but it needs to be distinct + // from __CxxFrameHandler3 to not confuse binary analysis tools. We return a different value to prevent folding. + 1 +} + +#[cfg(panic = "abort")] +#[allow(missing_docs)] +#[allow(clippy::missing_const_for_fn)] // const extern is not yet supported: https://github.com/rust-lang/rust/issues/64926 +#[no_mangle] +pub extern "system" fn __GSHandlerCheck_EH4() -> i32 { + // This is a stub for the C++ exception handling frame handler. It's never called but it needs to be distinct + // from __CxxFrameHandler3 and __CxxFrameHandler4 to not confuse binary analysis tools. We return a different + // value to prevent folding. + 2 +} + #[cfg(any( driver_model__driver_type = "WDM", driver_model__driver_type = "KMDF", From 6d188bc28b610d6dc2b9475be86285c136f45251 Mon Sep 17 00:00:00 2001 From: Ladi Prosek Date: Mon, 4 Aug 2025 14:18:45 +0200 Subject: [PATCH 2/5] Update crates/wdk-sys/src/lib.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ladi Prosek --- crates/wdk-sys/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wdk-sys/src/lib.rs b/crates/wdk-sys/src/lib.rs index 078945f88..947658bf1 100644 --- a/crates/wdk-sys/src/lib.rs +++ b/crates/wdk-sys/src/lib.rs @@ -135,7 +135,7 @@ pub extern "system" fn __CxxFrameHandler3() -> i32 { #[no_mangle] pub extern "system" fn __CxxFrameHandler4() -> i32 { // This is a stub for the C++ exception handling frame handler. It's never called but it needs to be distinct - // from __CxxFrameHandler3 to not confuse binary analysis tools. We return a different value to prevent folding. + // from __CxxFrameHandler3 to not confuse binary analysis tools. We return a different value to prevent folding. 1 } From 4f0b4882857a31c62adff7d8d210a0d109379af1 Mon Sep 17 00:00:00 2001 From: Ladi Prosek Date: Mon, 4 Aug 2025 14:19:17 +0200 Subject: [PATCH 3/5] Update crates/wdk-sys/src/lib.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Ladi Prosek --- crates/wdk-sys/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/wdk-sys/src/lib.rs b/crates/wdk-sys/src/lib.rs index 947658bf1..7acc4387a 100644 --- a/crates/wdk-sys/src/lib.rs +++ b/crates/wdk-sys/src/lib.rs @@ -146,7 +146,7 @@ pub extern "system" fn __CxxFrameHandler4() -> i32 { pub extern "system" fn __GSHandlerCheck_EH4() -> i32 { // This is a stub for the C++ exception handling frame handler. It's never called but it needs to be distinct // from __CxxFrameHandler3 and __CxxFrameHandler4 to not confuse binary analysis tools. We return a different - // value to prevent folding. + // value to prevent folding. 2 } From 5d2fc8de8d608d8b766126430aa92d9e74a005d0 Mon Sep 17 00:00:00 2001 From: Ladi Prosek Date: Mon, 4 Aug 2025 16:22:27 +0200 Subject: [PATCH 4/5] Fix formatting --- crates/wdk-sys/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/wdk-sys/src/lib.rs b/crates/wdk-sys/src/lib.rs index 7acc4387a..52d4fd338 100644 --- a/crates/wdk-sys/src/lib.rs +++ b/crates/wdk-sys/src/lib.rs @@ -134,8 +134,9 @@ pub extern "system" fn __CxxFrameHandler3() -> i32 { #[allow(clippy::missing_const_for_fn)] // const extern is not yet supported: https://github.com/rust-lang/rust/issues/64926 #[no_mangle] pub extern "system" fn __CxxFrameHandler4() -> i32 { - // This is a stub for the C++ exception handling frame handler. It's never called but it needs to be distinct - // from __CxxFrameHandler3 to not confuse binary analysis tools. We return a different value to prevent folding. + // This is a stub for the C++ exception handling frame handler. It's never + // called but it needs to be distinct from __CxxFrameHandler3 to not confuse + // binary analysis tools. We return a different value to prevent folding. 1 } @@ -144,9 +145,10 @@ pub extern "system" fn __CxxFrameHandler4() -> i32 { #[allow(clippy::missing_const_for_fn)] // const extern is not yet supported: https://github.com/rust-lang/rust/issues/64926 #[no_mangle] pub extern "system" fn __GSHandlerCheck_EH4() -> i32 { - // This is a stub for the C++ exception handling frame handler. It's never called but it needs to be distinct - // from __CxxFrameHandler3 and __CxxFrameHandler4 to not confuse binary analysis tools. We return a different - // value to prevent folding. + // This is a stub for the C++ exception handling frame handler. It's never + // called but it needs to be distinct from __CxxFrameHandler3 and + // __CxxFrameHandler4 to not confuse binary analysis tools. We return a + // different value to prevent folding. 2 } From f51cdfc33eeed843813bc5e27aefc50313fad47d Mon Sep 17 00:00:00 2001 From: Ladi Prosek Date: Tue, 5 Aug 2025 09:35:47 +0200 Subject: [PATCH 5/5] Use const extern --- crates/wdk-sys/src/lib.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/wdk-sys/src/lib.rs b/crates/wdk-sys/src/lib.rs index 52d4fd338..967fa7613 100644 --- a/crates/wdk-sys/src/lib.rs +++ b/crates/wdk-sys/src/lib.rs @@ -123,17 +123,15 @@ pub static _fltused: () = (); // FIXME: Is there any way to avoid these stubs? See https://github.com/rust-lang/rust/issues/101134 #[cfg(panic = "abort")] #[allow(missing_docs)] -#[allow(clippy::missing_const_for_fn)] // const extern is not yet supported: https://github.com/rust-lang/rust/issues/64926 #[no_mangle] -pub extern "system" fn __CxxFrameHandler3() -> i32 { +pub const extern "system" fn __CxxFrameHandler3() -> i32 { 0 } #[cfg(panic = "abort")] #[allow(missing_docs)] -#[allow(clippy::missing_const_for_fn)] // const extern is not yet supported: https://github.com/rust-lang/rust/issues/64926 #[no_mangle] -pub extern "system" fn __CxxFrameHandler4() -> i32 { +pub const extern "system" fn __CxxFrameHandler4() -> i32 { // This is a stub for the C++ exception handling frame handler. It's never // called but it needs to be distinct from __CxxFrameHandler3 to not confuse // binary analysis tools. We return a different value to prevent folding. @@ -142,9 +140,8 @@ pub extern "system" fn __CxxFrameHandler4() -> i32 { #[cfg(panic = "abort")] #[allow(missing_docs)] -#[allow(clippy::missing_const_for_fn)] // const extern is not yet supported: https://github.com/rust-lang/rust/issues/64926 #[no_mangle] -pub extern "system" fn __GSHandlerCheck_EH4() -> i32 { +pub const extern "system" fn __GSHandlerCheck_EH4() -> i32 { // This is a stub for the C++ exception handling frame handler. It's never // called but it needs to be distinct from __CxxFrameHandler3 and // __CxxFrameHandler4 to not confuse binary analysis tools. We return a