Rebase against afd5550b07f6d55e56738f61d829085d6bc82888.

This commit is contained in:
Alistair Leslie-Hughes
2021-06-17 10:06:41 +10:00
parent c933b26cb6
commit 876024f44f
5 changed files with 32 additions and 42 deletions

View File

@@ -1,4 +1,4 @@
From 4fd79db7e859dfa62c1c00cffa3de53b25086346 Mon Sep 17 00:00:00 2001
From 138645fb816f0b4fc9fe55f12ec20a4a6d5e2893 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Fri, 26 Feb 2021 22:31:19 -0600
Subject: [PATCH] shell32: Implement the "runas" verb.
@@ -14,7 +14,7 @@ Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c
index ce0b8f6d2be..9da9a0c81da 100644
index 49f7867ef7e..9a8bf4b5b52 100644
--- a/dlls/shell32/shlexec.c
+++ b/dlls/shell32/shlexec.c
@@ -305,6 +305,21 @@ static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR psz
@@ -39,7 +39,7 @@ index ce0b8f6d2be..9da9a0c81da 100644
/*************************************************************************
* SHELL_ExecuteW [Internal]
*
@@ -312,6 +327,7 @@ static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR psz
@@ -312,12 +327,14 @@ static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR psz
static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
const SHELLEXECUTEINFOW *psei, LPSHELLEXECUTEINFOW psei_out)
{
@@ -47,30 +47,29 @@ index ce0b8f6d2be..9da9a0c81da 100644
STARTUPINFOW startup;
PROCESS_INFORMATION info;
UINT_PTR retval = SE_ERR_NOASSOC;
@@ -319,6 +335,7 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
UINT gcdret = 0;
WCHAR curdir[MAX_PATH];
DWORD dwCreationFlags;
const WCHAR *lpDirectory = NULL;
+ HANDLE token = NULL;
TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd), debugstr_w(psei->lpDirectory));
@@ -344,8 +361,12 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
@@ -339,8 +356,12 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
dwCreationFlags = CREATE_UNICODE_ENVIRONMENT;
if (!(psei->fMask & SEE_MASK_NO_CONSOLE))
dwCreationFlags |= CREATE_NEW_CONSOLE;
- if (CreateProcessW(NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE, dwCreationFlags, env,
- lpDirectory, &startup, &info))
- NULL, &startup, &info))
+
+ if (psei->lpVerb && !strcmpiW(psei->lpVerb, runasW))
+ token = get_admin_token();
+
+ if (CreateProcessAsUserW(token, NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE,
+ dwCreationFlags, env, lpDirectory, &startup, &info))
+ dwCreationFlags, env, NULL, &startup, &info))
{
/* Give 30 seconds to the app to come up, if desired. Probably only needed
when starting app immediately before making a DDE connection. */
@@ -365,6 +386,8 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
@@ -360,6 +381,8 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
retval = ERROR_BAD_FORMAT;
}
@@ -80,5 +79,5 @@ index ce0b8f6d2be..9da9a0c81da 100644
psei_out->hInstApp = (HINSTANCE)retval;
--
2.20.1
2.30.2