Skip to content

Commit

Permalink
Add some missing flags and expose service handle (#115)
Browse files Browse the repository at this point in the history
* Expose raw service handle

* Additional service and SC manager flags
  • Loading branch information
NuSkooler authored and faern committed Jan 18, 2024
1 parent d754b99 commit 28a6e3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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,
Expand Down Expand Up @@ -80,6 +81,9 @@ bitflags::bitflags! {

/// Can use user-defined control codes
const USER_DEFINED_CONTROL = Services::SERVICE_USER_DEFINED_CONTROL;

/// Full access to the service object
const ALL_ACCESS = Services::SERVICE_ALL_ACCESS;
}
}

Expand Down Expand Up @@ -1438,6 +1442,11 @@ impl Service {
Service { service_handle }
}

/// Provides access to the underlying system service handle
pub fn raw_handle(&self) -> Security::SC_HANDLE {
self.service_handle.raw_handle()
}

/// Start the service.
///
/// # Example
Expand Down
3 changes: 3 additions & 0 deletions src/service_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ bitflags::bitflags! {

/// Can enumerate services or receive notifications.
const ENUMERATE_SERVICE = Services::SC_MANAGER_ENUMERATE_SERVICE;

/// Includes all possible access rights.
const ALL_ACCESS = Services::SC_MANAGER_ALL_ACCESS;
}
}

Expand Down

0 comments on commit 28a6e3a

Please sign in to comment.