ReactOS 0.4.16-dev-197-g92996da
api.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOL NTAPI _UserSoundSentry (VOID)
 
 CSR_API (SrvCreateSystemThreads)
 
 CSR_API (SrvActivateDebugger)
 
 CSR_API (SrvGetThreadConsoleDesktop)
 
 CSR_API (SrvDeviceEvent)
 
VOID NTAPI UserServerHardError (IN PCSR_THREAD ThreadData, IN PHARDERROR_MSG Message)
 
 CSR_API (SrvRegisterServicesProcess)
 
 CSR_API (SrvRegisterLogonProcess)
 
ULONG NTAPI UserClientShutdown (IN PCSR_PROCESS CsrProcess, IN ULONG Flags, IN BOOLEAN FirstPhase)
 
 CSR_API (SrvExitWindowsEx)
 
 CSR_API (SrvEndTask)
 
 CSR_API (SrvLogon)
 
 CSR_API (SrvRecordShutdownReason)
 

Function Documentation

◆ _UserSoundSentry()

BOOL NTAPI _UserSoundSentry ( VOID  )

Definition at line 107 of file init.c.

108{
109 // TODO: Do something.
110 return TRUE;
111}
#define TRUE
Definition: types.h:120

◆ CSR_API() [1/10]

CSR_API ( SrvActivateDebugger  )

Definition at line 135 of file init.c.

136{
137 DPRINT1("%s not yet implemented\n", __FUNCTION__);
139}
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define __FUNCTION__
Definition: types.h:116

◆ CSR_API() [2/10]

CSR_API ( SrvCreateSystemThreads  )

Definition at line 123 of file init.c.

124{
126 if (!NT_SUCCESS(Status))
127 {
128 DPRINT1("Cannot start system thread!\n");
129 }
130
131 return Status;
132}
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI CsrExecServerThread(IN PVOID ThreadHandler, IN ULONG Flags)
Definition: thredsup.c:886
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
Status
Definition: gdiplustypes.h:25
ULONG NTAPI CreateSystemThreads(PVOID pParam)
Definition: init.c:115

◆ CSR_API() [3/10]

CSR_API ( SrvDeviceEvent  )

Definition at line 160 of file init.c.

161{
162 DPRINT1("%s not yet implemented\n", __FUNCTION__);
164}

◆ CSR_API() [4/10]

CSR_API ( SrvEndTask  )

Definition at line 827 of file shutdown.c.

