mirror of https://github.com/dahall/Vanara.git
Fixed #296 - invalid `MIB_UDP6ROW_OWNER_PID.dwOwningPid` value when calling `GetExtendedUdpTable`
parent
0edde0e5a2
commit
fb607a799e
|
@ -210,7 +210,7 @@ namespace Vanara.PInvoke
|
|||
// _MIB_UDP6ROW_OWNER_PID { UCHAR ucLocalAddr[16]; DWORD dwLocalScopeId; DWORD dwLocalPort; DWORD dwOwningPid; }
|
||||
// MIB_UDP6ROW_OWNER_PID, *PMIB_UDP6ROW_OWNER_PID;
|
||||
[PInvokeData("udpmib.h", MSDNShortId = "d3d02485-381b-4058-b4b9-0a2c9c365f43")]
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
[StructLayout(LayoutKind.Sequential, Size = 28, Pack = 4)]
|
||||
public struct MIB_UDP6ROW_OWNER_PID
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -697,14 +697,10 @@ namespace Vanara.PInvoke
|
|||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>The number of MIB_UDP6ROW_OWNER_PID elements in <c>table</c>.</para>
|
||||
/// </summary>
|
||||
/// <summary>The number of MIB_UDP6ROW_OWNER_PID elements in <c>table</c>.</summary>
|
||||
public uint dwNumEntries => Count;
|
||||
|
||||
/// <summary>
|
||||
/// <para>An array of MIB_UDP6ROW_OWNER_PID structures returned by a call to GetExtendedUdpTable.</para>
|
||||
/// </summary>
|
||||
/// <summary>An array of MIB_UDP6ROW_OWNER_PID structures returned by a call to GetExtendedUdpTable.</summary>
|
||||
public MIB_UDP6ROW_OWNER_PID[] table { get => Elements; set => Elements = value; }
|
||||
|
||||
/// <summary>Performs an implicit conversion from <see cref="MIB_UDP6TABLE_OWNER_PID"/> to <see cref="IntPtr"/>.</summary>
|
||||
|
|
|
@ -16,8 +16,8 @@ namespace Vanara.InteropServices
|
|||
/// <typeparam name="TMem">The memory methods to use for allocation.</typeparam>
|
||||
public class SafeElementArray<TElem, TPrefix, TMem> : SafeMemoryHandle<TMem>, IEnumerable<TElem> where TMem : IMemoryMethods, new() where TElem : struct where TPrefix : IConvertible
|
||||
{
|
||||
private static readonly int ElemSize = Marshal.SizeOf(typeof(TElem));
|
||||
private static readonly int PrefixSize = Marshal.SizeOf(typeof(TPrefix));
|
||||
private static readonly int ElemSize = InteropExtensions.SizeOf(typeof(TElem));
|
||||
private static readonly int PrefixSize = InteropExtensions.SizeOf(typeof(TPrefix));
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="SafeElementArray{TElem, TPrefix, TMem}"/> class.</summary>
|
||||
protected SafeElementArray() : this(0) { }
|
||||
|
|
|
@ -277,8 +277,10 @@ namespace Vanara.PInvoke.Tests
|
|||
Assert.That(t5.dwNumEntries, Is.GreaterThan(0));
|
||||
var t10 = GetExtendedUdpTable<MIB_UDPTABLE_OWNER_PID>(UDP_TABLE_CLASS.UDP_TABLE_OWNER_PID);
|
||||
Assert.That(t10.dwNumEntries, Is.GreaterThan(0));
|
||||
TestContext.WriteLine("UDP PID: " + string.Join(",", t10.Select(t => t.dwOwningPid)));
|
||||
var t11 = GetExtendedUdpTable<MIB_UDP6TABLE_OWNER_PID>(UDP_TABLE_CLASS.UDP_TABLE_OWNER_PID, ADDRESS_FAMILY.AF_INET6);
|
||||
Assert.That(t11.dwNumEntries, Is.GreaterThan(0));
|
||||
TestContext.WriteLine("UDP6 PID: " + string.Join(",", t11.Select(t => t.dwOwningPid)));
|
||||
}, Throws.Nothing);
|
||||
Assert.That(() => GetExtendedUdpTable<MIB_UDPTABLE>(UDP_TABLE_CLASS.UDP_TABLE_OWNER_MODULE), Throws.InvalidOperationException);
|
||||
Assert.That(() => GetExtendedUdpTable<MIB_UDP6TABLE_OWNER_MODULE>(UDP_TABLE_CLASS.UDP_TABLE_OWNER_MODULE), Throws.InvalidOperationException);
|
||||
|
|
Loading…
Reference in New Issue