ReactOS 0.4.16-dev-122-g325d74c
console.c File Reference
#include <win32k.h>
Include dependency graph for console.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (UserMisc)
 
NTSTATUS APIENTRY NtUserConsoleControl (IN CONSOLECONTROL ConsoleCtrl, IN PVOID ConsoleCtrlInfo, IN ULONG ConsoleCtrlInfoLength)
 

Function Documentation

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserMisc  )

◆ NtUserConsoleControl()

NTSTATUS APIENTRY NtUserConsoleControl ( IN CONSOLECONTROL  ConsoleCtrl,
IN PVOID  ConsoleCtrlInfo,
IN ULONG  ConsoleCtrlInfoLength 
)

Definition at line 14 of file console.c.

18{
20
21 /* Allow only the Console Server to perform this operation (via CSRSS) */
24
26
27 switch (ConsoleCtrl)
28 {
30 {
31 DESKTOP_CONSOLE_THREAD DesktopConsoleThreadInfo;
33 ULONG_PTR OldThreadId;
34
35 if (ConsoleCtrlInfoLength != sizeof(DesktopConsoleThreadInfo))
36 {
38 break;
39 }
40
42 {
43 ProbeForWrite(ConsoleCtrlInfo, ConsoleCtrlInfoLength, sizeof(USHORT));
44 DesktopConsoleThreadInfo = *(PDESKTOP_CONSOLE_THREAD)ConsoleCtrlInfo;
45 }
47 {
49 _SEH2_YIELD(break);
50 }
52
53 /* Reference the desktop */
54 Status = ObReferenceObjectByHandle(DesktopConsoleThreadInfo.DesktopHandle,
55 0,
58 (PVOID*)&Desktop,
59 NULL);
60 if (!NT_SUCCESS(Status)) break;
61
62 /* Save the old thread ID, it is always returned to the caller */
63 OldThreadId = Desktop->dwConsoleThreadId;
64
65 /* Set the new console input thread ID for this desktop if required */
66 if (DesktopConsoleThreadInfo.ThreadId != (ULONG_PTR)INVALID_HANDLE_VALUE)
67 {
68 Desktop->dwConsoleThreadId = DesktopConsoleThreadInfo.ThreadId;
69 }
70
71 /* Always return the old thread ID */
72 DesktopConsoleThreadInfo.ThreadId = OldThreadId;
73
74 /* Dereference the desktop */
76
77 /* Return the information back to the caller */
79 {
80 *(PDESKTOP_CONSOLE_THREAD)ConsoleCtrlInfo = DesktopConsoleThreadInfo;
81 }
83 {
85 }
87
88 break;
89 }
90
92 {
93 if (ConsoleCtrlInfoLength != sizeof(ATOM))
94 {
96 break;
97 }
98
100 {
101 ProbeForRead(ConsoleCtrlInfo, ConsoleCtrlInfoLength, sizeof(USHORT));
102 gaGuiConsoleWndClass = *(ATOM*)ConsoleCtrlInfo;
103 }
105 {
107 }
108 _SEH2_END;
109
110 break;
111 }
112
114 {
115 HPALETTE hPalette;
116
117 if (ConsoleCtrlInfoLength != sizeof(hPalette))
118 {
120 break;
121 }
122
124 {
125 ProbeForRead(ConsoleCtrlInfo, ConsoleCtrlInfoLength, sizeof(USHORT));
126 hPalette = *(HPALETTE*)ConsoleCtrlInfo;
127 }
129 {
131 _SEH2_YIELD(break);
132 }
133 _SEH2_END;
134
135 /* Make the palette handle public */
136 GreSetObjectOwnerEx(hPalette,
139 break;
140 }
141
143 {
144 ERR("NtUserConsoleControl - ConsoleAcquireDisplayOwnership is UNIMPLEMENTED\n");
146 break;
147 }
148
149 default:
150 ERR("Calling invalid control %d in NtUserConsoleControl\n", ConsoleCtrl);
152 break;
153 }
154
155 UserLeave();
156
157 return Status;
158}
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: precomp.h:57
PEPROCESS gpepCSRSS
Definition: csr.c:15
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
@ GDIOBJFLAG_IGNOREPID
Definition: gdiobj.h:72
Status
Definition: gdiplustypes.h:25
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
@ ConsoleCtrlDesktopConsoleThread
Definition: ntuser.h:1798
@ ConsoleMakePalettePublic
Definition: ntuser.h:1800
@ GuiConsoleWndClassAtom
Definition: ntuser.h:1799
@ ConsoleAcquireDisplayOwnership
Definition: ntuser.h:1801
struct _DESKTOP_CONSOLE_THREAD * PDESKTOP_CONSOLE_THREAD
#define UserMode
Definition: asm.h:35
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_INVALID_INFO_CLASS
Definition: ntstatus.h:240
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
ATOM gaGuiConsoleWndClass
Definition: ntuser.c:27
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:494
unsigned short USHORT
Definition: pedump.c:61
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
#define STATUS_SUCCESS
Definition: shellext.h:65
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
POBJECT_TYPE ExDesktopObjectType
Definition: win32k.c:22
BOOL NTAPI GreSetObjectOwnerEx(HGDIOBJ hobj, ULONG ulOwner, ULONG Flags)
Definition: gdiobj.c:1222
#define ObDereferenceObject
Definition: obfuncs.h:203
#define PsGetCurrentProcess
Definition: psfuncs.h:17

Referenced by CON_API(), GuiConsoleInputThread(), GuiInit(), and RegisterConWndClass().