828{
829 PUSER_END_TASK EndTaskRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.EndTaskRequest;
831
832 // FIXME: This is HACK-plemented!!
833 DPRINT1("SrvEndTask is HACKPLEMENTED!!\n");
834
837 NULL,
838 0);
839 if (!NT_SUCCESS(Status))
840 {
841 DPRINT1("Failed to set thread desktop!\n");
842 return Status;
843 }
844
845 SendMessageW(EndTaskRequest->WndHandle, WM_CLOSE, 0, 0);
846 // PostMessageW(EndTaskRequest->WndHandle, WM_CLOSE, 0, 0);
847
848 if (IsWindow(EndTaskRequest->WndHandle))
849 {
850 if (EndTaskRequest->Force)
851 {
852 EndTaskRequest->Success = DestroyWindow(EndTaskRequest->WndHandle);
853 EndTaskRequest->LastError = GetLastError();
854 }
855 else
856 {
857 EndTaskRequest->Success = FALSE;
858 }
859 }
860 else
861 {
862 EndTaskRequest->Success = TRUE;
863 EndTaskRequest->LastError = ERROR_SUCCESS;
864 }
865
867
868 return STATUS_SUCCESS;
869}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI NtUserSetInformationThread(IN HANDLE ThreadHandle, IN USERTHREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: ntstubs.c:673
@ UserThreadRestoreDesktop
Definition: ntuser.h:77
@ UserThreadUseActiveDesktop
Definition: ntuser.h:75
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOL Force
Definition: winmsg.h:59
DWORD LastError
Definition: winmsg.h:57
BOOL Success
Definition: winmsg.h:60
HWND WndHandle
Definition: winmsg.h:58
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
struct _USER_API_MESSAGE * PUSER_API_MESSAGE
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define WM_CLOSE
Definition: winuser.h:1624
BOOL WINAPI DestroyWindow(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define NtCurrentThread()

◆ CSR_API() [5/10]

CSR_API ( SrvExitWindowsEx  )

Definition at line 802 of file shutdown.c.

803{
805 PUSER_EXIT_REACTOS ExitReactOSRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.ExitReactOSRequest;
806
809 NULL,
810 0);
811 if (!NT_SUCCESS(Status))
812 {
813 DPRINT1("Failed to set thread desktop!\n");
814 return Status;
815 }
816
817 Status = UserExitReactOS(CsrGetClientThread(), ExitReactOSRequest->Flags);
818 ExitReactOSRequest->Success = NT_SUCCESS(Status);
819 ExitReactOSRequest->LastError = GetLastError();
820
822
823 return Status;
824}
#define CsrGetClientThread()
Definition: csrsrv.h:77
DWORD LastError
Definition: winmsg.h:50
static NTSTATUS FASTCALL UserExitReactOS(PCSR_THREAD CsrThread, UINT Flags)
Definition: shutdown.c:610

◆ CSR_API() [6/10]

CSR_API ( SrvGetThreadConsoleDesktop  )

Definition at line 142 of file init.c.

143{
145 PUSER_GET_THREAD_CONSOLE_DESKTOP GetThreadConsoleDesktopRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.GetThreadConsoleDesktopRequest;
146
147 Status = GetThreadConsoleDesktop(GetThreadConsoleDesktopRequest->ThreadId,
148 &GetThreadConsoleDesktopRequest->ConsoleDesktop);
149 if (!NT_SUCCESS(Status))
150 {
151 DPRINT1("GetThreadConsoleDesktop(%lu) failed with Status 0x%08x\n",
152 GetThreadConsoleDesktopRequest->ThreadId, Status);
153 }
154
155 /* Windows-compatibility: Always return success since User32 relies on this! */
156 return STATUS_SUCCESS;
157}
NTSTATUS NTAPI GetThreadConsoleDesktop(IN ULONG_PTR ThreadId, OUT HDESK *ConsoleDesktop)
Definition: frontendctl.c:265

◆ CSR_API() [7/10]

CSR_API ( SrvLogon  )

Definition at line 167 of file init.c.

168{
169 PUSER_LOGON LogonRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.LogonRequest;
170
171 DPRINT1("We are logged %s\n", LogonRequest->IsLogon ? "on" : "off");
172
173 /* Impersonate the caller in order to retrieve settings in its context */
175 return STATUS_UNSUCCESSFUL;
176
178
179 /* We are done */
181 return STATUS_SUCCESS;
182}
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
Definition: procsup.c:932
BOOLEAN NTAPI CsrRevertToSelf(VOID)
Definition: procsup.c:1057
BOOL IsLogon
Definition: winmsg.h:65
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
VOID FASTCALL GetTimeouts(IN PSHUTDOWN_SETTINGS ShutdownSettings)
Definition: init.c:87
SHUTDOWN_SETTINGS ShutdownSettings
Definition: init.c:24

◆ CSR_API() [8/10]

CSR_API ( SrvRecordShutdownReason  )

Definition at line 872 of file shutdown.c.

873{
874 DPRINT1("%s not yet implemented\n", __FUNCTION__);
876}

◆ CSR_API() [9/10]

CSR_API ( SrvRegisterLogonProcess  )

Definition at line 30 of file register.c.

31{
32 PUSER_REGISTER_LOGON_PROCESS RegisterLogonProcessRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.RegisterLogonProcessRequest;
33
34 if (RegisterLogonProcessRequest->Register)
35 {
36 if (LogonProcessId != 0)
38
39 LogonProcessId = RegisterLogonProcessRequest->ProcessId;
40 }
41 else
42 {
43 if (ApiMessage->Header.ClientId.UniqueProcess != UlongToHandle(LogonProcessId))
44 {
45 DPRINT1("Current logon process 0x%x, can't deregister from process 0x%x\n",
46 LogonProcessId, ApiMessage->Header.ClientId.UniqueProcess);
48 }
49
51 }
52
53#if 1 //HAAAACK. This should be done in UserClientConnect which is never called!
54
55 /* Check if we don't have an API port yet */
56 if (CsrApiPort == NULL)
57 {
59
60 /* Query the API port and save it globally */
62
63 DPRINT("Giving win32k our api port\n");
64
65 /* Inform win32k about the API port */
69 sizeof(CsrApiPort));
70 if (!NT_SUCCESS(Status))
71 {
72 return Status;
73 }
74 }
75#endif
76
77 return STATUS_SUCCESS;
78}
#define UlongToHandle(ul)
Definition: basetsd.h:97
HANDLE NTAPI CsrQueryApiPort(VOID)
Definition: api.c:1097
@ UserThreadCsrApiPort
Definition: ntuser.h:78
#define STATUS_NOT_LOGON_PROCESS
Definition: ntstatus.h:473
#define STATUS_LOGON_SESSION_EXISTS
Definition: ntstatus.h:474
#define DPRINT
Definition: sndvol32.h:73
ULONG_PTR LogonProcessId
Definition: register.c:21
HANDLE CsrApiPort
Definition: connect.c:27

