ReactOS  0.4.15-dev-1377-ga59cecd
init.c File Reference
#include "usersrv.h"
#include "api.h"
#include "../consrv/api.h"
#include <debug.h>
Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOL CALLBACK FindTopLevelWnd (IN HWND hWnd, IN LPARAM lParam)
 
BOOL NTAPI _UserSoundSentry (VOID)
 
ULONG NTAPI CreateSystemThreads (PVOID pParam)
 
 CSR_API (SrvCreateSystemThreads)
 
 CSR_API (SrvActivateDebugger)
 
 CSR_API (SrvGetThreadConsoleDesktop)
 
 CSR_API (SrvDeviceEvent)
 
 CSR_API (SrvLogon)
 
NTSTATUS NTAPI UserClientConnect (IN PCSR_PROCESS CsrProcess, IN OUT PVOID ConnectionInfo, IN OUT PULONG ConnectionInfoLength)
 
 CSR_SERVER_DLL_INIT (UserServerDllInitialization)
 

Variables

HINSTANCE UserServerDllInstance = NULL
 
HANDLE ghPowerRequestEvent
 
HANDLE ghMediaRequestEvent
 
HANDLE CsrApiPort = NULL
 
HANDLE UserServerHeap = NULL
 
PCSR_API_ROUTINE UserServerApiDispatchTable [UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER]
 
BOOLEAN UserServerApiServerValidTable [UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file init.c.

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

◆ CreateSystemThreads()

ULONG NTAPI CreateSystemThreads ( PVOID  pParam)

Definition at line 115 of file init.c.

116 {
117  NtUserCallOneParam((DWORD_PTR)pParam, ONEPARAM_ROUTINE_CREATESYSTEMTHREADS);
119  return 0;
120 }
NTSYSAPI VOID NTAPI RtlExitUserThread(_In_ NTSTATUS Status)
DWORD_PTR NTAPI NtUserCallOneParam(DWORD_PTR Param, DWORD Routine)
Definition: simplecall.c:145
uint32_t DWORD_PTR
Definition: typedefs.h:65

Referenced by CSR_API().

◆ CSR_API() [1/5]

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 }
ULONG NTAPI CreateSystemThreads(PVOID pParam)
Definition: init.c:115
NTSTATUS NTAPI CsrExecServerThread(IN PVOID ThreadHandler, IN ULONG Flags)
Definition: thredsup.c:885
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DPRINT1
Definition: precomp.h:8

◆ CSR_API() [2/5]

CSR_API ( SrvActivateDebugger  )

Definition at line 135 of file init.c.

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

◆ CSR_API() [3/5]

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 }
LONG NTSTATUS
Definition: precomp.h:26
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _USER_API_MESSAGE * PUSER_API_MESSAGE
#define DPRINT1
Definition: precomp.h:8
#define STATUS_SUCCESS
Definition: shellext.h:65
NTSTATUS NTAPI GetThreadConsoleDesktop(IN ULONG_PTR ThreadId, OUT HDESK *ConsoleDesktop)
Definition: frontendctl.c:265

◆ CSR_API() [4/5]

CSR_API ( SrvDeviceEvent  )

Definition at line 160 of file init.c.

161 {
162  DPRINT1("%s not yet implemented\n", __FUNCTION__);
163  return STATUS_NOT_IMPLEMENTED;
164 }
return STATUS_NOT_IMPLEMENTED
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [5/5]

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 */
180  CsrRevertToSelf();
181  return STATUS_SUCCESS;
182 }
BOOL IsLogon
Definition: winmsg.h:65
BOOLEAN NTAPI CsrRevertToSelf(VOID)
Definition: procsup.c:1056
VOID FASTCALL GetTimeouts(IN PSHUTDOWN_SETTINGS ShutdownSettings)
Definition: init.c:87
struct _USER_API_MESSAGE * PUSER_API_MESSAGE
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
SHUTDOWN_SETTINGS ShutdownSettings
Definition: init.c:24
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
Definition: procsup.c:931
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ CSR_SERVER_DLL_INIT()

CSR_SERVER_DLL_INIT ( UserServerDllInitialization  )

Definition at line 236 of file init.c.

237 {
239 
240  /* Initialize the memory */
241  UserServerHeap = RtlGetProcessHeap();
242 
243  /* Setup the DLL Object */
244  LoadedServerDll->ApiBase = USERSRV_FIRST_API_NUMBER;
245  LoadedServerDll->HighestApiSupported = UserpMaxApiNumber;
246  LoadedServerDll->DispatchTable = UserServerApiDispatchTable;
247  LoadedServerDll->ValidTable = UserServerApiServerValidTable;
248 #ifdef CSR_DBG
249  LoadedServerDll->NameTable = UserServerApiNameTable;
250 #endif
251  LoadedServerDll->SizeOfProcessData = 0;
252  LoadedServerDll->ConnectCallback = UserClientConnect;
253  LoadedServerDll->DisconnectCallback = NULL;
254  LoadedServerDll->HardErrorCallback = UserServerHardError;
255  LoadedServerDll->ShutdownProcessCallback = UserClientShutdown;
256 
257  UserServerDllInstance = LoadedServerDll->ServerHandle;
258 
259  /* Create the power request event */
262  NULL,
264  FALSE);
265  if (!NT_SUCCESS(Status))
266  {
267  DPRINT1("Power request event creation failed with Status 0x%08x\n", Status);
268  return Status;
269  }
270 
271  /* Create the media request event */
274  NULL,
276  FALSE);
277  if (!NT_SUCCESS(Status))
278  {
279  DPRINT1("Media request event creation failed with Status 0x%08x\n", Status);
280  return Status;
281  }
282 
283  /* Set the process creation notify routine for BASE */
285 
286  /* Initialize the hard errors cache */
288 
289  /* Initialize the kernel mode subsystem */
293  if (!NT_SUCCESS(Status))
294  {
295  DPRINT1("NtUserInitialize failed with Status 0x%08x\n", Status);
296  return Status;
297  }
298 
299  /* All done */
300  return STATUS_SUCCESS;
301 }
PCSR_API_ROUTINE UserServerApiDispatchTable[UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER]
Definition: init.c:34
BOOL NTAPI NtUserNotifyProcessCreate(HANDLE NewProcessId, HANDLE ParentThreadId, ULONG dwUnknown, ULONG CreateFlags)
Definition: ntstubs.c:516
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:96
#define USER_VERSION
Definition: ntuser.h:1098
#define USERSRV_FIRST_API_NUMBER
Definition: winmsg.h:16
HANDLE ghPowerRequestEvent
Definition: init.c:24
NTSTATUS NTAPI UserClientConnect(IN PCSR_PROCESS CsrProcess, IN OUT PVOID ConnectionInfo, IN OUT PULONG ConnectionInfoLength)
Definition: init.c:186
#define FALSE
Definition: types.h:117
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtUserInitialize(DWORD dwWinVersion, HANDLE hPowerRequestEvent, HANDLE hMediaRequestEvent)
Definition: ntuser.c:175
HANDLE ghMediaRequestEvent
Definition: init.c:25
HINSTANCE UserServerDllInstance
Definition: init.c:21
VOID NTAPI BaseSetProcessCreateNotify(IN BASE_PROCESS_CREATE_NOTIFY_ROUTINE ProcessCreateNotifyProc)
Definition: proc.c:321
ULONG NTAPI UserClientShutdown(IN PCSR_PROCESS CsrProcess, IN ULONG Flags, IN BOOLEAN FirstPhase)
Definition: shutdown.c:732
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
VOID UserInitHardErrorsCache(VOID)
Definition: harderror.c:1189
HANDLE UserServerHeap
Definition: init.c:31
#define STATUS_SUCCESS
Definition: shellext.h:65
BOOLEAN UserServerApiServerValidTable[UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER]
Definition: init.c:51
VOID NTAPI UserServerHardError(IN PCSR_THREAD ThreadData, IN PHARDERROR_MSG Message)
Definition: harderror.c:1082

◆ FindTopLevelWnd()

BOOL CALLBACK FindTopLevelWnd ( IN HWND  hWnd,
IN LPARAM  lParam 
)

Definition at line 94 of file init.c.

