Documentation
¶
Index ¶
- Constants
- Variables
- func CloseHandle(handle syscall.Handle) (err error)
- func CoTaskMemFree(pv uintptr)
- func CreateEnvironment(env *[]string, hUser syscall.Handle) (mergedEnv *[]string, err error)
- func CreateEnvironmentBlock(lpEnvironment *uintptr, hToken syscall.Handle, bInherit bool) (err error)
- func DestroyEnvironmentBlock(lpEnvironment uintptr) (err error)
- func GetFolder(hUser syscall.Handle, folder *syscall.GUID, dwFlags uint32) (value string, err error)
- func GetLinkedToken(hToken syscall.Token) (syscall.Token, error)
- func GetProfilesDirectory(lpProfilesDir *uint16, lpcchSize *uint32) (err error)
- func GetTokenInformation(tokenHandle syscall.Token, tokenInformationClass TOKEN_INFORMATION_CLASS, ...) (err error)
- func GetUserProfileDirectory(hToken syscall.Handle, lpProfileDir *uint16, lpcchSize *uint32) (err error)
- func InteractiveUserToken(timeout time.Duration) (hToken syscall.Handle, err error)
- func IsWindows8OrGreater() bool
- func LoadUserProfile(token syscall.Handle, pinfo *ProfileInfo) error
- func LogonUser(username *uint16, domain *uint16, password *uint16, logonType uint32, ...) (token syscall.Handle, err error)
- func MergeEnvLists(envLists ...*[]string) (*[]string, error)
- func ProfileDirectory(hToken syscall.Handle) (string, error)
- func ProfilesDirectory() string
- func SHGetKnownFolderPath(rfid *syscall.GUID, dwFlags uint32, hToken syscall.Handle, pszPath *uintptr) (err error)
- func SHSetKnownFolderPath(rfid *syscall.GUID, dwFlags uint32, hToken syscall.Handle, pszPath *uint16) (err error)
- func SetAndCreateFolder(hUser syscall.Handle, folder *syscall.GUID, value string) (err error)
- func SetFolder(hUser syscall.Handle, folder *syscall.GUID, value string) (err error)
- func UnloadUserProfile(token, profile syscall.Handle) error
- func VerSetConditionMask(lConditionMask uint64, typeBitMask uint32, conditionMask uint8) uint64
- func VerifyWindowsInfoW(vi OSVersionInfoEx, typeMask uint32, conditionMask uint64) (bool, error)
- func WTSGetActiveConsoleSessionId() (sessionId uint32, err error)
- func WTSQueryUserToken(sessionId uint32, phToken *syscall.Handle) (err error)
- type LazyDLLWrapper
- type LazyProcWrapper
- type OSVersionInfoEx
- type ProfileInfo
- type TOKEN_INFORMATION_CLASS
- type TOKEN_LINKED_TOKEN
Examples ¶
Constants ¶
const ( LOGON32_PROVIDER_DEFAULT = 0 LOGON32_LOGON_INTERACTIVE = 2 PI_NOUI = 1 KF_FLAG_CREATE uint32 = 0x00008000 CREATE_BREAKAWAY_FROM_JOB = 0x01000000 CREATE_NEW_CONSOLE = 0x00000010 CREATE_NEW_PROCESS_GROUP = 0x00000200 VER_MAJORVERSION = 0x0000002 VER_MINORVERSION = 0x0000001 VER_SERVICEPACKMAJOR = 0x0000020 VER_SERVICEPACKMINOR = 0x0000010 VER_GREATER_EQUAL = 3 ERROR_OLD_WIN_VERSION syscall.Errno = 1150 // See https://msdn.microsoft.com/en-us/library/windows/desktop/aa379626(v=vs.85).aspx TokenLinkedToken = 19 )
Variables ¶
var ( FOLDERID_LocalAppData = syscall.GUID{Data1: 0xF1B32785, Data2: 0x6FBA, Data3: 0x4FCF, Data4: [8]byte{0x9D, 0x55, 0x7B, 0x8E, 0x7F, 0x15, 0x70, 0x91}} FOLDERID_RoamingAppData = syscall.GUID{Data1: 0x3EB685DB, Data2: 0x65F9, Data3: 0x4CF6, Data4: [8]byte{0xA0, 0x3A, 0xE3, 0xEF, 0x65, 0x72, 0x9F, 0x3D}} )
Functions ¶
func CloseHandle ¶
func CoTaskMemFree ¶
func CoTaskMemFree(pv uintptr)
https://msdn.microsoft.com/en-us/library/windows/desktop/ms680722(v=vs.85).aspx Note: the system call returns no value, so we can't check for an error
func CreateEnvironment ¶
CreateEnvironment returns an environment block, suitable for use with the CreateProcessAsUser system call. The default environment variables of hUser are overlayed with values in env.
func CreateEnvironmentBlock ¶
func CreateEnvironmentBlock( lpEnvironment *uintptr, hToken syscall.Handle, bInherit bool, ) (err error)
https://msdn.microsoft.com/en-us/library/windows/desktop/bb762270(v=vs.85).aspx
func DestroyEnvironmentBlock ¶
https://msdn.microsoft.com/en-us/library/windows/desktop/bb762274(v=vs.85).aspx
func GetProfilesDirectory ¶
https://msdn.microsoft.com/en-us/library/windows/desktop/bb762278(v=vs.85).aspx BOOL WINAPI GetProfilesDirectory(
_Out_ LPTSTR lpProfilesDir, _Inout_ LPDWORD lpcchSize
);
func GetTokenInformation ¶
func GetTokenInformation( tokenHandle syscall.Token, tokenInformationClass TOKEN_INFORMATION_CLASS, tokenInformation uintptr, tokenInformationLength uintptr, returnLength *uintptr, ) (err error)
https://msdn.microsoft.com/en-us/library/windows/desktop/aa446671(v=vs.85).aspx BOOL WINAPI GetTokenInformation(
_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_opt_ LPVOID TokenInformation, _In_ DWORD TokenInformationLength, _Out_ PDWORD ReturnLength
);
func GetUserProfileDirectory ¶
func GetUserProfileDirectory( hToken syscall.Handle, lpProfileDir *uint16, lpcchSize *uint32, ) (err error)
https://msdn.microsoft.com/en-us/library/windows/desktop/bb762280(v=vs.85).aspx BOOL WINAPI GetUserProfileDirectory(
_In_ HANDLE hToken, _Out_opt_ LPTSTR lpProfileDir, _Inout_ LPDWORD lpcchSize
);
func InteractiveUserToken ¶
InteractiveUserToken returns a user token (security context) for the interactive desktop session attached to the default console (i.e. what would be seen on a display connected directly to the computer, rather than a remote RDP session). It must be called from a process which is running under LocalSystem account in order to have the necessary privileges (typically a Windows service). Since the service might be running before a local logon occurs, a timeout can be specified for waiting for a successful logon (via winlogon) to occur. The returned token can be used in e.g. CreateProcessAsUser system call, which allows e.g. a Windows service to run a process in the interactive desktop session, as if the logged in user had executed the process directly. The function additionally waits for the user profile directory to exist, before returning.
func IsWindows8OrGreater ¶
func IsWindows8OrGreater() bool
func LoadUserProfile ¶
func LoadUserProfile(token syscall.Handle, pinfo *ProfileInfo) error
func MergeEnvLists ¶
Example ¶
package main
import (
"fmt"
"log"
"github.com/taskcluster/generic-worker/win32"
)
func main() {
lists := []*[]string{
{
"a=dog",
"Pete=man",
"x=ray",
}, {
"food=good",
"PETE=person",
},
}
res, err := win32.MergeEnvLists(lists...)
if err != nil {
log.Fatalf("Hit error: %v", err)
}
fmt.Println(*res)
}
Output: [a=dog food=good Pete=person x=ray]
func ProfileDirectory ¶
ProfileDirectory returns the profile directory of the user represented by the given user handle
func ProfilesDirectory ¶
func ProfilesDirectory() string
ProfilesDirectory returns the folder where user profiles get created, typically `C:\Users`
func SHGetKnownFolderPath ¶
func SHGetKnownFolderPath(rfid *syscall.GUID, dwFlags uint32, hToken syscall.Handle, pszPath *uintptr) (err error)
https://msdn.microsoft.com/en-us/library/windows/desktop/bb762188(v=vs.85).aspx
func SHSetKnownFolderPath ¶
func SHSetKnownFolderPath( rfid *syscall.GUID, dwFlags uint32, hToken syscall.Handle, pszPath *uint16, ) (err error)
https://msdn.microsoft.com/en-us/library/windows/desktop/bb762249(v=vs.85).aspx
func SetAndCreateFolder ¶
func UnloadUserProfile ¶
func VerSetConditionMask ¶
func VerifyWindowsInfoW ¶
func VerifyWindowsInfoW(vi OSVersionInfoEx, typeMask uint32, conditionMask uint64) (bool, error)
func WTSGetActiveConsoleSessionId ¶
https://msdn.microsoft.com/en-us/library/aa383835(VS.85).aspx DWORD WTSGetActiveConsoleSessionId(void);
func WTSQueryUserToken ¶
https://msdn.microsoft.com/en-us/library/aa383840(VS.85).aspx BOOL WTSQueryUserToken(
_In_ ULONG SessionId, _Out_ PHANDLE phToken
);
Types ¶
type LazyDLLWrapper ¶
These wrappers are used to be able to intercept system calls, and log what is being called...
func NewLazyDLL ¶
func NewLazyDLL(name string) *LazyDLLWrapper
func (*LazyDLLWrapper) NewProc ¶
func (l *LazyDLLWrapper) NewProc(name string) *LazyProcWrapper
type LazyProcWrapper ¶
These wrappers are used to be able to intercept system calls, and log what is being called...
type OSVersionInfoEx ¶
type ProfileInfo ¶
type TOKEN_INFORMATION_CLASS ¶
type TOKEN_INFORMATION_CLASS uint32
type TOKEN_LINKED_TOKEN ¶
https://msdn.microsoft.com/en-us/library/windows/desktop/bb530719(v=vs.85).aspx
typedef struct _TOKEN_LINKED_TOKEN {
HANDLE LinkedToken;
} TOKEN_LINKED_TOKEN, *PTOKEN_LINKED_TOKEN;