◆ CSR_API() [10/10]

CSR_API ( SrvRegisterServicesProcess  )

Definition at line 81 of file register.c.

82{
83 PUSER_REGISTER_SERVICES_PROCESS RegisterServicesProcessRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.RegisterServicesProcessRequest;
84
86 {
87 /* Only accept a single call */
89 }
90 else
91 {
92 ServicesProcessId = RegisterServicesProcessRequest->ProcessId;
94 return STATUS_SUCCESS;
95 }
96}
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static BOOLEAN ServicesProcessIdValid
Definition: register.c:19
ULONG_PTR ServicesProcessId
Definition: register.c:20

◆ UserClientShutdown()

ULONG NTAPI UserClientShutdown ( IN PCSR_PROCESS  CsrProcess,
IN ULONG  Flags,
IN BOOLEAN  FirstPhase 
)

Definition at line 732 of file shutdown.c.

735{
737
738 DPRINT("UserClientShutdown(0x%p, 0x%x, %s) - [0x%x, 0x%x], ShutdownFlags: %lu\n",
739 CsrProcess, Flags, FirstPhase ? "FirstPhase" : "LastPhase",
740 CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread,
741 CsrProcess->ShutdownFlags);
742
743 /*
744 * Check for process validity
745 */
746
747 /* Do not kill system processes when a user is logging off */
748 if ((Flags & EWX_SHUTDOWN) == EWX_LOGOFF &&
750 {
751 DPRINT("Do not kill a system process in a logoff request!\n");
753 }
754
755 /* Do not kill Winlogon */
756 if (CsrProcess->ClientId.UniqueProcess == UlongToHandle(LogonProcessId))
757 {
758 DPRINT("Not killing Winlogon; CsrProcess->ShutdownFlags = %lu\n",
759 CsrProcess->ShutdownFlags);
760
761 /* Returning CsrShutdownCsrProcess means that we handled this process by doing nothing */
762 /* This will mark winlogon as processed so consrv won't be notified again for it */
765 }
766
767 /* Notify the process for shutdown if needed */
770 {
772 DPRINT1("Process 0x%x aborted shutdown\n", CsrProcess->ClientId.UniqueProcess);
773 return result;
774 }
775
776 /* Terminate this process */
777#if DBG
778 {
781 {
782 DPRINT1("Terminating process %x\n", CsrProcess->ClientId.UniqueProcess);
783 }
784 else
785 {
786 DPRINT1("Terminating process %x (%S)\n", CsrProcess->ClientId.UniqueProcess, buffer);
787 }
788 }
789#endif
790 NtTerminateProcess(CsrProcess->ProcessHandle, 0);
792
793 /* We are done */
796}
@ CsrShutdownNonCsrProcess
Definition: csrsrv.h:113
@ CsrShutdownCsrProcess
Definition: csrsrv.h:112
@ CsrShutdownCancelled
Definition: csrsrv.h:114
VOID NTAPI CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:691
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define MAX_PATH
Definition: compat.h:34
DWORD WINAPI GetProcessImageFileNameW(HANDLE hProcess, LPWSTR lpImageFileName, DWORD nSize)
Definition: psapi.c:1163
GLuint buffer
Definition: glext.h:5915
GLuint64EXT * result
Definition: glext.h:11304
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)
ULONG ProcessTerminateTimeout
Definition: winsrv.h:54
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
uint32_t ULONG
Definition: typedefs.h:59
PKPROCESS CsrProcess
Definition: videoprt.c:39
#define SHUTDOWN_OTHERCONTEXT
Definition: shutdown.c:28
#define SHUTDOWN_SYSTEMCONTEXT
Definition: shutdown.c:27
static ULONG NotifyUserProcessForShutdown(PCSR_PROCESS CsrProcess, PSHUTDOWN_SETTINGS ShutdownSettings, UINT Flags)
Definition: shutdown.c:488
#define EWX_SHUTDOWN
Definition: winuser.h:639
#define EWX_LOGOFF
Definition: winuser.h:636
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by CSR_SERVER_DLL_INIT().

