windows: use RegisterServiceCtrlHandlerEx to allow for advanced notifications

This allows services written with this library to register for more
advanced notifications like SERVICE_CONTROL_DEVICEEVENT for example.

Also the code now exposes the service status handle through a new
api call, because the handle is needed to register for such
notifications and can not be obtained by any other means.

Change-Id: I80796e1dd9d94ec9d6c236d0413b17288c67fe1f
Reviewed-on: https://go-review.googlesource.com/42812
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Julian Pastarmov
2017-05-18 05:52:01 +00:00
committed by Alex Brainman
parent 98b5b1e7e8
commit e62c3de784
4 changed files with 58 additions and 29 deletions
+4 -3
View File
@@ -13,7 +13,8 @@ TEXT ·servicemain(SB),7,$0
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