本站源代码
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.

32 lines
862B

  1. // Copyright 2014 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. // +build go1.3
  6. package svc
  7. import "unsafe"
  8. const ptrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const
  9. // Should be a built-in for unsafe.Pointer?
  10. func add(p unsafe.Pointer, x uintptr) unsafe.Pointer {
  11. return unsafe.Pointer(uintptr(p) + x)
  12. }
  13. // funcPC returns the entry PC of the function f.
  14. // It assumes that f is a func value. Otherwise the behavior is undefined.
  15. func funcPC(f interface{}) uintptr {
  16. return **(**uintptr)(add(unsafe.Pointer(&f), ptrSize))
  17. }
  18. // from sys_386.s and sys_amd64.s
  19. func servicectlhandler(ctl uint32) uintptr
  20. func servicemain(argc uint32, argv **uint16)
  21. func getServiceMain(r *uintptr) {
  22. *r = funcPC(servicemain)
  23. }
上海开阖软件有限公司 沪ICP备12045867号-1