sys_386.s 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 argc+0(FP), AX
  8. MOVL AX, ·sArgc(SB)
  9. MOVL argv+4(FP), AX
  10. MOVL AX, ·sArgv(SB)
  11. PUSHL BP
  12. PUSHL BX
  13. PUSHL SI
  14. PUSHL DI
  15. SUBL $12, SP
  16. MOVL ·sName(SB), AX
  17. MOVL AX, (SP)
  18. MOVL $·servicectlhandler(SB), AX
  19. MOVL AX, 4(SP)
  20. // Set context to 123456 to test issue #25660.
  21. MOVL $123456, 8(SP)
  22. MOVL ·cRegisterServiceCtrlHandlerExW(SB), AX
  23. MOVL SP, BP
  24. CALL AX
  25. MOVL BP, SP
  26. CMPL AX, $0
  27. JE exit
  28. MOVL AX, ·ssHandle(SB)
  29. MOVL ·goWaitsH(SB), AX
  30. MOVL AX, (SP)
  31. MOVL ·cSetEvent(SB), AX
  32. MOVL SP, BP
  33. CALL AX
  34. MOVL BP, SP
  35. MOVL ·cWaitsH(SB), AX
  36. MOVL AX, (SP)
  37. MOVL $-1, AX
  38. MOVL AX, 4(SP)
  39. MOVL ·cWaitForSingleObject(SB), AX
  40. MOVL SP, BP
  41. CALL AX
  42. MOVL BP, SP
  43. exit:
  44. ADDL $12, SP
  45. POPL DI
  46. POPL SI
  47. POPL BX
  48. POPL BP
  49. MOVL 0(SP), CX
  50. ADDL $12, SP
  51. JMP CX
  52. // I do not know why, but this seems to be the only way to call
  53. // ctlHandlerProc on Windows 7.
  54. // func servicectlhandler(ctl uint32, evtype uint32, evdata uintptr, context uintptr) uintptr {
  55. TEXT ·servicectlhandler(SB),7,$0
  56. MOVL ·ctlHandlerExProc(SB), CX
  57. JMP CX