winsys

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Rendered for windows/amd64

Index

Constants

View Source
const (
	AF_INET  = 2
	AF_INET6 = 23
)
View Source
const (
	MAX_MODULE_NAME32 = 255
	MAX_PATH          = 260
)
View Source
const (
	TH32CS_SNAPHEAPLIST = 0x00000001
	TH32CS_SNAPPROCESS  = 0x00000002
	TH32CS_SNAPTHREAD   = 0x00000004
	TH32CS_SNAPMODULE   = 0x00000008
	TH32CS_SNAPMODULE32 = 0x00000010
	TH32CS_INHERIT      = 0x80000000
	TH32CS_SNAPALL      = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD
)

https://docs.microsoft.com/en-us/windows/desktop/api/tlhelp32/nf-tlhelp32-createtoolhelp32snapshot

View Source
const (
	MAX_ADAPTER_NAME       = 128
	MAX_INTERFACE_NAME_LEN = 256
	MAXLEN_PHYSADDR        = 8
	MAXLEN_IFDESCR         = 256
)
View Source
const (
	RPC_C_AUTHN_DEFAULT       uint32 = 0xFFFFFFFF
	FWPM_SESSION_FLAG_DYNAMIC uint32 = 0x00000001
)
View Source
const (
	FWP_MATCH_EQUAL                  uint32 = 0
	FWP_MATCH_GREATER                       = (FWP_MATCH_EQUAL + 1)
	FWP_MATCH_LESS                          = (FWP_MATCH_GREATER + 1)
	FWP_MATCH_GREATER_OR_EQUAL              = (FWP_MATCH_LESS + 1)
	FWP_MATCH_LESS_OR_EQUAL                 = (FWP_MATCH_GREATER_OR_EQUAL + 1)
	FWP_MATCH_RANGE                         = (FWP_MATCH_LESS_OR_EQUAL + 1)
	FWP_MATCH_FLAGS_ALL_SET                 = (FWP_MATCH_RANGE + 1)
	FWP_MATCH_FLAGS_ANY_SET                 = (FWP_MATCH_FLAGS_ALL_SET + 1)
	FWP_MATCH_FLAGS_NONE_SET                = (FWP_MATCH_FLAGS_ANY_SET + 1)
	FWP_MATCH_EQUAL_CASE_INSENSITIVE        = (FWP_MATCH_FLAGS_NONE_SET + 1)
	FWP_MATCH_NOT_EQUAL                     = (FWP_MATCH_EQUAL_CASE_INSENSITIVE + 1)
	FWP_MATCH_PREFIX                        = (FWP_MATCH_NOT_EQUAL + 1)
	FWP_MATCH_NOT_PREFIX                    = (FWP_MATCH_PREFIX + 1)
	FWP_MATCH_TYPE_MAX                      = (FWP_MATCH_NOT_PREFIX + 1)
)
View Source
const (
	FWP_EMPTY                         uint32 = 0
	FWP_UINT8                                = (FWP_EMPTY + 1)
	FWP_UINT16                               = (FWP_UINT8 + 1)
	FWP_UINT32                               = (FWP_UINT16 + 1)
	FWP_UINT64                               = (FWP_UINT32 + 1)
	FWP_INT8                                 = (FWP_UINT64 + 1)
	FWP_INT16                                = (FWP_INT8 + 1)
	FWP_INT32                                = (FWP_INT16 + 1)
	FWP_INT64                                = (FWP_INT32 + 1)
	FWP_FLOAT                                = (FWP_INT64 + 1)
	FWP_DOUBLE                               = (FWP_FLOAT + 1)
	FWP_BYTE_ARRAY16_TYPE                    = (FWP_DOUBLE + 1)
	FWP_BYTE_BLOB_TYPE                       = (FWP_BYTE_ARRAY16_TYPE + 1)
	FWP_SID                                  = (FWP_BYTE_BLOB_TYPE + 1)
	FWP_SECURITY_DESCRIPTOR_TYPE             = (FWP_SID + 1)
	FWP_TOKEN_INFORMATION_TYPE               = (FWP_SECURITY_DESCRIPTOR_TYPE + 1)
	FWP_TOKEN_ACCESS_INFORMATION_TYPE        = (FWP_TOKEN_INFORMATION_TYPE + 1)
	FWP_UNICODE_STRING_TYPE                  = (FWP_TOKEN_ACCESS_INFORMATION_TYPE + 1)
	FWP_BYTE_ARRAY6_TYPE                     = (FWP_UNICODE_STRING_TYPE + 1)
	FWP_BITMAP_INDEX_TYPE                    = (FWP_BYTE_ARRAY6_TYPE + 1)
	FWP_BITMAP_ARRAY64_TYPE                  = (FWP_BITMAP_INDEX_TYPE + 1)
	FWP_SINGLE_DATA_TYPE_MAX                 = 0xff
	FWP_V4_ADDR_MASK                         = (FWP_SINGLE_DATA_TYPE_MAX + 1)
	FWP_V6_ADDR_MASK                         = (FWP_V4_ADDR_MASK + 1)
	FWP_RANGE_TYPE                           = (FWP_V6_ADDR_MASK + 1)
	FWP_DATA_TYPE_MAX                        = (FWP_RANGE_TYPE + 1)
)
View Source
const (
	FWP_ACTION_FLAG_TERMINATING uint32 = 0x00001000
	FWP_ACTION_BLOCK            uint32 = (0x00000001 | FWP_ACTION_FLAG_TERMINATING)
	FWP_ACTION_PERMIT           uint32 = (0x00000002 | FWP_ACTION_FLAG_TERMINATING)
)
View Source
const (
	FWPM_FILTER_FLAG_NONE                                = 0x00000000
	FWPM_FILTER_FLAG_PERSISTENT                          = 0x00000001
	FWPM_FILTER_FLAG_BOOTTIME                            = 0x00000002
	FWPM_FILTER_FLAG_HAS_PROVIDER_CONTEXT                = 0x00000004
	FWPM_FILTER_FLAG_CLEAR_ACTION_RIGHT                  = 0x00000008
	FWPM_FILTER_FLAG_PERMIT_IF_CALLOUT_UNREGISTERED      = 0x00000010
	FWPM_FILTER_FLAG_DISABLED                            = 0x00000020
	FWPM_FILTER_FLAG_INDEXED                             = 0x00000040
	FWPM_FILTER_FLAG_HAS_SECURITY_REALM_PROVIDER_CONTEXT = 0x00000080
	FWPM_FILTER_FLAG_SYSTEMOS_ONLY                       = 0x00000100
	FWPM_FILTER_FLAG_GAMEOS_ONLY                         = 0x00000200
	FWPM_FILTER_FLAG_SILENT_MODE                         = 0x00000400
	FWPM_FILTER_FLAG_IPSEC_NO_ACQUIRE_INITIATE           = 0x00000800
)
View Source
const (
	ERROR_INSUFFICIENT_BUFFER = 122
)
View Source
const (
	IPPROTO_UDP uint32 = 17
)
View Source
const InvalidHandle = ^Handle(0)

