HDESK CreateDesktopNt(IN CONST PUNICODE_STRING DesktopName,
IN CONST PUNICODE_STRING DeviceName,
IN CONST PDEVMODEW DeviceMode,
IN CONST DWORD Flags,
IN CONST ACCESS_MASK DesiredAccess,
IN OPTIONAL CONST LPSECURITY_ATTRIBUTES SecurityAttributes,
IN CONST ULONG HeapSize)
{
CONST HWINSTA ProcessWindowStation{ NtUserGetProcessWindowStation() };
if (ProcessWindowStation == nullptr)
{
return nullptr;
}
ULONG Attributes{ OBJ_OPENIF | OBJ_CASE_INSENSITIVE };
if (SecurityAttributes != nullptr && SecurityAttributes->bInheritHandle == TRUE)
{
Attributes |= OBJ_INHERIT;
}
LPVOID SecurityDescriptor{};
if (SecurityAttributes)
{
SecurityDescriptor = SecurityAttributes->lpSecurityDescriptor;
}
OBJECT_ATTRIBUTES DesktopAttributes{};
InitializeObjectAttributes(&DesktopAttributes, DesktopName, Attributes, ProcessWindowStation, SecurityDescriptor)
return NtUserCreateDesktopEx(&DesktopAttributes, DeviceName, DeviceMode, Flags, DesiredAccess, HeapSize);
}