From 7402a7b579f93d20bf3d7817dbd58eaede5d5419 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Tue, 14 Jul 2026 11:50:56 +1000 Subject: [PATCH] fix: Windows String conversion in uninstall MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calling the function failed with: ``` The filename, directory name, or volume label syntax is incorrect. (0x8007007B) ``` "WinDivert" is a Rust &str literal. .as_ptr() gives a pointer to the raw UTF‑8 bytes of that literal — but Rust string literals are not guaranteed to be null-terminated. Ensure that the name is properly terminated. --- windivert/src/divert/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/windivert/src/divert/mod.rs b/windivert/src/divert/mod.rs index 66e65a9..e9e37e0 100644 --- a/windivert/src/divert/mod.rs +++ b/windivert/src/divert/mod.rs @@ -5,11 +5,11 @@ use std::{ marker::PhantomData, mem::MaybeUninit, }; - use crate::layer; use crate::prelude::*; use sys::{WinDivertParam, WinDivertShutdownMode}; use windivert_sys as sys; +use windows::core::s; use windows::{ core::{Error as WinError, Result as WinResult, PCSTR}, @@ -194,7 +194,7 @@ impl WinDivert<()> { let manager = OpenSCManagerA(None, None, SC_MANAGER_ALL_ACCESS)?; let service = OpenServiceA( manager, - PCSTR::from_raw("WinDivert".as_ptr()), + s!("WinDivert"), SC_MANAGER_ALL_ACCESS, )?; let res = ControlService(service, SERVICE_CONTROL_STOP, status);