reactos/base/services/seclogon/rpcserver.c

126 lines
3.2 KiB
C

/*
* PROJECT: ReactOS Secondary Logon Service
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Secondary Logon service RPC server
* COPYRIGHT: Eric Kohl 2022 <eric.kohl@reactos.org>
*/
/* INCLUDES *****************************************************************/
#include "precomp.h"
#include <seclogon_s.h>
WINE_DEFAULT_DEBUG_CHANNEL(seclogon);
/* FUNCTIONS *****************************************************************/
void __RPC_FAR * __RPC_USER midl_user_allocate(SIZE_T len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
void __RPC_USER midl_user_free(void __RPC_FAR * ptr)
{
HeapFree(GetProcessHeap(), 0, ptr);
}
DWORD
StartRpcServer(VOID)
{
ULONG Status;
Status = ((LPSTART_RPC_SERVER)lpServiceGlobals->RpcpStartRpcServer)(L"seclogon", ISeclogon_v1_0_s_ifspec);
TRACE("RpcpStartRpcServer returned 0x%08lx\n", Status);
return RtlNtStatusToDosError(Status);
}
DWORD
StopRpcServer(VOID)
{
ULONG Status;
Status = ((LPSTOP_RPC_SERVER)lpServiceGlobals->RpcpStopRpcServer)(ISeclogon_v1_0_s_ifspec);
TRACE("RpcpStopRpcServer returned 0x%08lx\n", Status);
return RtlNtStatusToDosError(Status);
}
VOID
__stdcall
SeclCreateProcessWithLogonW(
_In_ handle_t hBinding,
_In_ SECL_REQUEST *pRequest,
_Out_ SECL_RESPONSE *pResponse)
{
PROFILEINFOW ProfileInfo;
HANDLE hToken = NULL;
ULONG dwError = ERROR_SUCCESS;
BOOL rc;
TRACE("SeclCreateProcessWithLogonW(%p %p %p)\n", hBinding, pRequest, pResponse);
if (pRequest != NULL)
{
TRACE("Username: '%S'\n", pRequest->Username);
TRACE("Domain: '%S'\n", pRequest->Domain);
TRACE("Password: '%S'\n", pRequest->Password);
TRACE("ApplicationName: '%S'\n", pRequest->ApplicationName);
TRACE("CommandLine: '%S'\n", pRequest->CommandLine);
TRACE("CurrentDirectory: '%S'\n", pRequest->CurrentDirectory);
TRACE("LogonFlags: 0x%lx\n", pRequest->dwLogonFlags);
TRACE("CreationFlags: 0x%lx\n", pRequest->dwCreationFlags);
}
ZeroMemory(&ProfileInfo, sizeof(ProfileInfo));
/* Logon */
rc = LogonUser(pRequest->Username,
pRequest->Domain,
pRequest->Password,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
&hToken);
if (rc == FALSE)
{
dwError = GetLastError();
WARN("LogonUser() failed with Error %lu\n", dwError);
goto done;
}
/* Load the user profile */
if (pRequest->dwLogonFlags & LOGON_WITH_PROFILE)
{
ProfileInfo.dwSize = sizeof(ProfileInfo);
ProfileInfo.lpUserName = pRequest->Username;
rc = LoadUserProfileW(hToken,
&ProfileInfo);
if (rc == FALSE)
{
dwError = GetLastError();
WARN("LoadUserProfile() failed with Error %lu\n", dwError);
goto done;
}
}
/* FIXME: Create Process */
done:
if (ProfileInfo.hProfile != NULL)
UnloadUserProfile(hToken, ProfileInfo.hProfile);
if (hToken != NULL)
CloseHandle(hToken);
if (pResponse != NULL)
pResponse->ulError = dwError;
}