https://git.reactos.org/?p=reactos.git;a=commitdiff;h=0a327bfe9499e308fb314…
commit 0a327bfe9499e308fb314973e96d7dca154b1f89
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 17:01:10 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:27:56 2022 +0100
[WINESYNC] msi: Avoid starting the RPC server more than once for a given package.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 5c7cf0a47d9d43b11f84914f5890eae3fd694592 by Zebediah Figura
<z.figura12(a)gmail.com>
---
dll/win32/msi/custom.c | 46 +++++++++++++++++++++-------------------------
dll/win32/msi/msipriv.h | 1 +
dll/win32/msi/package.c | 2 ++
3 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/dll/win32/msi/custom.c b/dll/win32/msi/custom.c
index d444960c96f..ffea24278d4 100644
--- a/dll/win32/msi/custom.c
+++ b/dll/win32/msi/custom.c
@@ -573,16 +573,15 @@ UINT CDECL __wine_msi_call_dll_function(const GUID *guid)
return r;
}
-static DWORD WINAPI DllThread( LPVOID arg )
+static DWORD WINAPI custom_client_thread(void *arg)
{
static const WCHAR msiexecW[] =
{'\\','m','s','i','e','x','e','c','.','e','x','e',0};
static const WCHAR argsW[] = {'
','-','E','m','b','e','d','d','i','n','g','
',0};
- msi_custom_action_info *info;
+ msi_custom_action_info *info = arg;
PROCESS_INFORMATION pi = {0};
STARTUPINFOW si = {0};
WCHAR buffer[MAX_PATH], cmdline[MAX_PATH + 60];
RPC_STATUS status;
- GUID *guid = arg;
void *cookie;
BOOL wow64;
DWORD arch;
@@ -593,24 +592,28 @@ static DWORD WINAPI DllThread( LPVOID arg )
CoInitializeEx(NULL, COINIT_MULTITHREADED); /* needed to marshal streams */
- status = RpcServerUseProtseqEpW(ncalrpcW, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
endpoint_lrpcW, NULL);
- if (status != RPC_S_OK)
+ if (!info->package->rpc_server_started)
{
- ERR("RpcServerUseProtseqEp failed: %#x\n", status);
- return status;
- }
+ status = RpcServerUseProtseqEpW(ncalrpcW, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
+ endpoint_lrpcW, NULL);
+ if (status != RPC_S_OK)
+ {
+ ERR("RpcServerUseProtseqEp failed: %#x\n", status);
+ return status;
+ }
- status = RpcServerRegisterIfEx((RPC_IF_HANDLE)s_IWineMsiRemote_v0_0_s_ifspec, NULL,
NULL,
- RPC_IF_AUTOLISTEN, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL);
- if (status != RPC_S_OK)
- {
- ERR("RpcServerRegisterIfEx failed: %#x\n", status);
- return status;
+ status = RpcServerRegisterIfEx((RPC_IF_HANDLE)s_IWineMsiRemote_v0_0_s_ifspec,
NULL, NULL,
+ RPC_IF_AUTOLISTEN, RPC_C_LISTEN_MAX_CALLS_DEFAULT, NULL);
+ if (status != RPC_S_OK)
+ {
+ ERR("RpcServerRegisterIfEx failed: %#x\n", status);
+ return status;
+ }
+
+ info->package->rpc_server_started = 1;
}
- info = find_action_by_guid(guid);
ret = GetBinaryTypeW(info->source, &arch);
- release_custom_action_data(info);
if (sizeof(void *) == 8 && ret && arch == SCS_32BIT_BINARY)
GetSystemWow64DirectoryW(buffer, MAX_PATH - sizeof(msiexecW)/sizeof(WCHAR));
@@ -619,7 +622,7 @@ static DWORD WINAPI DllThread( LPVOID arg )
strcatW(buffer, msiexecW);
strcpyW(cmdline, buffer);
strcatW(cmdline, argsW);
- StringFromGUID2(guid, cmdline + strlenW(cmdline), 39);
+ StringFromGUID2(&info->guid, cmdline + strlenW(cmdline), 39);
if (IsWow64Process(GetCurrentProcess(), &wow64) && wow64 && arch
== SCS_64BIT_BINARY)
{
@@ -635,13 +638,6 @@ static DWORD WINAPI DllThread( LPVOID arg )
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
- status = RpcServerUnregisterIf((RPC_IF_HANDLE)s_IWineMsiRemote_v0_0_s_ifspec, NULL,
FALSE);
- if (status != RPC_S_OK)
- {
- ERR("RpcServerUnregisterIf failed: %#x\n", status);
- return status;
- }
-
CoUninitialize();
TRACE("custom action (%x) returned %i\n", GetCurrentThreadId(), rc );
@@ -672,7 +668,7 @@ static msi_custom_action_info *do_msidbCustomActionTypeDll(
list_add_tail( &msi_pending_custom_actions, &info->entry );
LeaveCriticalSection( &msi_custom_action_cs );
- info->handle = CreateThread( NULL, 0, DllThread, &info->guid, 0, NULL );
+ info->handle = CreateThread(NULL, 0, custom_client_thread, info, 0, NULL);
if (!info->handle)
{
/* release both references */
diff --git a/dll/win32/msi/msipriv.h b/dll/win32/msi/msipriv.h
index 3519d83f1c6..f701f91a866 100644
--- a/dll/win32/msi/msipriv.h
+++ b/dll/win32/msi/msipriv.h
@@ -449,6 +449,7 @@ typedef struct tagMSIPACKAGE
unsigned char need_reboot_at_end : 1;
unsigned char need_reboot_now : 1;
unsigned char need_rollback : 1;
+ unsigned char rpc_server_started : 1;
} MSIPACKAGE;
typedef struct tagMSIPREVIEW
diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c
index 6b3f46353a3..7cc9444a0f0 100644
--- a/dll/win32/msi/package.c
+++ b/dll/win32/msi/package.c
@@ -342,6 +342,8 @@ static void MSI_FreePackage( MSIOBJECTHDR *arg)
msiobj_release( &package->db->hdr );
free_package_structures(package);
CloseHandle( package->log_file );
+ if (package->rpc_server_started)
+ RpcServerUnregisterIf(s_IWineMsiRemote_v0_0_s_ifspec, NULL, FALSE);
if (package->delete_on_close) DeleteFileW( package->localfile );
msi_free( package->localfile );