示例#1
0
func main() {
	handle, _ := dl.Open("msvcrt.dll")
	proc, _ := dl.Sym(handle, "getenv")
	ret := dl.Call(
		proc,
		uintptr(unsafe.Pointer(&([]byte)("USERPROFILE")[0])),
		0,
		0)
	bytes := *((*[]byte)(unsafe.Pointer(ret)))
	println(string(bytes[0:clen(bytes)]))
}
示例#2
0
func main() {
	handle, _ := dl.Open("libc.so")
	proc, _ := dl.Sym(handle, "getenv")
	ret := dl.Call(
		proc,
		uintptr(unsafe.Pointer(&([]byte)("HOME")[0])),
		0,
		0)
	bytes := (([]byte)(unsafe.Pointer(ret)))
	println(string(bytes[0:clen(bytes)]))
}