ReactOS  0.4.15-dev-449-g64abd9f
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

 CON_API (SrvRegisterConsoleVDM, CONSOLE_REGISTERVDM, RegisterVDMRequest)
 
 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

◆ CON_API()

CON_API ( SrvRegisterConsoleVDM  ,
CONSOLE_REGISTERVDM  ,
RegisterVDMRequest   
)

Definition at line 23 of file subsysreg.c.

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,
58  SEC_COMMIT,
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,
78  ViewUnmap,
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 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3782
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:3373
LONG NTSTATUS
Definition: precomp.h:26
#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:3554
smooth NULL
Definition: ftsmooth.c:416
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:79
CConsole Console
#define DPRINT1
Definition: precomp.h:8
_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:3014
struct _CHAR_CELL CHAR_CELL
LONGLONG QuadPart
Definition: typedefs.h:113
#define PAGE_READWRITE
Definition: nt_native.h:1304

◆ CSR_API() [1/5]

CSR_API ( SrvVDMConsoleOperation  )

Definition at line 143 of file subsysreg.c.

144 {
145  DPRINT1("%s not yet implemented\n", __FUNCTION__);
146  return STATUS_NOT_IMPLEMENTED;
147 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [2/5]

CSR_API ( SrvRegisterConsoleOS2  )

Definition at line 155 of file subsysreg.c.

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

◆ CSR_API() [3/5]

CSR_API ( SrvSetConsoleOS2OemFormat  )

Definition at line 162 of file subsysreg.c.

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

◆ CSR_API() [4/5]

CSR_API ( SrvRegisterConsoleIME  )

Definition at line 174 of file subsysreg.c.

175 {
176  DPRINT1("%s not yet implemented\n", __FUNCTION__);
177  return STATUS_NOT_IMPLEMENTED;
178 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [5/5]

CSR_API ( SrvUnregisterConsoleIME  )

Definition at line 181 of file subsysreg.c.

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