ReactOS 0.4.15-dev-7918-g2a2556c
rpcserver.c File Reference
#include "precomp.h"
#include <seclogon_s.h>
Include dependency graph for rpcserver.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (seclogon)
 
void __RPC_FAR *__RPC_USER midl_user_allocate (SIZE_T len)
 
void __RPC_USER midl_user_free (void __RPC_FAR *ptr)
 
DWORD StartRpcServer (VOID)
 
DWORD StopRpcServer (VOID)
 
VOID __stdcall SeclCreateProcessWithLogonW (_In_ handle_t hBinding, _In_ SECL_REQUEST *pRequest, _Out_ SECL_RESPONSE *pResponse)
 

Function Documentation

◆ midl_user_allocate()

void __RPC_FAR *__RPC_USER midl_user_allocate ( SIZE_T  len)

Definition at line 19 of file rpcserver.c.

20{
22}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
GLenum GLsizei len
Definition: glext.h:6722

◆ midl_user_free()

void __RPC_USER midl_user_free ( void __RPC_FAR ptr)

Definition at line 25 of file rpcserver.c.

26{
28}
#define HeapFree(x, y, z)
Definition: compat.h:735
static PVOID ptr
Definition: dispmode.c:27

◆ SeclCreateProcessWithLogonW()

VOID __stdcall SeclCreateProcessWithLogonW ( _In_ handle_t  hBinding,
_In_ SECL_REQUEST pRequest,
_Out_ SECL_RESPONSE pResponse 
)

Definition at line 57 of file rpcserver.c.

