Module: wine Branch: master Commit: 5c7cf0a47d9d43b11f84914f5890eae3fd694592 URL: https://source.winehq.org/git/wine.git/?a=commit;h=5c7cf0a47d9d43b11f84914f5...
Author: Zebediah Figura z.figura12@gmail.com Date: Tue Jul 10 12:08:44 2018 +0200
msi: Avoid starting the RPC server more than once for a given package.
Signed-off-by: Zebediah Figura z.figura12@gmail.com Signed-off-by: Hans Leidekker hans@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/msi/custom.c | 46 +++++++++++++++++++++------------------------- dlls/msi/msipriv.h | 1 + dlls/msi/package.c | 2 ++ 3 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c index e68528f..af6e9f7 100644 --- a/dlls/msi/custom.c +++ b/dlls/msi/custom.c @@ -572,16 +572,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; @@ -592,24 +591,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(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(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)); @@ -618,7 +621,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) { @@ -634,13 +637,6 @@ static DWORD WINAPI DllThread( LPVOID arg ) CloseHandle(pi.hProcess); CloseHandle(pi.hThread);
- status = RpcServerUnregisterIf(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 ); @@ -671,7 +667,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/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index 789d541..6304375 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/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/dlls/msi/package.c b/dlls/msi/package.c index d6f22d0..9569c4f 100644 --- a/dlls/msi/package.c +++ b/dlls/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 );