◆ UserServerHardError()

VOID NTAPI UserServerHardError ( IN PCSR_THREAD  ThreadData,
IN PHARDERROR_MSG  Message 
)

Definition at line 1082 of file harderror.c.

1085{
1086 ULONG ErrorMode;
1087 UINT dwType = 0;
1089 UNICODE_STRING TextU, CaptionU;
1090 WCHAR LocalTextBuffer[256];
1091 WCHAR LocalCaptionBuffer[256];
1093
1094 ASSERT(ThreadData->Process != NULL);
1095
1096 /* Default to not handled */
1097 Message->Response = ResponseNotHandled;
1098
1099 /* Make sure we don't have too many parameters */
1100 if (Message->NumberOfParameters > MAXIMUM_HARDERROR_PARAMETERS)
1101 {
1102 // NOTE: Windows just fails (STATUS_INVALID_PARAMETER) & returns ResponseNotHandled.
1103 DPRINT1("Invalid NumberOfParameters = %d\n", Message->NumberOfParameters);
1104 Message->NumberOfParameters = MAXIMUM_HARDERROR_PARAMETERS;
1105 }
1106 if (Message->ValidResponseOptions > OptionCancelTryContinue)
1107 {
1108 DPRINT1("Unknown ValidResponseOptions = %d\n", Message->ValidResponseOptions);
1109 return; // STATUS_INVALID_PARAMETER;
1110 }
1111 if (Message->Status == STATUS_SERVICE_NOTIFICATION)
1112 {
1113 if (Message->NumberOfParameters < 3)
1114 {
1115 DPRINT1("Invalid NumberOfParameters = %d for STATUS_SERVICE_NOTIFICATION\n",
1116 Message->NumberOfParameters);
1117 return; // STATUS_INVALID_PARAMETER;
1118 }
1119 // (Message->UnicodeStringParameterMask & 0x3)
1120 }
1121
1124 NULL,
1125 0);
1126 if (!NT_SUCCESS(Status))
1127 {
1128 DPRINT1("Failed to set thread desktop!\n");
1129 return;
1130 }
1131
1132 /* Re-initialize the hard errors cache */
1134
1135 /* Format the message caption and text */
1136 RtlInitEmptyUnicodeString(&TextU, LocalTextBuffer, sizeof(LocalTextBuffer));
1137 RtlInitEmptyUnicodeString(&CaptionU, LocalCaptionBuffer, sizeof(LocalCaptionBuffer));
1138 UserpFormatMessages(&TextU, &CaptionU, &dwType, &Timeout, Message);
1139
1140 /* Log the hard error message */
1141 UserpLogHardError(&TextU, &CaptionU);
1142
1143 /* Display a hard error popup depending on the current ErrorMode */
1144
1145 /* Query the error mode value */
1146 ErrorMode = GetRegInt(L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Windows",
1147 L"ErrorMode", 0);
1148
1149 if (Message->Status != STATUS_SERVICE_NOTIFICATION && ErrorMode != 0)
1150 {
1151 /* Returns OK for the hard error */
1152 Message->Response = ResponseOk;
1153 goto Quit;
1154 }
1155
1156 if (Message->ValidResponseOptions == OptionOkNoWait)
1157 {
1158 /* Display the balloon */
1159 Message->Response = ResponseOk;
1160 if (UserpShowInformationBalloon(&TextU,
1161 &CaptionU,
1162 dwType,
1163 Message))
1164 {
1165 Message->Response = ResponseOk;
1166 goto Quit;
1167 }
1168 }
1169
1170 /* Display the message box */
1171 Message->Response = UserpMessageBox(&TextU,
1172 &CaptionU,
1173 dwType,
1174 Timeout);
1175
1176Quit:
1177 /* Free the strings if they have been reallocated */
1178 if (TextU.Buffer != LocalTextBuffer)
1179 RtlFreeUnicodeString(&TextU);
1180 if (CaptionU.Buffer != LocalCaptionBuffer)
1181 RtlFreeUnicodeString(&CaptionU);
1182
1184
1185 return;
1186}
static const WCHAR Message[]
Definition: register.c:74
#define INFINITE
Definition: serial.h:102
static BOOL UserpShowInformationBalloon(IN PUNICODE_STRING TextStringU, IN PUNICODE_STRING CaptionStringU, IN UINT Type, IN PHARDERROR_MSG Message)
Definition: harderror.c:933
static VOID UserpFormatMessages(IN OUT PUNICODE_STRING TextStringU, IN OUT PUNICODE_STRING CaptionStringU, OUT PUINT pdwType, OUT PULONG pdwTimeout, IN PHARDERROR_MSG Message)
Definition: harderror.c:367
static HARDERROR_RESPONSE UserpMessageBox(IN PUNICODE_STRING TextStringU, IN PUNICODE_STRING CaptionStringU, IN UINT Type, IN ULONG Timeout)
Definition: harderror.c:1008
static VOID UserpLogHardError(IN PUNICODE_STRING TextStringU, IN PUNICODE_STRING CaptionStringU)
Definition: harderror.c:1045
static ULONG GetRegInt(IN PCWSTR KeyName, IN PCWSTR ValueName, IN ULONG DefaultValue)
Definition: harderror.c:885
VOID UserInitHardErrorsCache(VOID)
Definition: harderror.c:1189
#define ASSERT(a)
Definition: mode.c:44
unsigned int UINT
Definition: ndis.h:50
#define MAXIMUM_HARDERROR_PARAMETERS
Definition: extypes.h:145
@ OptionCancelTryContinue
Definition: extypes.h:194
@ OptionOkNoWait
Definition: extypes.h:193
@ ResponseNotHandled
Definition: extypes.h:200
@ ResponseOk
Definition: extypes.h:205
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define STATUS_SERVICE_NOTIFICATION
Definition: ntstatus.h:138
#define L(x)
Definition: ntvdm.h:50
static ULONG Timeout
Definition: ping.c:61

Referenced by CSR_SERVER_DLL_INIT().