From a2a5c673f9f7fe81c6664025514144b82a82d29e Mon Sep 17 00:00:00 2001 From: Jonas Zaddach Date: Tue, 22 Oct 2024 08:56:34 +0200 Subject: [PATCH 1/7] Bump windows-sys version --- Cargo.toml | 2 +- src/sc_handle.rs | 8 ++++---- src/service.rs | 3 +-- src/service_control_handler.rs | 2 +- src/service_manager.rs | 6 +++--- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7edcb00..d948b19 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ bitflags = "2.3" widestring = "1" [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.52.0" +version = "0.59.0" features = [ "Win32_Foundation", "Win32_Security", diff --git a/src/sc_handle.rs b/src/sc_handle.rs index 4ef7602..3d895d8 100644 --- a/src/sc_handle.rs +++ b/src/sc_handle.rs @@ -1,15 +1,15 @@ -use windows_sys::Win32::{Security, System::Services}; +use windows_sys::Win32::System::Services; /// A handle holder that wraps a low level [`Security::SC_HANDLE`]. -pub(crate) struct ScHandle(Security::SC_HANDLE); +pub(crate) struct ScHandle(Services::SC_HANDLE); impl ScHandle { - pub(crate) unsafe fn new(handle: Security::SC_HANDLE) -> Self { + pub(crate) unsafe fn new(handle: Services::SC_HANDLE) -> Self { ScHandle(handle) } /// Returns underlying [`Security::SC_HANDLE`]. - pub(crate) fn raw_handle(&self) -> Security::SC_HANDLE { + pub(crate) fn raw_handle(&self) -> Services::SC_HANDLE { self.0 } } diff --git a/src/service.rs b/src/service.rs index 5a73fd2..3fe426d 100644 --- a/src/service.rs +++ b/src/service.rs @@ -12,7 +12,6 @@ use windows_sys::{ core::GUID, Win32::{ Foundation::{ERROR_SERVICE_SPECIFIC_ERROR, NO_ERROR}, - Security, Storage::FileSystem, System::{Power, RemoteDesktop, Services, SystemServices, Threading::INFINITE}, UI::WindowsAndMessaging, @@ -1454,7 +1453,7 @@ impl Service { } /// Provides access to the underlying system service handle - pub fn raw_handle(&self) -> Security::SC_HANDLE { + pub fn raw_handle(&self) -> Services::SC_HANDLE { self.service_handle.raw_handle() } diff --git a/src/service_control_handler.rs b/src/service_control_handler.rs index 765edca..3f1cca8 100644 --- a/src/service_control_handler.rs +++ b/src/service_control_handler.rs @@ -123,7 +123,7 @@ where ) }; - if status_handle == 0 { + if status_handle.is_null() { // Release the `event_handler` in case of an error. let _: Box = unsafe { Box::from_raw(context) }; Err(Error::Winapi(io::Error::last_os_error())) diff --git a/src/service_manager.rs b/src/service_manager.rs index 50a48b7..d48e5b0 100644 --- a/src/service_manager.rs +++ b/src/service_manager.rs @@ -57,7 +57,7 @@ impl ServiceManager { ) }; - if handle == 0 { + if handle.is_null() { Err(Error::Winapi(io::Error::last_os_error())) } else { Ok(ServiceManager { @@ -168,7 +168,7 @@ impl ServiceManager { ) }; - if service_handle == 0 { + if service_handle.is_null() { Err(Error::Winapi(io::Error::last_os_error())) } else { Ok(Service::new(unsafe { ScHandle::new(service_handle) })) @@ -209,7 +209,7 @@ impl ServiceManager { ) }; - if service_handle == 0 { + if service_handle.is_null() { Err(Error::Winapi(io::Error::last_os_error())) } else { Ok(Service::new(unsafe { ScHandle::new(service_handle) })) From cdeae9005dd644b14a605925afde066bf2bccd19 Mon Sep 17 00:00:00 2001 From: Jonas Zaddach Date: Wed, 23 Oct 2024 06:15:56 +0200 Subject: [PATCH 2/7] Documented change --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7282dfa..e241210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +- Update the `windows-sys` crate to version 0.59. ## [0.7.0] - 2024-04-12 From 9b965d0c4878a4c40153405a0801c40510d2c0f9 Mon Sep 17 00:00:00 2001 From: Jonas Zaddach Date: Wed, 23 Oct 2024 06:17:43 +0200 Subject: [PATCH 3/7] Reworded message --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e241210..176d430 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] -- Update the `windows-sys` crate to version 0.59. +- Upgrade `windows-sys` dependency to 0.59 ## [0.7.0] - 2024-04-12 From 827e93ed388ddddb8f3154fba191444556f54e90 Mon Sep 17 00:00:00 2001 From: Jonas Zaddach Date: Wed, 23 Oct 2024 06:19:34 +0200 Subject: [PATCH 4/7] Win32_Security isn't needed any more --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index d948b19..bae0269 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ widestring = "1" version = "0.59.0" features = [ "Win32_Foundation", - "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Power", "Win32_System_RemoteDesktop", From 36ba032cbb6ffe77ad5e97363849b3bbd87e387b Mon Sep 17 00:00:00 2001 From: Jonas Zaddach Date: Wed, 23 Oct 2024 06:28:09 +0200 Subject: [PATCH 5/7] Bump MSRV to 1.60.0 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 176d430..a4073ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] -- Upgrade `windows-sys` dependency to 0.59 +- Upgrade `windows-sys` dependency to 0.59 and bump the MSRV to 1.60.0 ## [0.7.0] - 2024-04-12 From f4d0fc1d675a4ba720e7f2704f459423c4a0f529 Mon Sep 17 00:00:00 2001 From: Jonas Zaddach Date: Wed, 23 Oct 2024 14:14:55 +0200 Subject: [PATCH 6/7] Forgot to add files after version bump --- .github/workflows/build-and-test.yml | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index f54e46a..d869b49 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -25,7 +25,7 @@ jobs: # but it should be mentioned in the changelog, # and `rust-version` in Cargo.toml should be updated. - target: x86_64-pc-windows-msvc - rust: 1.58.0 + rust: 1.60.0 runs-on: windows-latest steps: diff --git a/Cargo.toml b/Cargo.toml index bae0269..19feb56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ repository = "https://github.com/mullvad/windows-service-rs" license = "MIT OR Apache-2.0" edition = "2021" # Keep in sync with CI job in `build-and-test.yml` -rust-version = "1.58.0" +rust-version = "1.60.0" [package.metadata.docs.rs] default-target = "x86_64-pc-windows-msvc" From bee60a7c71b161ce8295031c9f16e45c4901eb30 Mon Sep 17 00:00:00 2001 From: Jonas Zaddach Date: Wed, 23 Oct 2024 14:20:02 +0200 Subject: [PATCH 7/7] Update documentation --- src/sc_handle.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sc_handle.rs b/src/sc_handle.rs index 3d895d8..40b03bf 100644 --- a/src/sc_handle.rs +++ b/src/sc_handle.rs @@ -1,6 +1,6 @@ use windows_sys::Win32::System::Services; -/// A handle holder that wraps a low level [`Security::SC_HANDLE`]. +/// A handle holder that wraps a low level [`Services::SC_HANDLE`]. pub(crate) struct ScHandle(Services::SC_HANDLE); impl ScHandle { @@ -8,7 +8,7 @@ impl ScHandle { ScHandle(handle) } - /// Returns underlying [`Security::SC_HANDLE`]. + /// Returns underlying [`Services::SC_HANDLE`]. pub(crate) fn raw_handle(&self) -> Services::SC_HANDLE { self.0 }