/// <summary>
        /// Query the directory for a list of entries.
        /// </summary>
        /// <returns>The list of entries.</returns>
        /// <exception cref="NtException">Thrown on error</exception>
        public IEnumerable<ObjectDirectoryInformation> Query()
        {
            using (SafeStructureInOutBuffer<OBJECT_DIRECTORY_INFORMATION> buffer
                = new SafeStructureInOutBuffer<OBJECT_DIRECTORY_INFORMATION>(2048, true))
            {
                NtStatus status;
                int context = 0;
                int return_length = 0;
                while ((status = NtSystemCalls.NtQueryDirectoryObject(Handle, buffer, buffer.Length, false,
                    true, ref context, out return_length)) == NtStatus.STATUS_MORE_ENTRIES)
                {
                    buffer.Resize(buffer.Length * 2);
                }

                if (status == NtStatus.STATUS_NO_MORE_ENTRIES)
                {
                    yield break;
                }

                status.ToNtException();
                IntPtr current = buffer.DangerousGetHandle();
                string name = String.Empty;
                while(true)
                {
                    OBJECT_DIRECTORY_INFORMATION dir_info = (OBJECT_DIRECTORY_INFORMATION)Marshal.PtrToStructure(current, typeof(OBJECT_DIRECTORY_INFORMATION));
                    name = dir_info.Name.ToString();
                    if (name.Length == 0)
                    {
                        break;
                    }
                    yield return new ObjectDirectoryInformation(this, dir_info);
                    current += Marshal.SizeOf(dir_info);
                }
            }
        }
 internal ObjectDirectoryInformation(NtDirectory root, string base_path, OBJECT_DIRECTORY_INFORMATION info)
     : this(root, base_path, info.Name.ToString(), info.TypeName.ToString())
 {
 }