aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/sys/windows/svc
diff options
context:
space:
mode:
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>2018-10-27 01:18:40 +0200
committertechknowlogick <hello@techknowlogick.com>2018-10-26 19:18:40 -0400
commit99c09dfbfa818c753459e90db5ff12a323d2936f (patch)
tree207f9b07137f2c01a9b7ebf53cc63da89731f518 /vendor/golang.org/x/sys/windows/svc
parent2af57c78206272c771e0798db953b9dea42e2fbe (diff)
downloadgitea-99c09dfbfa818c753459e90db5ff12a323d2936f.tar.gz
gitea-99c09dfbfa818c753459e90db5ff12a323d2936f.zip
Update vendor/golang.org/x/sys (#5059)
Diffstat (limited to 'vendor/golang.org/x/sys/windows/svc')
-rw-r--r--vendor/golang.org/x/sys/windows/svc/go12.go2
-rw-r--r--vendor/golang.org/x/sys/windows/svc/go13.go2
-rw-r--r--vendor/golang.org/x/sys/windows/svc/service.go101
-rw-r--r--vendor/golang.org/x/sys/windows/svc/sys_386.s7
-rw-r--r--vendor/golang.org/x/sys/windows/svc/sys_amd64.s9
-rw-r--r--vendor/golang.org/x/sys/windows/svc/sys_arm.s38
6 files changed, 123 insertions, 36 deletions
diff --git a/vendor/golang.org/x/sys/windows/svc/go12.go b/vendor/golang.org/x/sys/windows/svc/go12.go
index 6f0a924eaf..cd8b913c99 100644
--- a/vendor/golang.org/x/sys/windows/svc/go12.go
+++ b/vendor/golang.org/x/sys/windows/svc/go12.go
@@ -1,4 +1,4 @@
-// Copyright 2014 The Go Authors. All rights reserved.
+// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/vendor/golang.org/x/sys/windows/svc/go13.go b/vendor/golang.org/x/sys/windows/svc/go13.go
index 432a9e796a..9d7f3cec54 100644
--- a/vendor/golang.org/x/sys/windows/svc/go13.go
+++ b/vendor/golang.org/x/sys/windows/svc/go13.go
@@ -1,4 +1,4 @@
-// Copyright 2014 The Go Authors. All rights reserved.
+// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
diff --git a/vendor/golang.org/x/sys/windows/svc/service.go b/vendor/golang.org/x/sys/windows/svc/service.go
index 9864f7a72f..cda26b54b3 100644
--- a/vendor/golang.org/x/sys/windows/svc/service.go
+++ b/vendor/golang.org/x/sys/windows/svc/service.go
@@ -35,11 +35,20 @@ const (
type Cmd uint32
const (
- Stop = Cmd(windows.SERVICE_CONTROL_STOP)
- Pause = Cmd(windows.SERVICE_CONTROL_PAUSE)
- Continue = Cmd(windows.SERVICE_CONTROL_CONTINUE)
- Interrogate = Cmd(windows.SERVICE_CONTROL_INTERROGATE)
- Shutdown = Cmd(windows.SERVICE_CONTROL_SHUTDOWN)
+ Stop = Cmd(windows.SERVICE_CONTROL_STOP)
+ Pause = Cmd(windows.SERVICE_CONTROL_PAUSE)
+ Continue = Cmd(windows.SERVICE_CONTROL_CONTINUE)
+ Interrogate = Cmd(windows.SERVICE_CONTROL_INTERROGATE)
+ Shutdown = Cmd(windows.SERVICE_CONTROL_SHUTDOWN)
+ ParamChange = Cmd(windows.SERVICE_CONTROL_PARAMCHANGE)
+ NetBindAdd = Cmd(windows.SERVICE_CONTROL_NETBINDADD)
+ NetBindRemove = Cmd(windows.SERVICE_CONTROL_NETBINDREMOVE)
+ NetBindEnable = Cmd(windows.SERVICE_CONTROL_NETBINDENABLE)
+ NetBindDisable = Cmd(windows.SERVICE_CONTROL_NETBINDDISABLE)
+ DeviceEvent = Cmd(windows.SERVICE_CONTROL_DEVICEEVENT)
+ HardwareProfileChange = Cmd(windows.SERVICE_CONTROL_HARDWAREPROFILECHANGE)
+ PowerEvent = Cmd(windows.SERVICE_CONTROL_POWEREVENT)
+ SessionChange = Cmd(windows.SERVICE_CONTROL_SESSIONCHANGE)
)
// Accepted is used to describe commands accepted by the service.
@@ -47,9 +56,14 @@ const (
type Accepted uint32
const (
- AcceptStop = Accepted(windows.SERVICE_ACCEPT_STOP)
- AcceptShutdown = Accepted(windows.SERVICE_ACCEPT_SHUTDOWN)
- AcceptPauseAndContinue = Accepted(windows.SERVICE_ACCEPT_PAUSE_CONTINUE)
+ AcceptStop = Accepted(windows.SERVICE_ACCEPT_STOP)
+ AcceptShutdown = Accepted(windows.SERVICE_ACCEPT_SHUTDOWN)
+ AcceptPauseAndContinue = Accepted(windows.SERVICE_ACCEPT_PAUSE_CONTINUE)
+ AcceptParamChange = Accepted(windows.SERVICE_ACCEPT_PARAMCHANGE)
+ AcceptNetBindChange = Accepted(windows.SERVICE_ACCEPT_NETBINDCHANGE)
+ AcceptHardwareProfileChange = Accepted(windows.SERVICE_ACCEPT_HARDWAREPROFILECHANGE)
+ AcceptPowerEvent = Accepted(windows.SERVICE_ACCEPT_POWEREVENT)
+ AcceptSessionChange = Accepted(windows.SERVICE_ACCEPT_SESSIONCHANGE)
)
// Status combines State and Accepted commands to fully describe running service.
@@ -63,6 +77,8 @@ type Status struct {
// ChangeRequest is sent to the service Handler to request service status change.
type ChangeRequest struct {
Cmd Cmd
+ EventType uint32
+ EventData uintptr
CurrentStatus Status
}
@@ -85,16 +101,16 @@ type Handler interface {
var (
// These are used by asm code.
- goWaitsH uintptr
- cWaitsH uintptr
- ssHandle uintptr
- sName *uint16
- sArgc uintptr
- sArgv **uint16
- ctlHandlerProc uintptr
- cSetEvent uintptr
- cWaitForSingleObject uintptr
- cRegisterServiceCtrlHandlerW uintptr
+ goWaitsH uintptr
+ cWaitsH uintptr
+ ssHandle uintptr
+ sName *uint16
+ sArgc uintptr
+ sArgv **uint16
+ ctlHandlerExProc uintptr
+ cSetEvent uintptr
+ cWaitForSingleObject uintptr
+ cRegisterServiceCtrlHandlerExW uintptr
)
func init() {
@@ -102,12 +118,16 @@ func init() {
cSetEvent = k.MustFindProc("SetEvent").Addr()
cWaitForSingleObject = k.MustFindProc("WaitForSingleObject").Addr()
a := syscall.MustLoadDLL("advapi32.dll")
- cRegisterServiceCtrlHandlerW = a.MustFindProc("RegisterServiceCtrlHandlerW").Addr()
+ cRegisterServiceCtrlHandlerExW = a.MustFindProc("RegisterServiceCtrlHandlerExW").Addr()
}
+// The HandlerEx prototype also has a context pointer but since we don't use
+// it at start-up time we don't have to pass it over either.
type ctlEvent struct {
- cmd Cmd
- errno uint32
+ cmd Cmd
+ eventType uint32
+ eventData uintptr
+ errno uint32
}
// service provides access to windows service api.
@@ -165,6 +185,21 @@ func (s *service) updateStatus(status *Status, ec *exitCode) error {
if status.Accepts&AcceptPauseAndContinue != 0 {
t.ControlsAccepted |= windows.SERVICE_ACCEPT_PAUSE_CONTINUE
}
+ if status.Accepts&AcceptParamChange != 0 {
+ t.ControlsAccepted |= windows.SERVICE_ACCEPT_PARAMCHANGE
+ }
+ if status.Accepts&AcceptNetBindChange != 0 {
+ t.ControlsAccepted |= windows.SERVICE_ACCEPT_NETBINDCHANGE
+ }
+ if status.Accepts&AcceptHardwareProfileChange != 0 {
+ t.ControlsAccepted |= windows.SERVICE_ACCEPT_HARDWAREPROFILECHANGE
+ }
+ if status.Accepts&AcceptPowerEvent != 0 {
+ t.ControlsAccepted |= windows.SERVICE_ACCEPT_POWEREVENT
+ }
+ if status.Accepts&AcceptSessionChange != 0 {
+ t.ControlsAccepted |= windows.SERVICE_ACCEPT_SESSIONCHANGE
+ }
if ec.errno == 0 {
t.Win32ExitCode = windows.NO_ERROR
t.ServiceSpecificExitCode = windows.NO_ERROR
@@ -208,6 +243,8 @@ func (s *service) run() {
var outch chan ChangeRequest
inch := s.c
var cmd Cmd
+ var evtype uint32
+ var evdata uintptr
loop:
for {
select {
@@ -219,7 +256,9 @@ loop:
inch = nil
outch = cmdsToHandler
cmd = r.cmd
- case outch <- ChangeRequest{cmd, status}:
+ evtype = r.eventType
+ evdata = r.eventData
+ case outch <- ChangeRequest{cmd, evtype, evdata, status}:
inch = s.c
outch = nil
case c := <-changesFromHandler:
@@ -276,8 +315,8 @@ func Run(name string, handler Handler) error {
return err
}
- ctlHandler := func(ctl uint32) uintptr {
- e := ctlEvent{cmd: Cmd(ctl)}
+ ctlHandler := func(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr {
+ e := ctlEvent{cmd: Cmd(ctl), eventType: evtype, eventData: evdata}
// We assume that this callback function is running on
// the same thread as Run. Nowhere in MS documentation
// I could find statement to guarantee that. So putting
@@ -288,20 +327,21 @@ func Run(name string, handler Handler) error {
e.errno = sysErrNewThreadInCallback
}
s.c <- e
+ // Always return NO_ERROR (0) for now.
return 0
}
var svcmain uintptr
getServiceMain(&svcmain)
t := []windows.SERVICE_TABLE_ENTRY{
- {syscall.StringToUTF16Ptr(s.name), svcmain},
- {nil, 0},
+ {ServiceName: syscall.StringToUTF16Ptr(s.name), ServiceProc: svcmain},
+ {ServiceName: nil, ServiceProc: 0},
}
goWaitsH = uintptr(s.goWaits.h)
cWaitsH = uintptr(s.cWaits.h)
sName = t[0].ServiceName
- ctlHandlerProc, err = newCallback(ctlHandler)
+ ctlHandlerExProc, err = newCallback(ctlHandler)
if err != nil {
return err
}
@@ -314,3 +354,10 @@ func Run(name string, handler Handler) error {
}
return nil
}
+
+// StatusHandle returns service status handle. It is safe to call this function
+// from inside the Handler.Execute because then it is guaranteed to be set.
+// This code will have to change once multiple services are possible per process.
+func StatusHandle() windows.Handle {
+ return windows.Handle(ssHandle)
+}
diff --git a/vendor/golang.org/x/sys/windows/svc/sys_386.s b/vendor/golang.org/x/sys/windows/svc/sys_386.s
index 5e11bfadb5..2c82a9d91d 100644
--- a/vendor/golang.org/x/sys/windows/svc/sys_386.s
+++ b/vendor/golang.org/x/sys/windows/svc/sys_386.s
@@ -22,7 +22,8 @@ TEXT ·servicemain(SB),7,$0
MOVL AX, (SP)
MOVL $·servicectlhandler(SB), AX
MOVL AX, 4(SP)
- MOVL ·cRegisterServiceCtrlHandlerW(SB), AX
+ MOVL $0, 8(SP)
+ MOVL ·cRegisterServiceCtrlHandlerExW(SB), AX
MOVL SP, BP
CALL AX
MOVL BP, SP
@@ -61,7 +62,7 @@ exit:
// I do not know why, but this seems to be the only way to call
// ctlHandlerProc on Windows 7.
-// func servicectlhandler(ctl uint32) uintptr
+// func servicectlhandler(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr {
TEXT ·servicectlhandler(SB),7,$0
- MOVL ·ctlHandlerProc(SB), CX
+ MOVL ·ctlHandlerExProc(SB), CX
JMP CX
diff --git a/vendor/golang.org/x/sys/windows/svc/sys_amd64.s b/vendor/golang.org/x/sys/windows/svc/sys_amd64.s
index 87dbec8395..bde25e9c48 100644
--- a/vendor/golang.org/x/sys/windows/svc/sys_amd64.s
+++ b/vendor/golang.org/x/sys/windows/svc/sys_amd64.s
@@ -7,13 +7,14 @@
// func servicemain(argc uint32, argv **uint16)
TEXT ·servicemain(SB),7,$0
MOVL CX, ·sArgc(SB)
- MOVL DX, ·sArgv(SB)
+ MOVQ DX, ·sArgv(SB)
SUBQ $32, SP // stack for the first 4 syscall params
MOVQ ·sName(SB), CX
MOVQ $·servicectlhandler(SB), DX
- MOVQ ·cRegisterServiceCtrlHandlerW(SB), AX
+ // BUG(pastarmovj): Figure out a way to pass in context in R8.
+ MOVQ ·cRegisterServiceCtrlHandlerExW(SB), AX
CALL AX
CMPQ AX, $0
JE exit
@@ -35,7 +36,7 @@ exit:
// I do not know why, but this seems to be the only way to call
// ctlHandlerProc on Windows 7.
-// func servicectlhandler(ctl uint32) uintptr
+// func ·servicectlhandler(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr {
TEXT ·servicectlhandler(SB),7,$0
- MOVQ ·ctlHandlerProc(SB), AX
+ MOVQ ·ctlHandlerExProc(SB), AX
JMP AX
diff --git a/vendor/golang.org/x/sys/windows/svc/sys_arm.s b/vendor/golang.org/x/sys/windows/svc/sys_arm.s
new file mode 100644
index 0000000000..33c692a8de
--- /dev/null
+++ b/vendor/golang.org/x/sys/windows/svc/sys_arm.s
@@ -0,0 +1,38 @@
+// Copyright 2018 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// +build windows
+
+#include "textflag.h"
+
+// func servicemain(argc uint32, argv **uint16)
+TEXT ·servicemain(SB),NOSPLIT|NOFRAME,$0
+ MOVM.DB.W [R4, R14], (R13) // push {r4, lr}
+ MOVW R13, R4
+ BIC $0x7, R13 // alignment for ABI
+
+ MOVW R0, ·sArgc(SB)
+ MOVW R1, ·sArgv(SB)
+
+ MOVW ·sName(SB), R0
+ MOVW ·ctlHandlerExProc(SB), R1
+ MOVW $0, R2
+ MOVW ·cRegisterServiceCtrlHandlerExW(SB), R3
+ BL (R3)
+ CMP $0, R0
+ BEQ exit
+ MOVW R0, ·ssHandle(SB)
+
+ MOVW ·goWaitsH(SB), R0
+ MOVW ·cSetEvent(SB), R1
+ BL (R1)
+
+ MOVW ·cWaitsH(SB), R0
+ MOVW $-1, R1
+ MOVW ·cWaitForSingleObject(SB), R2
+ BL (R2)
+
+exit:
+ MOVW R4, R13 // free extra stack space
+ MOVM.IA.W (R13), [R4, R15] // pop {r4, pc}