Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

csrstubs.c File Reference

#include "precomp.h"
#include "csrmsg.h"
#include "dbt.h"
#include "csrhlpr.h"

Go to the source code of this file.

Classes

struct  _EXITWINDOWSDATA

Defines

#define SET_LAST_ERROR_RETURNED()   if (a->dwLastError) RIPERR0(a->dwLastError, RIP_VERBOSE, "")

Typedefs

typedef _EXITWINDOWSDATA EXITWINDOWSDATA
typedef _EXITWINDOWSDATAPEXITWINDOWSDATA

Functions

NTSTATUS APIENTRY CallUserpExitWindowsEx (IN UINT uFlags, IN DWORD dwReserved, OUT PBOOL pfSuccess)
DWORD ExitWindowsThread (PVOID pvParam)
BOOL WINAPI ExitWindowsWorker (UINT uFlags, DWORD dwReserved, BOOL fSecondThread)
BOOL WINAPI ExitWindowsEx (UINT uFlags, DWORD dwReserved)
BOOL WINAPI EndTask (HWND hwnd, BOOL fShutdown, BOOL fForce)
VOID APIENTRY Logon (BOOL fLogon)
NTSTATUS APIENTRY CallUserpRegisterLogonProcess (IN DWORD dwProcessId)
BOOL RegisterLogonProcess (DWORD dwProcessId, BOOL fSecure)
BOOL WINAPI RegisterServicesProcess (DWORD dwProcessId)
HDESK WINAPI GetThreadDesktop (DWORD dwThreadId)
ULONG WINAPI DeviceEventWorker (IN HWND hWnd, IN WPARAM wParam, IN LPARAM lParam, IN DWORD dwFlags, OUT PDWORD pdwResult)

Variables

BOOL gfLogonProcess


Define Documentation

 
#define SET_LAST_ERROR_RETURNED  )     if (a->dwLastError) RIPERR0(a->dwLastError, RIP_VERBOSE, "")
 

Definition at line 36 of file csrstubs.c.

Referenced by CallUserpExitWindowsEx(), EndTask(), and RegisterServicesProcess().


Typedef Documentation

typedef struct _EXITWINDOWSDATA EXITWINDOWSDATA
 

typedef struct _EXITWINDOWSDATA * PEXITWINDOWSDATA
 

Referenced by ExitWindowsThread().


Function Documentation

NTSTATUS APIENTRY CallUserpExitWindowsEx IN UINT  uFlags,
IN DWORD  dwReserved,
OUT PBOOL  pfSuccess
 

Definition at line 42 of file csrstubs.c.

References CsrClientCallServer(), _EXITWINDOWSEXMSG::dwReserved, FALSE, NT_SUCCESS, NULL, SET_LAST_ERROR_RETURNED, _USER_API_MSG::u, _EXITWINDOWSEXMSG::uFlags, and UserpExitWindowsEx.

Referenced by ExitWindowsWorker().

00046 { 00047 00048 USER_API_MSG m; 00049 PEXITWINDOWSEXMSG a = &m.u.ExitWindowsEx; 00050 00051 a->uFlags = uFlags; 00052 a->dwReserved = dwReserved; 00053 CsrClientCallServer( (PCSR_API_MSG)&m, 00054 NULL, 00055 CSR_MAKE_API_NUMBER( USERSRV_SERVERDLL_INDEX, 00056 UserpExitWindowsEx 00057 ), 00058 sizeof( *a ) 00059 ); 00060 00061 if (NT_SUCCESS( m.ReturnValue ) || m.ReturnValue == STATUS_CANT_WAIT) { 00062 SET_LAST_ERROR_RETURNED(); 00063 *pfSuccess = a->fSuccess; 00064 } else { 00065 RIPNTERR0(m.ReturnValue, RIP_VERBOSE, ""); 00066 *pfSuccess = FALSE; 00067 } 00068 00069 return m.ReturnValue; 00070 00071 }

NTSTATUS APIENTRY CallUserpRegisterLogonProcess IN DWORD  dwProcessId  ) 
 

Definition at line 228 of file csrstubs.c.

References CsrClientCallServer(), NTSTATUS(), NULL, Status, _USER_API_MSG::u, and UserpRegisterLogonProcess.

Referenced by RegisterLogonProcess().

00230 { 00231 00232 USER_API_MSG m; 00233 PLOGONMSG a = &m.u.Logon; 00234 NTSTATUS Status; 00235 00236 m.u.IdLogon = dwProcessId; 00237 Status = CsrClientCallServer( (PCSR_API_MSG)&m, 00238 NULL, 00239 CSR_MAKE_API_NUMBER( USERSRV_SERVERDLL_INDEX, 00240 UserpRegisterLogonProcess), 00241 sizeof(*a)); 00242 00243 return Status; 00244 }

ULONG WINAPI DeviceEventWorker IN HWND  hWnd,
IN WPARAM  wParam,
IN LPARAM  lParam,
IN DWORD  dwFlags,
OUT PDWORD  pdwResult
 

Definition at line 338 of file csrstubs.c.

References CsrAllocateCaptureBuffer(), CsrCaptureMessageBuffer(), CsrClientCallServer(), CsrFreeCaptureBuffer(), dwFlags, _DEVICEEVENTMSG::dwFlags, DWORD, _DEVICEEVENTMSG::dwResult, hWnd, _DEVICEEVENTMSG::hWnd, _DEVICEEVENTMSG::lParam, NT_SUCCESS, NULL, _USER_API_MSG::ReturnValue, _USER_API_MSG::u, UserpDeviceEvent, and _DEVICEEVENTMSG::wParam.

00345 { 00346 USER_API_MSG m; 00347 PDEVICEEVENTMSG a = &m.u.DeviceEvent; 00348 PCSR_CAPTURE_HEADER CaptureBuffer = NULL; 00349 int cb = 0; 00350 00351 a->hWnd = hWnd; 00352 a->wParam = wParam; 00353 a->lParam = lParam; 00354 a->dwFlags = dwFlags; 00355 a->dwResult = 0; 00356 00357 // 00358 // If lParam is specified, it must be marshalled (see the defines 00359 // for this structure in dbt.h - the structure always starts with 00360 // DEV_BROADCAST_HDR structure). 00361 // 00362 00363 if (lParam) { 00364 00365 cb = ((PDEV_BROADCAST_HDR)lParam)->dbch_size; 00366 00367 CaptureBuffer = CsrAllocateCaptureBuffer(1, cb); 00368 if (CaptureBuffer == NULL) { 00369 return STATUS_NO_MEMORY; 00370 } 00371 00372 CsrCaptureMessageBuffer(CaptureBuffer, 00373 (PCHAR)lParam, 00374 cb, 00375 (PVOID *)&a->lParam); 00376 00377 // 00378 // This ends up calling SrvDeviceEvent routine in the server. 00379 // 00380 00381 CsrClientCallServer((PCSR_API_MSG)&m, 00382 CaptureBuffer, 00383 CSR_MAKE_API_NUMBER(USERSRV_SERVERDLL_INDEX, 00384 UserpDeviceEvent), 00385 sizeof(*a)); 00386 00387 CsrFreeCaptureBuffer(CaptureBuffer); 00388 00389 } else { 00390 00391 // 00392 // This ends up calling SrvDeviceEvent routine in the server. 00393 // 00394 00395 CsrClientCallServer((PCSR_API_MSG)&m, 00396 NULL, 00397 CSR_MAKE_API_NUMBER(USERSRV_SERVERDLL_INDEX, 00398 UserpDeviceEvent), 00399 sizeof(*a)); 00400 } 00401 00402 00403 if (NT_SUCCESS(m.ReturnValue)) { 00404 *pdwResult = (DWORD)a->dwResult; 00405 } else { 00406 RIPMSG0(RIP_WARNING, "DeviceEventWorker failed."); 00407 } 00408 00409 return m.ReturnValue; 00410 00411 } // DeviceEventWorker

BOOL WINAPI EndTask HWND  hwnd,
BOOL  fShutdown,
BOOL  fForce
 

Definition at line 181 of file csrstubs.c.

References BOOL, CsrClientCallServer(), FALSE, _ENDTASKMSG::fForce, _ENDTASKMSG::fShutdown, _ENDTASKMSG::hwnd, NT_SUCCESS, NULL, SET_LAST_ERROR_RETURNED, _USER_API_MSG::u, and UserpEndTask.

00185 { 00186 USER_API_MSG m; 00187 PENDTASKMSG a = &m.u.EndTask; 00188 00189 a->hwnd = hwnd; 00190 a->fShutdown = fShutdown; 00191 a->fForce = fForce; 00192 CsrClientCallServer( (PCSR_API_MSG)&m, 00193 NULL, 00194 CSR_MAKE_API_NUMBER( USERSRV_SERVERDLL_INDEX, 00195 UserpEndTask 00196 ), 00197 sizeof( *a ) 00198 ); 00199 if (NT_SUCCESS( m.ReturnValue )) { 00200 SET_LAST_ERROR_RETURNED(); 00201 return a->fSuccess; 00202 } else { 00203 RIPNTERR0(m.ReturnValue, RIP_VERBOSE, ""); 00204 return FALSE; 00205 } 00206 }

BOOL WINAPI ExitWindowsEx UINT  uFlags,
DWORD  dwReserved
 

Definition at line 170 of file csrstubs.c.

References BOOL, ExitWindowsWorker(), and FALSE.

00173 { 00174 return ExitWindowsWorker(uFlags, dwReserved, FALSE); 00175 }

DWORD ExitWindowsThread PVOID  pvParam  ) 
 

