https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b17e8a5e3ce9fdf855010…
commit b17e8a5e3ce9fdf8550104421a8c3ef63c03cb0a
Author: Eric Kohl <eric.kohl(a)reactos.org>
AuthorDate: Thu Dec 27 19:27:43 2018 +0100
Commit: Eric Kohl <eric.kohl(a)reactos.org>
CommitDate: Thu Dec 27 19:29:20 2018 +0100
[ADVAPI32] CreateProcessAsUserA/W: Partially revert an obvious case of
over-engineering. Only share the common parts! Now it looks a lot better. No more stupid
bUnicode!
---
dll/win32/advapi32/misc/logon.c | 101 ++++++++++++++--------------------------
1 file changed, 34 insertions(+), 67 deletions(-)
diff --git a/dll/win32/advapi32/misc/logon.c b/dll/win32/advapi32/misc/logon.c
index 0b9d60320f..742c093178 100644
--- a/dll/win32/advapi32/misc/logon.c
+++ b/dll/win32/advapi32/misc/logon.c
@@ -89,60 +89,13 @@ CloseLogonLsaHandle(VOID)
static
BOOL
CreateProcessAsUserCommon(
- _In_ BOOL bUnicode,
_In_opt_ HANDLE hToken,
- _In_opt_ LPCVOID lpApplicationName,
- _Inout_opt_ LPVOID lpCommandLine,
- _In_opt_ LPSECURITY_ATTRIBUTES lpProcessAttributes,
- _In_opt_ LPSECURITY_ATTRIBUTES lpThreadAttributes,
- _In_ BOOL bInheritHandles,
_In_ DWORD dwCreationFlags,
- _In_opt_ LPVOID lpEnvironment,
- _In_opt_ LPCVOID lpCurrentDirectory,
- _In_ LPVOID lpStartupInfo,
_Out_ LPPROCESS_INFORMATION lpProcessInformation)
{
NTSTATUS Status;
PROCESS_ACCESS_TOKEN AccessToken;
- /* Create the process with a suspended main thread */
- if (bUnicode)
- {
- /* Call the UNICODE version */
- if (!CreateProcessW((LPCWSTR)lpApplicationName,
- (LPWSTR)lpCommandLine,
- lpProcessAttributes,
- lpThreadAttributes,
- bInheritHandles,
- dwCreationFlags | CREATE_SUSPENDED,
- lpEnvironment,
- (LPCWSTR)lpCurrentDirectory,
- (LPSTARTUPINFOW)lpStartupInfo,
- lpProcessInformation))
- {
- ERR("CreateProcessW failed, last error: %d\n", GetLastError());
- return FALSE;
- }
- }
- else
- {
- /* Call the ANSI version */
- if (!CreateProcessA((LPCSTR)lpApplicationName,
- (LPSTR)lpCommandLine,
- lpProcessAttributes,
- lpThreadAttributes,
- bInheritHandles,
- dwCreationFlags | CREATE_SUSPENDED,
- lpEnvironment,
- (LPCSTR)lpCurrentDirectory,
- (LPSTARTUPINFOA)lpStartupInfo,
- lpProcessInformation))
- {
- ERR("CreateProcessA failed, last error: %d\n", GetLastError());
- return FALSE;
- }
- }
-
if (hToken != NULL)
{
TOKEN_TYPE Type;
@@ -293,18 +246,25 @@ CreateProcessAsUserA(
debugstr_a(lpCommandLine), lpProcessAttributes, lpThreadAttributes,
bInheritHandles,
dwCreationFlags, lpEnvironment, debugstr_a(lpCurrentDirectory), lpStartupInfo,
lpProcessInformation);
+ /* Create the process with a suspended main thread */
+ if (!CreateProcessA(lpApplicationName,
+ lpCommandLine,
+ lpProcessAttributes,
+ lpThreadAttributes,
+ bInheritHandles,
+ dwCreationFlags | CREATE_SUSPENDED,
+ lpEnvironment,
+ lpCurrentDirectory,
+ lpStartupInfo,
+ lpProcessInformation))
+ {
+ ERR("CreateProcessA failed, last error: %d\n", GetLastError());
+ return FALSE;
+ }
+
/* Call the helper function */
- return CreateProcessAsUserCommon(FALSE,
- hToken,
- lpApplicationName,
- lpCommandLine,
- lpProcessAttributes,
- lpThreadAttributes,
- bInheritHandles,
+ return CreateProcessAsUserCommon(hToken,
dwCreationFlags,
- lpEnvironment,
- lpCurrentDirectory,
- lpStartupInfo,
lpProcessInformation);
}
@@ -332,18 +292,25 @@ CreateProcessAsUserW(
debugstr_w(lpCommandLine), lpProcessAttributes, lpThreadAttributes,
bInheritHandles,
dwCreationFlags, lpEnvironment, debugstr_w(lpCurrentDirectory), lpStartupInfo,
lpProcessInformation);
+ /* Create the process with a suspended main thread */
+ if (!CreateProcessW(lpApplicationName,
+ lpCommandLine,
+ lpProcessAttributes,
+ lpThreadAttributes,
+ bInheritHandles,
+ dwCreationFlags | CREATE_SUSPENDED,
+ lpEnvironment,
+ lpCurrentDirectory,
+ lpStartupInfo,
+ lpProcessInformation))
+ {
+ ERR("CreateProcessW failed, last error: %d\n", GetLastError());
+ return FALSE;
+ }
+
/* Call the helper function */
- return CreateProcessAsUserCommon(TRUE,
- hToken,
- lpApplicationName,
- lpCommandLine,
- lpProcessAttributes,
- lpThreadAttributes,
- bInheritHandles,
+ return CreateProcessAsUserCommon(hToken,
dwCreationFlags,
- lpEnvironment,
- lpCurrentDirectory,
- lpStartupInfo,
lpProcessInformation);
}