97 {
98  if (GetWindow(hWnd, GW_OWNER) == NULL)
99  {
100  *(HWND*)lParam = hWnd;
101  return FALSE;
102  }
103  return TRUE;
104 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define NULL
Definition: types.h:112
#define GW_OWNER
Definition: winuser.h:761
LPARAM lParam
Definition: combotst.c:139

Referenced by ThreadShutdownNotify(), and UserpFormatMessages().

◆ UserClientConnect()

NTSTATUS NTAPI UserClientConnect ( IN PCSR_PROCESS  CsrProcess,
IN OUT PVOID  ConnectionInfo,
IN OUT PULONG  ConnectionInfoLength 
)

Definition at line 186 of file init.c.

189 {
191  // PUSERCONNECT
192  PUSERSRV_API_CONNECTINFO ConnectInfo = (PUSERSRV_API_CONNECTINFO)ConnectionInfo;
193 
194  DPRINT("UserClientConnect\n");
195 
196  /* Check if we don't have an API port yet */
197  if (CsrApiPort == NULL)
198  {
199  /* Query the API port and save it globally */
201 
202  /* Inform win32k about the API port */
205  &CsrApiPort,
206  sizeof(CsrApiPort));
207  if (!NT_SUCCESS(Status))
208  {
209  return Status;
210  }
211  }
212 
213  /* Check connection info validity */
214  if ( ConnectionInfo == NULL ||
215  ConnectionInfoLength == NULL ||
216  *ConnectionInfoLength != sizeof(*ConnectInfo) )
217  {
218  DPRINT1("USERSRV: Connection failed - ConnectionInfo = 0x%p ; ConnectionInfoLength = 0x%p (%lu), expected %lu\n",
219  ConnectionInfo,
220  ConnectionInfoLength,
221  ConnectionInfoLength ? *ConnectionInfoLength : (ULONG)-1,
222  sizeof(*ConnectInfo));
223 
225  }
226 
227  /* Pass the request to win32k */
228  ConnectInfo->dwDispatchCount = 0; // gDispatchTableValues;
229  Status = NtUserProcessConnect(CsrProcess->ProcessHandle,
230  ConnectInfo,
231  *ConnectionInfoLength);
232 
233  return Status;
234 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define NtCurrentThread()
PKPROCESS CsrProcess
Definition: videoprt.c:39
#define PUSERSRV_API_CONNECTINFO
Definition: winmsg.h:41
NTSTATUS NTAPI NtUserSetInformationThread(IN HANDLE ThreadHandle, IN USERTHREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: ntstubs.c:699
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NULL
Definition: types.h:112
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
HANDLE NTAPI CsrQueryApiPort(VOID)
Definition: api.c:1093
NTSTATUS NTAPI NtUserProcessConnect(IN HANDLE ProcessHandle, OUT PUSERCONNECT pUserConnect, IN ULONG Size)
Definition: ntstubs.c:529
HANDLE CsrApiPort
Definition: init.c:33

Referenced by CSR_SERVER_DLL_INIT().

Variable Documentation

◆ CsrApiPort

◆ ghMediaRequestEvent

HANDLE ghMediaRequestEvent

Definition at line 25 of file init.c.

Referenced by CSR_SERVER_DLL_INIT().

◆ ghPowerRequestEvent

HANDLE ghPowerRequestEvent

Definition at line 24 of file init.c.

Referenced by CSR_SERVER_DLL_INIT().

◆ UserServerApiDispatchTable

Initial value:
=
{
SrvExitWindowsEx,
SrvEndTask,
SrvLogon,
SrvRegisterServicesProcess,
SrvActivateDebugger,
SrvGetThreadConsoleDesktop,
SrvDeviceEvent,
SrvRegisterLogonProcess,
SrvCreateSystemThreads,
SrvRecordShutdownReason,
}

Definition at line 34 of file init.c.

Referenced by CSR_SERVER_DLL_INIT().

◆ UserServerApiServerValidTable

BOOLEAN UserServerApiServerValidTable[UserpMaxApiNumber - USERSRV_FIRST_API_NUMBER]
Initial value:
=
{
TRUE,
}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

Definition at line 51 of file init.c.

Referenced by CSR_SERVER_DLL_INIT().

◆ UserServerDllInstance

HINSTANCE UserServerDllInstance = NULL

Definition at line 21 of file init.c.

Referenced by CSR_SERVER_DLL_INIT(), EndNowThreadProc(), and UserInitHardErrorsCache().

◆ UserServerHeap

HANDLE UserServerHeap = NULL

Definition at line 31 of file init.c.

Referenced by CSR_SERVER_DLL_INIT(), and EndNowDlgProc().