public static MibUdpTableOwnerPid GetUdpTable() { MibUdpTableOwnerPid table = new MibUdpTableOwnerPid(); int length = 0; GetExtendedUdpTable(IntPtr.Zero, ref length, false, AiFamily.INet, UdpTableClass.OwnerPid, 0); using (MemoryAlloc mem = new MemoryAlloc(length)) { GetExtendedUdpTable(mem, ref length, false, AiFamily.INet, UdpTableClass.OwnerPid, 0); int count = mem.ReadInt32(0); table.NumEntries = count; table.Table = new MibUdpRowOwnerPid[count]; for (int i = 0; i < count; i++) { table.Table[i] = mem.ReadStruct <MibUdpRowOwnerPid>(sizeof(int), i); } } return(table); }
public int[] GetProcessIdList() { List <int> processIds = new List <int>(); int retLength; // FIXME: Fixed buffer using (MemoryAlloc data = new MemoryAlloc(0x1000)) { if (!Win32.QueryInformationJobObject(this, JobObjectInformationClass.JobObjectBasicProcessIdList, data, data.Size, out retLength)) { Win32.ThrowLastError(); } JobObjectBasicProcessIdList listInfo = data.ReadStruct <JobObjectBasicProcessIdList>(); for (int i = 0; i < listInfo.NumberOfProcessIdsInList; i++) { processIds.Add(data.ReadInt32(8, i)); } } return(processIds.ToArray()); }
public static MibUdpTableOwnerPid GetUdpTable() { MibUdpTableOwnerPid table = new MibUdpTableOwnerPid(); int length = 0; GetExtendedUdpTable(IntPtr.Zero, ref length, false, AiFamily.INet, UdpTableClass.OwnerPid, 0); using (MemoryAlloc mem = new MemoryAlloc(length)) { GetExtendedUdpTable(mem, ref length, false, AiFamily.INet, UdpTableClass.OwnerPid, 0); int count = mem.ReadInt32(0); table.NumEntries = count; table.Table = new MibUdpRowOwnerPid[count]; for (int i = 0; i < count; i++) table.Table[i] = mem.ReadStruct<MibUdpRowOwnerPid>(sizeof(int), i); } return table; }