github.com/Andyfoo/golang/x/sys@v0.0.0-20190901054642-57c1bf301704/windows/svc/sys_amd64.s (about)

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build windows
     6  
     7  // func servicemain(argc uint32, argv **uint16)
     8  TEXT ·servicemain(SB),7,$0
     9  	MOVL	CX, ·sArgc(SB)
    10  	MOVQ	DX, ·sArgv(SB)
    11  
    12  	SUBQ	$32, SP		// stack for the first 4 syscall params
    13  
    14  	MOVQ	·sName(SB), CX
    15  	MOVQ	$·servicectlhandler(SB), DX
    16  	// BUG(pastarmovj): Figure out a way to pass in context in R8.
    17  	// Set context to 123456 to test issue #25660.
    18  	MOVQ	$123456, R8
    19  	MOVQ	·cRegisterServiceCtrlHandlerExW(SB), AX
    20  	CALL	AX
    21  	CMPQ	AX, $0
    22  	JE	exit
    23  	MOVQ	AX, ·ssHandle(SB)
    24  
    25  	MOVQ	·goWaitsH(SB), CX
    26  	MOVQ	·cSetEvent(SB), AX
    27  	CALL	AX
    28  
    29  	MOVQ	·cWaitsH(SB), CX
    30  	MOVQ	$4294967295, DX
    31  	MOVQ	·cWaitForSingleObject(SB), AX
    32  	CALL	AX
    33  
    34  exit:
    35  	ADDQ	$32, SP
    36  	RET
    37  
    38  // I do not know why, but this seems to be the only way to call
    39  // ctlHandlerProc on Windows 7.
    40  
    41  // func ·servicectlhandler(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr {
    42  TEXT ·servicectlhandler(SB),7,$0
    43  	MOVQ	·ctlHandlerExProc(SB), AX
    44  	JMP	AX