[USERENV] Implement error reporting via error dialog (#8139)

This feature is used to report errors when `LoadUserProfile()` fails.
It is also meant to be used by other functions in the future.

The error dialog is shown only when the `PI_NOUI` flag is _NOT_ set
in `PROFILEINFO::dwFlags`.

- Add support for retrieving USERENV-specific registry policies,
  in a systematic way.

- Add support for "timed" dialogs that automatically close after
  a given timeout has elapsed.
  The default timeout is controlled by the `"ProfileDlgTimeOut"` policy:
  https://www.visualautomation.com/comprod/secure6/profile_.htm
  https://www.infania.net/misc/kbarchive/kb/196/Q196284/index.html

- TODO for the future: report the error in the event log.

- `LoadUserProfileW()`: Reset `ret` to `FALSE` after the call to
  `CreateUserProfileW()`; this allows to return failure in case
  any other function calls down the line fails. (`ret` is set to
  `TRUE` only when everything has succeeded.)
This commit is contained in:
Hermès Bélusca-Maïto
2025-06-19 16:09:30 +02:00
parent 3a96c90c54
commit cbf3e61d63
38 changed files with 776 additions and 32 deletions
+41
View File
@@ -80,6 +80,47 @@ AppendBackslash(LPWSTR String);
PSECURITY_DESCRIPTOR
CreateDefaultSecurityDescriptor(VOID);
typedef struct _POLICY_VALUES
{
PCWSTR ValueName;
DWORD Type;
PVOID Data;
DWORD Length;
} POLICY_VALUES, *PPOLICY_VALUES;
LONG
GetPolicyValues(
_In_ HKEY hRootKey,
_Inout_ PPOLICY_VALUES QueryTable);
LONG
GetPolicyValue(
_In_ HKEY hRootKey,
_In_ PCWSTR ValueName,
_In_ DWORD Type,
_Out_opt_ PVOID pData,
_Inout_opt_ PDWORD pcbData);
VOID
ReportErrorWorker(
_In_ DWORD dwFlags,
_In_ PCWSTR pszStr);
VOID
ReportErrorV(
_In_ DWORD dwFlags,
_In_ PCWSTR pszStr,
_In_ va_list args);
VOID
__cdecl
ReportError(
_In_ DWORD dwFlags,
_In_ PCWSTR pszStr,
...);
/* profile.c */
BOOL
AppendSystemPostfix(LPWSTR lpName,
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_BULGARIAN, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -5,6 +5,18 @@
LANGUAGE LANG_CZECH, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_DANISH, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_GERMAN, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_GREEK, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile" // "User Environment"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -9,6 +9,18 @@
LANGUAGE LANG_SPANISH, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -7,6 +7,18 @@
LANGUAGE LANG_BASQUE, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_FRENCH, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "Profil utilisateur" // "Environnement utilisateur"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Temps restant :", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_HEBREW, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_HUNGARIAN, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_INDONESIAN, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -11,6 +11,18 @@
LANGUAGE LANG_ITALIAN, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_JAPANESE, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_LITHUANIAN, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_NORWEGIAN, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_POLISH, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_PORTUGUESE, SUBLANG_PORTUGUESE_BRAZILIAN
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_PORTUGUESE, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -8,6 +8,18 @@
LANGUAGE LANG_ROMANIAN, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -5,6 +5,18 @@
LANGUAGE LANG_SLOVAK, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+13 -2
View File
@@ -1,10 +1,21 @@
/* TRANSLATOR : Ardit Dani (Ard1t) ([email protected])
* DATE OF TRANSLATION: 06-02-2014
*/
*/
LANGUAGE LANG_ALBANIAN, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_SWEDISH, SUBLANG_NEUTRAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_THAI, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -2,6 +2,18 @@
LANGUAGE LANG_TURKISH, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -1,5 +1,17 @@
LANGUAGE LANG_UKRAINIAN, SUBLANG_DEFAULT
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -6,6 +6,18 @@ English folder names into Chinese, or it may cause problems in the system. */
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -12,6 +12,18 @@
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_HONGKONG
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+12
View File
@@ -5,6 +5,18 @@ English folder names into Chinese, or it may cause problems in the system. */
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
IDD_ERRORDLG DIALOGEX 0, 0, 250, 95
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
CAPTION "User Profile"
FONT 8, "MS Shell Dlg"
BEGIN
ICON IDI_USERENV, IDC_STATIC, 6, 10, 18, 20
DEFPUSHBUTTON "OK", IDOK, 190, 10, 50, 14, BS_NOTIFY | WS_TABSTOP
EDITTEXT IDC_ERRORDESC, 37, 10, 145, 66, ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | WS_VSCROLL | WS_BORDER | WS_TABSTOP
RTEXT "Time remaining:", IDC_TIMEOUTSTATIC, 172, 80, 54, 8
LTEXT "", IDC_TIMEOUT, 230, 80, 12, 8
END
/* See also: dll/win32/shell32/lang */
STRINGTABLE
BEGIN
+295 -4
View File
@@ -25,9 +25,10 @@
*/
#include "precomp.h"
#include <ndk/sefuncs.h>
#include "resources.h"
#define NDEBUG
#include <debug.h>
@@ -52,7 +53,6 @@ AppendBackslash(LPWSTR String)
return &String[Length];
}
PSECURITY_DESCRIPTOR
CreateDefaultSecurityDescriptor(VOID)
{
@@ -198,6 +198,299 @@ Cleanup:
return pSD;
}
/* Policy values helpers *****************************************************/
LONG
GetPolicyValues(
_In_ HKEY hRootKey,
_Inout_ PPOLICY_VALUES QueryTable)
{
static PCWSTR PolicyKeys[] =
{
L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
L"Software\\Policies\\Microsoft\\Windows\\System"
};
/* Retrieve the sought policy values in each of the policy keys */
DWORD i;
for (i = 0; i < _countof(PolicyKeys); ++i)
{
HKEY hKey;
PPOLICY_VALUES Value;
DWORD dwType, cbData;
if (RegOpenKeyExW(hRootKey, PolicyKeys[i], 0,
KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
{
continue;
}
for (Value = QueryTable; Value->ValueName || Value->Data; ++Value)
{
/* Retrieve the type and data length for validation checks */
if (RegQueryValueExW(hKey, Value->ValueName, NULL,
&dwType, NULL, &cbData) != ERROR_SUCCESS)
{
continue;
}
/* Verify for compatible types */
if ( ((Value->Type == REG_SZ || Value->Type == REG_EXPAND_SZ) &&
(dwType == REG_SZ || dwType == REG_EXPAND_SZ)) ||
(Value->Type == REG_DWORD && dwType == REG_DWORD) ||
(Value->Type == REG_QWORD && dwType == REG_QWORD) ||
(Value->Type == REG_MULTI_SZ && dwType == REG_MULTI_SZ) ||
(Value->Type == REG_NONE || Value->Type == REG_BINARY) )
{
/* Verify whether the given buffer can hold the data;
* if so, retrieve the actual data */
if (Value->Length >= cbData)
{
RegQueryValueExW(hKey, Value->ValueName, NULL,
&dwType, Value->Data, &cbData);
}
}
}
RegCloseKey(hKey);
}
return ERROR_SUCCESS;
}
LONG
GetPolicyValue(
_In_ HKEY hRootKey,
_In_ PCWSTR ValueName,
_In_ DWORD Type,
_Out_opt_ PVOID pData,
_Inout_opt_ PDWORD pcbData)
{
POLICY_VALUES QueryTable[] =
{
{ValueName, Type, pData, pcbData ? *pcbData : 0},
{NULL, 0, NULL, 0}
};
LONG ret = GetPolicyValues(hRootKey, QueryTable);
if ((ret == ERROR_SUCCESS) && pcbData)
*pcbData = QueryTable[0].Length;
return ret;
}
/* Timed dialog helpers ******************************************************/
#define IDT_DLGTIMER 1
typedef struct _TIMERDLG_BUTTON
{
UINT uID;
INT_PTR nResult;
} TIMERDLG_BUTTON, *PTIMERDLG_BUTTON;
typedef struct _TIMERDLG_INFO
{
ULONG ulTimeout; ///< Dialog timeout.
WORD wDefBtnOnTimeout; ///< Index in button map for the default action on timeout.
WORD wDefBtnOnCancel; ///< Index in button map for the default action on dialog cancel.
TIMERDLG_BUTTON ButtonMap[2]; ///< Button/result map for the 1st and 2nd buttons.
} TIMERDLG_INFO, *PTIMERDLG_INFO;
static INT_PTR
CALLBACK
TimerDlgProc(
_Inout_ PTIMERDLG_INFO Info,
_In_ HWND hDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
/* Setup the timeout */
if (Info->ulTimeout)
{
/* Display the countdown */
WCHAR szTimeout[10];
StringCchPrintfW(szTimeout, _countof(szTimeout), L"%d", Info->ulTimeout);
SetDlgItemTextW(hDlg, IDC_TIMEOUT, szTimeout);
/* Set a 1-second timer */
SetTimer(hDlg, IDT_DLGTIMER, 1000, NULL);
}
break;
}
case WM_COMMAND:
{
PTIMERDLG_BUTTON ButtonMap = Info->ButtonMap;
WORD wDefBtnOnTimeout = min(Info->wDefBtnOnTimeout, _countof(Info->ButtonMap)-1);
WORD i;
if (LOWORD(wParam) == IDCANCEL)
{
/* ESC or CANCEL button pressed: stop the timeout,
* close the dialog and return the default result */
WORD wDefBtnOnCancel = min(Info->wDefBtnOnCancel, _countof(Info->ButtonMap)-1);
KillTimer(hDlg, IDT_DLGTIMER);
EndDialog(hDlg, ButtonMap[wDefBtnOnCancel].nResult);
break;
}
for (i = 0; i < _countof(Info->ButtonMap); ++i)
{
if (LOWORD(wParam) == ButtonMap[i].uID)
{
if (HIWORD(wParam) == BN_CLICKED)
{
/* Button pressed: stop the timeout, close the
* dialog and return the corresponding result */
KillTimer(hDlg, IDT_DLGTIMER);
EndDialog(hDlg, ButtonMap[i].nResult);
}
else if (HIWORD(wParam) == BN_KILLFOCUS)
{
/* Button lost the focus: stop the timeout
* only if this isn't the default action */
if (i != wDefBtnOnTimeout)
break;
KillTimer(hDlg, IDT_DLGTIMER);
ShowWindow(GetDlgItem(hDlg, IDC_TIMEOUT), SW_HIDE);
ShowWindow(GetDlgItem(hDlg, IDC_TIMEOUTSTATIC), SW_HIDE);
}
break;
}
}
break;
}
case WM_TIMER:
{
if (Info->ulTimeout < 1)
{
/* Timeout ended, close the dialog */
WORD wDefBtnOnTimeout = min(Info->wDefBtnOnTimeout, _countof(Info->ButtonMap)-1);
PostMessageW(hDlg, WM_COMMAND,
MAKEWPARAM(Info->ButtonMap[wDefBtnOnTimeout].uID, BN_CLICKED),
0);
}
else
{
/* Decrement and display the countdown */
WCHAR szTimeout[10];
StringCchPrintfW(szTimeout, _countof(szTimeout), L"%d", --(Info->ulTimeout));
SetDlgItemTextW(hDlg, IDC_TIMEOUT, szTimeout);
}
break;
}
}
return FALSE;
}
/* Error reporting helpers ***************************************************/
typedef struct _ERRORDLG_PARAMS
{
ULONG ulTimeout;
PCWSTR pszString;
} ERRORDLG_PARAMS, *PERRORDLG_PARAMS;
static TIMERDLG_INFO ErrorDlg =
{
0, ///< Global error-dialog timeout, used for all displayed error dialogs.
0, 1,
{{IDOK, TRUE}, {IDCANCEL, FALSE}}
};
static INT_PTR
CALLBACK
ErrorDlgProc(
_In_ HWND hDlg,
_In_ UINT uMsg,
_In_ WPARAM wParam,
_In_ LPARAM lParam)
{
if (uMsg == WM_INITDIALOG)
{
PERRORDLG_PARAMS Params = (PERRORDLG_PARAMS)lParam;
/* Position and focus the dialog */
// CenterWindow(hDlg); // Already done with the DS_CENTER style.
SetForegroundWindow(hDlg);
/* Display the message */
SetDlgItemTextW(hDlg, IDC_ERRORDESC, Params->pszString);
/* Setup the timeout and display the countdown */
ErrorDlg.ulTimeout = Params->ulTimeout;
// SetWindowLongPtrW(hDlg, DWLP_USER, &ErrorDlg);
TimerDlgProc(&ErrorDlg, hDlg, WM_INITDIALOG, wParam, lParam);
return TRUE;
}
return TimerDlgProc(&ErrorDlg, hDlg, uMsg, wParam, lParam);
}
VOID
ErrorDialogEx(
_In_ ULONG ulTimeout,
_In_ PCWSTR pszString)
{
ERRORDLG_PARAMS Params = {ulTimeout, pszString};
DialogBoxParamW(hInstance, MAKEINTRESOURCEW(IDD_ERRORDLG),
NULL, ErrorDlgProc, (LPARAM)&Params);
}
VOID
ReportErrorWorker(
_In_ DWORD dwFlags,
_In_ PCWSTR pszStr)
{
// TODO: Report event to Application log, "Userenv" source.
DPRINT1("%S", pszStr);
if (!(dwFlags & PI_NOUI))
{
/* Retrieve the "Profile Dialog Time Out" policy value,
* defaulting to 30 seconds timeout */
ULONG ulTimeout = 30;
DWORD cbData = sizeof(ulTimeout);
GetPolicyValue(HKEY_LOCAL_MACHINE,
L"ProfileDlgTimeOut",
REG_DWORD,
&ulTimeout,
&cbData);
ErrorDialogEx(ulTimeout, pszStr);
}
}
VOID
ReportErrorV(
_In_ DWORD dwFlags,
_In_ PCWSTR pszStr,
_In_ va_list args)
{
WCHAR Buffer[4096];
_vsnwprintf(Buffer, _countof(Buffer), pszStr, args);
ReportErrorWorker(dwFlags, Buffer);
}
VOID
__cdecl
ReportError(
_In_ DWORD dwFlags,
_In_ PCWSTR pszStr,
...)
{
va_list args;
va_start(args, pszStr);
ReportErrorV(dwFlags, pszStr, args);
va_end(args);
}
/* Dynamic DLL loading interface **********************************************/
/* OLE32.DLL import table */
@@ -212,7 +505,6 @@ DYN_MODULE DynOle32 =
}
};
/*
* Use this function to load functions from other modules. We cannot statically
* link to e.g. ole32.dll because those dlls would get loaded on startup with
@@ -254,7 +546,6 @@ LoadDynamicImports(PDYN_MODULE Module,
return TRUE;
}
VOID
UnloadDynamicImports(PDYN_FUNCS DynFuncs)
{
+38 -25
View File
@@ -2007,12 +2007,12 @@ LoadUserProfileW(
_Inout_ LPPROFILEINFOW lpProfileInfo)
{
WCHAR szUserHivePath[MAX_PATH];
DWORD dwLength = _countof(szUserHivePath);
PTOKEN_USER UserSid = NULL;
UNICODE_STRING SidString = { 0, 0, NULL };
HANDLE hProfileMutex = NULL;
LONG Error;
DWORD dwError = MAXDWORD;
BOOL ret = FALSE;
DWORD dwLength = sizeof(szUserHivePath) / sizeof(szUserHivePath[0]);
DPRINT("LoadUserProfileW(%p %p)\n", hToken, lpProfileInfo);
@@ -2083,15 +2083,15 @@ LoadUserProfileW(
if (GetTokenInformation(hToken, TokenUser, NULL, 0, &dwLength) ||
GetLastError() != ERROR_INSUFFICIENT_BUFFER)
{
DPRINT1 ("GetTokenInformation() failed\n");
DPRINT1("GetTokenInformation() failed\n");
goto cleanup;
}
UserSid = (PTOKEN_USER)HeapAlloc(GetProcessHeap(), 0, dwLength);
if (!UserSid)
{
dwError = ERROR_NOT_ENOUGH_MEMORY;
DPRINT1("HeapAlloc() failed\n");
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
goto cleanup;
}
@@ -2108,6 +2108,7 @@ LoadUserProfileW(
DPRINT1("CreateUserProfileW() failed\n");
goto cleanup;
}
ret = FALSE;
}
/* Acquire restore privilege */
@@ -2117,20 +2118,19 @@ LoadUserProfileW(
goto cleanup;
}
/* Load user registry hive */
Error = RegLoadKeyW(HKEY_USERS,
SidString.Buffer,
szUserHivePath);
/* Load the user registry hive */
dwError = RegLoadKeyW(HKEY_USERS,
SidString.Buffer,
szUserHivePath);
AcquireRemoveRestorePrivilege(FALSE);
/* HACK: Do not fail if the profile has already been loaded! */
if (Error == ERROR_SHARING_VIOLATION)
Error = ERROR_SUCCESS;
if (dwError == ERROR_SHARING_VIOLATION)
dwError = ERROR_SUCCESS;
if (Error != ERROR_SUCCESS)
if (dwError != ERROR_SUCCESS)
{
DPRINT1("RegLoadKeyW() failed (Error %ld)\n", Error);
SetLastError((DWORD)Error);
DPRINT1("RegLoadKeyW() failed (Error %ld)\n", dwError);
goto cleanup;
}
@@ -2140,29 +2140,30 @@ LoadUserProfileW(
}
/* Open future HKEY_CURRENT_USER */
Error = RegOpenKeyExW(HKEY_USERS,
SidString.Buffer,
0,
MAXIMUM_ALLOWED,
(PHKEY)&lpProfileInfo->hProfile);
if (Error != ERROR_SUCCESS)
dwError = RegOpenKeyExW(HKEY_USERS,
SidString.Buffer,
0,
MAXIMUM_ALLOWED,
(PHKEY)&lpProfileInfo->hProfile);
if (dwError != ERROR_SUCCESS)
{
DPRINT1("RegOpenKeyExW() failed (Error %ld)\n", Error);
SetLastError((DWORD)Error);
DPRINT1("RegOpenKeyExW() failed (Error %ld)\n", dwError);
goto cleanup;
}
Error = IncrementRefCount(SidString.Buffer, NULL);
if (Error != ERROR_SUCCESS)
dwError = IncrementRefCount(SidString.Buffer, NULL);
if (dwError != ERROR_SUCCESS)
{
DPRINT1("IncrementRefCount() failed (Error %ld)\n", Error);
SetLastError((DWORD)Error);
DPRINT1("IncrementRefCount() failed (Error %ld)\n", dwError);
goto cleanup;
}
ret = TRUE;
cleanup:
if (dwError == MAXDWORD)
dwError = GetLastError();
if (UserSid != NULL)
HeapFree(GetProcessHeap(), 0, UserSid);
@@ -2174,7 +2175,19 @@ cleanup:
RtlFreeUnicodeString(&SidString);
/* Report any error occurred */
if (!ret)
{
// TODO: Use a localized *.mc resource message* error.
ReportError(lpProfileInfo->dwFlags,
L"ReactOS could not load the locally stored user profile. "
L"Possible causes of this error include insufficient security rights or a corrupt local profile.\n"
L"\nError: %lu\n",
dwError);
}
DPRINT("LoadUserProfileW() done\n");
SetLastError(dwError);
return ret;
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

+12
View File
@@ -8,6 +8,18 @@
#pragma once
#define IDC_STATIC (-1)
/* Icons */
#define IDI_USERENV 1
/* Dialogs */
#define IDD_ERRORDLG 3000
#define IDC_ERRORDESC 3001
#define IDC_TIMEOUTSTATIC 1005
#define IDC_TIMEOUT 1004
/* Strings */
#define IDS_PROFILEPATH 1
#define IDS_APPDATA 2
#define IDS_DESKTOP 3
+5 -1
View File
@@ -1,4 +1,5 @@
/* Copyright (C) 2004 Eric Kohl
/*
* Copyright (C) 2004 Eric Kohl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,6 +17,7 @@
*/
#include <windef.h>
#include <winuser.rh>
#include "resources.h"
@@ -30,6 +32,8 @@
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDI_USERENV ICON "res/userenv.ico"
/*
* Everything specific to any language goes in one of the specific
* files. Note that you can and may override resources which also have