[WINLOGON][USER32]

Fix the explanations of how Windows/ReactOS should shut down (it's winlogon itself that calls NtShutdownSystem, not something else; that story about "SMSS API #1" concerns the SMSS API SmpSessionCompleteApi called by the helper function SmSessionComplete which is in turn called by CSRSS function CsrDereferenceNtSession, when all win32 processes are gone, as it should).
The webpage http://www.reactos.org/wiki/ShutdownProcess should be corrected for.

[USER32]
Whitespace fixes for winstation code.

svn path=/trunk/; revision=66275
This commit is contained in:
Hermès Bélusca-Maïto 2015-02-15 02:07:23 +00:00
parent 61ec2f8e01
commit 4c28eeae21
3 changed files with 215 additions and 236 deletions

View file

@ -898,7 +898,8 @@ HandleShutdown(
/* Destroy SAS window */
UninitializeSAS(Session);
FIXME("FIXME: Call SMSS API #1\n");
/* Now we can shut down NT */
ERR("Shutting down NT...\n");
RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE, TRUE, FALSE, &Old);
if (wlxAction == WLX_SAS_ACTION_SHUTDOWN_REBOOT)
{

View file

@ -17,10 +17,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32);
*
* - App (usually explorer) calls ExitWindowsEx()
* - ExitWindowsEx() sends a message to CSRSS
* - CSRSS impersonates the caller and sends a message to a hidden WinLogon window
* - WinLogon checks if the caller has the required privileges
* - WinLogon enters pending log-out state
* - WinLogon impersonates the interactive user and calls ExitWindowsEx() again,
* - CSRSS impersonates the caller and sends a message to a hidden Winlogon window
* - Winlogon checks if the caller has the required privileges
* - Winlogon enters pending log-out state
* - Winlogon impersonates the interactive user and calls ExitWindowsEx() again,
* passing some special internal flags
* - CSRSS loops over all processes of the interactive user (sorted by their
* SetProcessShutdownParameters() level), sending WM_QUERYENDSESSION and
@ -39,28 +39,24 @@ WINE_DEFAULT_DEBUG_CHANNEL(user32);
* If the handler doesn't respond in time the same activities as for GUI
* apps (i.e. display dialog box etc) take place. This also happens if
* the handler returns TRUE.
* - This ends the processing for the first ExitWindowsEx() call from WinLogon.
* Execution continues in WinLogon, which calls ExitWindowsEx() again to
* - This ends the processing for the first ExitWindowsEx() call from Winlogon.
* Execution continues in Winlogon, which calls ExitWindowsEx() again to
* terminate COM processes in the interactive user's session.
* - WinLogon stops impersonating the interactive user (whose processes are
* - Winlogon stops impersonating the interactive user (whose processes are
* all dead by now). and enters log-out state
* - If the ExitWindowsEx() request was for a logoff, WinLogon sends a SAS
* event (to display the "press ctrl+alt+del") to the GINA. WinLogon then
* - If the ExitWindowsEx() request was for a logoff, Winlogon sends a SAS
* event (to display the "press ctrl+alt+del") to the GINA. Winlogon then
* waits for the GINA to send a SAS event to login.
* - If the ExitWindowsEx() request was for shutdown/restart, WinLogon calls
* - If the ExitWindowsEx() request was for shutdown/restart, Winlogon calls
* ExitWindowsEx() again in the system process context.
* - CSRSS goes through the motions of sending WM_QUERYENDSESSION/WM_ENDSESSION
* to GUI processes running in the system process context but won't display
* dialog boxes or kill threads/processes. Same for console processes,
* using the CTRL_SHUTDOWN_EVENT. The Service Control Manager is one of
* these console processes and has a special timeout value WaitToKillServiceTimeout.
* - WinLogon issues a "InitiateSystemShutdown" request to the SM (SMSS API # 1)
* - the SM propagates the shutdown request to every environment subsystem it
* started since bootstrap time (still active ones, of course)
* - each environment subsystem, on shutdown request, releases every resource
* it aquired during its life (processes, memory etc), then dies
* - when every environment subsystem has gone to bed, the SM actually initiates
* the kernel and executive shutdown by calling NtShutdownSystem.
* - After CSRSS has finished its pass notifying processes that system is shutting down,
* Winlogon finishes the shutdown process by calling the executive subsystem
* function NtShutdownSystem.
*/
typedef struct

View file

@ -113,7 +113,7 @@ EnumNamesW(HWINSTA WindowStation,
LPARAM Context,
BOOL Desktops)
{
char Buffer[256];
CHAR Buffer[256];
PVOID NameList;
PWCHAR Name;
NTSTATUS Status;
@ -121,17 +121,13 @@ EnumNamesW(HWINSTA WindowStation,
ULONG CurrentEntry, EntryCount;
BOOL Ret;
/*
* Check parameters
*/
if (NULL == WindowStation && Desktops)
/* Check parameters */
if (WindowStation == NULL && Desktops)
{
WindowStation = GetProcessWindowStation();
}
/*
* Try with fixed-size buffer
*/
/* Try with fixed-size buffer */
Status = NtUserBuildNameList(WindowStation, sizeof(Buffer), Buffer, &RequiredSize);
if (NT_SUCCESS(Status))
{
@ -142,13 +138,12 @@ EnumNamesW(HWINSTA WindowStation,
{
/* Allocate a larger buffer */
NameList = HeapAlloc(GetProcessHeap(), 0, RequiredSize);
if (NULL == NameList)
{
if (NameList == NULL)
return FALSE;
}
/* Try again */
Status = NtUserBuildNameList(WindowStation, RequiredSize, NameList, NULL);
if (! NT_SUCCESS(Status))
if (!NT_SUCCESS(Status))
{
HeapFree(GetProcessHeap(), 0, NameList);
SetLastError(RtlNtStatusToDosError(Status));
@ -162,9 +157,7 @@ EnumNamesW(HWINSTA WindowStation,
return FALSE;
}
/*
* Enum the names one by one
*/
/* Enum the names one by one */
EntryCount = *((DWORD *) NameList);
Name = (PWCHAR) ((PCHAR) NameList + sizeof(DWORD));
Ret = TRUE;
@ -174,9 +167,7 @@ EnumNamesW(HWINSTA WindowStation,
Name += wcslen(Name) + 1;
}
/*
* Cleanup
*/
/* Cleanup */
if (NameList != Buffer)
{
HeapFree(GetProcessHeap(), 0, NameList);
@ -201,14 +192,14 @@ BOOL CALLBACK
EnumNamesCallback(LPWSTR Name, LPARAM Param)
{
PENUMNAMESASCIICONTEXT Context = (PENUMNAMESASCIICONTEXT) Param;
char FixedNameA[32];
CHAR FixedNameA[32];
LPSTR NameA;
int Len;
INT Len;
BOOL Ret;
/*
* Determine required size of Ascii string and see if we can use
* fixed buffer
* Determine required size of Ascii string and see
* if we can use fixed buffer.
*/
Len = WideCharToMultiByte(CP_ACP, 0, Name, -1, NULL, 0, NULL, NULL);
if (Len <= 0)
@ -232,9 +223,7 @@ EnumNamesCallback(LPWSTR Name, LPARAM Param)
}
}
/*
* Do the Unicode ->Ascii conversion
*/
/* Do the Unicode ->Ascii conversion */
if (0 == WideCharToMultiByte(CP_ACP, 0, Name, -1, NameA, Len, NULL, NULL))
{
/* Something went wrong, clean up */
@ -245,14 +234,10 @@ EnumNamesCallback(LPWSTR Name, LPARAM Param)
return FALSE;
}
/*
* Call user callback
*/
/* Call user callback */
Ret = Context->UserEnumFunc(NameA, Context->UserContext);
/*
* Clean up
*/
/* Cleanup */
if (NameA != FixedNameA)
{
HeapFree(GetProcessHeap(), 0, NameA);
@ -372,7 +357,7 @@ OpenWindowStationW(LPCWSTR lpszWinSta,
hWindowStationsDir,
0);
if( fInherit )
if(fInherit)
{
ObjectAttributes.Attributes |= OBJ_INHERIT;
}
@ -390,15 +375,12 @@ OpenWindowStationW(LPCWSTR lpszWinSta,
*/
BOOL
WINAPI
SetWindowStationUser(
HWINSTA hWindowStation,
SetWindowStationUser(HWINSTA hWindowStation,
PLUID pluid,
PSID psid,
DWORD size
)
DWORD size)
{
return NtUserSetWindowStationUser(hWindowStation, pluid, psid, size);
}
/* EOF */