github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/osext/winsvc/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  TEXT ·servicemain(SB),7,$0
     6  	MOVL	CX, ·sArgc(SB)
     7  	MOVL	DX, ·sArgv(SB)
     8  
     9  	SUBQ	$32, SP		// stack for the first 4 syscall params
    10  
    11  	MOVQ	·sName(SB), CX
    12  	MOVQ	$·servicectlhandler(SB), DX
    13  	MOVQ	·cRegisterServiceCtrlHandlerW(SB), AX
    14  	CALL	AX
    15  	CMPQ	AX, $0
    16  	JE	exit
    17  	MOVQ	AX, ·ssHandle(SB)
    18  
    19  	MOVQ	·goWaitsH(SB), CX
    20  	MOVQ	·cSetEvent(SB), AX
    21  	CALL	AX
    22  
    23  	MOVQ	·cWaitsH(SB), CX
    24  	MOVQ	$4294967295, DX
    25  	MOVQ	·cWaitForSingleObject(SB), AX
    26  	CALL	AX
    27  
    28  exit:
    29  	ADDQ	$32, SP
    30  	RET
    31  
    32  // I do not know why, but this seems to be the only way to call
    33  // ctlHandlerProc on Windows 7.
    34  
    35  TEXT ·servicectlhandler(SB),7,$0
    36  	MOVQ	·ctlHandlerProc(SB), AX
    37  	JMP	AX