Added functions to create custom desktops with CreateDesktop and CreateDesktopEx#44
Added functions to create custom desktops with CreateDesktop and CreateDesktopEx#44ashley-pillay wants to merge 1 commit intogoogleprojectzero:mainfrom
Conversation
tyranid
left a comment
There was a problem hiding this comment.
Thanks for the PR. There's a few changes which would be good to implement. Thanks.
| SECURITY_ATTRIBUTES lpsa | ||
| ); | ||
|
|
||
| [DllImport("user32.dll", EntryPoint = "CreateDesktop", CharSet = CharSet.Unicode, SetLastError = true)] |
There was a problem hiding this comment.
Don't need to specify the EntryPoint property.
| SECURITY_ATTRIBUTES attributes); | ||
|
|
||
| [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)] | ||
| internal static extern SafeKernelObjectHandle CreateDesktopEx( |
There was a problem hiding this comment.
You should just define the Ex version which is supported on Vista+, no need to specify both versions of the function.
| IntPtr device, // must be null. | ||
| IntPtr deviceMode, // must be null, | ||
| int flags, // use 0 | ||
| AccessMask dwDesiredAccess, |
There was a problem hiding this comment.
I'd use DesktopAccessRights for this type rather than AccessMask.
| int flags, // use 0 | ||
| AccessMask dwDesiredAccess, | ||
| SECURITY_ATTRIBUTES attributes, | ||
| ulong heapSize, |
There was a problem hiding this comment.
According to the definition of the function the heapSize is ULONG, which is 32-bit in the native APIs. ulong in C# is 64bit. Use int or uint instead.
| /// <returns>The Desktop.</returns> | ||
| public static NtDesktop CreateDesktop(string name) | ||
| { | ||
| var handle = Win32NativeMethods.CreateDesktop(name, IntPtr.Zero, IntPtr.Zero, 0, WindowStationAccessRights.MaximumAllowed, null); |
There was a problem hiding this comment.
Call the CreateDesktop(string name, ulong heapsize) to use the Ex version of the function with the heapsize set to 0.
Win32Utils has a CreateWindowStation function, but did not have any helper methods to create custom desktops via CreateDesktop and CreateDesktopEx.