sys_amd64.s 911 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. // +build windows
  5. // func servicemain(argc uint32, argv **uint16)
  6. TEXT ·servicemain(SB),7,$0
  7. MOVL CX, ·sArgc(SB)
  8. MOVL DX, ·sArgv(SB)
  9. SUBQ $32, SP // stack for the first 4 syscall params
  10. MOVQ ·sName(SB), CX
  11. MOVQ $·servicectlhandler(SB), DX
  12. MOVQ ·cRegisterServiceCtrlHandlerW(SB), AX
  13. CALL AX
  14. CMPQ AX, $0
  15. JE exit
  16. MOVQ AX, ·ssHandle(SB)
  17. MOVQ ·goWaitsH(SB), CX
  18. MOVQ ·cSetEvent(SB), AX
  19. CALL AX
  20. MOVQ ·cWaitsH(SB), CX
  21. MOVQ $4294967295, DX
  22. MOVQ ·cWaitForSingleObject(SB), AX
  23. CALL AX
  24. exit:
  25. ADDQ $32, SP
  26. RET
  27. // I do not know why, but this seems to be the only way to call
  28. // ctlHandlerProc on Windows 7.
  29. // func servicectlhandler(ctl uint32) uintptr
  30. TEXT ·servicectlhandler(SB),7,$0
  31. MOVQ ·ctlHandlerProc(SB), AX
  32. JMP AX