ReactOS  0.4.13-dev-563-g0561610
subsysreg.c File Reference
#include "consrv.h"
#include <debug.h>
Include dependency graph for subsysreg.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 CSR_API (SrvRegisterConsoleVDM)
 
 CSR_API (SrvVDMConsoleOperation)
 
 CSR_API (SrvRegisterConsoleOS2)
 
 CSR_API (SrvSetConsoleOS2OemFormat)
 
 CSR_API (SrvRegisterConsoleIME)
 
 CSR_API (SrvUnregisterConsoleIME)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file subsysreg.c.

Function Documentation

◆ CSR_API() [1/6]

CSR_API ( SrvRegisterConsoleVDM  )

Definition at line 22 of file subsysreg.c.

23 {
25  PCONSOLE_REGISTERVDM RegisterVDMRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.RegisterVDMRequest;
27 
28  DPRINT1("SrvRegisterConsoleVDM(%d)\n", RegisterVDMRequest->RegisterFlags);
29 
31  &Console, TRUE);
32  if (!NT_SUCCESS(Status))
33  {
34  DPRINT1("Can't get console, status %lx\n", Status);
35  return Status;
36  }
37 
38  if (RegisterVDMRequest->RegisterFlags != 0)
39  {
40  LARGE_INTEGER SectionSize;
41  SIZE_T Size, ViewSize = 0;
43 
44  /*
45  * Remember the handle to the process so that we can close or unmap
46  * correctly the allocated resources when the client releases the
47  * screen buffer.
48  */
49  ProcessHandle = CsrGetClientThread()->Process->ProcessHandle;
50  Console->VDMClientProcess = ProcessHandle;
51 
52  Console->VDMBufferSize = RegisterVDMRequest->VDMBufferSize;
53 
54  Size = Console->VDMBufferSize.X * Console->VDMBufferSize.Y
55  * sizeof(CHAR_CELL);
56 
57  /*
58  * Create a memory section for the VDM buffer, to share with the client.
59  */
60  SectionSize.QuadPart = Size;
61  Status = NtCreateSection(&Console->VDMBufferSection,
63  NULL,
64  &SectionSize,
66  SEC_COMMIT,
67  NULL);
68  if (!NT_SUCCESS(Status))
69  {
70  DPRINT1("Error: Impossible to create a shared section, Status = 0x%08lx\n", Status);
71  goto Quit;
72  }
73 
74  /*
75  * Create a view for our needs.
76  */
77  ViewSize = 0;
78  Console->VDMBuffer = NULL;
79  Status = NtMapViewOfSection(Console->VDMBufferSection,
81  (PVOID*)&Console->VDMBuffer,
82  0,
83  0,
84  NULL,
85  &ViewSize,
86  ViewUnmap,
87  0,
89  if (!NT_SUCCESS(Status))
90  {
91  DPRINT1("Error: Impossible to map the shared section, Status = 0x%08lx\n", Status);
92  NtClose(Console->VDMBufferSection);
93  goto Quit;
94  }
95 
96  /*
97  * Create a view for the client. We must keep a trace of it so that
98  * we can unmap it when the client releases the VDM buffer.
99  */
100  ViewSize = 0;
101  Console->ClientVDMBuffer = NULL;
102  Status = NtMapViewOfSection(Console->VDMBufferSection,
104  (PVOID*)&Console->ClientVDMBuffer,
105  0,
106  0,
107  NULL,
108  &ViewSize,
109  ViewUnmap,
110  0,
112  if (!NT_SUCCESS(Status))
113  {
114  DPRINT1("Error: Impossible to map the shared section, Status = 0x%08lx\n", Status);
116  NtClose(Console->VDMBufferSection);
117  goto Quit;
118  }
119 
120  // TODO: Duplicate the event handles.
121 
122  RegisterVDMRequest->VDMBuffer = Console->ClientVDMBuffer;
123 
125  }
126  else
127  {
128  /* RegisterFlags == 0 means we are unregistering the VDM */
129 
130  // TODO: Close the duplicated handles.
131 
132  if (Console->VDMBuffer)
133  {
134  /*
135  * Uninitialize the graphics screen buffer
136  * in the reverse way we initialized it.
137  */
138  NtUnmapViewOfSection(Console->VDMClientProcess, Console->ClientVDMBuffer);
140  NtClose(Console->VDMBufferSection);
141  }
142  Console->VDMBuffer = Console->ClientVDMBuffer = NULL;
143 
144  Console->VDMBufferSize.X = Console->VDMBufferSize.Y = 0;
145  }
146 
147 Quit:
149  return Status;
150 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3780
#define TRUE
Definition: types.h:120
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:3371
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define SEC_COMMIT
Definition: mmtypes.h:99
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:3552
smooth NULL
Definition: ftsmooth.c:416
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
CConsole Console
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
return STATUS_SUCCESS
Definition: btrfs.c:2777
struct _CHAR_CELL CHAR_CELL
LONGLONG QuadPart
Definition: typedefs.h:112
#define PAGE_READWRITE
Definition: nt_native.h:1304

◆ CSR_API() [2/6]

CSR_API ( SrvVDMConsoleOperation  )

Definition at line 152 of file subsysreg.c.

153 {
154  DPRINT1("%s not yet implemented\n", __FUNCTION__);
155  return STATUS_NOT_IMPLEMENTED;
156 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [3/6]

CSR_API ( SrvRegisterConsoleOS2  )

Definition at line 163 of file subsysreg.c.

164 {
165  DPRINT1("%s not yet implemented\n", __FUNCTION__);
166  return STATUS_NOT_IMPLEMENTED;
167 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [4/6]

CSR_API ( SrvSetConsoleOS2OemFormat  )

Definition at line 169 of file subsysreg.c.

170 {
171  DPRINT1("%s not yet implemented\n", __FUNCTION__);
172  return STATUS_NOT_IMPLEMENTED;
173 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [5/6]

CSR_API ( SrvRegisterConsoleIME  )

Definition at line 180 of file subsysreg.c.

181 {
182  DPRINT1("%s not yet implemented\n", __FUNCTION__);
183  return STATUS_NOT_IMPLEMENTED;
184 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [6/6]

CSR_API ( SrvUnregisterConsoleIME  )

Definition at line 186 of file subsysreg.c.

187 {
188  DPRINT1("%s not yet implemented\n", __FUNCTION__);
189  return STATUS_NOT_IMPLEMENTED;
190 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112