3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS CSRSS subsystem
5 * FILE: subsys/csrss/win32csr/exitros.c
6 * PURPOSE: Logout/shutdown
9 /* INCLUDES ******************************************************************/
12 #include <reactos/winlogon.h>
19 static HWND LogonNotifyWindow
= NULL
;
20 static DWORD LogonProcess
= 0;
22 CSR_API(CsrRegisterLogonProcess
)
24 Reply
->Header
.MessageSize
= sizeof(CSRSS_API_REPLY
);
25 Reply
->Header
.DataSize
= sizeof(CSRSS_API_REPLY
) - LPC_MESSAGE_BASE_SIZE
;
27 if (Request
->Data
.RegisterLogonProcessRequest
.Register
)
29 if (0 != LogonProcess
)
31 Reply
->Status
= STATUS_LOGON_SESSION_EXISTS
;
34 LogonProcess
= Request
->Data
.RegisterLogonProcessRequest
.ProcessId
;
38 if ((DWORD
) Request
->Header
.ClientId
.UniqueProcess
!= LogonProcess
)
40 DPRINT1("Current logon process 0x%x, can't deregister from process 0x%x\n",
41 LogonProcess
, Request
->Header
.ClientId
.UniqueProcess
);
42 Reply
->Status
= STATUS_NOT_LOGON_PROCESS
;
48 Reply
->Status
= STATUS_SUCCESS
;
53 CSR_API(CsrSetLogonNotifyWindow
)
57 Reply
->Header
.MessageSize
= sizeof(CSRSS_API_REPLY
);
58 Reply
->Header
.DataSize
= sizeof(CSRSS_API_REPLY
) - LPC_MESSAGE_BASE_SIZE
;
60 if (0 == GetWindowThreadProcessId(Request
->Data
.SetLogonNotifyWindowRequest
.LogonNotifyWindow
,
63 DPRINT1("Can't get window creator\n");
64 Reply
->Status
= STATUS_INVALID_HANDLE
;
67 if (WindowCreator
!= LogonProcess
)
69 DPRINT1("Trying to register window not created by winlogon as notify window\n");
70 Reply
->Status
= STATUS_ACCESS_DENIED
;
74 LogonNotifyWindow
= Request
->Data
.SetLogonNotifyWindowRequest
.LogonNotifyWindow
;
76 Reply
->Status
= STATUS_SUCCESS
;
81 CSR_API(CsrExitReactos
)
83 Reply
->Header
.MessageSize
= sizeof(CSRSS_API_REPLY
);
84 Reply
->Header
.DataSize
= sizeof(CSRSS_API_REPLY
) - LPC_MESSAGE_BASE_SIZE
;
86 if (NULL
== LogonNotifyWindow
)
88 DPRINT1("No LogonNotifyWindow registered\n");
89 Reply
->Status
= STATUS_NOT_FOUND
;
93 /* FIXME Inside 2000 says we should impersonate the caller here */
94 Reply
->Status
= SendMessageW(LogonNotifyWindow
, PM_WINLOGON_EXITWINDOWS
,
95 (WPARAM
) Request
->Header
.ClientId
.UniqueProcess
,
96 (LPARAM
) Request
->Data
.ExitReactosRequest
.Flags
);
97 /* If the message isn't handled, the return value is 0, so 0 doesn't indicate success.
98 Success is indicated by a 1 return value, if anything besides 0 or 1 it's a
100 if (1 == Reply
->Status
)
102 Reply
->Status
= STATUS_SUCCESS
;
104 else if (0 == Reply
->Status
)
106 Reply
->Status
= STATUS_NOT_IMPLEMENTED
;
109 return Reply
->Status
;