ReactOS 0.4.15-dev-7889-g76290a6
guisettings.c File Reference
#include <consrv.h>
#include <debug.h>
#include "concfg/font.h"
#include "guiterm.h"
#include "guisettings.h"
Include dependency graph for guisettings.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOL GuiConsoleReadUserSettings (IN OUT PGUI_CONSOLE_INFO TermInfo)
 
BOOL GuiConsoleWriteUserSettings (IN OUT PGUI_CONSOLE_INFO TermInfo)
 
VOID GuiConsoleGetDefaultSettings (IN OUT PGUI_CONSOLE_INFO TermInfo)
 
VOID GuiConsoleShowConsoleProperties (PGUI_CONSOLE_DATA GuiData, BOOL Defaults)
 
VOID GuiApplyUserSettings (PGUI_CONSOLE_DATA GuiData, HANDLE hClientSection)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file guisettings.c.

Function Documentation

◆ GuiApplyUserSettings()

VOID GuiApplyUserSettings ( PGUI_CONSOLE_DATA  GuiData,
HANDLE  hClientSection 
)

Definition at line 258 of file guisettings.c.

260{
263 PCONSOLE_PROCESS_DATA ProcessData;
265 SIZE_T ViewSize = 0;
266 PCONSOLE_STATE_INFO pConInfo = NULL;
267
269
270 /* Get the console leader process, our client */
272
273 /* Duplicate the section handle for ourselves */
275 hClientSection,
277 &hSection,
279 if (!NT_SUCCESS(Status))
280 {
281 DPRINT1("Error when mapping client handle, Status = 0x%08lx\n", Status);
282 goto Quit;
283 }
284
285 /* Get a view of the shared section */
288 (PVOID*)&pConInfo,
289 0,
290 0,
291 NULL,
292 &ViewSize,
293 ViewUnmap,
294 0,
296 if (!NT_SUCCESS(Status))
297 {
298 DPRINT1("Error when mapping view of file, Status = 0x%08lx\n", Status);
299 goto Quit;
300 }
301
303 {
304 /* Check that the section is well-sized */
305 if ( (ViewSize < sizeof(CONSOLE_STATE_INFO)) ||
306 (pConInfo->cbSize < sizeof(CONSOLE_STATE_INFO)) )
307 {
308 DPRINT1("Error: section bad-sized: sizeof(Section) < sizeof(CONSOLE_STATE_INFO)\n");
310 _SEH2_YIELD(goto Quit);
311 }
312
313 // TODO: Check that GuiData->hWindow == pConInfo->hWnd
314
315 /* Console information */
316
317 /*
318 * Apply the settings
319 */
320
321 /* Refresh the additional TrueType fonts cache now,
322 * as ConSrvApplyUserSettings() could change the output
323 * code page and trigger a font change in the terminal. */
325
326 /* Apply the generic console settings */
328
329 /* Set the terminal settings */
330
331 /* Now, attempt to change the font to what the user specified */
332 InitFonts(GuiData,
333 pConInfo->FaceName,
334 pConInfo->FontWeight,
335 pConInfo->FontFamily,
336 pConInfo->FontSize,
337 0, FALSE);
338
339 /* Move the window to the user's values */
340 GuiData->GuiInfo.AutoPosition = !!pConInfo->AutoPosition;
341 GuiData->GuiInfo.WindowOrigin = pConInfo->WindowPosition;
342 GuiConsoleMoveWindow(GuiData);
343
344 InvalidateRect(GuiData->hWindow, NULL, TRUE);
345
346 /*
347 * Apply full-screen mode.
348 */
349 if (!!pConInfo->FullScreen != GuiData->GuiInfo.FullScreen)
350 {
351 SwitchFullScreen(GuiData, !!pConInfo->FullScreen);
352 }
353
354 /*
355 * The settings are saved in the registry by console.dll itself, if needed.
356 */
357 // if (SaveSettings)
358 // {
359 // GuiConsoleWriteUserSettings(GuiInfo);
360 // }
361
363 }
365 {
367 DPRINT1("GuiApplyUserSettings - Caught an exception, Status = 0x%08lx\n", Status);
368 }
369 _SEH2_END;
370
371Quit:
372 /* Finally, close the section and return */
373 if (hSection)
374 {
377 }
378
380 return;
381}
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3848
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
BOOL InitFonts(_Inout_ PGUI_CONSOLE_DATA GuiData, _In_reads_or_z_(LF_FACESIZE) PCWSTR FaceName, _In_ ULONG FontWeight, _In_ ULONG FontFamily, _In_ COORD FontSize, _In_opt_ UINT CodePage, _In_ BOOL UseDefaultFallback)
Definition: conwnd.c:521
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
VOID SwitchFullScreen(PGUI_CONSOLE_DATA GuiData, BOOL FullScreen)
Definition: fullscreen.c:49
Status
Definition: gdiplustypes.h:25
VOID GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:61
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_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 PAGE_READWRITE
Definition: nt_native.h:1304
#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_INVALID_VIEW_SIZE
Definition: ntstatus.h:268
NTSTATUS NTAPI NtDuplicateObject(IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle OPTIONAL, OUT PHANDLE TargetHandle OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG HandleAttributes, IN ULONG Options)
Definition: obhandle.c:3410
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:159
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:162
#define STATUS_SUCCESS
Definition: shellext.h:65
PCSR_PROCESS Process
Definition: consrv.h:43
POINT WindowPosition
Definition: settings.h:34
WCHAR FaceName[LF_FACESIZE]
Definition: settings.h:39
HANDLE ProcessHandle
Definition: csrsrv.h:46
PCONSRV_CONSOLE Console
Definition: conwnd.h:91
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:97
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VOID RefreshTTFontCache(VOID)
Refreshes the console TrueType font cache, by clearing and re-initializing it.
Definition: font.c:1153
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:36
PCONSOLE_PROCESS_DATA NTAPI ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console)
Definition: console.c:1363
@ CONSOLE_RUNNING
Definition: conio.h:283
VOID ConSrvApplyUserSettings(IN PCONSRV_CONSOLE Console, IN PCONSOLE_STATE_INFO ConsoleInfo)
Definition: settings.c:36
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3239
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define DUPLICATE_SAME_ACCESS

