Skip to content

Commit

Permalink
[ADVAPI32][SECLOGON] CreateProcessWithLogonW: Pass the environment to…
Browse files Browse the repository at this point in the history
… the callee
  • Loading branch information
EricKohl committed Jun 10, 2023
1 parent 59e7458 commit c3db5e9
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
4 changes: 3 additions & 1 deletion base/services/seclogon/rpcserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,13 @@ SeclCreateProcessWithLogonW(
}
}

/* Initialize the startup information */
ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof(StartupInfo);

/* FIXME: Get startup info from the caller */

/* Initialize the process information */
ZeroMemory(&ProcessInfo, sizeof(ProcessInfo));

/* Create Process */
Expand All @@ -141,7 +143,7 @@ SeclCreateProcessWithLogonW(
NULL, // lpThreadAttributes,
FALSE, // bInheritHandles,
pRequest->dwCreationFlags,
NULL, // lpEnvironment,
pRequest->Environment, // lpEnvironment,
pRequest->CurrentDirectory,
&StartupInfo,
&ProcessInfo);
Expand Down
56 changes: 56 additions & 0 deletions dll/win32/advapi32/wine/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -3472,6 +3472,53 @@ ConvertSidToStringSidA(PSID Sid,
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
*/
Expand Down Expand Up @@ -3535,6 +3582,15 @@ CreateProcessWithLogonW(
Request.CommandLine = (LPWSTR)lpCommandLine;
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.dwCreationFlags = dwCreationFlags;

Expand Down
2 changes: 2 additions & 0 deletions sdk/include/reactos/idl/seclogon.idl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ typedef struct _SECL_REQUEST
[string] WCHAR *ApplicationName;
[string] WCHAR *CommandLine;
[string] WCHAR *CurrentDirectory;
[size_is(dwEnvironmentSize)] BYTE *Environment;
DWORD dwEnvironmentSize;
DWORD dwLogonFlags;
DWORD dwCreationFlags;
DWORD dwProcessId;
Expand Down

0 comments on commit c3db5e9

Please sign in to comment.