Variables

View Source
var FWPM_CONDITION_ALE_APP_ID = windows.GUID{
	Data1: 0xd78e1e87,
	Data2: 0x8644,
	Data3: 0x4ea5,
	Data4: [8]byte{0x94, 0x37, 0xd8, 0x09, 0xec, 0xef, 0xc9, 0x71},
}
View Source
var FWPM_CONDITION_IP_PROTOCOL = windows.GUID{
	Data1: 0x3971ef2b,
	Data2: 0x623e,
	Data3: 0x4f9a,
	Data4: [8]byte{0x8c, 0xb1, 0x6e, 0x79, 0xb8, 0x06, 0xb9, 0xa7},
}
View Source
var FWPM_CONDITION_IP_REMOTE_PORT = windows.GUID{
	Data1: 0xc35a604d,
	Data2: 0xd22b,
	Data3: 0x4e1a,
	Data4: [8]byte{0x91, 0xb4, 0x68, 0xf6, 0x74, 0xee, 0x67, 0x4b},
}
View Source
var FWPM_CONDITION_LOCAL_INTERFACE_INDEX = windows.GUID{
	Data1: 0x667fd755,
	Data2: 0xd695,
	Data3: 0x434a,
	Data4: [8]byte{0x8a, 0xf5, 0xd3, 0x83, 0x5a, 0x12, 0x59, 0xbc},
}
View Source
var FWPM_LAYER_ALE_AUTH_CONNECT_V4 = windows.GUID{
	Data1: 0xc38d57d1,
	Data2: 0x05a7,
	Data3: 0x4c33,
	Data4: [8]byte{0x90, 0x4f, 0x7f, 0xbc, 0xee, 0xe6, 0x0e, 0x82},
}
View Source
var FWPM_LAYER_ALE_AUTH_CONNECT_V6 = windows.GUID{
	Data1: 0x4a72393b,
	Data2: 0x319f,
	Data3: 0x44bc,
	Data4: [8]byte{0x84, 0xc3, 0xba, 0x54, 0xdc, 0xb3, 0xb6, 0xb4},
}

Functions

func CreateIpForwardEntry

func CreateIpForwardEntry(route *MIB_IPFORWARDROW) uint32

func DeleteIpForwardEntry

func DeleteIpForwardEntry(route *MIB_IPFORWARDROW) uint32

func FwpmEngineOpen0

func FwpmEngineOpen0(serverName *uint16, authnService uint32, authIdentity *uintptr, session *FWPM_SESSION0, engineHandle unsafe.Pointer) (err error)

func FwpmFilterAdd0

func FwpmFilterAdd0(engineHandle uintptr, filter *FWPM_FILTER0, sd uintptr, id *uint64) (err error)

func FwpmFreeMemory0

func FwpmFreeMemory0(p unsafe.Pointer)

func FwpmGetAppIdFromFileName0

func FwpmGetAppIdFromFileName0(fileName *uint16, appID unsafe.Pointer) (err error)

func FwpmSubLayerAdd0

func FwpmSubLayerAdd0(engineHandle uintptr, subLayer *FWPM_SUBLAYER0, sd uintptr) (err error)

func GetBestRoute

func GetBestRoute(destAddr, sourceAddr uint32, bestRoute *MIB_IPFORWARDROW) int

func GetExtendedTcpTable

func GetExtendedTcpTable(tcpTable uintptr, size *uint32, order int32, af uint32, tableClass TCP_TABLE_CLASS) int

func GetExtendedUdpTable

func GetExtendedUdpTable(udpTable uintptr, size *uint32, order int32, af uint32, tableClass UDP_TABLE_CLASS) int

func GetIfTable

func GetIfTable(table *MIB_IFTABLE, size *uint32, order int32) int

func GetInterfaceInfo

func GetInterfaceInfo(ifTable *IP_INTERFACE_INFO, outBufLen *uint32) int

func GetIpForwardTable

func GetIpForwardTable(table *MIB_IPFORWARDTABLE, size *uint32, order int32) int

func GetTcpStatistics

func GetTcpStatistics(statistics *MIB_TCPSTATS) int

func IPAddrATON

func IPAddrATON(addr string) uint32

FIXME IPv6

func IPAddrNTOA

func IPAddrNTOA(addr uint32) string

FIXME IPv6

func Module32First

func Module32First(snapshot Handle, moduleEntry *ModuleEntry32) (err error)

func NTOHS

func NTOHS(port uint16) uint16

func UTF16PtrToString

func UTF16PtrToString(cstr *uint16) string

Types

type BOOL

type BOOL int32

type DWORD

type DWORD uint32

type FWPM_ACTION0

type FWPM_ACTION0 struct {
	Type  uint32
	Value windows.GUID
}

type FWPM_DISPLAY_DATA0

type FWPM_DISPLAY_DATA0 struct {
	Name        *uint16
	Description *uint16
}

