1// +build windows 2 3/* 4** Zabbix 5** Copyright (C) 2001-2021 Zabbix SIA 6** 7** This program is free software; you can redistribute it and/or modify 8** it under the terms of the GNU General Public License as published by 9** the Free Software Foundation; either version 2 of the License, or 10** (at your option) any later version. 11** 12** This program is distributed in the hope that it will be useful, 13** but WITHOUT ANY WARRANTY; without even the implied warranty of 14** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15** GNU General Public License for more details. 16** 17** You should have received a copy of the GNU General Public License 18** along with this program; if not, write to the Free Software 19** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20**/ 21 22package win32 23 24import ( 25 "syscall" 26 "unsafe" 27 28 "golang.org/x/sys/windows" 29) 30 31type Hlib syscall.Handle 32 33const ( 34 ANY_SIZE = 1 35 36 IF_MAX_STRING_SIZE = 256 37 IF_MAX_PHYS_ADDRESS_LENGTH = 32 38) 39 40const ( 41 MIB_TCP_STATE_CLOSED uint32 = 1 42 MIB_TCP_STATE_LISTEN uint32 = 2 43 MIB_TCP_STATE_SYN_SENT uint32 = 3 44 MIB_TCP_STATE_SYN_RCVD uint32 = 4 45 MIB_TCP_STATE_ESTAB uint32 = 5 46 MIB_TCP_STATE_FIN_WAIT1 uint32 = 6 47 MIB_TCP_STATE_FIN_WAIT2 uint32 = 7 48 MIB_TCP_STATE_CLOSE_WAIT uint32 = 8 49 MIB_TCP_STATE_CLOSING uint32 = 9 50 MIB_TCP_STATE_LAST_ACK uint32 = 10 51 MIB_TCP_STATE_TIME_WAIT uint32 = 11 52 MIB_TCP_STATE_DELETE_TCB uint32 = 12 53) 54 55type RGWSTR [ARRAY_MAX / unsafe.Sizeof(uint16(0))]uint16 56 57type GUID struct { 58 Data1 uint32 59 Data2 uint16 60 Data3 uint16 61 Data4 [8]byte 62} 63 64type MIB_IF_ROW2 struct { 65 InterfaceLuid uint64 66 InterfaceIndex uint32 67 InterfaceGuid GUID 68 Alias [IF_MAX_STRING_SIZE + 1]uint16 69 Description [IF_MAX_STRING_SIZE + 1]uint16 70 PhysicalAddressLength uint32 71 PhysicalAddress [IF_MAX_PHYS_ADDRESS_LENGTH]byte 72 PermanentPhysicalAddress [IF_MAX_PHYS_ADDRESS_LENGTH]byte 73 Mtu uint32 74 Type uint32 75 TunnelType int32 76 MediaType int32 77 PhysicalMediumType int32 78 AccessType int32 79 DirectionType int32 80 InterfaceAndOperStatusFlags byte 81 OperStatus int32 82 AdminStatus int32 83 MediaConnectState int32 84 NetworkGuid GUID 85 ConnectionType int32 86 _ [4]byte 87 TransmitLinkSpeed uint64 88 ReceiveLinkSpeed uint64 89 InOctets uint64 90 InUcastPkts uint64 91 InNUcastPkts uint64 92 InDiscards uint64 93 InErrors uint64 94 InUnknownProtos uint64 95 InUcastOctets uint64 96 InMulticastOctets uint64 97 InBroadcastOctets uint64 98 OutOctets uint64 99 OutUcastPkts uint64 100 OutNUcastPkts uint64 101 OutDiscards uint64 102 OutErrors uint64 103 OutUcastOctets uint64 104 OutMulticastOctets uint64 105 OutBroadcastOctets uint64 106 OutQLen uint64 107} 108 109type RGMIB_IF_ROW2 [ARRAY_MAX / unsafe.Sizeof(MIB_IF_ROW2{})]MIB_IF_ROW2 110 111type MIB_IF_TABLE2 struct { 112 NumEntries uint32 113 _ [4]byte 114 Table [ANY_SIZE]MIB_IF_ROW2 115} 116 117type MIB_IPADDRROW struct { 118 Addr uint32 119 Index uint32 120 Mask uint32 121 BCastAddr uint32 122 ReasmSize uint32 123 _ uint16 124 _ uint16 125} 126 127type RGMIB_IPADDRROW [ARRAY_MAX / unsafe.Sizeof(MIB_IPADDRROW{})]MIB_IPADDRROW 128 129type MIB_IPADDRTABLE struct { 130 NumEntries uint32 131 Table [ANY_SIZE]MIB_IPADDRROW 132} 133 134type MIB_TCPROW struct { 135 State uint32 136 LocalAddr uint32 137 LocalPort uint32 138 RemoteAddr uint32 139 RemotePort uint32 140} 141 142type RGMIB_TCPROW [ARRAY_MAX / unsafe.Sizeof(MIB_TCPROW{})]MIB_TCPROW 143 144type MIB_TCPTABLE struct { 145 NumEntries uint32 146 Table [ANY_SIZE]MIB_TCPROW 147} 148 149type ( 150 PDH_HQUERY windows.Handle 151 PDH_HCOUNTER windows.Handle 152) 153 154type PDH_COUNTER_PATH_ELEMENTS struct { 155 MachineName uintptr 156 ObjectName uintptr 157 InstanceName uintptr 158 ParentInstance uintptr 159 InstanceIndex uint32 160 CounterName uintptr 161} 162type LP_PDH_COUNTER_PATH_ELEMENTS *PDH_COUNTER_PATH_ELEMENTS 163 164type PDH_FMT_COUNTERVALUE_DOUBLE struct { 165 Status uint32 166 _ uint32 167 Value float64 168} 169 170type PDH_FMT_COUNTERVALUE_LARGE struct { 171 Status uint32 172 _ uint32 173 Value int64 174} 175 176type SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX struct { 177 Relationship uint32 178 Size uint32 179 Data [1]byte 180} 181 182type GROUP_AFFINITY struct { 183 Mask uintptr 184 Group uint16 185 Reserved [3]uint16 186} 187 188type RGGROUP_AFFINITY [ARRAY_MAX / unsafe.Sizeof(GROUP_AFFINITY{})]GROUP_AFFINITY 189 190type NUMA_NODE_RELATIONSHIP struct { 191 NodeNumber uint32 192 Reserved [20]uint8 193 GroupMask GROUP_AFFINITY 194} 195 196type PROCESSOR_RELATIONSHIP struct { 197 Flags uint8 198 EfficiencyClass uint8 199 Reserved [20]uint8 200 GroupCount uint16 201 GroupMask [1]GROUP_AFFINITY 202} 203 204type MEMORYSTATUSEX struct { 205 Length uint32 206 MemoryLoad uint32 207 TotalPhys uint64 208 AvailPhys uint64 209 TotalPageFile uint64 210 AvailPageFile uint64 211 TotalVirtual uint64 212 AvailVirtual uint64 213 AvailExtendedVirtual uint64 214} 215 216const ( 217 GR_GDIOBJECTS = 0 218 GR_GDIOBJECTS_PEAK = 2 219 GR_USEROBJECTS = 1 220 GR_USEROBJECTS_PEAK = 4 221) 222 223type IO_COUNTERS struct { 224 ReadOperationCount uint64 225 WriteOperationCount uint64 226 OtherOperationCount uint64 227 ReadTransferCount uint64 228 WriteTransferCount uint64 229 OtherTransferCount uint64 230} 231