https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c611d50ecc1e0c3e98cce…
commit c611d50ecc1e0c3e98cce8970f4f9ae0386f27e0
Author:     winesync <ros-dev(a)reactos.org>
AuthorDate: Sun Mar 13 01:17:51 2022 +0100
Commit:     Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:28:15 2022 +0100
    [WINESYNC] msi: Append the custom action client PID to the endpoint name.
    Wine-Bug: 
https://bugs.winehq.org/show_bug.cgi?id=46833
    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 27a7952a84d157caed21a663dd827728a02c443e by Zebediah Figura
<z.figura12(a)gmail.com>
---
 base/system/msiexec/msiexec.c |  9 +++++----
 dll/win32/msi/custom.c        | 14 ++++++++++----
 dll/win32/msi/msi.spec        |  2 +-
 3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/base/system/msiexec/msiexec.c b/base/system/msiexec/msiexec.c
index efbcb5c7f4d..3340ade7760 100644
--- a/base/system/msiexec/msiexec.c
+++ b/base/system/msiexec/msiexec.c
@@ -397,19 +397,20 @@ static DWORD DoUnregServer(void)
     return ret;
 }
-extern UINT CDECL __wine_msi_call_dll_function(GUID *guid);
+extern UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid);
+
+static DWORD client_pid;
 static DWORD CALLBACK custom_action_thread(void *arg)
 {
     GUID guid = *(GUID *)arg;
     heap_free(arg);
-    return __wine_msi_call_dll_function(&guid);
+    return __wine_msi_call_dll_function(client_pid, &guid);
 }
 static int custom_action_server(const WCHAR *arg)
 {
     static const WCHAR pipe_name[] =
{'\\','\\','.','\\','p','i','p','e','\\','m','s','i','c','a','_','%','x','_','%','d',0};
-    DWORD client_pid = atoiW(arg);
     GUID guid, *thread_guid;
     DWORD64 thread64;
     WCHAR buffer[24];
@@ -419,7 +420,7 @@ static int custom_action_server(const WCHAR *arg)
     TRACE("%s\n", debugstr_w(arg));
-    if (!client_pid)
+    if (!(client_pid = atoiW(arg)))
     {
         ERR("Invalid parameter %s\n", debugstr_w(arg));
         return 1;
diff --git a/dll/win32/msi/custom.c b/dll/win32/msi/custom.c
index b35226d696c..cde14ff34a8 100644
--- a/dll/win32/msi/custom.c
+++ b/dll/win32/msi/custom.c
@@ -478,7 +478,7 @@ static void handle_msi_break(LPCSTR target)
 }
 static WCHAR ncalrpcW[] =
{'n','c','a','l','r','p','c',0};
-static WCHAR endpoint_lrpcW[] = {'m','s','i',0};
+static WCHAR endpoint_fmtW[] =
{'m','s','i','%','x',0};
 #if defined __i386__ && defined _MSC_VER
 __declspec(naked) UINT custom_proc_wrapper(MsiCustomActionEntryPoint entry, MSIHANDLE
hinst)
@@ -517,7 +517,7 @@ static UINT custom_proc_wrapper( MsiCustomActionEntryPoint entry,
MSIHANDLE hins
 }
 #endif
-UINT CDECL __wine_msi_call_dll_function(const GUID *guid)
+UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid)
 {
     MsiCustomActionEntryPoint fn;
     MSIHANDLE remote_package = 0;
@@ -534,7 +534,10 @@ UINT CDECL __wine_msi_call_dll_function(const GUID *guid)
     if (!rpc_handle)
     {
-        status = RpcStringBindingComposeW(NULL, ncalrpcW, NULL, endpoint_lrpcW, NULL,
&binding_str);
+        WCHAR endpoint[12];
+
+        sprintfW(endpoint, endpoint_fmtW, client_pid);
+        status = RpcStringBindingComposeW(NULL, ncalrpcW, NULL, endpoint, NULL,
&binding_str);
         if (status != RPC_S_OK)
         {
             ERR("RpcStringBindingCompose failed: %#x\n", status);
@@ -755,8 +758,11 @@ static msi_custom_action_info *do_msidbCustomActionTypeDll(
     if (!package->rpc_server_started)
     {
+        WCHAR endpoint[12];
+
+        sprintfW(endpoint, endpoint_fmtW, GetCurrentProcessId());
         status = RpcServerUseProtseqEpW(ncalrpcW, RPC_C_PROTSEQ_MAX_REQS_DEFAULT,
-            endpoint_lrpcW, NULL);
+            endpoint, NULL);
         if (status != RPC_S_OK)
         {
             ERR("RpcServerUseProtseqEp failed: %#x\n", status);
diff --git a/dll/win32/msi/msi.spec b/dll/win32/msi/msi.spec
index aecba1b1b38..eeb9ea757c0 100644
--- a/dll/win32/msi/msi.spec
+++ b/dll/win32/msi/msi.spec
@@ -295,4 +295,4 @@
 @ stdcall -private DllRegisterServer()
 @ stdcall -private DllUnregisterServer()
-@ cdecl __wine_msi_call_dll_function(ptr)
+@ cdecl __wine_msi_call_dll_function(long ptr)