https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c3db5e9c8e1847562d94eb...
commit c3db5e9c8e1847562d94eb5bf8adaaac736597ee Author: Eric Kohl eric.kohl@reactos.org AuthorDate: Sat Jun 10 14:10:14 2023 +0200 Commit: Eric Kohl eric.kohl@reactos.org CommitDate: Sat Jun 10 14:10:14 2023 +0200
[ADVAPI32][SECLOGON] CreateProcessWithLogonW: Pass the environment to the callee --- base/services/seclogon/rpcserver.c | 4 ++- dll/win32/advapi32/wine/security.c | 56 ++++++++++++++++++++++++++++++++++++ sdk/include/reactos/idl/seclogon.idl | 2 ++ 3 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/base/services/seclogon/rpcserver.c b/base/services/seclogon/rpcserver.c index 17671e08801..e728f0a9a00 100644 --- a/base/services/seclogon/rpcserver.c +++ b/base/services/seclogon/rpcserver.c @@ -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 */ @@ -141,7 +143,7 @@ SeclCreateProcessWithLogonW( NULL, // lpThreadAttributes, FALSE, // bInheritHandles, pRequest->dwCreationFlags, - NULL, // lpEnvironment, + pRequest->Environment, // lpEnvironment, pRequest->CurrentDirectory, &StartupInfo, &ProcessInfo); diff --git a/dll/win32/advapi32/wine/security.c b/dll/win32/advapi32/wine/security.c index ce31d7fb474..88f122d6d97 100644 --- a/dll/win32/advapi32/wine/security.c +++ b/dll/win32/advapi32/wine/security.c @@ -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 */ @@ -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;
diff --git a/sdk/include/reactos/idl/seclogon.idl b/sdk/include/reactos/idl/seclogon.idl index d76689463a7..8386f62db9f 100644 --- a/sdk/include/reactos/idl/seclogon.idl +++ b/sdk/include/reactos/idl/seclogon.idl @@ -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;