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) }))