Changeset 69 in code for trunk/vendor/golang.org/x/sys/windows
- Timestamp:
- Sep 13, 2023, 10:49:50 AM (21 months ago)
- Location:
- trunk/vendor/golang.org/x/sys/windows
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vendor/golang.org/x/sys/windows/setupapi_windows.go
r67 r69 297 297 DI_INF_IS_SORTED DI_FLAGS = 0x00008000 298 298 299 // Flag to indicate that only the theINF specified by SP_DEVINSTALL_PARAMS.DriverPath should be searched.299 // Flag to indicate that only the INF specified by SP_DEVINSTALL_PARAMS.DriverPath should be searched. 300 300 DI_ENUMSINGLEINF DI_FLAGS = 0x00010000 301 301 -
trunk/vendor/golang.org/x/sys/windows/syscall.go
r67 r69 31 31 "syscall" 32 32 "unsafe" 33 34 "golang.org/x/sys/internal/unsafeheader"35 33 ) 36 34 … … 84 82 } 85 83 86 var s []byte 87 h := (*unsafeheader.Slice)(unsafe.Pointer(&s)) 88 h.Data = unsafe.Pointer(p) 89 h.Len = n 90 h.Cap = n 91 92 return string(s) 84 return string(unsafe.Slice(p, n)) 93 85 } 94 86 -
trunk/vendor/golang.org/x/sys/windows/syscall_windows.go
r67 r69 139 139 } 140 140 141 var s []uint16 142 h := (*unsafeheader.Slice)(unsafe.Pointer(&s)) 143 h.Data = unsafe.Pointer(p) 144 h.Len = n 145 h.Cap = n 146 147 return string(utf16.Decode(s)) 141 return string(utf16.Decode(unsafe.Slice(p, n))) 148 142 } 149 143 … … 365 359 //sys GetActiveProcessorCount(groupNumber uint16) (ret uint32) 366 360 //sys GetMaximumProcessorCount(groupNumber uint16) (ret uint32) 361 //sys EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) = user32.EnumWindows 362 //sys EnumChildWindows(hwnd HWND, enumFunc uintptr, param unsafe.Pointer) = user32.EnumChildWindows 363 //sys GetClassName(hwnd HWND, className *uint16, maxCount int32) (copied int32, err error) = user32.GetClassNameW 364 //sys GetDesktopWindow() (hwnd HWND) = user32.GetDesktopWindow 365 //sys GetForegroundWindow() (hwnd HWND) = user32.GetForegroundWindow 366 //sys IsWindow(hwnd HWND) (isWindow bool) = user32.IsWindow 367 //sys IsWindowUnicode(hwnd HWND) (isUnicode bool) = user32.IsWindowUnicode 368 //sys IsWindowVisible(hwnd HWND) (isVisible bool) = user32.IsWindowVisible 369 //sys GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) = user32.GetGUIThreadInfo 367 370 368 371 // Volume Management Functions … … 418 421 //sys GetModuleFileNameEx(process Handle, module Handle, filename *uint16, size uint32) (err error) = psapi.GetModuleFileNameExW 419 422 //sys GetModuleBaseName(process Handle, module Handle, baseName *uint16, size uint32) (err error) = psapi.GetModuleBaseNameW 423 //sys QueryWorkingSetEx(process Handle, pv uintptr, cb uint32) (err error) = psapi.QueryWorkingSetEx 420 424 421 425 // NT Native APIs … … 439 443 //sys RtlDeleteFunctionTable(functionTable *RUNTIME_FUNCTION) (ret bool) = ntdll.RtlDeleteFunctionTable 440 444 445 // Desktop Window Manager API (Dwmapi) 446 //sys DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmGetWindowAttribute 447 //sys DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) = dwmapi.DwmSetWindowAttribute 448 441 449 // syscall interface implementation for other packages 442 450 … … 748 756 return e 749 757 } 750 defer Close (h)758 defer CloseHandle(h) 751 759 a := NsecToFiletime(tv[0].Nanoseconds()) 752 760 w := NsecToFiletime(tv[1].Nanoseconds()) … … 768 776 return e 769 777 } 770 defer Close (h)778 defer CloseHandle(h) 771 779 a := NsecToFiletime(TimespecToNsec(ts[0])) 772 780 w := NsecToFiletime(TimespecToNsec(ts[1])) … … 972 980 } 973 981 982 type RawSockaddrBth struct { 983 AddressFamily [2]byte 984 BtAddr [8]byte 985 ServiceClassId [16]byte 986 Port [4]byte 987 } 988 989 type SockaddrBth struct { 990 BtAddr uint64 991 ServiceClassId GUID 992 Port uint32 993 994 raw RawSockaddrBth 995 } 996 997 func (sa *SockaddrBth) sockaddr() (unsafe.Pointer, int32, error) { 998 family := AF_BTH 999 sa.raw = RawSockaddrBth{ 1000 AddressFamily: *(*[2]byte)(unsafe.Pointer(&family)), 1001 BtAddr: *(*[8]byte)(unsafe.Pointer(&sa.BtAddr)), 1002 Port: *(*[4]byte)(unsafe.Pointer(&sa.Port)), 1003 ServiceClassId: *(*[16]byte)(unsafe.Pointer(&sa.ServiceClassId)), 1004 } 1005 return unsafe.Pointer(&sa.raw), int32(unsafe.Sizeof(sa.raw)), nil 1006 } 1007 974 1008 func (rsa *RawSockaddrAny) Sockaddr() (Sockaddr, error) { 975 1009 switch rsa.Addr.Family { … … 1082 1116 1083 1117 func WSASendto(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to Sockaddr, overlapped *Overlapped, croutine *byte) (err error) { 1084 rsa, l, err := to.sockaddr() 1085 if err != nil { 1086 return err 1118 var rsa unsafe.Pointer 1119 var l int32 1120 if to != nil { 1121 rsa, l, err = to.sockaddr() 1122 if err != nil { 1123 return err 1124 } 1087 1125 } 1088 1126 return WSASendTo(s, bufs, bufcnt, sent, flags, (*RawSockaddrAny)(unsafe.Pointer(rsa)), l, overlapped, croutine) … … 1708 1746 return 1709 1747 } 1748 1749 // PSAPI_WORKING_SET_EX_BLOCK contains extended working set information for a page. 1750 type PSAPI_WORKING_SET_EX_BLOCK uint64 1751 1752 // Valid returns the validity of this page. 1753 // If this bit is 1, the subsequent members are valid; otherwise they should be ignored. 1754 func (b PSAPI_WORKING_SET_EX_BLOCK) Valid() bool { 1755 return (b & 1) == 1 1756 } 1757 1758 // ShareCount is the number of processes that share this page. The maximum value of this member is 7. 1759 func (b PSAPI_WORKING_SET_EX_BLOCK) ShareCount() uint64 { 1760 return b.intField(1, 3) 1761 } 1762 1763 // Win32Protection is the memory protection attributes of the page. For a list of values, see 1764 // https://docs.microsoft.com/en-us/windows/win32/memory/memory-protection-constants 1765 func (b PSAPI_WORKING_SET_EX_BLOCK) Win32Protection() uint64 { 1766 return b.intField(4, 11) 1767 } 1768 1769 // Shared returns the shared status of this page. 1770 // If this bit is 1, the page can be shared. 1771 func (b PSAPI_WORKING_SET_EX_BLOCK) Shared() bool { 1772 return (b & (1 << 15)) == 1 1773 } 1774 1775 // Node is the NUMA node. The maximum value of this member is 63. 1776 func (b PSAPI_WORKING_SET_EX_BLOCK) Node() uint64 { 1777 return b.intField(16, 6) 1778 } 1779 1780 // Locked returns the locked status of this page. 1781 // If this bit is 1, the virtual page is locked in physical memory. 1782 func (b PSAPI_WORKING_SET_EX_BLOCK) Locked() bool { 1783 return (b & (1 << 22)) == 1 1784 } 1785 1786 // LargePage returns the large page status of this page. 1787 // If this bit is 1, the page is a large page. 1788 func (b PSAPI_WORKING_SET_EX_BLOCK) LargePage() bool { 1789 return (b & (1 << 23)) == 1 1790 } 1791 1792 // Bad returns the bad status of this page. 1793 // If this bit is 1, the page is has been reported as bad. 1794 func (b PSAPI_WORKING_SET_EX_BLOCK) Bad() bool { 1795 return (b & (1 << 31)) == 1 1796 } 1797 1798 // intField extracts an integer field in the PSAPI_WORKING_SET_EX_BLOCK union. 1799 func (b PSAPI_WORKING_SET_EX_BLOCK) intField(start, length int) uint64 { 1800 var mask PSAPI_WORKING_SET_EX_BLOCK 1801 for pos := start; pos < start+length; pos++ { 1802 mask |= (1 << pos) 1803 } 1804 1805 masked := b & mask 1806 return uint64(masked >> start) 1807 } 1808 1809 // PSAPI_WORKING_SET_EX_INFORMATION contains extended working set information for a process. 1810 type PSAPI_WORKING_SET_EX_INFORMATION struct { 1811 // The virtual address. 1812 VirtualAddress Pointer 1813 // A PSAPI_WORKING_SET_EX_BLOCK union that indicates the attributes of the page at VirtualAddress. 1814 VirtualAttributes PSAPI_WORKING_SET_EX_BLOCK 1815 } -
trunk/vendor/golang.org/x/sys/windows/types_windows.go
r67 r69 3214 3214 3215 3215 const ALL_PROCESSOR_GROUPS = 0xFFFF 3216 3217 type Rect struct { 3218 Left int32 3219 Top int32 3220 Right int32 3221 Bottom int32 3222 } 3223 3224 type GUIThreadInfo struct { 3225 Size uint32 3226 Flags uint32 3227 Active HWND 3228 Focus HWND 3229 Capture HWND 3230 MenuOwner HWND 3231 MoveSize HWND 3232 CaretHandle HWND 3233 CaretRect Rect 3234 } 3235 3236 const ( 3237 DWMWA_NCRENDERING_ENABLED = 1 3238 DWMWA_NCRENDERING_POLICY = 2 3239 DWMWA_TRANSITIONS_FORCEDISABLED = 3 3240 DWMWA_ALLOW_NCPAINT = 4 3241 DWMWA_CAPTION_BUTTON_BOUNDS = 5 3242 DWMWA_NONCLIENT_RTL_LAYOUT = 6 3243 DWMWA_FORCE_ICONIC_REPRESENTATION = 7 3244 DWMWA_FLIP3D_POLICY = 8 3245 DWMWA_EXTENDED_FRAME_BOUNDS = 9 3246 DWMWA_HAS_ICONIC_BITMAP = 10 3247 DWMWA_DISALLOW_PEEK = 11 3248 DWMWA_EXCLUDED_FROM_PEEK = 12 3249 DWMWA_CLOAK = 13 3250 DWMWA_CLOAKED = 14 3251 DWMWA_FREEZE_REPRESENTATION = 15 3252 DWMWA_PASSIVE_UPDATE_MODE = 16 3253 DWMWA_USE_HOSTBACKDROPBRUSH = 17 3254 DWMWA_USE_IMMERSIVE_DARK_MODE = 20 3255 DWMWA_WINDOW_CORNER_PREFERENCE = 33 3256 DWMWA_BORDER_COLOR = 34 3257 DWMWA_CAPTION_COLOR = 35 3258 DWMWA_TEXT_COLOR = 36 3259 DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37 3260 ) -
trunk/vendor/golang.org/x/sys/windows/zsyscall_windows.go
r67 r69 41 41 modcrypt32 = NewLazySystemDLL("crypt32.dll") 42 42 moddnsapi = NewLazySystemDLL("dnsapi.dll") 43 moddwmapi = NewLazySystemDLL("dwmapi.dll") 43 44 modiphlpapi = NewLazySystemDLL("iphlpapi.dll") 44 45 modkernel32 = NewLazySystemDLL("kernel32.dll") … … 176 177 procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W") 177 178 procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree") 179 procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute") 180 procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute") 178 181 procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses") 179 182 procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo") … … 409 412 procGetModuleFileNameExW = modpsapi.NewProc("GetModuleFileNameExW") 410 413 procGetModuleInformation = modpsapi.NewProc("GetModuleInformation") 414 procQueryWorkingSetEx = modpsapi.NewProc("QueryWorkingSetEx") 411 415 procSubscribeServiceChangeNotifications = modsechost.NewProc("SubscribeServiceChangeNotifications") 412 416 procUnsubscribeServiceChangeNotifications = modsechost.NewProc("UnsubscribeServiceChangeNotifications") … … 444 448 procSHGetKnownFolderPath = modshell32.NewProc("SHGetKnownFolderPath") 445 449 procShellExecuteW = modshell32.NewProc("ShellExecuteW") 450 procEnumChildWindows = moduser32.NewProc("EnumChildWindows") 451 procEnumWindows = moduser32.NewProc("EnumWindows") 446 452 procExitWindowsEx = moduser32.NewProc("ExitWindowsEx") 453 procGetClassNameW = moduser32.NewProc("GetClassNameW") 454 procGetDesktopWindow = moduser32.NewProc("GetDesktopWindow") 455 procGetForegroundWindow = moduser32.NewProc("GetForegroundWindow") 456 procGetGUIThreadInfo = moduser32.NewProc("GetGUIThreadInfo") 447 457 procGetShellWindow = moduser32.NewProc("GetShellWindow") 448 458 procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId") 459 procIsWindow = moduser32.NewProc("IsWindow") 460 procIsWindowUnicode = moduser32.NewProc("IsWindowUnicode") 461 procIsWindowVisible = moduser32.NewProc("IsWindowVisible") 449 462 procMessageBoxW = moduser32.NewProc("MessageBoxW") 450 463 procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock") … … 1525 1538 } 1526 1539 1540 func DwmGetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) { 1541 r0, _, _ := syscall.Syscall6(procDwmGetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(value), uintptr(size), 0, 0) 1542 if r0 != 0 { 1543 ret = syscall.Errno(r0) 1544 } 1545 return 1546 } 1547 1548 func DwmSetWindowAttribute(hwnd HWND, attribute uint32, value unsafe.Pointer, size uint32) (ret error) { 1549 r0, _, _ := syscall.Syscall6(procDwmSetWindowAttribute.Addr(), 4, uintptr(hwnd), uintptr(attribute), uintptr(value), uintptr(size), 0, 0) 1550 if r0 != 0 { 1551 ret = syscall.Errno(r0) 1552 } 1553 return 1554 } 1555 1527 1556 func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) { 1528 1557 r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0) … … 3505 3534 } 3506 3535 3536 func QueryWorkingSetEx(process Handle, pv uintptr, cb uint32) (err error) { 3537 r1, _, e1 := syscall.Syscall(procQueryWorkingSetEx.Addr(), 3, uintptr(process), uintptr(pv), uintptr(cb)) 3538 if r1 == 0 { 3539 err = errnoErr(e1) 3540 } 3541 return 3542 } 3543 3507 3544 func SubscribeServiceChangeNotifications(service Handle, eventType uint32, callback uintptr, callbackCtx uintptr, subscription *uintptr) (ret error) { 3508 3545 ret = procSubscribeServiceChangeNotifications.Find() … … 3794 3831 } 3795 3832 3833 func EnumChildWindows(hwnd HWND, enumFunc uintptr, param unsafe.Pointer) { 3834 syscall.Syscall(procEnumChildWindows.Addr(), 3, uintptr(hwnd), uintptr(enumFunc), uintptr(param)) 3835 return 3836 } 3837 3838 func EnumWindows(enumFunc uintptr, param unsafe.Pointer) (err error) { 3839 r1, _, e1 := syscall.Syscall(procEnumWindows.Addr(), 2, uintptr(enumFunc), uintptr(param), 0) 3840 if r1 == 0 { 3841 err = errnoErr(e1) 3842 } 3843 return 3844 } 3845 3796 3846 func ExitWindowsEx(flags uint32, reason uint32) (err error) { 3797 3847 r1, _, e1 := syscall.Syscall(procExitWindowsEx.Addr(), 2, uintptr(flags), uintptr(reason), 0) 3848 if r1 == 0 { 3849 err = errnoErr(e1) 3850 } 3851 return 3852 } 3853 3854 func GetClassName(hwnd HWND, className *uint16, maxCount int32) (copied int32, err error) { 3855 r0, _, e1 := syscall.Syscall(procGetClassNameW.Addr(), 3, uintptr(hwnd), uintptr(unsafe.Pointer(className)), uintptr(maxCount)) 3856 copied = int32(r0) 3857 if copied == 0 { 3858 err = errnoErr(e1) 3859 } 3860 return 3861 } 3862 3863 func GetDesktopWindow() (hwnd HWND) { 3864 r0, _, _ := syscall.Syscall(procGetDesktopWindow.Addr(), 0, 0, 0, 0) 3865 hwnd = HWND(r0) 3866 return 3867 } 3868 3869 func GetForegroundWindow() (hwnd HWND) { 3870 r0, _, _ := syscall.Syscall(procGetForegroundWindow.Addr(), 0, 0, 0, 0) 3871 hwnd = HWND(r0) 3872 return 3873 } 3874 3875 func GetGUIThreadInfo(thread uint32, info *GUIThreadInfo) (err error) { 3876 r1, _, e1 := syscall.Syscall(procGetGUIThreadInfo.Addr(), 2, uintptr(thread), uintptr(unsafe.Pointer(info)), 0) 3798 3877 if r1 == 0 { 3799 3878 err = errnoErr(e1) … … 3814 3893 err = errnoErr(e1) 3815 3894 } 3895 return 3896 } 3897 3898 func IsWindow(hwnd HWND) (isWindow bool) { 3899 r0, _, _ := syscall.Syscall(procIsWindow.Addr(), 1, uintptr(hwnd), 0, 0) 3900 isWindow = r0 != 0 3901 return 3902 } 3903 3904 func IsWindowUnicode(hwnd HWND) (isUnicode bool) { 3905 r0, _, _ := syscall.Syscall(procIsWindowUnicode.Addr(), 1, uintptr(hwnd), 0, 0) 3906 isUnicode = r0 != 0 3907 return 3908 } 3909 3910 func IsWindowVisible(hwnd HWND) (isVisible bool) { 3911 r0, _, _ := syscall.Syscall(procIsWindowVisible.Addr(), 1, uintptr(hwnd), 0, 0) 3912 isVisible = r0 != 0 3816 3913 return 3817 3914 }
Note:
See TracChangeset
for help on using the changeset viewer.