[PATCH] msi: Use custom action name for MsiBreak handling.

Hans Leidekker hans at codeweavers.com
Fri Jan 21 09:45:32 CST 2022


Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50433
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/msi/custom.c    | 31 ++++++++++++++-----------------
 dlls/msi/winemsi.idl |  4 ++--
 2 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index 19ad3917265..ee4f59b5faa 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -449,21 +449,15 @@ static msi_custom_action_info *find_action_by_guid( const GUID *guid )
     return info;
 }
 
-static void handle_msi_break(LPCSTR target)
+static void handle_msi_break( const WCHAR *action )
 {
-    char format[] = "To debug your custom action, attach your debugger to "
-                    "process %i (0x%X) and press OK";
-    char val[MAX_PATH];
-    char msg[100];
+    const WCHAR fmt[] = L"To debug your custom action, attach your debugger to process %u (0x%x) and press OK";
+    WCHAR val[MAX_PATH], msg[100];
 
-    if (!GetEnvironmentVariableA("MsiBreak", val, MAX_PATH))
-        return;
+    if (!GetEnvironmentVariableW( L"MsiBreak", val, MAX_PATH ) || wcscmp( val, action )) return;
 
-    if (strcmp(val, target))
-        return;
-
-    sprintf(msg, format, GetCurrentProcessId(), GetCurrentProcessId());
-    MessageBoxA(NULL, msg, "Windows Installer", MB_OK);
+    swprintf( msg, ARRAY_SIZE(msg), fmt, GetCurrentProcessId(), GetCurrentProcessId() );
+    MessageBoxW( NULL, msg, L"Windows Installer", MB_OK );
     DebugBreak();
 }
 
@@ -497,7 +491,7 @@ UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid)
     RPC_WSTR binding_str;
     MSIHANDLE hPackage;
     RPC_STATUS status;
-    LPWSTR dll = NULL;
+    WCHAR *dll = NULL, *action = NULL;
     LPSTR proc = NULL;
     HANDLE hModule;
     INT type;
@@ -525,7 +519,7 @@ UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid)
         RpcStringFreeW(&binding_str);
     }
 
-    r = remote_GetActionInfo(guid, &type, &dll, &proc, &remote_package);
+    r = remote_GetActionInfo(guid, &action, &type, &dll, &proc, &remote_package);
     if (r != ERROR_SUCCESS)
         return r;
 
@@ -533,6 +527,7 @@ UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid)
     if (!hPackage)
     {
         ERR( "failed to create handle for %x\n", remote_package );
+        midl_user_free( action );
         midl_user_free( dll );
         midl_user_free( proc );
         return ERROR_INSTALL_FAILURE;
@@ -542,6 +537,7 @@ UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid)
     if (!hModule)
     {
         ERR( "failed to load dll %s (%u)\n", debugstr_w( dll ), GetLastError() );
+        midl_user_free( action );
         midl_user_free( dll );
         midl_user_free( proc );
         MsiCloseHandle( hPackage );
@@ -552,7 +548,7 @@ UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid)
     if (!fn) WARN( "GetProcAddress(%s) failed\n", debugstr_a(proc) );
     else
     {
-        handle_msi_break(proc);
+        handle_msi_break(action);
 
         __TRY
         {
@@ -569,11 +565,11 @@ UINT CDECL __wine_msi_call_dll_function(DWORD client_pid, const GUID *guid)
 
     FreeLibrary(hModule);
 
+    midl_user_free(action);
     midl_user_free(dll);
     midl_user_free(proc);
 
     MsiCloseAllHandles();
-
     return r;
 }
 
@@ -1612,7 +1608,7 @@ void ACTION_FinishCustomActions(const MSIPACKAGE* package)
     LeaveCriticalSection( &msi_custom_action_cs );
 }
 
-UINT __cdecl s_remote_GetActionInfo(const GUID *guid, int *type, LPWSTR *dll, LPSTR *func, MSIHANDLE *hinst)
+UINT __cdecl s_remote_GetActionInfo(const GUID *guid, WCHAR **name, int *type, WCHAR **dll, char **func, MSIHANDLE *hinst)
 {
     msi_custom_action_info *info;
 
@@ -1620,6 +1616,7 @@ UINT __cdecl s_remote_GetActionInfo(const GUID *guid, int *type, LPWSTR *dll, LP
     if (!info)
         return ERROR_INVALID_DATA;
 
+    *name = strdupW(info->action);
     *type = info->type;
     *hinst = alloc_msihandle(&info->package->hdr);
     *dll = strdupW(info->source);
diff --git a/dlls/msi/winemsi.idl b/dlls/msi/winemsi.idl
index 7888b0ceb40..e9f0f9e6e59 100644
--- a/dlls/msi/winemsi.idl
+++ b/dlls/msi/winemsi.idl
@@ -105,7 +105,7 @@ interface IWineMsiRemote
     UINT remote_EnumComponentCosts( [in] MSIHANDLE hinst, [in, string, unique] LPCWSTR component, [in] DWORD index, [in] INSTALLSTATE state,
                                     [out, string, size_is(3)] LPWSTR drive, [out] INT *cost, [out] INT *temp );
 
-    UINT remote_GetActionInfo( [in] const GUID *guid, [out] int *type, [out, string] LPWSTR *dllname,
-                               [out, string] LPSTR *function, [out] MSIHANDLE *hinst );
+    UINT remote_GetActionInfo( [in] const GUID *guid, [out, string] WCHAR **action, [out] int *type, [out, string] WCHAR **dllname,
+                               [out, string] char **function, [out] MSIHANDLE *hinst );
     UINT remote_CloseHandle( [in] MSIHANDLE handle );
 }
-- 
2.30.2




More information about the wine-devel mailing list