- [INCLUDE/WINE] Add synced Wine headers for the iphlpapi winetest to use. This helps us slowly decouple our headers and wine's headers.
- [PSDK] Add definitions we are missing for other winetest syncs.
- [WINETESTS][APITESTS] Fix breaking changes, remove duplicate definitions for debugstr_guid.
CORE-19104
- Use `NtPowerInformation()` and the `IS_PWR_*` macros instead.
- Fancy shutdown dialog:
* Enable or disable the hibernate/sleep buttons depending on
the previously-determined available shutdown options.
* Don't invoke `ExitWindowsEx()` or `SetSuspendState()` directly
within Msgina, but return a suitable `WLX_SAS_ACTION_SHUTDOWN_*`
value, like what's done by the classic dialog. The power action
proper is then performed by the caller of the shutdown dialog:
either Shell32 or Winlogon.
CORE-19104
This fixes failure to create or open the `PowerProfileRegistrySemaphore`,
when it has been first created by a Process1 using powrprof from a "User1",
and while this process stays running, the semaphore is attempted to be
re-created (or opened) by another Process2 using powrprof from a different
"User2".
For example, this happens when "User1" is either the LocalSystem account
with the Process1 being Winlogon.exe (via the msgina.dll -> powrprof.dll
dependency), or, "Administrator" with the explorer.exe process when opening
the "Shutdown" dialog (via the shell32.dll -> runtime-loading of msgina.dll
-> powrprof.dll dependency),
AND,
"User2" being a non-administrator user and Process2 being explorer.exe,
again when opening the "Shutdown" dialog. In this situation, msgina.dll
fails to be loaded, because powrprof.dll fails in its `DllMain()` routine
-- see log excerpt below --, and the shell falls back to a minimal shutdown
confirmation dialog.
```
err:(dll\win32\powrprof\powrprof.c:1420) Couldn't create Semaphore: 5
(dll\ntdll\ldr\ldrinit.c:879) LDR: DLL_PROCESS_ATTACH for dll "powrprof.dll" (InitRoutine: 7ADC6DB0) failed
(dll\win32\kernel32\client\loader.c:386) LoadLibraryExW(msgina.dll) failing with status c0000142
err:(dll\win32\powrprof\powrprof.c:1420) Couldn't create Semaphore: 5
(dll\ntdll\ldr\ldrinit.c:879) LDR: DLL_PROCESS_ATTACH for dll "powrprof.dll" (InitRoutine: 7ADC6DB0) failed
(dll\win32\kernel32\client\loader.c:386) LoadLibraryExW(msgina.dll) failing with status c0000142
(dll\ntdll\ldr\ldrutils.c:2340) Image explorer.exe has no exports, but were trying to get procedure (null). BaseAddress asked 0x00400000, got entry BA 0x00400000
err:(win32ss\user\user32\windows\messagebox.c:1048) MessageBox: L"Do you want to shutdown?"
```
- Don't hardcode buffer sizes.
- `ShowWindow()` 2nd parameter is an `SW_*` flag, not `TRUE`/`FALSE`.
- The "FIXME: Add battery page" comment is outdated since commit 4bdbb3092c
- Use standard `IDC_STATIC` instead of `-1` for resource control IDs.
- `AUTOCHECKBOX` already contains `WS_TABSTOP`, no need to add it explicitly.
- Reformat file headers.
Add Wow64PrepareForException handler, which is well documented as a hook for KiUserExceptionDispatcher (see e.g. https://github.com/brew02/KiUserExceptionDispatcherHook) and used by ntdll_winetest.
This also reloads rcx and rdx for the call to RtlDispatchException from the stack instead of relying on the registers to be set up by the kernel, which again is a feature used by ntdll_winetest, which calls this function from a hook with zeroed registers.
This is useful for numerical values that are documented as being stored
in string format as `REG_SZ` in the registry; the reason being that they
are still read or written via `GetProfileIntW()`/`WriteProfileStringW()`
by Windows' Winlogon, and these functions store `REG_SZ` values because
of the INI <-> Registry mapping mechanism.
Addendum to commit 1499e7ef53.
Poor thing was crying that it was ignoring trigraph `??)`, even
though this whole thing was inside an `#if 0`-commented block...
Use something else instead.
```
msgina/shutdown.c: In function 'ShutdownDialog':
msgina/shutdown.c:1217:56: error: trigraph ??) ignored, use -trigraphs to enable [-Werror=trigraphs]
pgContext->nShutdownAction = LoadShutdownSelState(???);
msgina/shutdown.c: At top level:
cc1: error: unrecognized command line option '-Wno-unknown-warning-option' [-Werror]
```
Otherwise, you wouldn't see anything at all when opening a .NET app, and
the only hint that a .NET runtime is needed would be to see the message
in the debug log, provided a debugger is connected to ReactOS ...
NOTE: `shell32!ShellMessageBoxA()` is used instead of
`user32!MessageBoxA`, because it turns out mscoree isn't importing
from user32 but from shell32 instead (as in Wine's), and I don't want
to modify the list of imported modules.
NOTE 2: This warning function has been gradually removed with Wine commits:
c99754ef156b889fe9185cd6db034926c9bd9f15
Now, a mere `ERR("Wine Mono is not installed\n");` is emitted.
- Respect system policies for showing or hiding:
* Security dialog "Lock Workstation", "Log Off", "Shut Down",
"Change Password", "Task Manager" buttons;
* "Log Off" entry in the Shutdown dialog;
- Disable the "Shut Down" Security dialog button, and the "Stand by",
"Shut down" entries in the Shutdown dialog, if the logged user
doesn't have the SeShutdownPrivilege.
- Add other missing `WLX_SHUTDOWN_STATE_*` shutdown flags that are
supported by Windows.
- Improve the retrieval of shutdown options to be displayed in the
"Shut Down" dialog. In particular, don't hardcode any sort of
defaults, but let them come from what the user can do (Is logoff
allowed? Does (s)he have the rights to shutdown/reboot? etc.).
If no shutdown options are available, then simply don't display
the dialog!
- Don't hardcode the default selected shutdown option. Either it comes
from the user's registry and is valid (i.e. corresponds to an existing
shutdown option in the dialog), otherwise, fall back to the first
option in the dialog.
In particular this means:
* when opening the "Shut Down" dialog from the C-A-D Security
dialog, by default we will select the "Log Off" option, or
whatever the user last selected;
* when opening the dialog from the "Turn Off" Start Menu item, default
to the "Shut down" option, or whatever the user last selected.
* when opening the dialog from the C-A-D "Log On" dialog (no user
is logged in), the "Shut down" option will also be selected, or
whatever the system operator last selected.
- For the shell-invokable `ShellShutdownDialog()` function, implement
support for using a custom display user name, or the one in the
`"Logon User Name"` registry value saved by `WlxActivateUserShell()`.
Plus, the 3rd parameter specifies the list of shutdown options to
*exclude* from the options list.
The Security dialog can be displayed only when a user is logged.
When this is so, the `pgContext->bAutoAdminLogon` has already been
reset to `FALSE`, see `gui.c!DoLogon()`. Thus there is really no
reason to disable the "Log Off" button in that case.
Addendum to commit c633b79451 (r61622)
- Add SAL annotations;
- Avoid using hardcoded buffer sizes in function calls.
- If the start-application (Userinit) launched successfully, store
in the logged-in user's Explorer key, value `"Logon User Name"`,
the user name that was entered verbatim in the "Log On" dialog
to log into the system. This value is used as a "convenience" to
display the `"Log Off <username>"` item in the explorer's Start menu
(see `explorer!util.cpp:GetCurrentLoggedOnUserName()`), and the
corresponding item in the "Shut Down" dialog.
- utils.c: Introduce the `RegOpenLoggedOnHKCU()` helper, for opening
the current logged-in user HKCU key.
NOTE: Regarding the `.Default` registry key, see:
https://devblogs.microsoft.com/oldnewthing/20070302-00/?p=27783
- Registry-value getters; string copy functions.
- ReadRegSzValue(): Use a meaningful error value
when the value type isn't the expected one.
- Rename `DuplicationString` -> `DuplicateString`
- WlxLogoff(): Zero out cached Winlogon buffer pointers and some more
user login info.
- WlxLoggedOutSAS(): Return the logged-in user token handle *ONLY* if
the user is actually logging into the system.
If (s)he doesn't log in, but instead cancels the Log-On dialog, or
chooses to Shutdown/Reboot the computer from that dialog, do *NOT*
return any previous logged-in user token handle.
For example, in the case of a previously failed logon attempt due
to a wrong or corrupted user profile, shutting down the computer
from the Log-On dialog would show the following errors in the debugger:
```
err:(.../winlogon/sas.c:757) ImpersonateLoggedOnUser() failed with error 6
err:(.../winlogon/sas.c:859) Shutdown thread returned failure
err:(.../winlogon/sas.c:1182) Failed to start the Shutdown thread, Status 0xc0000001
```
Fix some erroneous `SetFocus()` invocations in dialog procedures:
- In `WM_INITDIALOG`, don't return `TRUE` if focus is changed to a
control, otherwise any focus set by the caller would be ignored;
- In other handlers, `SetFocus()` would generate an inconsistent
behaviour with the dialog push-buttons, as mentioned in:
https://devblogs.microsoft.com/oldnewthing/20040802-00/?p=38283
This allows pressing ENTER or ESC on the keyboard and have the correct
action done. The equivalent dialog in shell32.dll was already using that.
Simplify the associated code as well.
Also: remove the unused `", 400, 0, 1"` `FONT` resource specification info.
And add missing keyboard accelerators to the dialog buttons
(except for Hebrew where it's not clear what the preferred way
of specifying accelerators is).