Skip to content

Commit

Permalink
fix(checks): os_service lifecycle bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
deblasis committed Sep 21, 2022
1 parent fc0dd92 commit f440966
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions agent/checks/os_service_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ var (
win windowsSystem = windowsOS{}
)

type OSServiceClient struct {
scHandle windows.Handle
}
type OSServiceClient struct{}

func NewOSServiceClient() (*OSServiceClient, error) {
scHandle, err := win.OpenSCManager(nil, nil, windows.SC_MANAGER_CONNECT)
if err != nil {
return nil, fmt.Errorf("error connecting to service manager: %w", err)
}
return &OSServiceClient{scHandle: scHandle}, nil
return &OSServiceClient{}, nil
}

func (client *OSServiceClient) Check(serviceName string) (err error) {
m := win.getWindowsSvcMgr(client.scHandle)
h, err := windows.OpenSCManager(nil, nil, windows.SC_MANAGER_CONNECT)
if err != nil {
return fmt.Errorf("failed to connect to Windows service manager: %w", err)
}

m := win.getWindowsSvcMgr(h)
defer m.Disconnect()

svcNamePtr, err := syscall.UTF16PtrFromString(serviceName)
Expand Down

0 comments on commit f440966

Please sign in to comment.