typedef struct _USER_GET_THREAD_CONSOLE_DESKTOP
{
ULONG_PTR ThreadId;
- HANDLE ConsoleDesktop;
+ HDESK ConsoleDesktop;
} USER_GET_THREAD_CONSOLE_DESKTOP, *PUSER_GET_THREAD_CONSOLE_DESKTOP;
typedef struct _USER_REGISTER_SERVICES_PROCESS
CSR_API(SrvSetConsoleCursor);
CSR_API(SrvConsoleMenuControl);
CSR_API(SrvSetConsoleMenuClose);
+
+/* Used by USERSRV!SrvGetThreadConsoleDesktop() */
+NTSTATUS
+NTAPI
+GetThreadConsoleDesktop(
+ IN ULONG_PTR ThreadId,
+ OUT HDESK* ConsoleDesktop);
+
CSR_API(SrvGetConsoleWindow);
CSR_API(SrvSetConsoleIcon);
CSR_API(SrvGetConsoleSelectionInfo);
return (Success ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);
}
+/* Used by USERSRV!SrvGetThreadConsoleDesktop() */
+NTSTATUS
+NTAPI
+GetThreadConsoleDesktop(
+ IN ULONG_PTR ThreadId,
+ OUT HDESK* ConsoleDesktop)
+{
+ NTSTATUS Status;
+ PCSR_THREAD CsrThread;
+ PCONSRV_CONSOLE Console;
+
+ /* No console desktop handle by default */
+ *ConsoleDesktop = NULL;
+
+ /* Retrieve and lock the thread */
+ Status = CsrLockThreadByClientId(ULongToHandle(ThreadId), &CsrThread);
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ ASSERT(CsrThread->Process);
+
+ /* Retrieve the console to which the process is attached, and unlock the thread */
+ Status = ConSrvGetConsole(ConsoleGetPerProcessData(CsrThread->Process),
+ &Console, TRUE);
+ CsrUnlockThread(CsrThread);
+
+ if (!NT_SUCCESS(Status))
+ return Status;
+
+ /* Retrieve the console desktop handle, and release the console */
+ *ConsoleDesktop = TermGetThreadConsoleDesktop(Console);
+ ConSrvReleaseConsole(Console, TRUE);
+
+ return STATUS_SUCCESS;
+}
+
CSR_API(SrvGetConsoleWindow)
{
NTSTATUS Status;
return TRUE;
}
+static HDESK NTAPI
+GuiGetThreadConsoleDesktop(IN OUT PFRONTEND This)
+{
+ PGUI_CONSOLE_DATA GuiData = This->Context;
+ return GuiData->Desktop;
+}
+
static HWND NTAPI
GuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
{
GuiRefreshInternalInfo,
GuiChangeTitle,
GuiChangeIcon,
+ GuiGetThreadConsoleDesktop,
GuiGetConsoleWindowHandle,
GuiGetLargestConsoleWindowSize,
GuiGetSelectionInfo,
return TRUE;
}
+static HDESK NTAPI
+TuiGetThreadConsoleDesktop(IN OUT PFRONTEND This)
+{
+ // PTUI_CONSOLE_DATA TuiData = This->Context;
+ return NULL;
+}
+
static HWND NTAPI
TuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
{
TuiRefreshInternalInfo,
TuiChangeTitle,
TuiChangeIcon,
+ TuiGetThreadConsoleDesktop,
TuiGetConsoleWindowHandle,
TuiGetLargestConsoleWindowSize,
TuiGetSelectionInfo,
VOID (NTAPI *ChangeTitle)(IN OUT PFRONTEND This);
BOOL (NTAPI *ChangeIcon)(IN OUT PFRONTEND This,
HICON IconHandle);
+ HDESK (NTAPI *GetThreadConsoleDesktop)(IN OUT PFRONTEND This);
HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This);
VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This,
PCOORD pSize);
(Console)->FrontEndIFace.Vtbl->ChangeTitle(&(Console)->FrontEndIFace)
#define TermChangeIcon(Console, IconHandle) \
(Console)->FrontEndIFace.Vtbl->ChangeIcon(&(Console)->FrontEndIFace, (IconHandle))
+#define TermGetThreadConsoleDesktop(Console) \
+ (Console)->FrontEndIFace.Vtbl->GetThreadConsoleDesktop(&(Console)->FrontEndIFace)
#define TermGetConsoleWindowHandle(Console) \
(Console)->FrontEndIFace.Vtbl->GetConsoleWindowHandle(&(Console)->FrontEndIFace)
#define TermGetSelectionInfo(Console, pSelectionInfo) \
/* INCLUDES *******************************************************************/
#include "usersrv.h"
-
-#include "api.h"
+#include "api.h" // USERSRV Public server APIs definitions
+#include "../consrv/api.h" // CONSRV Public server APIs definitions
#define NDEBUG
#include <debug.h>
CSR_API(SrvGetThreadConsoleDesktop)
{
+ NTSTATUS Status;
PUSER_GET_THREAD_CONSOLE_DESKTOP GetThreadConsoleDesktopRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.GetThreadConsoleDesktopRequest;
- UNIMPLEMENTED_ONCE;
-
- /* Return nothing for the moment... */
- GetThreadConsoleDesktopRequest->ConsoleDesktop = NULL;
+ Status = GetThreadConsoleDesktop(GetThreadConsoleDesktopRequest->ThreadId,
+ &GetThreadConsoleDesktopRequest->ConsoleDesktop);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("GetThreadConsoleDesktop(%lu) failed with Status 0x%08x\n",
+ GetThreadConsoleDesktopRequest->ThreadId, Status);
+ }
- /* Always succeeds */
+ /* Windows-compatibility: Always return success since User32 relies on this! */
return STATUS_SUCCESS;
}