Example #1
0
        /// <summary>
        /// Create a new desktop.
        /// </summary>
        /// <param name="object_attributes">The object attributes for opening.</param>
        /// <param name="flags">Flags for opening the desktop.</param>
        /// <param name="desired_access">Desired access.</param>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <param name="device">Device name.</param>
        /// <param name="dev_mode">Device mode.</param>
        /// <param name="heap_size">Heap size.</param>
        /// <returns>An instance of NtDesktop.</returns>
        public static NtResult <NtDesktop> Create(ObjectAttributes object_attributes, string device,
                                                  DEVMODE dev_mode, CreateDesktopFlags flags, DesktopAccessRights desired_access, int heap_size,
                                                  bool throw_on_error)
        {
            SafeKernelObjectHandle handle = NtSystemCalls.NtUserCreateDesktopEx(object_attributes,
                                                                                string.IsNullOrEmpty(device) ? null : new UnicodeString(device),
                                                                                dev_mode, flags, desired_access, heap_size);

            if (handle.IsInvalid)
            {
                return(NtObjectUtils.CreateResultFromDosError <NtDesktop>(Marshal.GetLastWin32Error(), throw_on_error));
            }
            return(new NtResult <NtDesktop>(NtStatus.STATUS_SUCCESS, new NtDesktop(handle)));
        }
Example #2
0
 /// <summary>
 /// Open a desktop by name.
 /// </summary>
 /// <param name="object_attributes">The object attributes for opening.</param>
 /// <param name="flags">Flags for opening the desktop.</param>
 /// <param name="desired_access">Desired access.</param>
 /// <returns>The instance of the desktop.</returns>
 /// <exception cref="NtException">Thrown on error.</exception>
 public static NtDesktop Open(ObjectAttributes object_attributes, CreateDesktopFlags flags,
                              DesktopAccessRights desired_access)
 {
     return(Open(object_attributes, flags, desired_access, true).Result);
 }
Example #3
0
 /// <summary>
 /// Create a new desktop.
 /// </summary>
 /// <param name="object_attributes">The object attributes for opening.</param>
 /// <param name="flags">Flags for opening the desktop.</param>
 /// <param name="desired_access">Desired access.</param>
 /// <param name="device">Device name.</param>
 /// <param name="dev_mode">Device mode.</param>
 /// <param name="heap_size">Heap size.</param>
 /// <returns>An instance of NtDesktop.</returns>
 public static NtDesktop Create(ObjectAttributes object_attributes, string device,
                                DEVMODE dev_mode, CreateDesktopFlags flags, DesktopAccessRights desired_access, int heap_size)
 {
     return(Create(object_attributes, device, dev_mode, flags, desired_access, heap_size, true).Result);
 }
Example #4
0
 public static extern SafeKernelObjectHandle NtUserCreateDesktopEx(
     ObjectAttributes ObjectAttributes, UnicodeString Device,
     DEVMODE DevMode, CreateDesktopFlags Flags,
     DesktopAccessRights DesiredAccess,
     int HeapSize);
Example #5
0
 public static extern SafeKernelObjectHandle NtUserOpenDesktop(
     ObjectAttributes ObjectAttributes, CreateDesktopFlags Flags,
     DesktopAccessRights DesiredAccess);