Commit 90aadc70 authored by Zebediah Figura's avatar Zebediah Figura Committed by Vitaly Lipatov

msi: Create the custom action server as an elevated process.

parent 77d40cf4
......@@ -572,12 +572,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;
......@@ -599,14 +615,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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment