[ADVAPI32][SECLOGON] CreateProcessWithLogonW: Pass the environment to the callee

This commit is contained in:
Eric Kohl 2023-06-10 14:10:14 +02:00
parent 59e74584ac
commit c3db5e9c8e
3 changed files with 61 additions and 1 deletions

View file

@ -126,11 +126,13 @@ SeclCreateProcessWithLogonW(
} }
} }
/* Initialize the startup information */
ZeroMemory(&StartupInfo, sizeof(StartupInfo)); ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof(StartupInfo); StartupInfo.cb = sizeof(StartupInfo);
/* FIXME: Get startup info from the caller */ /* FIXME: Get startup info from the caller */
/* Initialize the process information */
ZeroMemory(&ProcessInfo, sizeof(ProcessInfo)); ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));
/* Create Process */ /* Create Process */
@ -141,7 +143,7 @@ SeclCreateProcessWithLogonW(
NULL, // lpThreadAttributes, NULL, // lpThreadAttributes,
FALSE, // bInheritHandles, FALSE, // bInheritHandles,
pRequest->dwCreationFlags, pRequest->dwCreationFlags,
NULL, // lpEnvironment, pRequest->Environment, // lpEnvironment,
pRequest->CurrentDirectory, pRequest->CurrentDirectory,
&StartupInfo, &StartupInfo,
&ProcessInfo); &ProcessInfo);

View file

@ -3472,6 +3472,53 @@ ConvertSidToStringSidA(PSID Sid,
return TRUE; return TRUE;
} }
static
DWORD
GetUnicodeEnvironmentSize(
PVOID pEnvironment)
{
INT Length, TotalLength = 0;
PWCHAR Ptr;
if (pEnvironment == NULL)
return 0;
Ptr = (PWCHAR)pEnvironment;
while (*Ptr != UNICODE_NULL)
{
Length = wcslen(Ptr) + 1;
TotalLength += Length;
Ptr = Ptr + Length;
}
return (TotalLength + 1) * sizeof(WCHAR);
}
static
DWORD
GetAnsiEnvironmentSize(
PVOID pEnvironment)
{
INT Length, TotalLength = 0;
PCHAR Ptr;
if (pEnvironment == NULL)
return 0;
Ptr = (PCHAR)pEnvironment;
while (*Ptr != ANSI_NULL)
{
Length = strlen(Ptr) + 1;
TotalLength += Length;
Ptr = Ptr + Length;
}
return TotalLength + 1;
}
/* /*
* @unimplemented * @unimplemented
*/ */
@ -3535,6 +3582,15 @@ CreateProcessWithLogonW(
Request.CommandLine = (LPWSTR)lpCommandLine; Request.CommandLine = (LPWSTR)lpCommandLine;
Request.CurrentDirectory = (LPWSTR)lpCurrentDirectory; Request.CurrentDirectory = (LPWSTR)lpCurrentDirectory;
if (dwCreationFlags & CREATE_UNICODE_ENVIRONMENT)
Request.dwEnvironmentSize = GetUnicodeEnvironmentSize(lpEnvironment);
else
Request.dwEnvironmentSize = GetAnsiEnvironmentSize(lpEnvironment);
Request.Environment = lpEnvironment;
TRACE("Request.dwEnvironmentSize %lu\n", Request.dwEnvironmentSize);
TRACE("Request.Environment %p\n", Request.Environment);
Request.dwLogonFlags = dwLogonFlags; Request.dwLogonFlags = dwLogonFlags;
Request.dwCreationFlags = dwCreationFlags; Request.dwCreationFlags = dwCreationFlags;

View file

@ -12,6 +12,8 @@ typedef struct _SECL_REQUEST
[string] WCHAR *ApplicationName; [string] WCHAR *ApplicationName;
[string] WCHAR *CommandLine; [string] WCHAR *CommandLine;
[string] WCHAR *CurrentDirectory; [string] WCHAR *CurrentDirectory;
[size_is(dwEnvironmentSize)] BYTE *Environment;
DWORD dwEnvironmentSize;
DWORD dwLogonFlags; DWORD dwLogonFlags;
DWORD dwCreationFlags; DWORD dwCreationFlags;
DWORD dwProcessId; DWORD dwProcessId;