Rebase against c1b8db0c28ac5b7a14567bfb6df2c0af364de6a2.

This commit is contained in:
Zebediah Figura
2024-03-04 16:41:59 -06:00
parent 21b92f9611
commit ff5fc9c0fa
8 changed files with 2 additions and 365 deletions

View File

@ -1,76 +0,0 @@
From ede24db26773b5ce2c2d7e13bf12939b55124281 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.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Based on a patch by Michael Müller.
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/shell32/shlexec.c | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/shlexec.c b/dlls/shell32/shlexec.c
index 8c7e3cf0808..c9a996a13dd 100644
--- a/dlls/shell32/shlexec.c
+++ b/dlls/shell32/shlexec.c
@@ -292,6 +292,21 @@ static HRESULT SHELL_GetPathFromIDListForExecuteW(LPCITEMIDLIST pidl, LPWSTR psz
return hr;
}
+static HANDLE get_admin_token(void)
+{
+ TOKEN_ELEVATION_TYPE type;
+ TOKEN_LINKED_TOKEN linked;
+ DWORD size;
+
+ if (!GetTokenInformation(GetCurrentThreadEffectiveToken(), TokenElevationType, &type, sizeof(type), &size)
+ || type == TokenElevationTypeFull)
+ return NULL;
+
+ if (!GetTokenInformation(GetCurrentThreadEffectiveToken(), TokenLinkedToken, &linked, sizeof(linked), &size))
+ return NULL;
+ return linked.LinkedToken;
+}
+
/*************************************************************************
* SHELL_ExecuteW [Internal]
*
@@ -305,6 +320,7 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
UINT gcdret = 0;
WCHAR curdir[MAX_PATH];
DWORD dwCreationFlags;
+ HANDLE token = NULL;
TRACE("Execute %s from directory %s\n", debugstr_w(lpCmd), debugstr_w(psei->lpDirectory));
@@ -326,8 +342,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,
- NULL, &startup, &info))
+
+ if (psei->lpVerb && !wcsicmp(psei->lpVerb, L"runas"))
+ token = get_admin_token();
+
+ if (CreateProcessAsUserW(token, NULL, (LPWSTR)lpCmd, NULL, NULL, FALSE,
+ 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. */
@@ -347,6 +367,8 @@ static UINT_PTR SHELL_ExecuteW(const WCHAR *lpCmd, WCHAR *env, BOOL shWait,
retval = ERROR_BAD_FORMAT;
}
+ CloseHandle(token);
+
TRACE("returning %Iu\n", retval);
psei_out->hInstApp = (HINSTANCE)retval;
--
2.34.1

View File

@ -1,29 +0,0 @@
From dc1f602da6ed3a574697fe8b5bc4590d74e344f5 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Fri, 26 Feb 2021 22:41:35 -0600
Subject: [PATCH] wine.inf: Set the EnableLUA value to 1.
This signifies that UAC is active.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50727
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
loader/wine.inf.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/loader/wine.inf.in b/loader/wine.inf.in
index 24da6f3af6b..a72279e9881 100644
--- a/loader/wine.inf.in
+++ b/loader/wine.inf.in
@@ -526,7 +526,7 @@ HKLM,%CurrentVersion%\Explorer\DriveIcons,,16
HKLM,%CurrentVersion%\Explorer\KindMap,,16
HKLM,%CurrentVersion%\Group Policy,,16
HKLM,%CurrentVersion%\Installer,"InstallerLocation",,"%11%"
-HKLM,%CurrentVersion%\Policies\System,"EnableLUA",0x10003,0
+HKLM,%CurrentVersion%\Policies\System,"EnableLUA",0x10001,1
HKLM,%CurrentVersion%\PreviewHandlers,,16
HKLM,%CurrentVersion%\Run,,16
HKLM,%CurrentVersion%\Setup,"BootDir",,"%30%"
--
2.30.2

View File

@ -1,68 +0,0 @@
From f2de1c5d2fcda876276e077b61f9fba5ff3f7f12 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Sun, 16 May 2021 20:49:05 -0500
Subject: [PATCH] msi: Create the custom action server as an elevated process.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51143
Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
---
dlls/msi/custom.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index fb03958eb11..874b9b92118 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -574,12 +574,28 @@ UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid)
return r;
}
+static HANDLE get_admin_token(void)
+{
+ TOKEN_ELEVATION_TYPE type;
+ TOKEN_LINKED_TOKEN linked;
+ DWORD size;
+
+ if (!GetTokenInformation(GetCurrentThreadEffectiveToken(), TokenElevationType, &type, sizeof(type), &size)
+ || type == TokenElevationTypeFull)
+ return NULL;
+
+ if (!GetTokenInformation(GetCurrentThreadEffectiveToken(), TokenLinkedToken, &linked, sizeof(linked), &size))
+ return NULL;
+ return linked.LinkedToken;
+}
+
static DWORD custom_start_server(MSIPACKAGE *package, DWORD arch)
{
WCHAR path[MAX_PATH], cmdline[MAX_PATH + 23];
PROCESS_INFORMATION pi = {0};
STARTUPINFOW si = {0};
WCHAR buffer[24];
+ HANDLE token;
void *cookie;
HANDLE pipe;
@@ -601,14 +617,18 @@ static DWORD custom_start_server(MSIPACKAGE *package, DWORD arch)
lstrcatW(path, L"\\msiexec.exe");
swprintf(cmdline, ARRAY_SIZE(cmdline), L"%s -Embedding %d", path, GetCurrentProcessId());
+ token = get_admin_token();
+
if (is_wow64 && arch == SCS_64BIT_BINARY)
{
Wow64DisableWow64FsRedirection(&cookie);
- CreateProcessW(path, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+ CreateProcessAsUserW(token, path, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
Wow64RevertWow64FsRedirection(cookie);
}
else
- CreateProcessW(path, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+ CreateProcessAsUserW(token, path, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
+
+ if (token) CloseHandle(token);
CloseHandle(pi.hThread);
--
2.30.2