Created
June 21, 2016 02:36
-
-
Save hut8/d4105b241694ea707f52e2bbb7f87362 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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