|
@@ -8,6 +8,7 @@ package mgr
|
|
|
|
|
|
|
|
import (
|
|
import (
|
|
|
"syscall"
|
|
"syscall"
|
|
|
|
|
+ "unsafe"
|
|
|
|
|
|
|
|
"golang.org/x/sys/windows"
|
|
"golang.org/x/sys/windows"
|
|
|
"golang.org/x/sys/windows/svc"
|
|
"golang.org/x/sys/windows/svc"
|
|
@@ -60,13 +61,15 @@ func (s *Service) Control(c svc.Cmd) (svc.Status, error) {
|
|
|
|
|
|
|
|
// Query returns current status of service s.
|
|
// Query returns current status of service s.
|
|
|
func (s *Service) Query() (svc.Status, error) {
|
|
func (s *Service) Query() (svc.Status, error) {
|
|
|
- var t windows.SERVICE_STATUS
|
|
|
|
|
- err := windows.QueryServiceStatus(s.Handle, &t)
|
|
|
|
|
|
|
+ var t windows.SERVICE_STATUS_PROCESS
|
|
|
|
|
+ var needed uint32
|
|
|
|
|
+ err := windows.QueryServiceStatusEx(s.Handle, windows.SC_STATUS_PROCESS_INFO, (*byte)(unsafe.Pointer(&t)), uint32(unsafe.Sizeof(t)), &needed)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
return svc.Status{}, err
|
|
return svc.Status{}, err
|
|
|
}
|
|
}
|
|
|
return svc.Status{
|
|
return svc.Status{
|
|
|
- State: svc.State(t.CurrentState),
|
|
|
|
|
- Accepts: svc.Accepted(t.ControlsAccepted),
|
|
|
|
|
|
|
+ State: svc.State(t.CurrentState),
|
|
|
|
|
+ Accepts: svc.Accepted(t.ControlsAccepted),
|
|
|
|
|
+ ProcessId: t.ProcessId,
|
|
|
}, nil
|
|
}, nil
|
|
|
}
|
|
}
|