Skip to content

Instantly share code, notes, and snippets.

@hut8
Created June 21, 2016 02:36
Show Gist options
  • Save hut8/d4105b241694ea707f52e2bbb7f87362 to your computer and use it in GitHub Desktop.
Save hut8/d4105b241694ea707f52e2bbb7f87362 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"syscall"
"unsafe"
)
type (
DWORD uint32
)
type TCP_CONNECTION_OFFLOAD_STATE int
const (
TcpConnectionOffloadStateInHost TCP_CONNECTION_OFFLOAD_STATE = 0
TcpConnectionOffloadStateOffloading TCP_CONNECTION_OFFLOAD_STATE = 1
TcpConnectionOffloadStateOffloaded TCP_CONNECTION_OFFLOAD_STATE = 2
TcpConnectionOffloadStateUploading TCP_CONNECTION_OFFLOAD_STATE = 3
TcpConnectionOffloadStateMax TCP_CONNECTION_OFFLOAD_STATE = 4
)
type MIB_TCPROW2 struct {
dwState DWORD
dwLocalAddr DWORD
dwLocalPort DWORD
dwRemoteAddr DWORD
dwRemotePort DWORD
dwOwningPid DWORD
dwOffloadState TCP_CONNECTION_OFFLOAD_STATE
}
type MIB_TCPTABLE2 struct {
dwNumEntries DWORD
table []MIB_TCPROW2
}
func main() {
call := syscall.NewLazyDLL("Iphlpapi.dll")
var table MIB_TCPTABLE2 = MIB_TCPTABLE2{}
getTcpTable2 := call.NewProc("GetTcpTable2")
bbb := true
getTcpTable2.Call(uintptr(unsafe.Pointer(&table)), unsafe.Sizeof(table), uintptr(unsafe.Pointer(&bbb)))
fmt.Println(table)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment