You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 lines
1.0 KiB

  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. MOVQ 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. // BUG(pastarmovj): Figure out a way to pass in context in R8.
  13. MOVQ ·cRegisterServiceCtrlHandlerExW(SB), AX
  14. CALL AX
  15. CMPQ AX, $0
  16. JE exit
  17. MOVQ AX, ·ssHandle(SB)
  18. MOVQ ·goWaitsH(SB), CX
  19. MOVQ ·cSetEvent(SB), AX
  20. CALL AX
  21. MOVQ ·cWaitsH(SB), CX
  22. MOVQ $4294967295, DX
  23. MOVQ ·cWaitForSingleObject(SB), AX
  24. CALL AX
  25. exit:
  26. ADDQ $32, SP
  27. RET
  28. // I do not know why, but this seems to be the only way to call
  29. // ctlHandlerProc on Windows 7.
  30. // func ·servicectlhandler(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr {
  31. TEXT ·servicectlhandler(SB),7,$0
  32. MOVQ ·ctlHandlerExProc(SB), AX
  33. JMP AX