Author: hbelusca
Date: Sun Apr 5 23:04:42 2015
New Revision: 67068
URL:
http://svn.reactos.org/svn/reactos?rev=67068&view=rev
Log:
[CONSRV][CONSOLE.DLL]
- Correctly retrieve/set the default console properties.
- (for console.dll only): split ApplyConsoleInfo so that it only deals with displaying the
confirmation dialog (and set the correct return value for the PSN_APPLY notification
message); the code that really sets console properties and save them in the registry is
done in the main CPL function, after the property dialog is destroyed and before the CPL
returns.
Modified:
trunk/reactos/dll/cpl/console/colors.c
trunk/reactos/dll/cpl/console/console.c
trunk/reactos/dll/cpl/console/console.h
trunk/reactos/dll/cpl/console/font.c
trunk/reactos/dll/cpl/console/options.c
trunk/reactos/win32ss/user/winsrv/concfg/settings.c
trunk/reactos/win32ss/user/winsrv/concfg/settings.h
trunk/reactos/win32ss/user/winsrv/consrv/console.c
Modified: trunk/reactos/dll/cpl/console/colors.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/console/colors.c?r…
==============================================================================
--- trunk/reactos/dll/cpl/console/colors.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/console/colors.c [iso-8859-1] Sun Apr 5 23:04:42 2015
@@ -81,17 +81,8 @@
{
case PSN_APPLY:
{
- if (!AppliedConfig)
- {
- return ApplyConsoleInfo(hwndDlg, ConInfo);
- }
- else
- {
- /* Options have already been applied */
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
- return TRUE;
- }
- break;
+ ApplyConsoleInfo(hwndDlg);
+ return TRUE;
}
case UDN_DELTAPOS:
Modified: trunk/reactos/dll/cpl/console/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/console/console.c?…
==============================================================================
--- trunk/reactos/dll/cpl/console/console.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/console/console.c [iso-8859-1] Sun Apr 5 23:04:42 2015
@@ -18,10 +18,12 @@
INT_PTR CALLBACK ColorsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
HINSTANCE hApplet = NULL;
-BOOLEAN AppliedConfig = FALSE;
-
-/* Local copy of the console informations */
+
+/* Local copy of the console information */
PCONSOLE_STATE_INFO ConInfo = NULL;
+/* What to do with the console information */
+static BOOL SetConsoleInfo = FALSE;
+static BOOL SaveConsoleInfo = FALSE;
static VOID
InitPropSheetPage(PROPSHEETPAGEW *psp,
@@ -40,8 +42,8 @@
static VOID
InitDefaultConsoleInfo(PCONSOLE_STATE_INFO pConInfo)
{
- /* FIXME: Get also the defaults from the registry */
- ConCfgInitDefaultSettings(pConInfo);
+ // FIXME: Also retrieve the value of REG_DWORD CurrentPage.
+ ConCfgGetDefaultSettings(pConInfo);
}
static INT_PTR
@@ -82,41 +84,177 @@
return FALSE;
}
-BOOL
-ApplyConsoleInfo(HWND hwndDlg,
- PCONSOLE_STATE_INFO pConInfo)
-{
- BOOL SetParams = FALSE;
- BOOL SaveParams = FALSE;
+VOID
+ApplyConsoleInfo(HWND hwndDlg)
+{
+ static BOOL ConsoleInfoAlreadySaved = FALSE;
+
+ /*
+ * We alread applied all the console properties (and saved if needed).
+ * Nothing more needs to be done.
+ */
+ if (ConsoleInfoAlreadySaved)
+ goto Done;
/*
* If we are setting the default parameters, just save them,
- * otherwise display the save-confirmation dialog.
- */
- if (pConInfo->hWnd == NULL)
- {
- SetParams = FALSE;
- SaveParams = TRUE; // FIXME: What happens if one clicks on CANCEL??
+ * otherwise display the confirmation & apply dialog.
+ */
+ if (ConInfo->hWnd == NULL)
+ {
+ SetConsoleInfo = FALSE;
+ SaveConsoleInfo = TRUE;
}
else
{
INT_PTR res = DialogBoxW(hApplet, MAKEINTRESOURCEW(IDD_APPLYOPTIONS), hwndDlg,
ApplyProc);
- SetParams = (res != IDCANCEL);
- SaveParams = (res == IDC_RADIO_APPLY_ALL);
-
- if (SetParams == FALSE)
- {
- /* Don't destroy when user presses cancel */
+ SetConsoleInfo = (res != IDCANCEL);
+ SaveConsoleInfo = (res == IDC_RADIO_APPLY_ALL);
+
+ if (SetConsoleInfo == FALSE)
+ {
+ /* Don't destroy when the user presses cancel */
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE);
- // return TRUE;
- }
- }
-
- if (SetParams)
+ return;
+ }
+ }
+
+ /*
+ * We applied all the console properties (and saved if needed).
+ * Set the flag so that if this function is called again, we won't
+ * need to redo everything again.
+ */
+ ConsoleInfoAlreadySaved = TRUE;
+
+Done:
+ /* Options have been applied */
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
+ return;
+}
+
+/* First Applet */
+static LONG
+APIENTRY
+InitApplet(HANDLE hSectionOrWnd)
+{
+ INT_PTR Result;
+ PCONSOLE_STATE_INFO pSharedInfo = NULL;
+ WCHAR szTitle[MAX_PATH + 1];
+ PROPSHEETPAGEW psp[4];
+ PROPSHEETHEADERW psh;
+ INT i = 0;
+
+ /*
+ * Because of Windows compatibility, we need to behave the same concerning
+ * information sharing with CONSRV. For some obscure reason the designers
+ * decided to use the CPlApplet hWnd parameter as being either a handle to
+ * the applet's parent caller's window (in case we ask for displaying
+ * the global console settings), or a handle to a shared section holding
+ * a CONSOLE_STATE_INFO structure (they don't use the extra l/wParams).
+ */
+
+ /*
+ * Try to open the shared section via the handle parameter. If we succeed,
+ * it means we were called by CONSRV for retrieving/setting parameters for
+ * a given console. If we fail, it means we are retrieving/setting default
+ * global parameters (and we were either called by CONSRV or directly by
+ * the user via the Control Panel, etc...)
+ */
+ pSharedInfo = MapViewOfFile(hSectionOrWnd, FILE_MAP_READ, 0, 0, 0);
+ if (pSharedInfo != NULL)
+ {
+ /*
+ * We succeeded. We were called by CONSRV and are retrieving
+ * parameters for a given console.
+ */
+
+ /* Copy the shared data into our allocated buffer */
+ DPRINT1("pSharedInfo->cbSize == %lu ; sizeof(CONSOLE_STATE_INFO) ==
%u\n",
+ pSharedInfo->cbSize, sizeof(CONSOLE_STATE_INFO));
+ ASSERT(pSharedInfo->cbSize >= sizeof(CONSOLE_STATE_INFO));
+
+ /* Allocate a local buffer to hold console information */
+ ConInfo = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ pSharedInfo->cbSize);
+ if (ConInfo)
+ RtlCopyMemory(ConInfo, pSharedInfo, pSharedInfo->cbSize);
+
+ /* Close the section */
+ UnmapViewOfFile(pSharedInfo);
+ CloseHandle(hSectionOrWnd);
+
+ if (!ConInfo) return 0;
+ }
+ else
+ {
+ /*
+ * We failed. We are retrieving the default global parameters.
+ */
+
+ /* Allocate a local buffer to hold console information */
+ ConInfo = HeapAlloc(GetProcessHeap(),
+ HEAP_ZERO_MEMORY,
+ sizeof(CONSOLE_STATE_INFO));
+ if (!ConInfo) return 0;
+
+ /*
+ * Setting the console window handle to NULL indicates we are
+ * retrieving/setting the default console parameters.
+ */
+ ConInfo->hWnd = NULL;
+ ConInfo->ConsoleTitle[0] = UNICODE_NULL;
+
+ /* Use defaults */
+ InitDefaultConsoleInfo(ConInfo);
+ }
+
+ /* Initialize the property sheet structure */
+ ZeroMemory(&psh, sizeof(psh));
+ psh.dwSize = sizeof(psh);
+ psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | /* PSH_USEHICON */ PSH_USEICONID |
PSH_NOAPPLYNOW;
+
+ if (ConInfo->ConsoleTitle[0] != UNICODE_NULL)
+ {
+ wcsncpy(szTitle, L"\"", MAX_PATH);
+ wcsncat(szTitle, ConInfo->ConsoleTitle, MAX_PATH - wcslen(szTitle));
+ wcsncat(szTitle, L"\"", MAX_PATH - wcslen(szTitle));
+ }
+ else
+ {
+ wcscpy(szTitle, L"ReactOS Console");
+ }
+ psh.pszCaption = szTitle;
+
+ if (/* pSharedInfo != NULL && */ ConInfo->hWnd != NULL)
+ {
+ /* We were started from a console window: this is our parent. */
+ psh.hwndParent = ConInfo->hWnd;
+ }
+ else
+ {
+ /* We were started in another way (--> default parameters). Caller's
window is our parent. */
+ psh.hwndParent = (HWND)hSectionOrWnd;
+ }
+
+ psh.hInstance = hApplet;
+ // psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCEW(IDC_CPLICON));
+ psh.pszIcon = MAKEINTRESOURCEW(IDC_CPLICON);
+ psh.nPages = ARRAYSIZE(psp);
+ psh.nStartPage = 0;
+ psh.ppsp = psp;
+
+ InitPropSheetPage(&psp[i++], IDD_PROPPAGEOPTIONS, OptionsProc);
+ InitPropSheetPage(&psp[i++], IDD_PROPPAGEFONT , FontProc );
+ InitPropSheetPage(&psp[i++], IDD_PROPPAGELAYOUT , LayoutProc );
+ InitPropSheetPage(&psp[i++], IDD_PROPPAGECOLORS , ColorsProc );
+
+ Result = PropertySheetW(&psh);
+
+ if (SetConsoleInfo)
{
HANDLE hSection;
- PCONSOLE_STATE_INFO pSharedInfo;
/*
* Create a memory section to share with CONSRV, and map it.
@@ -125,12 +263,12 @@
NULL,
PAGE_READWRITE,
0,
- pConInfo->cbSize,
+ ConInfo->cbSize,
NULL);
if (!hSection)
{
DPRINT1("Error when creating file mapping, error = %d\n",
GetLastError());
- return FALSE;
+ goto Quit;
}
pSharedInfo = MapViewOfFile(hSection, FILE_MAP_ALL_ACCESS, 0, 0, 0);
@@ -138,21 +276,17 @@
{
DPRINT1("Error when mapping view of file, error = %d\n",
GetLastError());
CloseHandle(hSection);
- return FALSE;
- }
-
- /* We are applying the chosen configuration */
- AppliedConfig = TRUE;
+ goto Quit;
+ }
/* Copy the console information into the section */
- RtlCopyMemory(pSharedInfo, pConInfo, pConInfo->cbSize);
+ RtlCopyMemory(pSharedInfo, ConInfo, ConInfo->cbSize);
/* Unmap it */
UnmapViewOfFile(pSharedInfo);
/* Signal to CONSRV that it can apply the new configuration */
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
- SendMessage(pConInfo->hWnd,
+ SendMessage(ConInfo->hWnd,
WM_SETCONSOLEINFO,
(WPARAM)hSection, 0);
@@ -160,133 +294,13 @@
CloseHandle(hSection);
}
- if (SaveParams)
- {
- ConCfgWriteUserSettings(pConInfo);
- }
-
- return TRUE;
-}
-
-/* First Applet */
-static LONG
-APIENTRY
-InitApplet(HANDLE hSectionOrWnd)
-{
- INT_PTR Result;
- PCONSOLE_STATE_INFO pSharedInfo = NULL;
- WCHAR szTitle[MAX_PATH + 1];
- PROPSHEETPAGEW psp[4];
- PROPSHEETHEADERW psh;
- INT i = 0;
-
- /*
- * Because of Windows compatibility, we need to behave the same concerning
- * information sharing with CONSRV. For some obscure reason the designers
- * decided to use the CPlApplet hWnd parameter as being either a handle to
- * the applet's parent caller's window (in case we ask for displaying
- * the global console settings), or a handle to a shared section holding
- * a CONSOLE_STATE_INFO structure (they don't use the extra l/wParams).
- */
-
- /*
- * Try to open the shared section via the handle parameter. If we succeed,
- * it means we were called by CONSRV for retrieving/setting parameters for
- * a given console. If we fail, it means we are retrieving/setting default
- * global parameters (and we were either called by CONSRV or directly by
- * the user via the Control Panel, etc...)
- */
- pSharedInfo = MapViewOfFile(hSectionOrWnd, FILE_MAP_READ, 0, 0, 0);
- if (pSharedInfo != NULL)
- {
- /*
- * We succeeded. We were called by CONSRV and are retrieving
- * parameters for a given console.
- */
-
- /* Copy the shared data into our allocated buffer */
- DPRINT1("pSharedInfo->cbSize == %lu ; sizeof(CONSOLE_STATE_INFO) ==
%u\n",
- pSharedInfo->cbSize, sizeof(CONSOLE_STATE_INFO));
- ASSERT(pSharedInfo->cbSize >= sizeof(CONSOLE_STATE_INFO));
-
- /* Allocate a local buffer to hold console information */
- ConInfo = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- pSharedInfo->cbSize);
- if (ConInfo)
- RtlCopyMemory(ConInfo, pSharedInfo, pSharedInfo->cbSize);
-
- /* Close the section */
- UnmapViewOfFile(pSharedInfo);
- CloseHandle(hSectionOrWnd);
-
- if (!ConInfo) return 0;
- }
- else
- {
- /*
- * We failed. We are retrieving the default global parameters.
- */
-
- /* Allocate a local buffer to hold console information */
- ConInfo = HeapAlloc(GetProcessHeap(),
- HEAP_ZERO_MEMORY,
- sizeof(CONSOLE_STATE_INFO));
- if (!ConInfo) return 0;
-
- /*
- * Setting the console window handle to NULL indicates we are
- * retrieving/setting the default console parameters.
- */
- ConInfo->hWnd = NULL;
- ConInfo->ConsoleTitle[0] = UNICODE_NULL;
-
- /* Use defaults */
- InitDefaultConsoleInfo(ConInfo);
- }
-
- /* Initialize the property sheet structure */
- ZeroMemory(&psh, sizeof(psh));
- psh.dwSize = sizeof(psh);
- psh.dwFlags = PSH_PROPSHEETPAGE | PSH_PROPTITLE | /* PSH_USEHICON */ PSH_USEICONID |
PSH_NOAPPLYNOW;
-
- if (ConInfo->ConsoleTitle[0] != UNICODE_NULL)
- {
- wcsncpy(szTitle, L"\"", MAX_PATH);
- wcsncat(szTitle, ConInfo->ConsoleTitle, MAX_PATH - wcslen(szTitle));
- wcsncat(szTitle, L"\"", MAX_PATH - wcslen(szTitle));
- }
- else
- {
- wcscpy(szTitle, L"ReactOS Console");
- }
- psh.pszCaption = szTitle;
-
- if (/* pSharedInfo != NULL && */ ConInfo->hWnd != NULL)
- {
- /* We were started from a console window: this is our parent. */
- psh.hwndParent = ConInfo->hWnd;
- }
- else
- {
- /* We were started in another way (--> default parameters). Caller's
window is our parent. */
- psh.hwndParent = (HWND)hSectionOrWnd;
- }
-
- psh.hInstance = hApplet;
- // psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCEW(IDC_CPLICON));
- psh.pszIcon = MAKEINTRESOURCEW(IDC_CPLICON);
- psh.nPages = ARRAYSIZE(psp);
- psh.nStartPage = 0;
- psh.ppsp = psp;
-
- InitPropSheetPage(&psp[i++], IDD_PROPPAGEOPTIONS, OptionsProc);
- InitPropSheetPage(&psp[i++], IDD_PROPPAGEFONT , FontProc );
- InitPropSheetPage(&psp[i++], IDD_PROPPAGELAYOUT , LayoutProc );
- InitPropSheetPage(&psp[i++], IDD_PROPPAGECOLORS , ColorsProc );
-
- Result = PropertySheetW(&psh);
-
+ if (SaveConsoleInfo)
+ {
+ /* Default settings saved when ConInfo->hWnd == NULL */
+ ConCfgWriteUserSettings(ConInfo, ConInfo->hWnd == NULL);
+ }
+
+Quit:
/* Cleanup */
HeapFree(GetProcessHeap(), 0, ConInfo);
ConInfo = NULL;
Modified: trunk/reactos/dll/cpl/console/console.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/console/console.h?…
==============================================================================
--- trunk/reactos/dll/cpl/console/console.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/console/console.h [iso-8859-1] Sun Apr 5 23:04:42 2015
@@ -29,10 +29,9 @@
} TEXT_TYPE;
/* Globals */
-extern BOOLEAN AppliedConfig;
extern PCONSOLE_STATE_INFO ConInfo;
-BOOL ApplyConsoleInfo(HWND hwndDlg, PCONSOLE_STATE_INFO pConInfo);
+VOID ApplyConsoleInfo(HWND hwndDlg);
VOID PaintConsole(LPDRAWITEMSTRUCT drawItem, PCONSOLE_STATE_INFO pConInfo);
BOOL PaintText(LPDRAWITEMSTRUCT drawItem, PCONSOLE_STATE_INFO pConInfo, TEXT_TYPE
TextMode);
Modified: trunk/reactos/dll/cpl/console/font.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/console/font.c?rev…
==============================================================================
--- trunk/reactos/dll/cpl/console/font.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/console/font.c [iso-8859-1] Sun Apr 5 23:04:42 2015
@@ -421,17 +421,8 @@
{
case PSN_APPLY:
{
- if (!AppliedConfig)
- {
- return ApplyConsoleInfo(hwndDlg, ConInfo);
- }
- else
- {
- /* Options have already been applied */
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
- return TRUE;
- }
- break;
+ ApplyConsoleInfo(hwndDlg);
+ return TRUE;
}
}
Modified: trunk/reactos/dll/cpl/console/options.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/console/options.c?…
==============================================================================
--- trunk/reactos/dll/cpl/console/options.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/console/options.c [iso-8859-1] Sun Apr 5 23:04:42 2015
@@ -127,16 +127,8 @@
}
else if (lppsn->hdr.code == PSN_APPLY)
{
- if (!AppliedConfig)
- {
- return ApplyConsoleInfo(hwndDlg, ConInfo);
- }
- else
- {
- /* Options have already been applied */
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
- return TRUE;
- }
+ ApplyConsoleInfo(hwndDlg);
+ return TRUE;
}
break;
}
Modified: trunk/reactos/win32ss/user/winsrv/concfg/settings.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/concfg…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/concfg/settings.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/concfg/settings.c [iso-8859-1] Sun Apr 5 23:04:42
2015
@@ -115,13 +115,13 @@
while ((DestString = wcschr(DestString, PATH_SEPARATOR))) *DestString =
L'_';
}
-BOOL
+BOOLEAN
ConCfgOpenUserSettings(LPCWSTR ConsoleTitle,
PHKEY hSubKey,
REGSAM samDesired,
- BOOL bCreate)
-{
- BOOL bRet = TRUE;
+ BOOLEAN Create)
+{
+ BOOLEAN RetVal = TRUE;
NTSTATUS Status;
WCHAR szBuffer[MAX_PATH] = L"Console\\";
WCHAR szBuffer2[MAX_PATH] = L"";
@@ -161,37 +161,38 @@
wcsncat(szBuffer, szBuffer2, MAX_PATH - wcslen(szBuffer) - 1);
/* Create or open the registry key */
- if (bCreate)
+ if (Create)
{
/* Create the key */
- bRet = (RegCreateKeyExW(hKey,
+ RetVal = (RegCreateKeyExW(hKey,
+ szBuffer,
+ 0, NULL,
+ REG_OPTION_NON_VOLATILE,
+ samDesired,
+ NULL,
+ hSubKey,
+ NULL) == ERROR_SUCCESS);
+ }
+ else
+ {
+ /* Open the key */
+ RetVal = (RegOpenKeyExW(hKey,
szBuffer,
- 0, NULL,
- REG_OPTION_NON_VOLATILE,
+ 0,
samDesired,
- NULL,
- hSubKey,
- NULL) == ERROR_SUCCESS);
- }
- else
- {
- /* Open the key */
- bRet = (RegOpenKeyExW(hKey,
- szBuffer,
- 0,
- samDesired,
- hSubKey) == ERROR_SUCCESS);
+ hSubKey) == ERROR_SUCCESS);
}
/* Close the parent key and return success or not */
NtClose(hKey);
- return bRet;
+ return RetVal;
}
-BOOL
-ConCfgReadUserSettings(IN OUT PCONSOLE_STATE_INFO ConsoleInfo)
-{
- BOOL RetVal = FALSE;
+BOOLEAN
+ConCfgReadUserSettings(IN OUT PCONSOLE_STATE_INFO ConsoleInfo,
+ IN BOOLEAN DefaultSettings)
+{
+ BOOLEAN RetVal = FALSE;
HKEY hKey;
DWORD dwNumSubKeys = 0;
DWORD dwIndex;
@@ -203,9 +204,8 @@
DWORD Value;
DWORD dwValue;
- if (!ConCfgOpenUserSettings(ConsoleInfo->ConsoleTitle,
- &hKey, KEY_READ,
- FALSE))
+ if (!ConCfgOpenUserSettings(DefaultSettings ? L"" :
ConsoleInfo->ConsoleTitle,
+ &hKey, KEY_READ, FALSE))
{
DPRINT("ConCfgOpenUserSettings failed\n");
return FALSE;
@@ -346,16 +346,16 @@
return RetVal;
}
-BOOL
-ConCfgWriteUserSettings(IN PCONSOLE_STATE_INFO ConsoleInfo)
-{
- BOOL GlobalSettings = (ConsoleInfo->ConsoleTitle[0] == L'\0'); // FIXME
+BOOLEAN
+ConCfgWriteUserSettings(IN PCONSOLE_STATE_INFO ConsoleInfo,
+ IN BOOLEAN DefaultSettings)
+{
HKEY hKey;
DWORD Storage = 0;
#define SetConsoleSetting(SettingName, SettingType, SettingSize, Setting, DefaultValue)
\
do {
\
- if (GlobalSettings || (!GlobalSettings && (*(Setting) != (DefaultValue))))
\
+ if (DefaultSettings || (!DefaultSettings && (*(Setting) != (DefaultValue))))
\
{
\
RegSetValueExW(hKey, (SettingName), 0, (SettingType), (PBYTE)(Setting),
(SettingSize)); \
}
\
@@ -368,9 +368,8 @@
WCHAR szValueName[15];
UINT i;
- if (!ConCfgOpenUserSettings(ConsoleInfo->ConsoleTitle,
- &hKey, KEY_WRITE,
- TRUE))
+ if (!ConCfgOpenUserSettings(DefaultSettings ? L"" :
ConsoleInfo->ConsoleTitle,
+ &hKey, KEY_WRITE, TRUE))
{
return FALSE;
}
@@ -489,9 +488,6 @@
RtlCopyMemory(ConsoleInfo->ColorTable, s_Colors, sizeof(s_Colors));
ConsoleInfo->CodePage = 0;
-
- /* Default settings --> console title is NULL */
- ConsoleInfo->ConsoleTitle[0] = UNICODE_NULL;
}
VOID
@@ -509,8 +505,8 @@
* If the HKCU\Console key doesn't exist, create it
* and store the default values inside.
*/
- if (!ConCfgReadUserSettings(ConsoleInfo))
- ConCfgWriteUserSettings(ConsoleInfo);
+ if (!ConCfgReadUserSettings(ConsoleInfo, TRUE))
+ ConCfgWriteUserSettings(ConsoleInfo, TRUE);
}
/* EOF */
Modified: trunk/reactos/win32ss/user/winsrv/concfg/settings.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/concfg…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/concfg/settings.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/concfg/settings.h [iso-8859-1] Sun Apr 5 23:04:42
2015
@@ -75,13 +75,18 @@
/* FUNCTIONS ******************************************************************/
-BOOL ConCfgOpenUserSettings(LPCWSTR ConsoleTitle,
- PHKEY hSubKey,
- REGSAM samDesired,
- BOOL bCreate);
+BOOLEAN
+ConCfgOpenUserSettings(LPCWSTR ConsoleTitle,
+ PHKEY hSubKey,
+ REGSAM samDesired,
+ BOOLEAN Create);
+BOOLEAN
+ConCfgReadUserSettings(IN OUT PCONSOLE_STATE_INFO ConsoleInfo,
+ IN BOOLEAN DefaultSettings);
+BOOLEAN
+ConCfgWriteUserSettings(IN PCONSOLE_STATE_INFO ConsoleInfo,
+ IN BOOLEAN DefaultSettings);
-BOOL ConCfgReadUserSettings(IN OUT PCONSOLE_STATE_INFO ConsoleInfo);
-BOOL ConCfgWriteUserSettings(IN PCONSOLE_STATE_INFO ConsoleInfo);
VOID ConCfgInitDefaultSettings(IN OUT PCONSOLE_STATE_INFO ConsoleInfo);
VOID ConCfgGetDefaultSettings(IN OUT PCONSOLE_STATE_INFO ConsoleInfo);
Modified: trunk/reactos/win32ss/user/winsrv/consrv/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/console.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/console.c [iso-8859-1] Sun Apr 5 23:04:42
2015
@@ -535,24 +535,24 @@
/*
* Load the console settings
*/
-
- /* Impersonate the caller in order to retrieve settings in its context */
- if (!CsrImpersonateClient(NULL))
- return STATUS_BAD_IMPERSONATION_LEVEL;
-
- /* 1. Load the default settings */
RtlZeroMemory(ConsoleInfo, sizeof(ConsoleInfoBuffer));
ConsoleInfo->cbSize = sizeof(ConsoleInfoBuffer);
- ConCfgGetDefaultSettings(ConsoleInfo);
-
- /* 2. Get the title of the console (initialize ConsoleInfo->ConsoleTitle) */
+
+ /* 1. Get the title of the console (initialize ConsoleInfo->ConsoleTitle) */
Length = min(ConsoleInitInfo->TitleLength,
(ConsoleInfo->cbSize - FIELD_OFFSET(CONSOLE_STATE_INFO, ConsoleTitle)
- sizeof(UNICODE_NULL)) / sizeof(WCHAR));
wcsncpy(ConsoleInfo->ConsoleTitle, ConsoleInitInfo->ConsoleTitle, Length);
ConsoleInfo->ConsoleTitle[Length] = UNICODE_NULL; // NULL-terminate it.
+ /* 2. Impersonate the caller in order to retrieve settings in its context */
+ if (!CsrImpersonateClient(NULL))
+ return STATUS_BAD_IMPERSONATION_LEVEL;
+
+ /* 3. Load the default settings */
+ ConCfgGetDefaultSettings(ConsoleInfo);
+
/*
- * 3. Load per-application terminal settings.
+ * 4. Load per-application terminal settings.
*
* Check whether the process creating the console was launched via
* a shell-link. ConsoleInfo->ConsoleTitle may be updated with the
@@ -567,7 +567,7 @@
}
/*
- * 4. Load the remaining console settings via the registry.
+ * 5. Load the remaining console settings via the registry.
*/
if ((ConsoleInitInfo->ConsoleStartInfo->dwStartupFlags &
STARTF_TITLEISLINKNAME) == 0)
{
@@ -576,7 +576,7 @@
* or we failed to load shell-link console properties.
* Therefore, load the console infos for the application from the registry.
*/
- ConCfgReadUserSettings(ConsoleInfo);
+ ConCfgReadUserSettings(ConsoleInfo, FALSE);
/*
* Now, update them with the properties the user might gave to us
@@ -617,7 +617,7 @@
#endif
}
- /* Revert impersonation */
+ /* 6. Revert impersonation */
CsrRevertToSelf();
/* Set-up the code page */
@@ -1044,7 +1044,7 @@
PROCESS_BASIC_INFORMATION ProcessInfo;
ULONG Length = sizeof(ProcessInfo);
- /* Get the real parent's ID */
+ /* Get the real parent's PID */
Status = NtQueryInformationProcess(TargetProcess->ProcessHandle,
ProcessBasicInformation,