ReactOS 0.4.15-dev-7924-g5949c20
subsysreg.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Console Server DLL
4 * FILE: win32ss/user/winsrv/consrv/subsysreg.c
5 * PURPOSE: Registration APIs for VDM, OS2 and IME subsystems
6 * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include "consrv.h"
12
13#define NDEBUG
14#include <debug.h>
15
16/* PUBLIC SERVER APIS *********************************************************/
17
18/*
19 * VDM Subsystem
20 */
21
22/* API_NUMBER: ConsolepRegisterVDM */
23CON_API(SrvRegisterConsoleVDM,
24 CONSOLE_REGISTERVDM, RegisterVDMRequest)
25{
27
28 DPRINT1("SrvRegisterConsoleVDM(%d)\n", RegisterVDMRequest->RegisterFlags);
29
30 if (RegisterVDMRequest->RegisterFlags != 0)
31 {
32 LARGE_INTEGER SectionSize;
33 SIZE_T Size, ViewSize = 0;
35
36 /*
37 * Remember the handle to the process so that we can close or unmap
38 * correctly the allocated resources when the client releases the
39 * screen buffer.
40 */
41 ProcessHandle = CsrGetClientThread()->Process->ProcessHandle;
42 Console->VDMClientProcess = ProcessHandle;
43
44 Console->VDMBufferSize = RegisterVDMRequest->VDMBufferSize;
45
46 Size = Console->VDMBufferSize.X * Console->VDMBufferSize.Y
47 * sizeof(CHAR_CELL);
48
49 /*
50 * Create a memory section for the VDM buffer, to share with the client.
51 */
52 SectionSize.QuadPart = Size;
53 Status = NtCreateSection(&Console->VDMBufferSection,
55 NULL,
56 &SectionSize,
59 NULL);
60 if (!NT_SUCCESS(Status))
61 {
62 DPRINT1("Error: Impossible to create a shared section, Status = 0x%08lx\n", Status);
63 return Status;
64 }
65
66 /*
67 * Create a view for our needs.
68 */
69 ViewSize = 0;
70 Console->VDMBuffer = NULL;
71 Status = NtMapViewOfSection(Console->VDMBufferSection,
73 (PVOID*)&Console->VDMBuffer,
74 0,
75 0,
76 NULL,
77 &ViewSize,
79 0,
81 if (!NT_SUCCESS(Status))
82 {
83 DPRINT1("Error: Impossible to map the shared section, Status = 0x%08lx\n", Status);
84 NtClose(Console->VDMBufferSection);
85 return Status;
86 }
87
88 /*
89 * Create a view for the client. We must keep a trace of it so that
90 * we can unmap it when the client releases the VDM buffer.
91 */
92 ViewSize = 0;
93 Console->ClientVDMBuffer = NULL;
94 Status = NtMapViewOfSection(Console->VDMBufferSection,
96 (PVOID*)&Console->ClientVDMBuffer,
97 0,
98 0,
99 NULL,
100 &ViewSize,
101 ViewUnmap,
102 0,
104 if (!NT_SUCCESS(Status))
105 {
106 DPRINT1("Error: Impossible to map the shared section, Status = 0x%08lx\n", Status);
108 NtClose(Console->VDMBufferSection);
109 return Status;
110 }
111
112 // TODO: Duplicate the event handles.
113
114 RegisterVDMRequest->VDMBuffer = Console->ClientVDMBuffer;
115
116 return STATUS_SUCCESS;
117 }
118 else
119 {
120 /* RegisterFlags == 0 means we are unregistering the VDM */
121
122 // TODO: Close the duplicated handles.
123
124 if (Console->VDMBuffer)
125 {
126 /*
127 * Uninitialize the graphics screen buffer
128 * in the reverse way we initialized it.
129 */
130 NtUnmapViewOfSection(Console->VDMClientProcess, Console->ClientVDMBuffer);
132 NtClose(Console->VDMBufferSection);
133 }
134 Console->VDMBuffer = Console->ClientVDMBuffer = NULL;
135
136 Console->VDMBufferSize.X = Console->VDMBufferSize.Y = 0;
137
138 return STATUS_SUCCESS;
139 }
140}
141
142/* API_NUMBER: ConsolepVDMOperation */
143CSR_API(SrvVDMConsoleOperation)
144{
145 DPRINT1("%s not yet implemented\n", __FUNCTION__);
147}
148
149
150/*
151 * OS/2 Subsystem
152 */
153
154/* API_NUMBER: ConsolepRegisterOS2 */
155CSR_API(SrvRegisterConsoleOS2)
156{
157 DPRINT1("%s not yet implemented\n", __FUNCTION__);
159}
160
161/* API_NUMBER: ConsolepSetOS2OemFormat */
162CSR_API(SrvSetConsoleOS2OemFormat)
163{
164 DPRINT1("%s not yet implemented\n", __FUNCTION__);
166}
167
168
169/*
170 * IME Subsystem
171 */
172
173/* API_NUMBER: ConsolepRegisterConsoleIME */
174CSR_API(SrvRegisterConsoleIME)
175{
176 DPRINT1("%s not yet implemented\n", __FUNCTION__);
178}
179
180/* API_NUMBER: ConsolepUnregisterConsoleIME */
181CSR_API(SrvUnregisterConsoleIME)
182{
183 DPRINT1("%s not yet implemented\n", __FUNCTION__);
185}
186
187/* EOF */
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3848
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3441
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3622
CConsole Console
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define CSR_API(n)
Definition: csrsrv.h:176
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define __FUNCTION__
Definition: types.h:116
Status
Definition: gdiplustypes.h:25
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:408
#define SEC_COMMIT
Definition: mmtypes.h:100
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define NtCurrentProcess()
Definition: nt_native.h:1657
@ ViewUnmap
Definition: nt_native.h:1279
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _CHAR_CELL CHAR_CELL
ULONG_PTR SIZE_T
Definition: typedefs.h:80
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
#define CON_API(Name, TYPE, RequestName)
Definition: api.h:80