Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

30 lines (26 sloc) 0.712 kb
package main
import (
"flag"
"fmt"
"syscall"
"unicode/utf16"
"unsafe"
)
func create_sock_flag(name, desc string) *string {
return flag.String(name, "tcp", desc)
}
// Full path of the current executable
func get_executable_filename() string {
kernel32, _ := syscall.LoadLibrary("kernel32.dll")
defer syscall.FreeLibrary(kernel32)
b := make([]uint16, syscall.MAX_PATH)
getModuleFileName, _ := syscall.GetProcAddress(kernel32, "GetModuleFileNameW")
ret, _, callErr := syscall.Syscall(uintptr(getModuleFileName),
3, 0,
uintptr(unsafe.Pointer(&b[0])),
uintptr(len(b)))
if callErr != 0 {
panic(fmt.Sprintf("GetModuleFileNameW : err %d", int(callErr)))
}
return string(utf16.Decode(b[:ret]))
}
Jump to Line
Something went wrong with that request. Please try again.