func CreateDisplayData

func CreateDisplayData(name, description string) (*FWPM_DISPLAY_DATA0, error)

type FWPM_FILTER0

type FWPM_FILTER0 struct {
	FilterKey           windows.GUID
	DisplayData         FWPM_DISPLAY_DATA0
	Flags               uint32
	ProviderKey         *windows.GUID
	ProviderData        FWP_BYTE_BLOB
	LayerKey            windows.GUID
	SubLayerKey         windows.GUID
	Weight              FWP_VALUE0
	NumFilterConditions uint32
	FilterCondition     *FWPM_FILTER_CONDITION0
	Action              FWPM_ACTION0
	Offset1             [4]byte
	Context             windows.GUID
	Reserved            *windows.GUID
	FilterId            uint64
	EffectiveWeight     FWP_VALUE0
}

type FWPM_FILTER_CONDITION0

type FWPM_FILTER_CONDITION0 struct {
	FieldKey       windows.GUID // Windows type: GUID
	MatchType      uint32
	ConditionValue FWP_CONDITION_VALUE0
}

type FWPM_SESSION0

type FWPM_SESSION0 struct {
	SessionKey           windows.GUID
	DisplayData          FWPM_DISPLAY_DATA0
	Flags                uint32
	TxnWaitTimeoutInMSec uint32
	ProcessId            uint32
	Sid                  *windows.SID
	Username             *uint16
	KernelMode           int32
}

type FWPM_SUBLAYER0

type FWPM_SUBLAYER0 struct {
	SubLayerKey  windows.GUID // Windows type: GUID
	DisplayData  FWPM_DISPLAY_DATA0
	Flags        uint32
	ProviderKey  *windows.GUID // Windows type: *GUID
	ProviderData FWP_BYTE_BLOB
	Weight       uint16
}

type FWP_BYTE_BLOB

type FWP_BYTE_BLOB struct {
	// contains filtered or unexported fields
}

func GetCurrentProcessAppID

func GetCurrentProcessAppID() (*FWP_BYTE_BLOB, error)

type FWP_CONDITION_VALUE0

type FWP_CONDITION_VALUE0 FWP_VALUE0

type FWP_VALUE0

type FWP_VALUE0 struct {
	Type  uint32
	Value uintptr
}

type HANDLE

type HANDLE uintptr

type HMODULE

type HMODULE HANDLE

type Handle

type Handle uintptr

type IP_ADAPTER_INDEX_MAP

type IP_ADAPTER_INDEX_MAP struct {
	Index uint32
	Name  [MAX_ADAPTER_NAME]uint16
}

type IP_INTERFACE_INFO

type IP_INTERFACE_INFO struct {
	NumAdapters int32
	Adapter     [1 << 30]IP_ADAPTER_INDEX_MAP
}

type MIB_IFROW

type MIB_IFROW struct {
	Name            [MAX_INTERFACE_NAME_LEN]uint16
	Index           uint32
	Type            uint32
	Mtu             uint32
	Speed           uint32
	PhysAddrLen     uint32
	PhysAddr        [MAXLEN_PHYSADDR]uint8
	AdminStatus     uint32
	OperStatus      uint32
	LastChange      uint32
	InOctets        uint32
	InUcastPkts     uint32
	InNUcastPkts    uint32
	InDiscards      uint32
	InErrors        uint32
	InUnknownProtos uint32
	OutOctets       uint32
	OutUcastPkts    uint32
	OutNUcastPkts   uint32
	OutDiscards     uint32
	OutErrors       uint32
	OutQLen         uint32
	DescrLen        uint32
	Descr           [MAXLEN_IFDESCR]uint8
}

type MIB_IFTABLE

type MIB_IFTABLE struct {
	NumEntries uint32
	Table      [1 << 30]MIB_IFROW
}

type MIB_IPFORWARDROW

