Skip to content

Instantly share code, notes, and snippets.

@justenwalker
Last active January 10, 2019 03:57
Show Gist options
  • Save justenwalker/9c925c662690d25c0782d67bfe510939 to your computer and use it in GitHub Desktop.
Save justenwalker/9c925c662690d25c0782d67bfe510939 to your computer and use it in GitHub Desktop.
Iterate through each array entry using unsafe.Pointer arithmetic
rows := make([]_MIB_TCPROW_OWNER_PID,int(pTable.dwNumEntries))
for i := 0; i < int(pTable.dwNumEntries); i++ {
rows[i] = *(*_MIB_TCPROW_OWNER_PID)(unsafe.Pointer(
uintptr(unsafe.Pointer(&pTable.table[0])) +
uintptr(i) * unsafe.Sizeof(pTable.table[0])
))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment