示例#1
0
        // Windows Kernel Architecture Internals
        // http://research.microsoft.com/en-us/um/redmond/events/wincore2010/Dave_Probert_1.pdf

        // Object Manager Routines (kernel-mode file systems and file system filter drivers)
        // https://msdn.microsoft.com/en-us/library/windows/hardware/ff550969.aspx
        // https://msdn.microsoft.com/en-us/library/windows/hardware/ff557759.aspx

        // Managing Kernel Objects
        // https://msdn.microsoft.com/en-us/library/windows/hardware/ff554383.aspx

        /// <summary>
        /// Open a handle to a directory object at the given NT path.
        /// </summary>
        public static DirectoryObjectHandle OpenDirectoryObject(
            string path,
            DirectoryObjectRights desiredAccess = DirectoryObjectRights.Query)
        {
            return((DirectoryObjectHandle)OpenObjectHelper(path, (attributes) =>
            {
                Imports.NtOpenDirectoryObject(
                    DirectoryHandle: out var directory,
                    DesiredAccess: desiredAccess,
                    ObjectAttributes: ref attributes)
                .ThrowIfFailed(path);

                return directory;
            }));
示例#2
0
        // Windows Kernel Architecture Internals
        // http://research.microsoft.com/en-us/um/redmond/events/wincore2010/Dave_Probert_1.pdf

        // Object Manager Routines (kernel-mode file systems and file system filter drivers)
        // https://msdn.microsoft.com/en-us/library/windows/hardware/ff550969.aspx
        // https://msdn.microsoft.com/en-us/library/windows/hardware/ff557759.aspx

        // Managing Kernel Objects
        // https://msdn.microsoft.com/en-us/library/windows/hardware/ff554383.aspx

        /// <summary>
        /// Open a handle to a directory object at the given NT path.
        /// </summary>
        public static DirectoryObjectHandle OpenDirectoryObject(
            string path,
            DirectoryObjectRights desiredAccess = DirectoryObjectRights.Query)
        {
            return((DirectoryObjectHandle)OpenObjectHelper(path, (attributes) =>
            {
                NTSTATUS status = Imports.NtOpenDirectoryObject(
                    DirectoryHandle: out var directory,
                    DesiredAccess: desiredAccess,
                    ObjectAttributes: ref attributes);

                if (status != NTSTATUS.STATUS_SUCCESS)
                {
                    throw ErrorMethods.GetIoExceptionForNTStatus(status, path);
                }

                return directory;
            }));
示例#3
0
 public static extern NTStatus NtOpenDirectoryObject(
     out DirectoryObjectHandle DirectoryHandle,
     DirectoryObjectRights DesiredAccess,
     ref OBJECT_ATTRIBUTES ObjectAttributes);