github.com/docker/engine@v22.0.0-20211208180946-d456264580cf+incompatible/pkg/system/syscall_windows.go (about) 1 package system // import "github.com/docker/docker/pkg/system" 2 3 import ( 4 "unsafe" 5 6 "github.com/sirupsen/logrus" 7 "golang.org/x/sys/windows" 8 ) 9 10 const ( 11 // Deprecated: use github.com/docker/pkg/idtools.SeTakeOwnershipPrivilege 12 SeTakeOwnershipPrivilege = "SeTakeOwnershipPrivilege" 13 ) 14 15 const ( 16 // Deprecated: use github.com/docker/pkg/idtools.ContainerAdministratorSidString 17 ContainerAdministratorSidString = "S-1-5-93-2-1" 18 // Deprecated: use github.com/docker/pkg/idtools.ContainerUserSidString 19 ContainerUserSidString = "S-1-5-93-2-2" 20 ) 21 22 var ( 23 ntuserApiset = windows.NewLazyDLL("ext-ms-win-ntuser-window-l1-1-0") 24 procGetVersionExW = modkernel32.NewProc("GetVersionExW") 25 ) 26 27 // https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa 28 // TODO: use golang.org/x/sys/windows.OsVersionInfoEx (needs OSVersionInfoSize to be exported) 29 type osVersionInfoEx struct { 30 OSVersionInfoSize uint32 31 MajorVersion uint32 32 MinorVersion uint32 33 BuildNumber uint32 34 PlatformID uint32 35 CSDVersion [128]uint16 36 ServicePackMajor uint16 37 ServicePackMinor uint16 38 SuiteMask uint16 39 ProductType byte 40 Reserve byte 41 } 42 43 // IsWindowsClient returns true if the SKU is client. It returns false on 44 // Windows server, or if an error occurred when making the GetVersionExW 45 // syscall. 46 func IsWindowsClient() bool { 47 osviex := &osVersionInfoEx{OSVersionInfoSize: 284} 48 r1, _, err := procGetVersionExW.Call(uintptr(unsafe.Pointer(osviex))) 49 if r1 == 0 { 50 logrus.WithError(err).Warn("GetVersionExW failed - assuming server SKU") 51 return false 52 } 53 // VER_NT_WORKSTATION, see https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-osversioninfoexa 54 const verNTWorkstation = 0x00000001 // VER_NT_WORKSTATION 55 return osviex.ProductType == verNTWorkstation 56 } 57 58 // HasWin32KSupport determines whether containers that depend on win32k can 59 // run on this machine. Win32k is the driver used to implement windowing. 60 func HasWin32KSupport() bool { 61 // For now, check for ntuser API support on the host. In the future, a host 62 // may support win32k in containers even if the host does not support ntuser 63 // APIs. 64 return ntuserApiset.Load() == nil 65 }