ReactOS  0.4.14-dev-52-g6116262
guisettings.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _GUI_CONSOLE_INFO
 
struct  _GUI_CONSOLE_DATA
 

Macros

#define WM_APP   0x8000
 
#define PM_APPLY_CONSOLE_INFO   (WM_APP + 100)
 

Typedefs

typedef struct _GUI_CONSOLE_INFO GUI_CONSOLE_INFO
 
typedef struct _GUI_CONSOLE_INFOPGUI_CONSOLE_INFO
 
typedef struct _GUI_CONSOLE_DATA GUI_CONSOLE_DATA
 
typedef struct _GUI_CONSOLE_DATAPGUI_CONSOLE_DATA
 

Functions

BOOL GuiConsoleReadUserSettings (IN OUT PGUI_CONSOLE_INFO TermInfo, IN LPCWSTR ConsoleTitle, IN DWORD ProcessId)
 
BOOL GuiConsoleWriteUserSettings (IN OUT PGUI_CONSOLE_INFO TermInfo, IN LPCWSTR ConsoleTitle, IN DWORD ProcessId)
 
VOID GuiConsoleGetDefaultSettings (IN OUT PGUI_CONSOLE_INFO TermInfo, IN DWORD ProcessId)
 
VOID GuiConsoleShowConsoleProperties (PGUI_CONSOLE_DATA GuiData, BOOL Defaults)
 
NTSTATUS GuiApplyUserSettings (PGUI_CONSOLE_DATA GuiData, HANDLE hClientSection, BOOL SaveSettings)
 

Macro Definition Documentation

◆ PM_APPLY_CONSOLE_INFO

#define PM_APPLY_CONSOLE_INFO   (WM_APP + 100)

Definition at line 17 of file guisettings.h.

◆ WM_APP

#define WM_APP   0x8000

Definition at line 15 of file guisettings.h.

Typedef Documentation

◆ GUI_CONSOLE_DATA

◆ GUI_CONSOLE_INFO

◆ PGUI_CONSOLE_DATA

◆ PGUI_CONSOLE_INFO

Function Documentation

◆ GuiApplyUserSettings()

NTSTATUS GuiApplyUserSettings ( PGUI_CONSOLE_DATA  GuiData,
HANDLE  hClientSection,
BOOL  SaveSettings 
)

Definition at line 419 of file guisettings.c.

422 {
424  PCONSOLE Console = GuiData->Console;
425  PCONSOLE_PROCESS_DATA ProcessData;
426  HANDLE hSection = NULL;
427  ULONG ViewSize = 0;
428  PCONSOLE_PROPS pConInfo = NULL;
430  PTERMINAL_INFO TermInfo = NULL;
431  PGUI_CONSOLE_INFO GuiInfo = NULL;
432 
433  /* Get the console leader process, our client */
434  ProcessData = CONTAINING_RECORD(Console->ProcessList.Blink,
436  ConsoleLink);
437 
438  /* Duplicate the section handle for ourselves */
440  hClientSection,
442  &hSection,
443  0, 0, DUPLICATE_SAME_ACCESS);
444  if (!NT_SUCCESS(Status))
445  {
446  DPRINT1("Error when mapping client handle, Status = %lu\n", Status);
447  return Status;
448  }
449 
450  /* Get a view of the shared section */
453  (PVOID*)&pConInfo,
454  0,
455  0,
456  NULL,
457  &ViewSize,
458  ViewUnmap,
459  0,
460  PAGE_READONLY);
461  if (!NT_SUCCESS(Status))
462  {
463  DPRINT1("Error when mapping view of file, Status = %lu\n", Status);
464  NtClose(hSection);
465  return Status;
466  }
467 
468  _SEH2_TRY
469  {
470  /* Check that the section is well-sized */
471  if ( (ViewSize < sizeof(CONSOLE_PROPS)) ||
472  (pConInfo->TerminalInfo.Size != sizeof(GUI_CONSOLE_INFO)) ||
473  (ViewSize < sizeof(CONSOLE_PROPS) + pConInfo->TerminalInfo.Size) )
474  {
475  DPRINT1("Error: section bad-sized: sizeof(Section) < sizeof(CONSOLE_PROPS) + sizeof(Terminal_specific_info)\n");
477  _SEH2_YIELD(goto Quit);
478  }
479 
480  // TODO: Check that GuiData->hWindow == pConInfo->hConsoleWindow
481 
482  /* Retrieve terminal informations */
483  ConInfo = &pConInfo->ci;
484  TermInfo = &pConInfo->TerminalInfo;
485  GuiInfo = TermInfo->TermInfo = (PVOID)((ULONG_PTR)pConInfo + (ULONG_PTR)TermInfo->TermInfo);
486 
487  /*
488  * If we don't set the default parameters,
489  * apply them, otherwise just save them.
490  */
491  if (pConInfo->ShowDefaultParams == FALSE)
492  {
493  /* Set the console informations */
495 
496  /* Set the terminal informations */
497 
498  // memcpy(&GuiData->GuiInfo, GuiInfo, sizeof(GUI_CONSOLE_INFO));
499 
500  /* Move the window to the user's values */
501  GuiData->GuiInfo.AutoPosition = GuiInfo->AutoPosition;
502  GuiData->GuiInfo.WindowOrigin = GuiInfo->WindowOrigin;
503  GuiConsoleMoveWindow(GuiData);
504 
505  InvalidateRect(GuiData->hWindow, NULL, TRUE);
506 
507  /*
508  * Apply full-screen mode.
509  */
510  GuiData->GuiInfo.FullScreen = GuiInfo->FullScreen;
511  // TODO: Apply it really
512  }
513 
514  /*
515  * Save settings if needed
516  */
517  // FIXME: Do it in the console properties applet ??
518  if (SaveSettings)
519  {
523  }
524 
526  }
528  {
530  DPRINT1("GuiApplyUserSettings - Caught an exception, Status = %08X\n", Status);
531  }
532  _SEH2_END;
533 
534 Quit:
535  /* Finally, close the section and return */
537  NtClose(hSection);
538  return Status;
539 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3782
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define HandleToUlong(h)
Definition: basetsd.h:79
BOOL ConSrvWriteUserSettings(IN PCONSOLE_INFO ConsoleInfo, IN DWORD ProcessId)
Definition: settings.c:321
PVOID TermInfo
Definition: settings.h:20
ULONG Size
Definition: settings.h:19
HANDLE UniqueProcess
Definition: compat.h:474
_SEH2_TRY
Definition: create.c:4250
uint32_t ULONG_PTR
Definition: typedefs.h:63
void SaveSettings(void)
Definition: settings.c:113
#define DUPLICATE_SAME_ACCESS
BOOL ShowDefaultParams
Definition: settings.h:63
TERMINAL_INFO TerminalInfo
Definition: settings.h:69
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
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HANDLE ProcessHandle
Definition: csrsrv.h:46
VOID ConSrvApplyUserSettings(IN PCONSOLE Console, IN PCONSOLE_STATE_INFO ConsoleInfo)
Definition: settings.c:34
smooth NULL
Definition: ftsmooth.c:416
CLIENT_ID ClientId
Definition: csrsrv.h:38
void * PVOID
Definition: retypes.h:9
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define NtCurrentProcess()
Definition: nt_native.h:1657
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
PCSR_PROCESS Process
Definition: consrv.h:43
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
CONSOLE_INFO ci
Definition: settings.h:68
Status
Definition: gdiplustypes.h:24
#define STATUS_INVALID_VIEW_SIZE
Definition: ntstatus.h:254
_SEH2_END
Definition: create.c:4424
VOID GuiConsoleMoveWindow(PGUI_CONSOLE_DATA GuiData)
Definition: guiterm.c:61
PCONSOLE_STATE_INFO ConInfo
Definition: console.c:23
#define PAGE_READONLY
Definition: compat.h:127
WCHAR ConsoleTitle[ANYSIZE_ARRAY]
Definition: settings.h:58
CConsole Console
#define DPRINT1
Definition: precomp.h:8
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
BOOL GuiConsoleWriteUserSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
Definition: guisettings.c:31
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:3407
_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
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2966
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3234

◆ GuiConsoleGetDefaultSettings()

VOID GuiConsoleGetDefaultSettings ( IN OUT PGUI_CONSOLE_INFO  TermInfo,
IN DWORD  ProcessId 
)

Definition at line 183 of file guisettings.c.

185 {
186  /*******************************************************
187  * Adapted from ConSrvGetDefaultSettings in settings.c *
188  *******************************************************/
189 
190  if (TermInfo == NULL) return;
191 
192  /*
193  * 1. Load the default values
194  */
195  // wcsncpy(TermInfo->FaceName, L"DejaVu Sans Mono", LF_FACESIZE);
196  // TermInfo->FontSize = MAKELONG(12, 8); // 0x0008000C; // font is 8x12
197  // TermInfo->FontSize = MAKELONG(16, 16); // font is 16x16
198  // TermInfo->FontWeight = FW_NORMAL;
199 
200  wcsncpy(TermInfo->FaceName, L"VGA", LF_FACESIZE); // HACK: !!
201  // TermInfo->FaceName[0] = L'\0';
202  TermInfo->FontFamily = FF_DONTCARE;
203  TermInfo->FontSize = 0;
204  TermInfo->FontWeight = FW_DONTCARE;
205  TermInfo->UseRasterFonts = TRUE;
206 
207  TermInfo->FullScreen = FALSE;
208  TermInfo->ShowWindow = SW_SHOWNORMAL;
209  TermInfo->AutoPosition = TRUE;
210  TermInfo->WindowOrigin.x = 0;
211  TermInfo->WindowOrigin.y = 0;
212 
213  /*
214  * 2. Overwrite them with the ones stored in HKCU\Console.
215  * If the HKCU\Console key doesn't exist, create it
216  * and store the default values inside.
217  */
218  if (!GuiConsoleReadUserSettings(TermInfo, L"", ProcessId))
219  {
221  }
222 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
#define TRUE
Definition: types.h:120
#define LF_FACESIZE
Definition: dimm.idl:39
#define FF_DONTCARE
Definition: wingdi.h:447
smooth NULL
Definition: ftsmooth.c:416
static const WCHAR L[]
Definition: oid.c:1250
#define FW_DONTCARE
Definition: wingdi.h:367
#define SW_SHOWNORMAL
Definition: winuser.h:764
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
BOOL GuiConsoleWriteUserSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
Definition: guisettings.c:31
BOOL GuiConsoleReadUserSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
Definition: guisettings.c:24

◆ GuiConsoleReadUserSettings()

BOOL GuiConsoleReadUserSettings ( IN OUT PGUI_CONSOLE_INFO  TermInfo,
IN LPCWSTR  ConsoleTitle,
IN DWORD  ProcessId 
)

Definition at line 26 of file guisettings.c.

29 {
30  /*****************************************************
31  * Adapted from ConSrvReadUserSettings in settings.c *
32  *****************************************************/
33 
34  BOOL RetVal = FALSE;
35  HKEY hKey;
36  DWORD dwNumSubKeys = 0;
37  DWORD dwIndex;
38  DWORD dwType;
39  WCHAR szValueName[MAX_PATH];
40  DWORD dwValueName;
41  WCHAR szValue[LF_FACESIZE] = L"\0";
42  DWORD Value;
43  DWORD dwValue;
44 
46  ConsoleTitle,
47  &hKey, KEY_READ,
48  FALSE))
49  {
50  DPRINT("ConSrvOpenUserSettings failed\n");
51  return FALSE;
52  }
53 
54  if (RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
55  &dwNumSubKeys, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
56  {
57  DPRINT("GuiConsoleReadUserSettings: RegQueryInfoKey failed\n");
58  RegCloseKey(hKey);
59  return FALSE;
60  }
61 
62  DPRINT("GuiConsoleReadUserSettings entered dwNumSubKeys %d\n", dwNumSubKeys);
63 
64  for (dwIndex = 0; dwIndex < dwNumSubKeys; dwIndex++)
65  {
66  dwValue = sizeof(Value);
67  dwValueName = MAX_PATH; // sizeof(szValueName)/sizeof(szValueName[0])
68 
69  if (RegEnumValueW(hKey, dwIndex, szValueName, &dwValueName, NULL, &dwType, (BYTE*)&Value, &dwValue) != ERROR_SUCCESS)
70  {
71  if (dwType == REG_SZ)
72  {
73  /*
74  * Retry in case of string value
75  */
76  dwValue = sizeof(szValue);
77  dwValueName = MAX_PATH; // sizeof(szValueName)/sizeof(szValueName[0])
78  if (RegEnumValueW(hKey, dwIndex, szValueName, &dwValueName, NULL, NULL, (BYTE*)szValue, &dwValue) != ERROR_SUCCESS)
79  break;
80  }
81  else
82  {
83  break;
84  }
85  }
86 
87  if (!wcscmp(szValueName, L"FaceName"))
88  {
89  SIZE_T Length = min(wcslen(szValue) + 1, LF_FACESIZE); // wcsnlen
90  wcsncpy(TermInfo->FaceName, szValue, LF_FACESIZE);
91  TermInfo->FaceName[Length] = L'\0';
92  RetVal = TRUE;
93  }
94  else if (!wcscmp(szValueName, L"FontFamily"))
95  {
96  TermInfo->FontFamily = Value;
97  RetVal = TRUE;
98  }
99  else if (!wcscmp(szValueName, L"FontSize"))
100  {
101  TermInfo->FontSize = Value;
102  RetVal = TRUE;
103  }
104  else if (!wcscmp(szValueName, L"FontWeight"))
105  {
106  TermInfo->FontWeight = Value;
107  RetVal = TRUE;
108  }
109  else if (!wcscmp(szValueName, L"FullScreen"))
110  {
111  TermInfo->FullScreen = Value;
112  RetVal = TRUE;
113  }
114  else if (!wcscmp(szValueName, L"WindowPosition"))
115  {
116  TermInfo->AutoPosition = FALSE;
117  TermInfo->WindowOrigin.x = LOWORD(Value);
118  TermInfo->WindowOrigin.y = HIWORD(Value);
119  RetVal = TRUE;
120  }
121  }
122 
123  RegCloseKey(hKey);
124  return RetVal;
125 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
#define TRUE
Definition: types.h:120
#define LF_FACESIZE
Definition: dimm.idl:39
#define RegQueryInfoKey
Definition: winreg.h:521
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2853
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
ULONG_PTR SIZE_T
Definition: typedefs.h:78
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
BOOL ConSrvOpenUserSettings(DWORD ProcessId, LPCWSTR ConsoleTitle, PHKEY hSubKey, REGSAM samDesired, BOOL bCreate)
Definition: settings.c:123
#define min(a, b)
Definition: monoChain.cc:55
#define HIWORD(l)
Definition: typedefs.h:246
#define LOWORD(l)
Definition: pedump.c:82
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22

◆ GuiConsoleShowConsoleProperties()

VOID GuiConsoleShowConsoleProperties ( PGUI_CONSOLE_DATA  GuiData,
BOOL  Defaults 
)

pSharedInfo->InputBufferSize = 0;

GuiInfo->WindowPosition = GuiData->GuiInfo.WindowPosition;

WaitForSingleObject(Thread, INFINITE);

Definition at line 44 of file guisettings.c.

46 {
48  PCONSRV_CONSOLE Console = GuiData->Console;
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,
95  SEC_COMMIT,
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->HistoryBufferSize = Console->HistoryBufferSize;
136  pSharedInfo->NumberOfHistoryBuffers = Console->NumberOfHistoryBuffers;
137  pSharedInfo->HistoryNoDup = Console->HistoryNoDup;
138  pSharedInfo->QuickEdit = Console->QuickEdit;
139  pSharedInfo->InsertMode = Console->InsertMode;
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 ?
157  pSharedInfo->PopupAttributes = DEFAULT_POPUP_ATTRIB ;
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->FontFamily = GuiData->GuiInfo.FontFamily;
167  pSharedInfo->FontSize = GuiData->GuiInfo.FontSize;
168  pSharedInfo->FontWeight = GuiData->GuiInfo.FontWeight;
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 */
186  NtUnmapViewOfSection(NtCurrentProcess(), pSharedInfo);
187 
188  /* Duplicate the section handle for the client */
190  hSection,
191  ProcessData->Process->ProcessHandle,
192  &hClientSection,
193  0, 0, DUPLICATE_SAME_ACCESS);
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 */
210  _SEH2_TRY
211  {
212  HANDLE Thread = NULL;
213 
214  _SEH2_TRY
215  {
216  Thread = CreateRemoteThread(ProcessData->Process->ProcessHandle, NULL, 0,
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 
242 Quit:
243  /* We have finished, close the section handle if any */
244  if (hSection) NtClose(hSection);
245 
247  return;
248 }
PCONSOLE_PROCESS_DATA NTAPI ConSrvGetConsoleLeaderProcess(IN PCONSRV_CONSOLE Console)
Definition: console.c:867
#define DEFAULT_SCREEN_ATTRIB
Definition: settings.c:29
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3782
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define CloseHandle
Definition: compat.h:398
USHORT ScreenAttributes
Definition: settings.h:47
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
POINT WindowPosition
Definition: settings.h:34
struct _CONSOLE_STATE_INFO CONSOLE_STATE_INFO
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define TEXTMODE_BUFFER
Definition: pccons.c:21
#define PCONSRV_CONSOLE
Definition: conio.h:27
HANDLE UniqueProcess
Definition: compat.h:474
_SEH2_TRY
Definition: create.c:4250
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define DUPLICATE_SAME_ACCESS
#define SEC_COMMIT
Definition: mmtypes.h:99
#define UNICODE_NULL
COORD ScreenBufferSize
Definition: conio.h:87
COLORREF ColorTable[16]
Definition: settings.h:53
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
PCONSOLE_SCREEN_BUFFER ActiveBuffer
Definition: conwnd.h:91
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HANDLE ProcessHandle
Definition: csrsrv.h:46
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
CLIENT_ID ClientId
Definition: csrsrv.h:38
void * PVOID
Definition: retypes.h:9
#define NtCurrentProcess()
Definition: nt_native.h:1657
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG HistoryBufferSize
Definition: settings.h:50
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
PCSR_PROCESS Process
Definition: consrv.h:43
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
WCHAR FaceName[LF_FACESIZE]
Definition: settings.h:39
LPTHREAD_START_ROUTINE PropRoutine
Definition: consrv.h:53
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define DEFAULT_POPUP_ATTRIB
Definition: settings.c:30
_SEH2_END
Definition: create.c:4424
ULONG NumberOfHistoryBuffers
Definition: settings.h:51
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
_SEH2_FINALLY
Definition: create.c:4395
WCHAR FaceName[LF_FACESIZE]
Definition: guisettings.h:18
WCHAR ConsoleTitle[ANYSIZE_ARRAY]
Definition: settings.h:58
CConsole Console
#define DPRINT1
Definition: precomp.h:8
GUI_CONSOLE_INFO GuiInfo
Definition: conwnd.h:96
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:3407
_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
COORD ScreenBufferSize
Definition: settings.h:32
PCONSRV_CONSOLE Console
Definition: conwnd.h:90
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
USHORT PopupAttributes
Definition: settings.h:48
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
CONSOLE_CURSOR_INFO CursorInfo
Definition: conio.h:102
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
_In_ const BITMAPINFO _In_ UINT _In_opt_ HANDLE hSection
Definition: wingdi.h:3234
LONGLONG QuadPart
Definition: typedefs.h:112
#define PAGE_READWRITE
Definition: nt_native.h:1304
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:158

Referenced by GuiConsoleHandleSysMenuCommand(), and OnCommand().

◆ GuiConsoleWriteUserSettings()

BOOL GuiConsoleWriteUserSettings ( IN OUT PGUI_CONSOLE_INFO  TermInfo,
IN LPCWSTR  ConsoleTitle,
IN DWORD  ProcessId 
)

Definition at line 128 of file guisettings.c.

131 {
132  /******************************************************
133  * Adapted from ConSrvWriteUserSettings in settings.c *
134  ******************************************************/
135 
136  BOOL GlobalSettings = (ConsoleTitle[0] == L'\0');
137  HKEY hKey;
138  DWORD Storage = 0;
139 
140 #define SetConsoleSetting(SettingName, SettingType, SettingSize, Setting, DefaultValue) \
141 do { \
142  if (GlobalSettings || (!GlobalSettings && (*(Setting) != (DefaultValue)))) \
143  { \
144  RegSetValueExW(hKey, (SettingName), 0, (SettingType), (PBYTE)(Setting), (SettingSize)); \
145  } \
146  else \
147  { \
148  RegDeleteValue(hKey, (SettingName)); \
149  } \
150 } while (0)
151 
153  ConsoleTitle,
154  &hKey, KEY_WRITE,
155  TRUE))
156  {
157  return FALSE;
158  }
159 
160  SetConsoleSetting(L"FaceName", REG_SZ, (wcslen(TermInfo->FaceName) + 1) * sizeof(WCHAR), TermInfo->FaceName, L'\0'); // wcsnlen
161  SetConsoleSetting(L"FontFamily", REG_DWORD, sizeof(DWORD), &TermInfo->FontFamily, FF_DONTCARE);
162  SetConsoleSetting(L"FontSize", REG_DWORD, sizeof(DWORD), &TermInfo->FontSize, 0);
163  SetConsoleSetting(L"FontWeight", REG_DWORD, sizeof(DWORD), &TermInfo->FontWeight, FW_DONTCARE);
164 
165  Storage = TermInfo->FullScreen;
166  SetConsoleSetting(L"FullScreen", REG_DWORD, sizeof(DWORD), &Storage, FALSE);
167 
168  if (TermInfo->AutoPosition == FALSE)
169  {
170  Storage = MAKELONG(TermInfo->WindowOrigin.x, TermInfo->WindowOrigin.y);
171  RegSetValueExW(hKey, L"WindowPosition", 0, REG_DWORD, (PBYTE)&Storage, sizeof(DWORD));
172  }
173  else
174  {
175  RegDeleteValue(hKey, L"WindowPosition");
176  }
177 
178  RegCloseKey(hKey);
179  return TRUE;
180 }
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
#define TRUE
Definition: types.h:120
#define FF_DONTCARE
Definition: wingdi.h:447
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
#define MAKELONG(a, b)
Definition: typedefs.h:248
#define SetConsoleSetting(SettingName, SettingType, SettingSize, Setting, DefaultValue)
#define KEY_WRITE
Definition: nt_native.h:1031
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4895
#define RegDeleteValue
Definition: winreg.h:508
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define FW_DONTCARE
Definition: wingdi.h:367
BOOL ConSrvOpenUserSettings(DWORD ProcessId, LPCWSTR ConsoleTitle, PHKEY hSubKey, REGSAM samDesired, BOOL bCreate)
Definition: settings.c:123
#define REG_DWORD
Definition: sdbapi.c:596
BYTE * PBYTE
Definition: pedump.c:66
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static IStorage Storage
Definition: ole2.c:3548
NTVDM_SETTINGS GlobalSettings
Definition: ntvdm.c:25
#define REG_SZ
Definition: layer.c:22