Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: x/sys/windows/svc/mgr: Add EnumDependentServices method to Service struct #56766

Open
sebsoto opened this issue Nov 16, 2022 · 3 comments

Comments

@sebsoto
Copy link

sebsoto commented Nov 16, 2022

The mgr package does not provide a way to interact with the EnumDependentServicesW Windows API call. Usage of this call allows a user to list all Windows services which are dependent upon a given service. Without this API call, a user would have to iterate through each service on the system, and check if the given service is listed in each service's dependencies list.

This functionality being missing is called out in a TODO within the code.

I propose:

  1. EnumDependentServicesW is added to the list of syscalls in https://github.com/golang/sys/blob/master/windows/service.go, causing it to be generated and added to https://github.com/golang/sys/blob/master/windows/zsyscall_windows.go
  2. A new struct ENUM_SERVICE_STATUSW is added to service.go, this enables the use of the data returned by EnumDependentServicesW.
  3. A new type is added:
type Activity uint32
const (
	Active       = Activity(windows.SERVICE_ACTIVE)
	Inactive     = Activity(windows.SERVICE_INACTIVE)
	All          = Activity(windows.SERVICE_ALL)
)
  1. Service is given a new method ListDependentServices which will return a slice of strings, listing all services dependent on the service. func (s *Service) ListDependentServices(serviceState Activity) ([]string, error)
@gopherbot gopherbot added this to the Proposal milestone Nov 16, 2022
@ianlancetaylor
Copy link
Contributor

CC @golang/windows

@gopherbot
Copy link

Change https://go.dev/cl/451363 mentions this issue: windows: add Service.ListDependentServices

@alexbrainman
Copy link
Member

@sebsoto

I just reviewed your https://go.dev/cl/451363 CL. Let's continue our conversation there.

Thank you.

Alex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Incoming
Development

No branches or pull requests

4 participants