Referenced by ConWndProc().

◆ GuiConsoleGetDefaultSettings()

VOID GuiConsoleGetDefaultSettings ( IN OUT PGUI_CONSOLE_INFO  TermInfo)

Definition at line 38 of file guisettings.c.

39{
40 /* Do nothing */
41}

Referenced by GuiLoadFrontEnd().

◆ GuiConsoleReadUserSettings()

BOOL GuiConsoleReadUserSettings ( IN OUT PGUI_CONSOLE_INFO  TermInfo)

Definition at line 24 of file guisettings.c.

25{
26 /* Do nothing */
27 return TRUE;
28}

Referenced by GuiLoadFrontEnd().

◆ GuiConsoleShowConsoleProperties()

VOID GuiConsoleShowConsoleProperties ( PGUI_CONSOLE_DATA  GuiData,
BOOL  Defaults 
)

pSharedInfo->InputBufferSize = 0;

Definition at line 44 of file guisettings.c.

46{
49 PCONSOLE_PROCESS_DATA ProcessData;
50 HANDLE hSection = NULL, hClientSection = NULL;
51 PVOID ThreadParameter = NULL; // Is either hClientSection or the console window handle,
52 // depending on whether we display the default settings or
53 // the settings of a particular console.
54
55 DPRINT("GuiConsoleShowConsoleProperties entered\n");
56
58
59 /* Get the console leader process, our client */
61
62 /*
63 * Be sure we effectively have a properties dialog routine (that launches
64 * the console control panel applet). It resides in kernel32.dll (client).
65 */
66 if (ProcessData->PropRoutine == NULL) goto Quit;
67
68 /*
69 * Create a memory section to be shared with the console control panel applet
70 * in the case we are displaying the settings of a particular console.
71 * In that case the ThreadParameter is the hClientSection handle.
72 * In the case we display the default console parameters, we don't need to
73 * create a memory section. We just need to open the applet, and in this case
74 * the ThreadParameter is the parent window handle of the applet's window,
75 * that is, the console window.
76 */
77 if (!Defaults)
78 {
79 PCONSOLE_SCREEN_BUFFER ActiveBuffer = GuiData->ActiveBuffer;
80 LARGE_INTEGER SectionSize;
81 SIZE_T ViewSize = 0;
82 PCONSOLE_STATE_INFO pSharedInfo = NULL;
83
84 /*
85 * Create a memory section to share with the applet, and map it.
86 */
87 SectionSize.QuadPart = sizeof(CONSOLE_STATE_INFO); // Standard size
88 SectionSize.QuadPart += Console->OriginalTitle.Length; // Add the length in bytes of the console title string
89
92 NULL,
93 &SectionSize,
96 NULL);
97 if (!NT_SUCCESS(Status))
98 {
99 DPRINT1("Error: Impossible to create a shared section, Status = 0x%08lx\n", Status);
100 goto Quit;
101 }
102
105 (PVOID*)&pSharedInfo,
106 0,
107 0,
108 NULL,
109 &ViewSize,
110 ViewUnmap,
111 0,
113 if (!NT_SUCCESS(Status))
114 {
115 DPRINT1("Error: Impossible to map the shared section, Status = 0x%08lx\n", Status);
116 goto Quit;
117 }
118
119
120 /*
121 * Setup the shared console properties structure.
122 */
123
124 /* Store the real size of the structure */
125 pSharedInfo->cbSize = SectionSize.QuadPart;
126
127 /*
128 * When we setup the settings of a particular console, the parent window
129 * of the applet's window is the console window, and it is given via the
130 * hWnd member of the shared console info structure.
131 */
132 pSharedInfo->hWnd = GuiData->hWindow;
133
134 /* Console information */
135 pSharedInfo->QuickEdit = Console->QuickEdit;
136 pSharedInfo->InsertMode = Console->InsertMode;
137 pSharedInfo->NumberOfHistoryBuffers = Console->MaxNumberOfHistoryBuffers;
138 pSharedInfo->HistoryBufferSize = Console->HistoryBufferSize;
139 pSharedInfo->HistoryNoDup = Console->HistoryNoDup;
141 pSharedInfo->ScreenBufferSize = ActiveBuffer->ScreenBufferSize;
142 pSharedInfo->WindowSize = ActiveBuffer->ViewSize;
143 pSharedInfo->CursorSize = ActiveBuffer->CursorInfo.dwSize;
144 if (GetType(ActiveBuffer) == TEXTMODE_BUFFER)
145 {
147
148 pSharedInfo->ScreenAttributes = Buffer->ScreenDefaultAttrib;
149 pSharedInfo->PopupAttributes = Buffer->PopupDefaultAttrib;
150 }
151 else // if (GetType(ActiveBuffer) == GRAPHICS_BUFFER)
152 {
153 // PGRAPHICS_SCREEN_BUFFER Buffer = (PGRAPHICS_SCREEN_BUFFER)ActiveBuffer;
154
155 // FIXME: Gather defaults from the registry ?
158 }
159
160 /* We display the output code page only */
161 pSharedInfo->CodePage = Console->OutputCodePage;
162
163 /* GUI Information */
164 StringCchCopyNW(pSharedInfo->FaceName, ARRAYSIZE(pSharedInfo->FaceName),
165 GuiData->GuiInfo.FaceName, ARRAYSIZE(GuiData->GuiInfo.FaceName));
166 pSharedInfo->FontWeight = GuiData->GuiInfo.FontWeight;
167 pSharedInfo->FontFamily = GuiData->GuiInfo.FontFamily;
168 pSharedInfo->FontSize = GuiData->GuiInfo.FontSize;
169 pSharedInfo->FullScreen = GuiData->GuiInfo.FullScreen;
170 pSharedInfo->AutoPosition = GuiData->GuiInfo.AutoPosition;
171 pSharedInfo->WindowPosition = GuiData->GuiInfo.WindowOrigin;
172
173 /* Palette */
174 RtlCopyMemory(pSharedInfo->ColorTable,
175 Console->Colors, sizeof(Console->Colors));
176
177 /* Copy the original title of the console and null-terminate it */
178 RtlCopyMemory(pSharedInfo->ConsoleTitle,
179 Console->OriginalTitle.Buffer,
180 Console->OriginalTitle.Length);
181
182 pSharedInfo->ConsoleTitle[Console->OriginalTitle.Length / sizeof(WCHAR)] = UNICODE_NULL;
183
184
185 /* Unmap the view */
187
188 /* Duplicate the section handle for the client */
190 hSection,
191 ProcessData->Process->ProcessHandle,
192 &hClientSection,
194 if (!NT_SUCCESS(Status))
195 {
196 DPRINT1("Error: Impossible to duplicate section handle for client, Status = 0x%08lx\n", Status);
197 goto Quit;
198 }
199
200 /* For the settings of a particular console, use the shared client section handle as the thread parameter */
201 ThreadParameter = (PVOID)hClientSection;
202 }
203 else
204 {
205 /* For the default settings, use the console window handle as the thread parameter */
206 ThreadParameter = (PVOID)GuiData->hWindow;
207 }
208
209 /* Start the console control panel applet */
211 {
213
215 {
217 ProcessData->PropRoutine,
218 ThreadParameter, 0, NULL);
219 if (NULL == Thread)
220 {
221 DPRINT1("Failed thread creation (Error: 0x%x)\n", GetLastError());
222 }
223 else
224 {
225 DPRINT("ProcessData->PropRoutine remote thread creation succeeded, ProcessId = %x, Process = 0x%p\n",
226 ProcessData->Process->ClientId.UniqueProcess, ProcessData->Process);
227 }
228 }
230 {
232 }
233 _SEH2_END;
234 }
236 {
238 DPRINT1("GuiConsoleShowConsoleProperties - Caught an exception, Status = 0x%08lx\n", Status);
239 }
240 _SEH2_END;
241
242Quit:
243 /* We have finished, close the section handle if any */
245
247 return;
248}
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
Definition: bufpool.h:45
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define CloseHandle
Definition: compat.h:739
HANDLE WINAPI CreateRemoteThread(IN HANDLE hProcess, IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:159
#define _SEH2_FINALLY
Definition: filesup.c:21
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define SEC_COMMIT
Definition: mmtypes.h:100
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define UNICODE_NULL
#define TEXTMODE_BUFFER
Definition: pccons.c:21
#define DPRINT
Definition: sndvol32.h:71
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
HANDLE UniqueProcess
Definition: compat.h:825
LPTHREAD_START_ROUTINE PropRoutine
Definition: consrv.h:53
CONSOLE_CURSOR_INFO CursorInfo
Definition: conio.h:75
COORD ScreenBufferSize
Definition: conio.h:62
ULONG NumberOfHistoryBuffers
Definition: settings.h:51
ULONG HistoryBufferSize
Definition: settings.h:50
COORD ScreenBufferSize
Definition: settings.h:32
WCHAR ConsoleTitle[ANYSIZE_ARRAY]
Definition: settings.h:58
COLORREF ColorTable[16]
Definition: settings.h:53
USHORT PopupAttributes
Definition: settings.h:48
USHORT ScreenAttributes
Definition: settings.h:47
CLIENT_ID ClientId
Definition: csrsrv.h:38
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:92
WCHAR FaceName[LF_FACESIZE]
Definition: guisettings.h:18
void * PVOID
Definition: typedefs.h:50
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
LONGLONG QuadPart
Definition: typedefs.h:114
#define DEFAULT_SCREEN_ATTRIB
Definition: settings.c:29
#define DEFAULT_POPUP_ATTRIB
Definition: settings.c:30
struct _CONSOLE_STATE_INFO CONSOLE_STATE_INFO
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
#define GetType(This)
Definition: conio.h:54
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by OnCommand().

◆ GuiConsoleWriteUserSettings()

BOOL GuiConsoleWriteUserSettings ( IN OUT PGUI_CONSOLE_INFO  TermInfo)

Definition at line 31 of file guisettings.c.

32{
33 /* Do nothing */
34 return TRUE;
35}