2016-11-29 17:26:36 +01:00
|
|
|
// Copyright 2012 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
|
|
|
|
|
|
|
|
// func servicemain(argc uint32, argv **uint16)
|
|
|
|
TEXT ·servicemain(SB),7,$0
|
2020-09-22 19:02:16 +02:00
|
|
|
MOVQ SP, AX
|
|
|
|
ANDQ $~15, SP // alignment as per Windows requirement
|
|
|
|
SUBQ $48, SP // room for SP and 4 args as per Windows requirement
|
|
|
|
// plus one extra word to keep stack 16 bytes aligned
|
|
|
|
MOVQ AX, 32(SP)
|
|
|
|
|
2016-11-29 17:26:36 +01:00
|
|
|
MOVL CX, ·sArgc(SB)
|
2018-10-27 01:18:40 +02:00
|
|
|
MOVQ DX, ·sArgv(SB)
|
2016-11-29 17:26:36 +01:00
|
|
|
|
|
|
|
MOVQ ·sName(SB), CX
|
|
|
|
MOVQ $·servicectlhandler(SB), DX
|
2018-10-27 01:18:40 +02:00
|
|
|
// BUG(pastarmovj): Figure out a way to pass in context in R8.
|
2019-05-13 17:38:53 +02:00
|
|
|
// Set context to 123456 to test issue #25660.
|
|
|
|
MOVQ $123456, R8
|
2018-10-27 01:18:40 +02:00
|
|
|
MOVQ ·cRegisterServiceCtrlHandlerExW(SB), AX
|
2016-11-29 17:26:36 +01:00
|
|
|
CALL AX
|
|
|
|
CMPQ AX, $0
|
|
|
|
JE exit
|
|
|
|
MOVQ AX, ·ssHandle(SB)
|
|
|
|
|
|
|
|
MOVQ ·goWaitsH(SB), CX
|
|
|
|
MOVQ ·cSetEvent(SB), AX
|
|
|
|
CALL AX
|
|
|
|
|
|
|
|
MOVQ ·cWaitsH(SB), CX
|
|
|
|
MOVQ $4294967295, DX
|
|
|
|
MOVQ ·cWaitForSingleObject(SB), AX
|
|
|
|
CALL AX
|
|
|
|
|
|
|
|
exit:
|
2020-09-22 19:02:16 +02:00
|
|
|
MOVQ 32(SP), SP
|
2016-11-29 17:26:36 +01:00
|
|
|
RET
|
|
|
|
|
|
|
|
// I do not know why, but this seems to be the only way to call
|
|
|
|
// ctlHandlerProc on Windows 7.
|
|
|
|
|
2018-10-27 01:18:40 +02:00
|
|
|
// func ·servicectlhandler(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr {
|
2016-11-29 17:26:36 +01:00
|
|
|
TEXT ·servicectlhandler(SB),7,$0
|
2018-10-27 01:18:40 +02:00
|
|
|
MOVQ ·ctlHandlerExProc(SB), AX
|
2016-11-29 17:26:36 +01:00
|
|
|
JMP AX
|