Definition at line 156 of file csrstubs.c.

References DWORD, _EXITWINDOWSDATA::dwReserved, ExitWindowsWorker(), PEXITWINDOWSDATA, TRUE, and _EXITWINDOWSDATA::uFlags.

Referenced by ExitWindowsWorker().

00158 { 00159 PEXITWINDOWSDATA pewd = pvParam; 00160 DWORD dwExitCode; 00161 00162 if (ExitWindowsWorker(pewd->uFlags, pewd->dwReserved, TRUE)) 00163 dwExitCode = 0; 00164 else 00165 dwExitCode = GetLastError(); 00166 ExitThread(dwExitCode); 00167 return 0; 00168 }

BOOL WINAPI ExitWindowsWorker UINT  uFlags,
DWORD  dwReserved,
BOOL  fSecondThread
 

Definition at line 84 of file csrstubs.c.

References BOOL, CallUserpExitWindowsEx(), DispatchMessage(), DWORD, _EXITWINDOWSDATA::dwReserved, ExitWindowsThread(), FALSE, msg, MsgWaitForMultipleObjectsEx(), NT_SUCCESS, NtClose(), NTSTATUS(), NtUserCallOneParam(), NULL, PeekMessage(), PtiCurrent, Status, TRUE, and _EXITWINDOWSDATA::uFlags.

Referenced by ExitWindowsEx(), and ExitWindowsThread().

00088 { 00089 EXITWINDOWSDATA ewd; 00090 HANDLE hThread; 00091 DWORD dwThreadId; 00092 DWORD dwExitCode; 00093 DWORD idWait; 00094 MSG msg; 00095 BOOL fSuccess; 00096 NTSTATUS Status; 00097 00098 /* 00099 * Force a connection so apps will have a windowstation 00100 * to log off of. 00101 */ 00102 if (PtiCurrent() == NULL) 00103 return FALSE; 00104 00105 /* 00106 * Check for UI restrictions 00107 */ 00108 00109 if (!NtUserCallOneParam((ULONG_PTR)uFlags, SFI_PREPAREFORLOGOFF)) { 00110 RIPMSG0(RIP_WARNING, "ExitWindows called by a restricted thread\n"); 00111 return FALSE; 00112 } 00113 00114 Status = CallUserpExitWindowsEx(uFlags, dwReserved, &fSuccess); 00115 00116 if (NT_SUCCESS( Status )) { 00117 return fSuccess; 00118 } else if (Status == STATUS_CANT_WAIT && !fSecondThread) { 00119 ewd.uFlags = uFlags; 00120 ewd.dwReserved = dwReserved; 00121 hThread = CreateThread(NULL, 0, ExitWindowsThread, &ewd, 00122 0, &dwThreadId); 00123 if (hThread == NULL) { 00124 return FALSE; 00125 } 00126 while (1) { 00127 idWait = MsgWaitForMultipleObjectsEx(1, &hThread, 00128 INFINITE, QS_ALLINPUT, 0); 00129 00130 /* 00131 * If the thread was signaled, we're done. 00132 */ 00133 if (idWait == WAIT_OBJECT_0) 00134 break; 00135 00136 /* 00137 * Process any waiting messages 00138 */ 00139 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) 00140 DispatchMessage(&msg); 00141 } 00142 GetExitCodeThread(hThread, &dwExitCode); 00143 NtClose(hThread); 00144 if (dwExitCode == ERROR_SUCCESS) 00145 return TRUE; 00146 else { 00147 RIPERR0(dwExitCode, RIP_VERBOSE, ""); 00148 return FALSE; 00149 } 00150 } else { 00151 RIPNTERR0(Status, RIP_VERBOSE, ""); 00152 return FALSE; 00153 } 00154 }

HDESK WINAPI GetThreadDesktop DWORD  dwThreadId  ) 
 

Definition at line 298 of file csrstubs.c.

References CsrClientCallServer(), _GETTHREADCONSOLEDESKTOPMSG::dwThreadId, NT_SUCCESS, NtUserGetThreadDesktop(), NULL, _USER_API_MSG::u, and UserpGetThreadConsoleDesktop.

00300 { 00301 USER_API_MSG m; 00302 PGETTHREADCONSOLEDESKTOPMSG a = &m.u.GetThreadConsoleDesktop; 00303 00304 a->dwThreadId = dwThreadId; 00305 CsrClientCallServer( (PCSR_API_MSG)&m, 00306 NULL, 00307 CSR_MAKE_API_NUMBER( USERSRV_SERVERDLL_INDEX, 00308 UserpGetThreadConsoleDesktop 00309 ), 00310 sizeof( *a ) 00311 ); 00312 if (NT_SUCCESS( m.ReturnValue )) { 00313 return NtUserGetThreadDesktop(dwThreadId, a->hdeskConsole); 00314 } else { 00315 RIPNTERR0(m.ReturnValue, RIP_VERBOSE, ""); 00316 return NULL; 00317 } 00318 }

VOID APIENTRY Logon BOOL  fLogon  ) 
 

Definition at line 210 of file csrstubs.c.

References CsrClientCallServer(), _LOGONMSG::fLogon, NULL, _USER_API_MSG::u, and UserpLogon.

00212 { 00213 USER_API_MSG m; 00214 PLOGONMSG a = &m.u.Logon; 00215 00216 a->fLogon = fLogon; 00217 CsrClientCallServer( (PCSR_API_MSG)&m, 00218 NULL, 00219 CSR_MAKE_API_NUMBER( USERSRV_SERVERDLL_INDEX, 00220 UserpLogon 00221 ), 00222 sizeof(*a) 00223 ); 00224 }

BOOL RegisterLogonProcess DWORD  dwProcessId,
BOOL  fSecure
 

Definition at line 252 of file csrstubs.c.

References BOOL, CallUserpRegisterLogonProcess(), gfLogonProcess, and NtUserCallTwoParam().

00255 { 00256 gfLogonProcess = (BOOL)NtUserCallTwoParam(dwProcessId, fSecure, 00257 SFI__REGISTERLOGONPROCESS); 00258 00259 /* 00260 * Now, register the logon process into winsrv. 00261 */ 00262 if (gfLogonProcess) { 00263 CallUserpRegisterLogonProcess(dwProcessId); 00264 } 00265 00266 return gfLogonProcess; 00267 }

BOOL WINAPI RegisterServicesProcess DWORD  dwProcessId  ) 
 

Definition at line 275 of file csrstubs.c.

References CsrClientCallServer(), _REGISTERSERVICESPROCESSMSG::dwProcessId, FALSE, NT_SUCCESS, NULL, SET_LAST_ERROR_RETURNED, _USER_API_MSG::u, and UserpRegisterServicesProcess.

00277 { 00278 USER_API_MSG m; 00279 PREGISTERSERVICESPROCESSMSG a = &m.u.RegisterServicesProcess; 00280 00281 a->dwProcessId = dwProcessId; 00282 CsrClientCallServer( (PCSR_API_MSG)&m, 00283 NULL, 00284 CSR_MAKE_API_NUMBER( USERSRV_SERVERDLL_INDEX, 00285 UserpRegisterServicesProcess 00286 ), 00287 sizeof( *a ) 00288 ); 00289 if (NT_SUCCESS( m.ReturnValue )) { 00290 SET_LAST_ERROR_RETURNED(); 00291 return a->fSuccess; 00292 } else { 00293 RIPNTERR0(m.ReturnValue, RIP_VERBOSE, ""); 00294 return FALSE; 00295 } 00296 }


Variable Documentation

BOOL gfLogonProcess
 

Definition at line 250 of file csrstubs.c.

Referenced by ImeWndCreateHandler(), LoadAppDlls(), and RegisterLogonProcess().


Generated on Sat May 15 19:43:20 2004 for test by doxygen 1.3.7