https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c2e9daf59eab5a94e43be…
commit c2e9daf59eab5a94e43be6f5f2cbf94e75f7b6d3
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 15:12:07 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:27:42 2022 +0100
[WINESYNC] msi: Make remote_GetActionInfo() RPC-compatible.
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 2635333922f13c0312b3cdae08f7cf870e10f49a by Zebediah Figura
<z.figura12(a)gmail.com>
---
dll/win32/msi/custom.c | 74 +++++++++++++++++------------------------------
dll/win32/msi/winemsi.idl | 4 +--
2 files changed, 29 insertions(+), 49 deletions(-)
diff --git a/dll/win32/msi/custom.c b/dll/win32/msi/custom.c
index 7a05cb5d670..e5636083451 100644
--- a/dll/win32/msi/custom.c
+++ b/dll/win32/msi/custom.c
@@ -25,6 +25,7 @@
#define COBJMACROS
#include <stdarg.h>
+#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
@@ -472,37 +473,21 @@ static msi_custom_action_info *find_action_by_guid( const GUID *guid
)
return info;
}
-static void handle_msi_break( LPCWSTR target )
+static void handle_msi_break(LPCSTR target)
{
- LPWSTR msg;
- WCHAR val[MAX_PATH];
+ 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];
- static const WCHAR MsiBreak[] = {
'M','s','i','B','r','e','a','k',0
};
- static const WCHAR WindowsInstaller[] = {
-
'W','i','n','d','o','w','s','
','I','n','s','t','a','l','l','e','r',0
- };
-
- static const WCHAR format[] = {
- 'T','o','
','d','e','b','u','g','
','y','o','u','r',' ',
- 'c','u','s','t','o','m','
','a','c','t','i','o','n',',','
',
- 'a','t','t','a','c','h','
','y','o','u','r','
','d','e','b','u','g','g','e','r','
',
- 't','o','
','p','r','o','c','e','s','s','
','%','i','
','(','0','x','%','X',')','
',
- 'a','n','d','
','p','r','e','s','s','
','O','K',0
- };
-
- if( !GetEnvironmentVariableW( MsiBreak, val, MAX_PATH ))
+ if (!GetEnvironmentVariableA("MsiBreak", val, MAX_PATH))
return;
- if( strcmpiW( val, target ))
+ if (strcasecmp(val, target))
return;
- msg = msi_alloc( (lstrlenW(format) + 10) * sizeof(WCHAR) );
- if (!msg)
- return;
-
- wsprintfW( msg, format, GetCurrentProcessId(), GetCurrentProcessId());
- MessageBoxW( NULL, msg, WindowsInstaller, MB_OK);
- msi_free(msg);
+ sprintf(msg, format, GetCurrentProcessId(), GetCurrentProcessId());
+ MessageBoxA(NULL, msg, "Windows Installer", MB_OK);
DebugBreak();
}
@@ -535,14 +520,14 @@ static DWORD ACTION_CallDllFunction( const GUID *guid )
MSIHANDLE remote_package = 0;
MSIHANDLE hPackage;
HANDLE hModule;
+ LPWSTR dll;
LPSTR proc;
- UINT r = ERROR_FUNCTION_FAILED;
- BSTR dll = NULL, function = NULL;
INT type;
+ UINT r;
TRACE("%s\n", debugstr_guid( guid ));
- r = remote_GetActionInfo( guid, &type, &dll, &function,
&remote_package );
+ r = remote_GetActionInfo(guid, &type, &dll, &proc, &remote_package);
if (r != ERROR_SUCCESS)
return r;
@@ -553,16 +538,14 @@ static DWORD ACTION_CallDllFunction( const GUID *guid )
return ERROR_SUCCESS;
}
- proc = strdupWtoA( function );
fn = (MsiCustomActionEntryPoint) GetProcAddress( hModule, proc );
- msi_free( proc );
if (fn)
{
hPackage = alloc_msi_remote_handle( remote_package );
if (hPackage)
{
- TRACE("calling %s\n", debugstr_w( function ) );
- handle_msi_break( function );
+ TRACE("calling %s\n", debugstr_a(proc));
+ handle_msi_break(proc);
__TRY
{
@@ -571,7 +554,7 @@ static DWORD ACTION_CallDllFunction( const GUID *guid )
__EXCEPT_PAGE_FAULT
{
ERR("Custom action (%s:%s) caused a page fault: %08x\n",
- debugstr_w(dll), debugstr_w(function), GetExceptionCode());
+ debugstr_w(dll), debugstr_a(proc), GetExceptionCode());
r = ERROR_SUCCESS;
}
__ENDTRY;
@@ -582,13 +565,13 @@ static DWORD ACTION_CallDllFunction( const GUID *guid )
ERR("failed to create handle for %x\n", remote_package );
}
else
- ERR("GetProcAddress(%s) failed\n", debugstr_w( function ) );
+ ERR("GetProcAddress(%s) failed\n", debugstr_a(proc));
FreeLibrary(hModule);
MsiCloseHandle(hPackage);
- SysFreeString( dll );
- SysFreeString( function );
+ midl_user_free(dll);
+ midl_user_free(proc);
return r;
}
@@ -1365,22 +1348,19 @@ void ACTION_FinishCustomActions(const MSIPACKAGE* package)
LeaveCriticalSection( &msi_custom_action_cs );
}
-HRESULT __cdecl remote_GetActionInfo( const GUID *custom_action_guid,
- INT *type, BSTR *dll, BSTR *func, MSIHANDLE *remote_package )
+UINT __cdecl remote_GetActionInfo(const GUID *guid, int *type, LPWSTR *dll, LPSTR *func,
MSIHANDLE *hinst)
{
msi_custom_action_info *info;
- MSIHANDLE handle;
- info = find_action_by_guid( custom_action_guid );
+ info = find_action_by_guid(guid);
if (!info)
- return E_FAIL;
+ return ERROR_INVALID_DATA;
*type = info->type;
- handle = alloc_msihandle( &info->package->hdr );
- *dll = SysAllocString( info->source );
- *func = SysAllocString( info->target );
+ *hinst = alloc_msihandle(&info->package->hdr);
+ *dll = strdupW(info->source);
+ *func = strdupWtoA(info->target);
- release_custom_action_data( info );
- *remote_package = handle;
- return S_OK;
+ release_custom_action_data(info);
+ return ERROR_SUCCESS;
}
diff --git a/dll/win32/msi/winemsi.idl b/dll/win32/msi/winemsi.idl
index 388450084e9..8af175999b8 100644
--- a/dll/win32/msi/winemsi.idl
+++ b/dll/win32/msi/winemsi.idl
@@ -94,7 +94,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 );
- HRESULT remote_GetActionInfo( [in] LPCGUID guid, [out] INT *type, [out] BSTR
*dllname,
- [out] BSTR *function, [out] MSIHANDLE *package );
+ UINT remote_GetActionInfo( [in] const GUID *guid, [out] int *type, [out, string]
LPWSTR *dllname,
+ [out, string] LPSTR *function, [out] MSIHANDLE *hinst );
UINT remote_CloseHandle( [in] MSIHANDLE handle );
}