Example #1
0
        internal static EntryInfo[] GetEntries(string prefix, NtType types)
        {
            UIntPtr size;

            byte[]  str           = CreateUTF8String(prefix, out size);
            UIntPtr arrSize       = UIntPtr.Zero;
            IntPtr  arr           = Interop.NT_GetEntryInfo(str, size, (uint)types, ref arrSize);
            int     entryInfoSize = Marshal.SizeOf(typeof(NtEntryInfo));
            int     arraySize     = (int)arrSize.ToUInt64();

            EntryInfo[] entryArray = new EntryInfo[arraySize];

            for (int i = 0; i < arraySize; i++)
            {
                IntPtr      data = new IntPtr(arr.ToInt64() + entryInfoSize * i);
                NtEntryInfo info = (NtEntryInfo)Marshal.PtrToStructure(data, typeof(NtEntryInfo));
                entryArray[i] = new EntryInfo(info.name.ToString(), info.type, (EntryFlags)info.flags, (long)info.last_change);
            }
            Interop.NT_DisposeEntryInfoArray(arr, arrSize);
            return(entryArray);
        }