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/CHANGELOG.md b/CHANGELOG.md index 7282dfa..a4073ee 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] +- Upgrade `windows-sys` dependency to 0.59 and bump the MSRV to 1.60.0 ## [0.7.0] - 2024-04-12 diff --git a/Cargo.toml b/Cargo.toml index 7edcb00..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" @@ -20,10 +20,9 @@ bitflags = "2.3" widestring = "1" [target.'cfg(windows)'.dependencies.windows-sys] -version = "0.52.0" +version = "0.59.0" features = [ "Win32_Foundation", - "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Power", "Win32_System_RemoteDesktop", diff --git a/src/sc_handle.rs b/src/sc_handle.rs index 4ef7602..40b03bf 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); +/// A handle holder that wraps a low level [`Services::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 { + /// Returns underlying [`Services::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) }))