Question

The docs for MIB_IPNETTABLE say:

The MIB_IPNETTABLE structure may contain padding for alignment between the dwNumEntries member and the first MIB_IPNETROW array entry in the table member. Padding for alignment may also be present between the MIB_IPNETROW array entries in the table member. Any access to a MIB_IPNETROW array entry should assume padding may exist.

Will

Marshal.SizeOf(typeof(MIB_IPNETROW))

Take care of that? If not - how do I know how much padding exists in order to account for it. If yes - will it work on x64 without a problem (See 64 Bit P/Invoke Idiosyncrasy )?

Was it helpful?

Solution

The alignment of both MIB_IPNETROW and MIB_IPNETTABLE on x86 and x64 is 4. That can be deduced by looking at the alignment of the struct members. And as for the array, there will be no padding between elements because there never is padding between array elements.

Hence there will be no padding at all on those platforms, and indeed the layout is the same on both platforms.

I cannot explain why the documentation talks of padding. Perhaps on Alpha or Itanium there would be padding, but not on x86 and x64. Or perhaps the documentation is just wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top