You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
746 B
Go
33 lines
746 B
Go
package win32api
|
|
|
|
import (
|
|
"errors"
|
|
"syscall"
|
|
"unsafe"
|
|
)
|
|
|
|
/*
|
|
BOOL CreateEnvironmentBlock(
|
|
LPVOID *lpEnvironment,
|
|
HANDLE hToken,
|
|
BOOL bInherit
|
|
);
|
|
*/
|
|
|
|
func CreateEnvironmentBlock(lpEnvironment *HANDLE, hToken TOKEN, bInherit uintptr) error {
|
|
userenv, err := syscall.LoadLibrary("userenv.dll")
|
|
if err != nil {
|
|
return errors.New("Can't Load Userenv API")
|
|
}
|
|
defer syscall.FreeLibrary(userenv)
|
|
Dup, err := syscall.GetProcAddress(syscall.Handle(userenv), "CreateEnvironmentBlock")
|
|
if err != nil {
|
|
return errors.New("Can't Load WTSQueryUserToken API")
|
|
}
|
|
r, _, errno := syscall.Syscall6(uintptr(Dup), 3, uintptr(unsafe.Pointer(lpEnvironment)), uintptr(hToken), bInherit, 0, 0, 0)
|
|
if r == 0 {
|
|
return error(errno)
|
|
}
|
|
return nil
|
|
}
|