mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 22:18:13 +00:00
[WINSRV] Implement SrvGetThreadConsoleDesktop(). CORE-13470
It retrieves the handle to the desktop assigned to the specified thread belonging to a console application, which is going to be where the input thread of this console is.
This commit is contained in:
parent
2da24f7274
commit
d70848b8b7
8 changed files with 75 additions and 8 deletions
|
@ -68,7 +68,7 @@ typedef struct _USER_LOGON
|
||||||
typedef struct _USER_GET_THREAD_CONSOLE_DESKTOP
|
typedef struct _USER_GET_THREAD_CONSOLE_DESKTOP
|
||||||
{
|
{
|
||||||
ULONG_PTR ThreadId;
|
ULONG_PTR ThreadId;
|
||||||
HANDLE ConsoleDesktop;
|
HDESK ConsoleDesktop;
|
||||||
} USER_GET_THREAD_CONSOLE_DESKTOP, *PUSER_GET_THREAD_CONSOLE_DESKTOP;
|
} USER_GET_THREAD_CONSOLE_DESKTOP, *PUSER_GET_THREAD_CONSOLE_DESKTOP;
|
||||||
|
|
||||||
typedef struct _USER_REGISTER_SERVICES_PROCESS
|
typedef struct _USER_REGISTER_SERVICES_PROCESS
|
||||||
|
|
|
@ -78,6 +78,14 @@ CSR_API(SrvShowConsoleCursor);
|
||||||
CSR_API(SrvSetConsoleCursor);
|
CSR_API(SrvSetConsoleCursor);
|
||||||
CSR_API(SrvConsoleMenuControl);
|
CSR_API(SrvConsoleMenuControl);
|
||||||
CSR_API(SrvSetConsoleMenuClose);
|
CSR_API(SrvSetConsoleMenuClose);
|
||||||
|
|
||||||
|
/* Used by USERSRV!SrvGetThreadConsoleDesktop() */
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
GetThreadConsoleDesktop(
|
||||||
|
IN ULONG_PTR ThreadId,
|
||||||
|
OUT HDESK* ConsoleDesktop);
|
||||||
|
|
||||||
CSR_API(SrvGetConsoleWindow);
|
CSR_API(SrvGetConsoleWindow);
|
||||||
CSR_API(SrvSetConsoleIcon);
|
CSR_API(SrvSetConsoleIcon);
|
||||||
CSR_API(SrvGetConsoleSelectionInfo);
|
CSR_API(SrvGetConsoleSelectionInfo);
|
||||||
|
|
|
@ -275,6 +275,42 @@ CSR_API(SrvSetConsoleMenuClose)
|
||||||
return (Success ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL);
|
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)
|
CSR_API(SrvGetConsoleWindow)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
|
@ -911,6 +911,13 @@ GuiChangeIcon(IN OUT PFRONTEND This,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HDESK NTAPI
|
||||||
|
GuiGetThreadConsoleDesktop(IN OUT PFRONTEND This)
|
||||||
|
{
|
||||||
|
PGUI_CONSOLE_DATA GuiData = This->Context;
|
||||||
|
return GuiData->Desktop;
|
||||||
|
}
|
||||||
|
|
||||||
static HWND NTAPI
|
static HWND NTAPI
|
||||||
GuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
|
GuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
|
||||||
{
|
{
|
||||||
|
@ -1148,6 +1155,7 @@ static FRONTEND_VTBL GuiVtbl =
|
||||||
GuiRefreshInternalInfo,
|
GuiRefreshInternalInfo,
|
||||||
GuiChangeTitle,
|
GuiChangeTitle,
|
||||||
GuiChangeIcon,
|
GuiChangeIcon,
|
||||||
|
GuiGetThreadConsoleDesktop,
|
||||||
GuiGetConsoleWindowHandle,
|
GuiGetConsoleWindowHandle,
|
||||||
GuiGetLargestConsoleWindowSize,
|
GuiGetLargestConsoleWindowSize,
|
||||||
GuiGetSelectionInfo,
|
GuiGetSelectionInfo,
|
||||||
|
|
|
@ -831,6 +831,13 @@ TuiChangeIcon(IN OUT PFRONTEND This,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HDESK NTAPI
|
||||||
|
TuiGetThreadConsoleDesktop(IN OUT PFRONTEND This)
|
||||||
|
{
|
||||||
|
// PTUI_CONSOLE_DATA TuiData = This->Context;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static HWND NTAPI
|
static HWND NTAPI
|
||||||
TuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
|
TuiGetConsoleWindowHandle(IN OUT PFRONTEND This)
|
||||||
{
|
{
|
||||||
|
@ -920,6 +927,7 @@ static FRONTEND_VTBL TuiVtbl =
|
||||||
TuiRefreshInternalInfo,
|
TuiRefreshInternalInfo,
|
||||||
TuiChangeTitle,
|
TuiChangeTitle,
|
||||||
TuiChangeIcon,
|
TuiChangeIcon,
|
||||||
|
TuiGetThreadConsoleDesktop,
|
||||||
TuiGetConsoleWindowHandle,
|
TuiGetConsoleWindowHandle,
|
||||||
TuiGetLargestConsoleWindowSize,
|
TuiGetLargestConsoleWindowSize,
|
||||||
TuiGetSelectionInfo,
|
TuiGetSelectionInfo,
|
||||||
|
|
|
@ -89,6 +89,7 @@ typedef struct _FRONTEND_VTBL
|
||||||
VOID (NTAPI *ChangeTitle)(IN OUT PFRONTEND This);
|
VOID (NTAPI *ChangeTitle)(IN OUT PFRONTEND This);
|
||||||
BOOL (NTAPI *ChangeIcon)(IN OUT PFRONTEND This,
|
BOOL (NTAPI *ChangeIcon)(IN OUT PFRONTEND This,
|
||||||
HICON IconHandle);
|
HICON IconHandle);
|
||||||
|
HDESK (NTAPI *GetThreadConsoleDesktop)(IN OUT PFRONTEND This);
|
||||||
HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This);
|
HWND (NTAPI *GetConsoleWindowHandle)(IN OUT PFRONTEND This);
|
||||||
VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This,
|
VOID (NTAPI *GetLargestConsoleWindowSize)(IN OUT PFRONTEND This,
|
||||||
PCOORD pSize);
|
PCOORD pSize);
|
||||||
|
|
|
@ -47,6 +47,8 @@
|
||||||
(Console)->FrontEndIFace.Vtbl->ChangeTitle(&(Console)->FrontEndIFace)
|
(Console)->FrontEndIFace.Vtbl->ChangeTitle(&(Console)->FrontEndIFace)
|
||||||
#define TermChangeIcon(Console, IconHandle) \
|
#define TermChangeIcon(Console, IconHandle) \
|
||||||
(Console)->FrontEndIFace.Vtbl->ChangeIcon(&(Console)->FrontEndIFace, (IconHandle))
|
(Console)->FrontEndIFace.Vtbl->ChangeIcon(&(Console)->FrontEndIFace, (IconHandle))
|
||||||
|
#define TermGetThreadConsoleDesktop(Console) \
|
||||||
|
(Console)->FrontEndIFace.Vtbl->GetThreadConsoleDesktop(&(Console)->FrontEndIFace)
|
||||||
#define TermGetConsoleWindowHandle(Console) \
|
#define TermGetConsoleWindowHandle(Console) \
|
||||||
(Console)->FrontEndIFace.Vtbl->GetConsoleWindowHandle(&(Console)->FrontEndIFace)
|
(Console)->FrontEndIFace.Vtbl->GetConsoleWindowHandle(&(Console)->FrontEndIFace)
|
||||||
#define TermGetSelectionInfo(Console, pSelectionInfo) \
|
#define TermGetSelectionInfo(Console, pSelectionInfo) \
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
/* INCLUDES *******************************************************************/
|
/* INCLUDES *******************************************************************/
|
||||||
|
|
||||||
#include "usersrv.h"
|
#include "usersrv.h"
|
||||||
|
#include "api.h" // USERSRV Public server APIs definitions
|
||||||
#include "api.h"
|
#include "../consrv/api.h" // CONSRV Public server APIs definitions
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
@ -138,14 +138,18 @@ CSR_API(SrvActivateDebugger)
|
||||||
|
|
||||||
CSR_API(SrvGetThreadConsoleDesktop)
|
CSR_API(SrvGetThreadConsoleDesktop)
|
||||||
{
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
PUSER_GET_THREAD_CONSOLE_DESKTOP GetThreadConsoleDesktopRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.GetThreadConsoleDesktopRequest;
|
PUSER_GET_THREAD_CONSOLE_DESKTOP GetThreadConsoleDesktopRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.GetThreadConsoleDesktopRequest;
|
||||||
|
|
||||||
UNIMPLEMENTED_ONCE;
|
Status = GetThreadConsoleDesktop(GetThreadConsoleDesktopRequest->ThreadId,
|
||||||
|
&GetThreadConsoleDesktopRequest->ConsoleDesktop);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("GetThreadConsoleDesktop(%lu) failed with Status 0x%08x\n",
|
||||||
|
GetThreadConsoleDesktopRequest->ThreadId, Status);
|
||||||
|
}
|
||||||
|
|
||||||
/* Return nothing for the moment... */
|
/* Windows-compatibility: Always return success since User32 relies on this! */
|
||||||
GetThreadConsoleDesktopRequest->ConsoleDesktop = NULL;
|
|
||||||
|
|
||||||
/* Always succeeds */
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue