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 5// +build windows 6// +build go1.3 7 8package svc 9 10import "unsafe" 11 12const ptrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const 13 14// Should be a built-in for unsafe.Pointer? 15func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { 16 return unsafe.Pointer(uintptr(p) + x) 17} 18 19// funcPC returns the entry PC of the function f. 20// It assumes that f is a func value. Otherwise the behavior is undefined. 21func funcPC(f interface{}) uintptr { 22 return **(**uintptr)(add(unsafe.Pointer(&f), ptrSize)) 23} 24 25// from sys_386.s and sys_amd64.s 26func servicectlhandler(ctl uint32) uintptr 27func servicemain(argc uint32, argv **uint16) 28 29func getServiceMain(r *uintptr) { 30 *r = funcPC(servicemain) 31} 32