mirror of
https://github.com/reactos/reactos.git
synced 2025-05-27 21:18:15 +00:00
[WINESYNC] 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> wine-staging patch by Zebediah Figura <z.figura12@gmail.com>
This commit is contained in:
parent
48d97683b3
commit
3b5586f635
2 changed files with 90 additions and 2 deletions
|
@ -593,12 +593,35 @@ UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HANDLE get_admin_token(void)
|
||||||
|
{
|
||||||
|
TOKEN_ELEVATION_TYPE type;
|
||||||
|
TOKEN_LINKED_TOKEN linked;
|
||||||
|
DWORD size;
|
||||||
|
|
||||||
|
#ifdef __REACTOS__
|
||||||
|
#ifndef GetCurrentThreadEffectiveToken
|
||||||
|
#define GetCurrentProcessToken() ((HANDLE)~(ULONG_PTR)3)
|
||||||
|
#define GetCurrentThreadEffectiveToken() GetCurrentProcessToken()
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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)
|
static DWORD custom_start_server(MSIPACKAGE *package, DWORD arch)
|
||||||
{
|
{
|
||||||
WCHAR path[MAX_PATH], cmdline[MAX_PATH + 23];
|
WCHAR path[MAX_PATH], cmdline[MAX_PATH + 23];
|
||||||
PROCESS_INFORMATION pi = {0};
|
PROCESS_INFORMATION pi = {0};
|
||||||
STARTUPINFOW si = {0};
|
STARTUPINFOW si = {0};
|
||||||
WCHAR buffer[24];
|
WCHAR buffer[24];
|
||||||
|
HANDLE token;
|
||||||
void *cookie;
|
void *cookie;
|
||||||
HANDLE pipe;
|
HANDLE pipe;
|
||||||
|
|
||||||
|
@ -620,14 +643,18 @@ static DWORD custom_start_server(MSIPACKAGE *package, DWORD arch)
|
||||||
lstrcatW(path, L"\\msiexec.exe");
|
lstrcatW(path, L"\\msiexec.exe");
|
||||||
swprintf(cmdline, ARRAY_SIZE(cmdline), L"%s -Embedding %d", path, GetCurrentProcessId());
|
swprintf(cmdline, ARRAY_SIZE(cmdline), L"%s -Embedding %d", path, GetCurrentProcessId());
|
||||||
|
|
||||||
|
token = get_admin_token();
|
||||||
|
|
||||||
if (is_wow64 && arch == SCS_64BIT_BINARY)
|
if (is_wow64 && arch == SCS_64BIT_BINARY)
|
||||||
{
|
{
|
||||||
Wow64DisableWow64FsRedirection(&cookie);
|
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);
|
Wow64RevertWow64FsRedirection(cookie);
|
||||||
}
|
}
|
||||||
else
|
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);
|
CloseHandle(pi.hThread);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
diff --git a/dll/win32/msi/custom.c b/dll/win32/msi/custom.c
|
||||||
|
index 143de262971..f29699bd54b 100644
|
||||||
|
--- a/dll/win32/msi/custom.c
|
||||||
|
+++ b/dll/win32/msi/custom.c
|
||||||
|
@@ -593,12 +593,35 @@ 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;
|
||||||
|
+
|
||||||
|
+#ifdef __REACTOS__
|
||||||
|
+#ifndef GetCurrentThreadEffectiveToken
|
||||||
|
+#define GetCurrentProcessToken() ((HANDLE)~(ULONG_PTR)3)
|
||||||
|
+#define GetCurrentThreadEffectiveToken() GetCurrentProcessToken()
|
||||||
|
+#endif
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+ 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;
|
||||||
|
|
||||||
|
@@ -620,14 +643,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);
|
||||||
|
|
Loading…
Reference in a new issue