type MIB_IPFORWARDROW struct {
	ForwardDest      uint32
	ForwardMask      uint32
	ForwardPolicy    uint32
	ForwardNextHop   uint32
	ForwardIfIndex   uint32
	ForwardType      uint32
	ForwardProto     uint32
	ForwardAge       uint32
	ForwardNextHopAS uint32
	ForwardMetric1   uint32
	ForwardMetric2   uint32
	ForwardMetric3   uint32
	ForwardMetric4   uint32
	ForwardMetric5   uint32
}

type MIB_IPFORWARDTABLE

type MIB_IPFORWARDTABLE struct {
	NumEntries DWORD
	Table      [1 << 30]MIB_IPFORWARDROW
}

type MIB_TCPROW_OWNER_PID

type MIB_TCPROW_OWNER_PID struct {
	State      DWORD
	LocalAddr  DWORD
	LocalPort  DWORD
	RemoteAddr DWORD
	RemotePort DWORD
	OwningPid  DWORD
}

type MIB_TCPSTATS

type MIB_TCPSTATS struct {
	RtoAlgorithm DWORD
	RtoMin       DWORD
	RtoMax       DWORD
	MaxConn      DWORD
	ActiveOpens  DWORD
	PassiveOpens DWORD
	AttemptFails DWORD
	EstabResets  DWORD
	CurrEstab    DWORD
	InSegs       DWORD
	OutSegs      DWORD
	RetransSegs  DWORD
	InErrs       DWORD
	OutRsts      DWORD
	NumConns     DWORD
}

type MIB_TCPTABLE_OWNER_PID

type MIB_TCPTABLE_OWNER_PID struct {
	NumEntries DWORD
	Table      [1 << 30]MIB_TCPROW_OWNER_PID
}

type MIB_UDP6ROW_OWNER_PID

type MIB_UDP6ROW_OWNER_PID struct {
	LocalAddr    [16]uint8
	LocalScopeId DWORD
	LocalPort    DWORD
	OwningPid    DWORD
}

type MIB_UDP6TABLE_OWNER_PID

type MIB_UDP6TABLE_OWNER_PID struct {
	NumEntries DWORD
	Table      [1 << 30]MIB_UDP6ROW_OWNER_PID
}

type MIB_UDPROW_OWNER_PID

type MIB_UDPROW_OWNER_PID struct {
	LocalAddr DWORD
	LocalPort DWORD
	OwningPid DWORD
}

type MIB_UDPTABLE_OWNER_PID

type MIB_UDPTABLE_OWNER_PID struct {
	NumEntries DWORD
	Table      [1 << 30]MIB_UDPROW_OWNER_PID
}

type ModuleEntry32

type ModuleEntry32 struct {
	Size         uint32
	ModuleID     uint32
	ProcessID    uint32
	GlblcntUsage uint32
	ProccntUsage uint32
	ModBaseAddr  *uint8
	ModBaseSize  uint32
	HModule      HMODULE
	Module       [MAX_MODULE_NAME32 + 1]uint16
	ExePath      [MAX_PATH]uint16
}

type PDWORD

type PDWORD uintptr

type TCP_TABLE_CLASS

type TCP_TABLE_CLASS DWORD
const (
	TCP_TABLE_BASIC_LISTENER TCP_TABLE_CLASS = iota
	TCP_TABLE_BASIC_CONNECTIONS
	TCP_TABLE_BASIC_ALL
	TCP_TABLE_OWNER_PID_LISTENER
	TCP_TABLE_OWNER_PID_CONNECTIONS
	TCP_TABLE_OWNER_PID_ALL
	TCP_TABLE_OWNER_MODULE_LISTENER
	TCP_TABLE_OWNER_MODULE_CONNECTIONS
	TCP_TABLE_OWNER_MODULE_ALL
)

type UDP_TABLE_CLASS

type UDP_TABLE_CLASS DWORD
const (
	UDP_TABLE_BASIC UDP_TABLE_CLASS = iota
	UDP_TABLE_OWNER_PID
	UDP_TABLE_OWNER_MODULE
)

type ULONG

type ULONG uint32

type ULONG_PTR

type ULONG_PTR uintptr

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL