mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:33:07 +00:00
[USERINIT]
- Use explicit unicode functions where possible. - Use ARRAYSIZE(foo) instead of sizeof(foo)/sizeof(foo[0]). - Don't hardcode some buffer sizes. - Try reducing level of code indentation in some functions. - Make StartShell and StartInstaller return a boolean (TRUE: success; FALSE: failure). Will be needed in the next commit. - Remove a useless "#pragma warning". svn path=/trunk/; revision=72821
This commit is contained in:
parent
ed8515d7ed
commit
0a81885192
2 changed files with 173 additions and 160 deletions
|
@ -18,8 +18,8 @@ InitImageInfo(PIMGINFO ImgInfo)
|
||||||
|
|
||||||
ZeroMemory(ImgInfo, sizeof(*ImgInfo));
|
ZeroMemory(ImgInfo, sizeof(*ImgInfo));
|
||||||
|
|
||||||
ImgInfo->hBitmap = LoadImage(hInstance,
|
ImgInfo->hBitmap = LoadImageW(hInstance,
|
||||||
MAKEINTRESOURCE(IDB_ROSLOGO),
|
MAKEINTRESOURCEW(IDB_ROSLOGO),
|
||||||
IMAGE_BITMAP,
|
IMAGE_BITMAP,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -27,7 +27,7 @@ InitImageInfo(PIMGINFO ImgInfo)
|
||||||
|
|
||||||
if (ImgInfo->hBitmap != NULL)
|
if (ImgInfo->hBitmap != NULL)
|
||||||
{
|
{
|
||||||
GetObject(ImgInfo->hBitmap, sizeof(BITMAP), &bitmap);
|
GetObject(ImgInfo->hBitmap, sizeof(bitmap), &bitmap);
|
||||||
|
|
||||||
ImgInfo->cxSource = bitmap.bmWidth;
|
ImgInfo->cxSource = bitmap.bmWidth;
|
||||||
ImgInfo->cySource = bitmap.bmHeight;
|
ImgInfo->cySource = bitmap.bmHeight;
|
||||||
|
@ -46,7 +46,7 @@ IsLiveCD(VOID)
|
||||||
|
|
||||||
TRACE("IsLiveCD()\n");
|
TRACE("IsLiveCD()\n");
|
||||||
|
|
||||||
rc = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
REGSTR_PATH_CURRENT_CONTROL_SET,
|
REGSTR_PATH_CURRENT_CONTROL_SET,
|
||||||
0,
|
0,
|
||||||
KEY_QUERY_VALUE,
|
KEY_QUERY_VALUE,
|
||||||
|
@ -110,7 +110,7 @@ LocalesEnumProc(LPTSTR lpLocale)
|
||||||
{
|
{
|
||||||
if (bSpain == FALSE)
|
if (bSpain == FALSE)
|
||||||
{
|
{
|
||||||
LoadStringW(hInstance, IDS_SPAIN, lang, 255);
|
LoadStringW(hInstance, IDS_SPAIN, lang, ARRAYSIZE(lang));
|
||||||
bSpain = TRUE;
|
bSpain = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -120,7 +120,7 @@ LocalesEnumProc(LPTSTR lpLocale)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GetLocaleInfoW(lcid, LOCALE_SLANGUAGE, lang, sizeof(lang)/sizeof(WCHAR));
|
GetLocaleInfoW(lcid, LOCALE_SLANGUAGE, lang, ARRAYSIZE(lang));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bNoShow == FALSE)
|
if (bNoShow == FALSE)
|
||||||
|
@ -151,7 +151,7 @@ CreateLanguagesList(HWND hwnd)
|
||||||
|
|
||||||
/* Select current locale */
|
/* Select current locale */
|
||||||
/* or should it be System and not user? */
|
/* or should it be System and not user? */
|
||||||
GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_SLANGUAGE, langSel, sizeof(langSel)/sizeof(WCHAR));
|
GetLocaleInfoW(GetUserDefaultLCID(), LOCALE_SLANGUAGE, langSel, ARRAYSIZE(langSel));
|
||||||
|
|
||||||
SendMessageW(hList,
|
SendMessageW(hList,
|
||||||
CB_SELECTSTRING,
|
CB_SELECTSTRING,
|
||||||
|
@ -170,13 +170,13 @@ GetLayoutName(
|
||||||
DWORD dwBufLen;
|
DWORD dwBufLen;
|
||||||
WCHAR szBuf[MAX_PATH], szDispName[MAX_PATH], szIndex[MAX_PATH], szPath[MAX_PATH];
|
WCHAR szBuf[MAX_PATH], szDispName[MAX_PATH], szIndex[MAX_PATH], szPath[MAX_PATH];
|
||||||
HANDLE hLib;
|
HANDLE hLib;
|
||||||
unsigned i, j, k;
|
UINT i, j, k;
|
||||||
|
|
||||||
wsprintf(szBuf, L"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s", szLCID);
|
wsprintf(szBuf, L"SYSTEM\\CurrentControlSet\\Control\\Keyboard Layouts\\%s", szLCID);
|
||||||
|
|
||||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, (LPCTSTR)szBuf, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, (LPCTSTR)szBuf, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
dwBufLen = sizeof(szBuf);
|
dwBufLen = sizeof(szDispName);
|
||||||
|
|
||||||
if (RegQueryValueExW(hKey, L"Layout Display Name", NULL, NULL, (LPBYTE)szDispName, &dwBufLen) == ERROR_SUCCESS)
|
if (RegQueryValueExW(hKey, L"Layout Display Name", NULL, NULL, (LPBYTE)szDispName, &dwBufLen) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
@ -197,12 +197,12 @@ GetLayoutName(
|
||||||
szDispName[i] = szDispName[i + 1];
|
szDispName[i] = szDispName[i + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ExpandEnvironmentStringsW(szDispName, szPath, MAX_PATH))
|
if (ExpandEnvironmentStringsW(szDispName, szPath, ARRAYSIZE(szPath)))
|
||||||
{
|
{
|
||||||
hLib = LoadLibraryW(szPath);
|
hLib = LoadLibraryW(szPath);
|
||||||
if (hLib)
|
if (hLib)
|
||||||
{
|
{
|
||||||
if (LoadStringW(hLib, _wtoi(szIndex), szPath, sizeof(szPath) / sizeof(WCHAR)) != 0)
|
if (LoadStringW(hLib, _wtoi(szIndex), szPath, ARRAYSIZE(szPath)) != 0)
|
||||||
{
|
{
|
||||||
wcscpy(szName, szPath);
|
wcscpy(szName, szPath);
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
|
@ -323,7 +323,7 @@ CreateKeyboardLayoutList(
|
||||||
|
|
||||||
while (TRUE)
|
while (TRUE)
|
||||||
{
|
{
|
||||||
dwSize = sizeof(szLayoutId) / sizeof(WCHAR);
|
dwSize = ARRAYSIZE(szLayoutId);
|
||||||
|
|
||||||
lError = RegEnumKeyExW(hKey,
|
lError = RegEnumKeyExW(hKey,
|
||||||
dwIndex,
|
dwIndex,
|
||||||
|
@ -458,10 +458,10 @@ InitializeDefaultUserLocale(
|
||||||
i = 0;
|
i = 0;
|
||||||
while (LocaleData[i].pValue != NULL)
|
while (LocaleData[i].pValue != NULL)
|
||||||
{
|
{
|
||||||
if (GetLocaleInfo(lcid,
|
if (GetLocaleInfoW(lcid,
|
||||||
LocaleData[i].LCType | LOCALE_NOUSEROVERRIDE,
|
LocaleData[i].LCType | LOCALE_NOUSEROVERRIDE,
|
||||||
szBuffer,
|
szBuffer,
|
||||||
sizeof(szBuffer) / sizeof(WCHAR)))
|
ARRAYSIZE(szBuffer)))
|
||||||
{
|
{
|
||||||
RegSetValueExW(hLocaleKey,
|
RegSetValueExW(hLocaleKey,
|
||||||
LocaleData[i].pValue,
|
LocaleData[i].pValue,
|
||||||
|
@ -515,7 +515,7 @@ OnDrawItem(
|
||||||
|
|
||||||
if (lpDrawItem->CtlID == uCtlID)
|
if (lpDrawItem->CtlID == uCtlID)
|
||||||
{
|
{
|
||||||
/* position image in centre of dialog */
|
/* Position image in centre of dialog */
|
||||||
left = (lpDrawItem->rcItem.right - pState->ImageInfo.cxSource) / 2;
|
left = (lpDrawItem->rcItem.right - pState->ImageInfo.cxSource) / 2;
|
||||||
|
|
||||||
hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
|
hdcMem = CreateCompatibleDC(lpDrawItem->hDC);
|
||||||
|
@ -549,17 +549,17 @@ LocaleDlgProc(
|
||||||
PSTATE pState;
|
PSTATE pState;
|
||||||
|
|
||||||
/* Retrieve pointer to the state */
|
/* Retrieve pointer to the state */
|
||||||
pState = (PSTATE)GetWindowLongPtr (hwndDlg, GWL_USERDATA);
|
pState = (PSTATE)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
/* Save pointer to the global state */
|
/* Save pointer to the global state */
|
||||||
pState = (PSTATE)lParam;
|
pState = (PSTATE)lParam;
|
||||||
SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pState);
|
SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (DWORD_PTR)pState);
|
||||||
|
|
||||||
/* Center the dialog window */
|
/* Center the dialog window */
|
||||||
CenterWindow (hwndDlg);
|
CenterWindow(hwndDlg);
|
||||||
|
|
||||||
/* Fill the language and keyboard layout lists */
|
/* Fill the language and keyboard layout lists */
|
||||||
CreateLanguagesList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST));
|
CreateLanguagesList(GetDlgItem(hwndDlg, IDC_LANGUAGELIST));
|
||||||
|
@ -666,14 +666,14 @@ StartDlgProc(
|
||||||
PSTATE pState;
|
PSTATE pState;
|
||||||
|
|
||||||
/* Retrieve pointer to the state */
|
/* Retrieve pointer to the state */
|
||||||
pState = (PSTATE)GetWindowLongPtr (hwndDlg, GWL_USERDATA);
|
pState = (PSTATE)GetWindowLongPtrW(hwndDlg, GWLP_USERDATA);
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
{
|
{
|
||||||
case WM_INITDIALOG:
|
case WM_INITDIALOG:
|
||||||
/* Save pointer to the state */
|
/* Save pointer to the state */
|
||||||
pState = (PSTATE)lParam;
|
pState = (PSTATE)lParam;
|
||||||
SetWindowLongPtr(hwndDlg, GWL_USERDATA, (DWORD_PTR)pState);
|
SetWindowLongPtrW(hwndDlg, GWLP_USERDATA, (DWORD_PTR)pState);
|
||||||
|
|
||||||
/* Center the dialog window */
|
/* Center the dialog window */
|
||||||
CenterWindow(hwndDlg);
|
CenterWindow(hwndDlg);
|
||||||
|
@ -734,16 +734,16 @@ RunLiveCD(
|
||||||
switch (pState->NextPage)
|
switch (pState->NextPage)
|
||||||
{
|
{
|
||||||
case LOCALEPAGE:
|
case LOCALEPAGE:
|
||||||
DialogBoxParam(hInstance,
|
DialogBoxParamW(hInstance,
|
||||||
MAKEINTRESOURCE(IDD_LOCALEPAGE),
|
MAKEINTRESOURCEW(IDD_LOCALEPAGE),
|
||||||
NULL,
|
NULL,
|
||||||
LocaleDlgProc,
|
LocaleDlgProc,
|
||||||
(LPARAM)pState);
|
(LPARAM)pState);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STARTPAGE:
|
case STARTPAGE:
|
||||||
DialogBoxParam(hInstance,
|
DialogBoxParamW(hInstance,
|
||||||
MAKEINTRESOURCE(IDD_STARTPAGE),
|
MAKEINTRESOURCEW(IDD_STARTPAGE),
|
||||||
NULL,
|
NULL,
|
||||||
StartDlgProc,
|
StartDlgProc,
|
||||||
(LPARAM)pState);
|
(LPARAM)pState);
|
||||||
|
|
|
@ -73,14 +73,14 @@ ReadRegSzKey(
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
/* NULL-terminate the string */
|
/* NULL-terminate the string */
|
||||||
Value[cbData / sizeof(WCHAR)] = '\0';
|
Value[cbData / sizeof(WCHAR)] = L'\0';
|
||||||
|
|
||||||
*pValue = Value;
|
*pValue = Value;
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static BOOL
|
||||||
BOOL IsConsoleShell(VOID)
|
IsConsoleShell(VOID)
|
||||||
{
|
{
|
||||||
HKEY ControlKey = NULL;
|
HKEY ControlKey = NULL;
|
||||||
LPWSTR SystemStartOptions = NULL;
|
LPWSTR SystemStartOptions = NULL;
|
||||||
|
@ -133,15 +133,14 @@ cleanup:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static BOOL
|
||||||
BOOL GetShell(
|
GetShell(
|
||||||
OUT WCHAR *CommandLine, /* must be at least MAX_PATH long */
|
OUT WCHAR *CommandLine, /* must be at least MAX_PATH long */
|
||||||
IN HKEY hRootKey)
|
IN HKEY hRootKey)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD Type, Size;
|
DWORD Type, Size;
|
||||||
WCHAR Shell[MAX_PATH];
|
WCHAR Shell[MAX_PATH];
|
||||||
BOOL Ret = FALSE;
|
|
||||||
BOOL ConsoleShell = IsConsoleShell();
|
BOOL ConsoleShell = IsConsoleShell();
|
||||||
LONG rc;
|
LONG rc;
|
||||||
|
|
||||||
|
@ -149,34 +148,38 @@ BOOL GetShell(
|
||||||
|
|
||||||
rc = RegOpenKeyExW(hRootKey, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
|
rc = RegOpenKeyExW(hRootKey, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
|
||||||
0, KEY_QUERY_VALUE, &hKey);
|
0, KEY_QUERY_VALUE, &hKey);
|
||||||
if (rc == ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
Size = MAX_PATH * sizeof(WCHAR);
|
WARN("RegOpenKeyEx() failed with error %lu\n", rc);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Size = sizeof(Shell);
|
||||||
rc = RegQueryValueExW(hKey,
|
rc = RegQueryValueExW(hKey,
|
||||||
ConsoleShell ? L"ConsoleShell" : L"Shell",
|
ConsoleShell ? L"ConsoleShell" : L"Shell",
|
||||||
NULL,
|
NULL,
|
||||||
&Type,
|
&Type,
|
||||||
(LPBYTE)Shell,
|
(LPBYTE)Shell,
|
||||||
&Size);
|
&Size);
|
||||||
if (rc == ERROR_SUCCESS)
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
|
if (rc != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
WARN("RegQueryValueEx() failed with error %lu\n", rc);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
if ((Type == REG_SZ) || (Type == REG_EXPAND_SZ))
|
if ((Type == REG_SZ) || (Type == REG_EXPAND_SZ))
|
||||||
{
|
{
|
||||||
TRACE("Found command line %s\n", debugstr_w(Shell));
|
TRACE("Found command line %s\n", debugstr_w(Shell));
|
||||||
wcscpy(CommandLine, Shell);
|
wcscpy(CommandLine, Shell);
|
||||||
Ret = TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
WARN("Wrong type %lu (expected %u or %u)\n", Type, REG_SZ, REG_EXPAND_SZ);
|
WARN("Wrong type %lu (expected %u or %u)\n", Type, REG_SZ, REG_EXPAND_SZ);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
WARN("RegQueryValueEx() failed with error %lu\n", rc);
|
|
||||||
RegCloseKey(hKey);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
WARN("RegOpenKeyEx() failed with error %lu\n", rc);
|
|
||||||
|
|
||||||
return Ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
|
@ -212,7 +215,7 @@ StartAutoApplications(
|
||||||
{
|
{
|
||||||
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (findData.nFileSizeHigh || findData.nFileSizeLow))
|
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && (findData.nFileSizeHigh || findData.nFileSizeLow))
|
||||||
{
|
{
|
||||||
ZeroMemory(&ExecInfo, sizeof(SHELLEXECUTEINFOW));
|
ZeroMemory(&ExecInfo, sizeof(ExecInfo));
|
||||||
ExecInfo.cbSize = sizeof(ExecInfo);
|
ExecInfo.cbSize = sizeof(ExecInfo);
|
||||||
wcscpy(&szPath[len+1], findData.cFileName);
|
wcscpy(&szPath[len+1], findData.cFileName);
|
||||||
ExecInfo.lpVerb = L"open";
|
ExecInfo.lpVerb = L"open";
|
||||||
|
@ -242,9 +245,9 @@ TryToStartShell(
|
||||||
si.wShowWindow = SW_SHOWNORMAL;
|
si.wShowWindow = SW_SHOWNORMAL;
|
||||||
ZeroMemory(&pi, sizeof(pi));
|
ZeroMemory(&pi, sizeof(pi));
|
||||||
|
|
||||||
ExpandEnvironmentStrings(Shell, ExpandedShell, MAX_PATH);
|
ExpandEnvironmentStringsW(Shell, ExpandedShell, ARRAYSIZE(ExpandedShell));
|
||||||
|
|
||||||
if (!CreateProcess(NULL,
|
if (!CreateProcessW(NULL,
|
||||||
ExpandedShell,
|
ExpandedShell,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -266,8 +269,8 @@ TryToStartShell(
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static BOOL
|
||||||
VOID StartShell(VOID)
|
StartShell(VOID)
|
||||||
{
|
{
|
||||||
WCHAR Shell[MAX_PATH];
|
WCHAR Shell[MAX_PATH];
|
||||||
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
TCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||||
|
@ -282,38 +285,41 @@ VOID StartShell(VOID)
|
||||||
rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option",
|
L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot\\Option",
|
||||||
0, KEY_QUERY_VALUE, &hKey);
|
0, KEY_QUERY_VALUE, &hKey);
|
||||||
if(rc == ERROR_SUCCESS)
|
if (rc == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
Size = sizeof(Value);
|
Size = sizeof(Value);
|
||||||
rc = RegQueryValueExW(hKey, L"UseAlternateShell", NULL,
|
rc = RegQueryValueExW(hKey, L"UseAlternateShell", NULL,
|
||||||
&Type, (LPBYTE)&Value, &Size);
|
&Type, (LPBYTE)&Value, &Size);
|
||||||
if(rc == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
if(Type == REG_DWORD)
|
|
||||||
|
if (rc == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
if(Value)
|
if (Type == REG_DWORD)
|
||||||
|
{
|
||||||
|
if (Value)
|
||||||
{
|
{
|
||||||
/* Safe Mode Alternate Shell required */
|
/* Safe Mode Alternate Shell required */
|
||||||
rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
rc = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
|
||||||
L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot",
|
L"SYSTEM\\CurrentControlSet\\Control\\SafeBoot",
|
||||||
0, KEY_READ, &hKey);
|
0, KEY_READ, &hKey);
|
||||||
if(rc == ERROR_SUCCESS)
|
if (rc == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
Size = MAX_PATH * sizeof(WCHAR);
|
Size = sizeof(Shell);
|
||||||
rc = RegQueryValueExW(hKey, L"AlternateShell", NULL,
|
rc = RegQueryValueExW(hKey, L"AlternateShell", NULL,
|
||||||
&Type, (LPBYTE)Shell, &Size);
|
&Type, (LPBYTE)Shell, &Size);
|
||||||
if(rc == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
|
if (rc == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
if ((Type == REG_SZ) || (Type == REG_EXPAND_SZ))
|
if ((Type == REG_SZ) || (Type == REG_EXPAND_SZ))
|
||||||
{
|
{
|
||||||
TRACE("Key located - %s\n", debugstr_w(Shell));
|
TRACE("Key located - %s\n", debugstr_w(Shell));
|
||||||
|
|
||||||
/* Try to run alternate shell */
|
/* Try to run alternate shell */
|
||||||
if (TryToStartShell(Shell))
|
if (TryToStartShell(Shell))
|
||||||
{
|
{
|
||||||
TRACE("Alternate shell started (Safe Mode)\n");
|
TRACE("Alternate shell started (Safe Mode)\n");
|
||||||
return;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -335,41 +341,45 @@ VOID StartShell(VOID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to run shell in user key */
|
/* Try to run shell in user key */
|
||||||
if (GetShell(Shell, HKEY_CURRENT_USER) && TryToStartShell(Shell))
|
if (GetShell(Shell, HKEY_CURRENT_USER) && TryToStartShell(Shell))
|
||||||
{
|
{
|
||||||
TRACE("Started shell from HKEY_CURRENT_USER\n");
|
TRACE("Started shell from HKEY_CURRENT_USER\n");
|
||||||
return;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to run shell in local machine key */
|
/* Try to run shell in local machine key */
|
||||||
if (GetShell(Shell, HKEY_LOCAL_MACHINE) && TryToStartShell(Shell))
|
if (GetShell(Shell, HKEY_LOCAL_MACHINE) && TryToStartShell(Shell))
|
||||||
{
|
{
|
||||||
TRACE("Started shell from HKEY_LOCAL_MACHINE\n");
|
TRACE("Started shell from HKEY_LOCAL_MACHINE\n");
|
||||||
return;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try default shell */
|
/* Try default shell */
|
||||||
if (IsConsoleShell())
|
if (IsConsoleShell())
|
||||||
{
|
{
|
||||||
if (GetSystemDirectory(Shell, MAX_PATH - 8))
|
if (GetSystemDirectoryW(Shell, ARRAYSIZE(Shell) - 8))
|
||||||
wcscat(Shell, L"\\cmd.exe");
|
wcscat(Shell, L"\\cmd.exe");
|
||||||
else
|
else
|
||||||
wcscpy(Shell, L"cmd.exe");
|
wcscpy(Shell, L"cmd.exe");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (GetWindowsDirectory(Shell, MAX_PATH - 13))
|
if (GetWindowsDirectoryW(Shell, ARRAYSIZE(Shell) - 13))
|
||||||
wcscat(Shell, L"\\explorer.exe");
|
wcscat(Shell, L"\\explorer.exe");
|
||||||
else
|
else
|
||||||
wcscpy(Shell, L"explorer.exe");
|
wcscpy(Shell, L"explorer.exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TryToStartShell(Shell))
|
if (!TryToStartShell(Shell))
|
||||||
{
|
{
|
||||||
WARN("Failed to start default shell %s\n", debugstr_w(Shell));
|
WARN("Failed to start default shell %s\n", debugstr_w(Shell));
|
||||||
LoadString( GetModuleHandle(NULL), IDS_SHELL_FAIL, szMsg, sizeof(szMsg) / sizeof(szMsg[0]));
|
LoadString( GetModuleHandle(NULL), IDS_SHELL_FAIL, szMsg, ARRAYSIZE(szMsg));
|
||||||
MessageBox(0, szMsg, NULL, 0);
|
MessageBox(NULL, szMsg, NULL, MB_OK);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WCHAR g_RegColorNames[][32] = {
|
const WCHAR g_RegColorNames[][32] = {
|
||||||
|
@ -405,10 +415,9 @@ const WCHAR g_RegColorNames[][32] = {
|
||||||
L"MenuHilight", /* 29 = COLOR_MENUHILIGHT */
|
L"MenuHilight", /* 29 = COLOR_MENUHILIGHT */
|
||||||
L"MenuBar" /* 30 = COLOR_MENUBAR */
|
L"MenuBar" /* 30 = COLOR_MENUBAR */
|
||||||
};
|
};
|
||||||
#define NUM_SYSCOLORS (sizeof(g_RegColorNames) / sizeof(g_RegColorNames[0]))
|
|
||||||
|
|
||||||
static
|
static COLORREF
|
||||||
COLORREF StrToColorref(
|
StrToColorref(
|
||||||
IN LPWSTR lpszCol)
|
IN LPWSTR lpszCol)
|
||||||
{
|
{
|
||||||
BYTE rgb[3];
|
BYTE rgb[3];
|
||||||
|
@ -421,8 +430,8 @@ COLORREF StrToColorref(
|
||||||
return RGB(rgb[0], rgb[1], rgb[2]);
|
return RGB(rgb[0], rgb[1], rgb[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static VOID
|
||||||
VOID SetUserSysColors(VOID)
|
SetUserSysColors(VOID)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
INT i;
|
INT i;
|
||||||
|
@ -433,17 +442,18 @@ VOID SetUserSysColors(VOID)
|
||||||
|
|
||||||
TRACE("()\n");
|
TRACE("()\n");
|
||||||
|
|
||||||
rc = RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_COLORS,
|
rc = RegOpenKeyExW(HKEY_CURRENT_USER, REGSTR_PATH_COLORS,
|
||||||
0, KEY_QUERY_VALUE, &hKey);
|
0, KEY_QUERY_VALUE, &hKey);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
WARN("RegOpenKeyEx() failed with error %lu\n", rc);
|
WARN("RegOpenKeyEx() failed with error %lu\n", rc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(i = 0; i < NUM_SYSCOLORS; i++)
|
|
||||||
|
for (i = 0; i < ARRAYSIZE(g_RegColorNames); i++)
|
||||||
{
|
{
|
||||||
Size = sizeof(szColor);
|
Size = sizeof(szColor);
|
||||||
rc = RegQueryValueEx(hKey, g_RegColorNames[i], NULL, &Type,
|
rc = RegQueryValueExW(hKey, g_RegColorNames[i], NULL, &Type,
|
||||||
(LPBYTE)szColor, &Size);
|
(LPBYTE)szColor, &Size);
|
||||||
if (rc == ERROR_SUCCESS && Type == REG_SZ)
|
if (rc == ERROR_SUCCESS && Type == REG_SZ)
|
||||||
{
|
{
|
||||||
|
@ -451,14 +461,17 @@ VOID SetUserSysColors(VOID)
|
||||||
SetSysColors(1, &i, &crColor);
|
SetSysColors(1, &i, &crColor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
WARN("RegQueryValueEx(%s) failed with error %lu\n",
|
WARN("RegQueryValueEx(%s) failed with error %lu\n",
|
||||||
debugstr_w(g_RegColorNames[i]), rc);
|
debugstr_w(g_RegColorNames[i]), rc);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static VOID
|
||||||
VOID SetUserWallpaper(VOID)
|
SetUserWallpaper(VOID)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD Type, Size;
|
DWORD Type, Size;
|
||||||
|
@ -467,39 +480,41 @@ VOID SetUserWallpaper(VOID)
|
||||||
|
|
||||||
TRACE("()\n");
|
TRACE("()\n");
|
||||||
|
|
||||||
rc = RegOpenKeyEx(HKEY_CURRENT_USER, REGSTR_PATH_DESKTOP,
|
rc = RegOpenKeyExW(HKEY_CURRENT_USER, REGSTR_PATH_DESKTOP,
|
||||||
0, KEY_QUERY_VALUE, &hKey);
|
0, KEY_QUERY_VALUE, &hKey);
|
||||||
if (rc == ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
|
WARN("RegOpenKeyEx() failed with error %lu\n", rc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Size = sizeof(szWallpaper);
|
Size = sizeof(szWallpaper);
|
||||||
rc = RegQueryValueEx(hKey,
|
rc = RegQueryValueExW(hKey,
|
||||||
L"Wallpaper",
|
L"Wallpaper",
|
||||||
NULL,
|
NULL,
|
||||||
&Type,
|
&Type,
|
||||||
(LPBYTE)szWallpaper,
|
(LPBYTE)szWallpaper,
|
||||||
&Size);
|
&Size);
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
|
||||||
if (rc == ERROR_SUCCESS && Type == REG_SZ)
|
if (rc == ERROR_SUCCESS && Type == REG_SZ)
|
||||||
{
|
{
|
||||||
ExpandEnvironmentStrings(szWallpaper, szWallpaper, MAX_PATH);
|
ExpandEnvironmentStringsW(szWallpaper, szWallpaper, ARRAYSIZE(szWallpaper));
|
||||||
TRACE("Using wallpaper %s\n", debugstr_w(szWallpaper));
|
TRACE("Using wallpaper %s\n", debugstr_w(szWallpaper));
|
||||||
|
|
||||||
/* Load and change the wallpaper */
|
/* Load and change the wallpaper */
|
||||||
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, szWallpaper, SPIF_SENDCHANGE);
|
SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, szWallpaper, SPIF_SENDCHANGE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* remove the wallpaper */
|
/* Remove the wallpaper */
|
||||||
TRACE("No wallpaper set in registry (error %lu)\n", rc);
|
TRACE("No wallpaper set in registry (error %lu)\n", rc);
|
||||||
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, NULL, SPIF_SENDCHANGE);
|
SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, NULL, SPIF_SENDCHANGE);
|
||||||
}
|
}
|
||||||
RegCloseKey(hKey);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
WARN("RegOpenKeyEx() failed with error %lu\n", rc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static VOID
|
||||||
VOID SetUserSettings(VOID)
|
SetUserSettings(VOID)
|
||||||
{
|
{
|
||||||
TRACE("()\n");
|
TRACE("()\n");
|
||||||
|
|
||||||
|
@ -518,9 +533,13 @@ NotifyLogon(VOID)
|
||||||
|
|
||||||
TRACE("()\n");
|
TRACE("()\n");
|
||||||
|
|
||||||
hModule = LoadLibrary(L"setupapi.dll");
|
hModule = LoadLibraryW(L"setupapi.dll");
|
||||||
if (hModule)
|
if (!hModule)
|
||||||
{
|
{
|
||||||
|
WARN("LoadLibrary() failed with error %lu\n", GetLastError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CMP_Report_LogOn = (PCMP_REPORT_LOGON)GetProcAddress(hModule, "CMP_Report_LogOn");
|
CMP_Report_LogOn = (PCMP_REPORT_LOGON)GetProcAddress(hModule, "CMP_Report_LogOn");
|
||||||
if (CMP_Report_LogOn)
|
if (CMP_Report_LogOn)
|
||||||
CMP_Report_LogOn(CMP_MAGIC, GetCurrentProcessId());
|
CMP_Report_LogOn(CMP_MAGIC, GetCurrentProcessId());
|
||||||
|
@ -528,19 +547,15 @@ NotifyLogon(VOID)
|
||||||
WARN("GetProcAddress() failed\n");
|
WARN("GetProcAddress() failed\n");
|
||||||
|
|
||||||
FreeLibrary(hModule);
|
FreeLibrary(hModule);
|
||||||
}
|
|
||||||
else
|
|
||||||
WARN("LoadLibrary() failed with error %lu\n", GetLastError());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static BOOL
|
||||||
VOID
|
|
||||||
StartInstaller(VOID)
|
StartInstaller(VOID)
|
||||||
{
|
{
|
||||||
WCHAR Shell[MAX_PATH];
|
WCHAR Shell[MAX_PATH];
|
||||||
WCHAR szMsg[RC_STRING_MAX_SIZE];
|
WCHAR szMsg[RC_STRING_MAX_SIZE];
|
||||||
|
|
||||||
if (GetWindowsDirectory(Shell, MAX_PATH - 12))
|
if (GetWindowsDirectoryW(Shell, ARRAYSIZE(Shell) - 12))
|
||||||
wcscat(Shell, L"\\reactos.exe");
|
wcscat(Shell, L"\\reactos.exe");
|
||||||
else
|
else
|
||||||
wcscpy(Shell, L"reactos.exe");
|
wcscpy(Shell, L"reactos.exe");
|
||||||
|
@ -548,16 +563,14 @@ StartInstaller(VOID)
|
||||||
if (!TryToStartShell(Shell))
|
if (!TryToStartShell(Shell))
|
||||||
{
|
{
|
||||||
ERR("Failed to start the installer: %s\n", debugstr_w(Shell));
|
ERR("Failed to start the installer: %s\n", debugstr_w(Shell));
|
||||||
LoadStringW(GetModuleHandle(NULL), IDS_INSTALLER_FAIL, szMsg, sizeof(szMsg) / sizeof(szMsg[0]));
|
LoadStringW(GetModuleHandle(NULL), IDS_INSTALLER_FAIL, szMsg, ARRAYSIZE(szMsg));
|
||||||
MessageBoxW(0, szMsg, NULL, 0);
|
MessageBoxW(NULL, szMsg, NULL, MB_OK);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning(disable : 4100)
|
|
||||||
#endif /* _MSC_VER */
|
|
||||||
|
|
||||||
int WINAPI
|
int WINAPI
|
||||||
wWinMain(IN HINSTANCE hInst,
|
wWinMain(IN HINSTANCE hInst,
|
||||||
IN HINSTANCE hPrevInstance,
|
IN HINSTANCE hPrevInstance,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue