sys_amd64.s 1.1 KB

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