61{
62 STARTUPINFOW StartupInfo;
63 PROCESS_INFORMATION ProcessInfo;
64
65 PROFILEINFOW ProfileInfo;
66 HANDLE hToken = NULL;
67 HANDLE hTargetProcessHandle = NULL;
68
69 ULONG dwError = ERROR_SUCCESS;
70 BOOL rc;
71
72 TRACE("SeclCreateProcessWithLogonW(%p %p %p)\n", hBinding, pRequest, pResponse);
73
74 if (pRequest != NULL)
75 {
76 TRACE("Username: '%S'\n", pRequest->Username);
77 TRACE("Domain: '%S'\n", pRequest->Domain);
78 TRACE("Password: '%S'\n", pRequest->Password);
79 TRACE("ApplicationName: '%S'\n", pRequest->ApplicationName);
80 TRACE("CommandLine: '%S'\n", pRequest->CommandLine);
81 TRACE("CurrentDirectory: '%S'\n", pRequest->CurrentDirectory);
82 TRACE("LogonFlags: 0x%lx\n", pRequest->dwLogonFlags);
83 TRACE("CreationFlags: 0x%lx\n", pRequest->dwCreationFlags);
84 TRACE("ProcessId: %lu\n", pRequest->dwProcessId);
85 }
86
87 hTargetProcessHandle = OpenProcess(PROCESS_DUP_HANDLE,
88 FALSE,
89 pRequest->dwProcessId);
90 if (hTargetProcessHandle == NULL)
91 {
92 dwError = GetLastError();
93 WARN("OpenProcess() failed with Error %lu\n", dwError);
94 goto done;
95 }
96
97 ZeroMemory(&ProfileInfo, sizeof(ProfileInfo));
98
99 /* Logon */
100 rc = LogonUser(pRequest->Username,
101 pRequest->Domain,
102 pRequest->Password,
105 &hToken);
106 if (rc == FALSE)
107 {
108 dwError = GetLastError();
109 WARN("LogonUser() failed with Error %lu\n", dwError);
110 goto done;
111 }
112
113 /* Load the user profile */
114 if (pRequest->dwLogonFlags & LOGON_WITH_PROFILE)
115 {
116 ProfileInfo.dwSize = sizeof(ProfileInfo);
117 ProfileInfo.lpUserName = pRequest->Username;
118
119 rc = LoadUserProfileW(hToken,
120 &ProfileInfo);
121 if (rc == FALSE)
122 {
123 dwError = GetLastError();
124 WARN("LoadUserProfile() failed with Error %lu\n", dwError);
125 goto done;
126 }
127 }
128
129 /* Initialize the startup information */
130 ZeroMemory(&StartupInfo, sizeof(StartupInfo));
131 StartupInfo.cb = sizeof(StartupInfo);
132
133 /* FIXME: Get startup info from the caller */
134
135 /* Initialize the process information */
136 ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
137
138 /* Create Process */
139 rc = CreateProcessAsUserW(hToken,
140 pRequest->ApplicationName,
141 pRequest->CommandLine,
142 NULL, // lpProcessAttributes,
143 NULL, // lpThreadAttributes,
144 FALSE, // bInheritHandles,
145 pRequest->dwCreationFlags,
146 pRequest->Environment, // lpEnvironment,
147 pRequest->CurrentDirectory,
148 &StartupInfo,
149 &ProcessInfo);
150 if (rc == FALSE)
151 {
152 dwError = GetLastError();
153 WARN("CreateProcessAsUser() failed with Error %lu\n", dwError);
154 goto done;
155 }
156
157 /* Return process info to the caller */
158 if (pResponse != NULL)
159 {
161 ProcessInfo.hProcess,
162 hTargetProcessHandle,
163 (PHANDLE)&pResponse->hProcess,
164 0,
165 FALSE,
167
169 ProcessInfo.hThread,
170 hTargetProcessHandle,
171 (PHANDLE)&pResponse->hThread,
172 0,
173 FALSE,
175
176 pResponse->dwProcessId = ProcessInfo.dwProcessId;
177 pResponse->dwThreadId = ProcessInfo.dwThreadId;
178 }
179
180done:
181 if (hTargetProcessHandle)
182 CloseHandle(hTargetProcessHandle);
183
184 if (ProcessInfo.hThread)
185 CloseHandle(ProcessInfo.hThread);
186
187 if (ProcessInfo.hProcess)
188 CloseHandle(ProcessInfo.hProcess);
189
190 if (ProfileInfo.hProfile != NULL)
191 UnloadUserProfile(hToken, ProfileInfo.hProfile);
192
193 if (hToken != NULL)
194 CloseHandle(hToken);
195
196 if (pResponse != NULL)
197 pResponse->dwError = dwError;
198}
#define WARN(fmt,...)
Definition: debug.h:112
handle_t hBinding
Definition: ctx_c.c:54
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessAsUserW(_In_opt_ HANDLE hToken, _In_opt_ LPCWSTR lpApplicationName, _Inout_opt_ LPWSTR lpCommandLine, _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes, _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes, _In_ BOOL bInheritHandles, _In_ DWORD dwCreationFlags, _In_opt_ LPVOID lpEnvironment, _In_opt_ LPCWSTR lpCurrentDirectory, _In_ LPSTARTUPINFOW lpStartupInfo, _Out_ LPPROCESS_INFORMATION lpProcessInformation)
Definition: logon.c:993
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
Definition: handle.c:149
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
BOOL WINAPI LoadUserProfileW(_In_ HANDLE hToken, _Inout_ LPPROFILEINFOW lpProfileInfo)
Definition: profile.c:2005
BOOL WINAPI UnloadUserProfile(_In_ HANDLE hToken, _In_ HANDLE hProfile)
Definition: profile.c:2184
unsigned int BOOL
Definition: ntddk_ex.h:94
FxRequest * pRequest
#define PROCESS_DUP_HANDLE
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwSize
Definition: userenv.h:36
HANDLE hProfile
Definition: userenv.h:43
LPWSTR lpUserName
Definition: userenv.h:38
DWORD cb
Definition: winbase.h:852
uint32_t ULONG
Definition: typedefs.h:59
#define ZeroMemory
Definition: winbase.h:1712
#define LOGON_WITH_PROFILE
Definition: winbase.h:619
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define LogonUser
Definition: winbase.h:3864
#define LOGON32_LOGON_INTERACTIVE
Definition: winbase.h:391
#define LOGON32_PROVIDER_DEFAULT
Definition: winbase.h:387
#define DUPLICATE_SAME_ACCESS

Referenced by CreateProcessWithLogonW().

◆ StartRpcServer()

DWORD StartRpcServer ( VOID  )

Definition at line 32 of file rpcserver.c.

33{
35
36 Status = lpServiceGlobals->StartRpcServer(L"seclogon", ISeclogon_v1_0_s_ifspec);
37 TRACE("StartRpcServer returned 0x%08lx\n", Status);
38
40}
LONG NTSTATUS
Definition: precomp.h:26
PSVCHOST_GLOBAL_DATA lpServiceGlobals
Definition: seclogon.c:18
Status
Definition: gdiplustypes.h:25
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define L(x)
Definition: ntvdm.h:50
PSTART_RPC_SERVER StartRpcServer
Definition: svc.h:114

◆ StopRpcServer()

DWORD StopRpcServer ( VOID  )

Definition at line 44 of file rpcserver.c.

45{
47
48 Status = lpServiceGlobals->StopRpcServer(ISeclogon_v1_0_s_ifspec);
49 TRACE("StopRpcServer returned 0x%08lx\n", Status);
50
52}
PSTOP_RPC_SERVER StopRpcServer
Definition: svc.h:115

Referenced by ServiceControlHandlerEx().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( seclogon  )