[WINESYNC] msi: Make remote_GetActionInfo() RPC-compatible.

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>

wine commit id 2635333922f13c0312b3cdae08f7cf870e10f49a by Zebediah Figura <z.figura12@gmail.com>
This commit is contained in:
winesync 2022-03-12 15:12:07 +01:00 committed by Mark Jansen
parent 3919813408
commit c2e9daf59e
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
2 changed files with 29 additions and 49 deletions

View file

@ -25,6 +25,7 @@
#define COBJMACROS #define COBJMACROS
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winerror.h" #include "winerror.h"
@ -472,37 +473,21 @@ static msi_custom_action_info *find_action_by_guid( const GUID *guid )
return info; return info;
} }
static void handle_msi_break( LPCWSTR target ) static void handle_msi_break(LPCSTR target)
{ {
LPWSTR msg; char format[] = "To debug your custom action, attach your debugger to "
WCHAR val[MAX_PATH]; "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 }; if (!GetEnvironmentVariableA("MsiBreak", val, MAX_PATH))
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 ))
return; return;
if( strcmpiW( val, target )) if (strcasecmp(val, target))
return; return;
msg = msi_alloc( (lstrlenW(format) + 10) * sizeof(WCHAR) ); sprintf(msg, format, GetCurrentProcessId(), GetCurrentProcessId());
if (!msg) MessageBoxA(NULL, msg, "Windows Installer", MB_OK);
return;
wsprintfW( msg, format, GetCurrentProcessId(), GetCurrentProcessId());
MessageBoxW( NULL, msg, WindowsInstaller, MB_OK);
msi_free(msg);
DebugBreak(); DebugBreak();
} }
@ -535,14 +520,14 @@ static DWORD ACTION_CallDllFunction( const GUID *guid )
MSIHANDLE remote_package = 0; MSIHANDLE remote_package = 0;
MSIHANDLE hPackage; MSIHANDLE hPackage;
HANDLE hModule; HANDLE hModule;
LPWSTR dll;
LPSTR proc; LPSTR proc;
UINT r = ERROR_FUNCTION_FAILED;
BSTR dll = NULL, function = NULL;
INT type; INT type;
UINT r;
TRACE("%s\n", debugstr_guid( guid )); 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) if (r != ERROR_SUCCESS)
return r; return r;
@ -553,16 +538,14 @@ static DWORD ACTION_CallDllFunction( const GUID *guid )
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
proc = strdupWtoA( function );
fn = (MsiCustomActionEntryPoint) GetProcAddress( hModule, proc ); fn = (MsiCustomActionEntryPoint) GetProcAddress( hModule, proc );
msi_free( proc );
if (fn) if (fn)
{ {
hPackage = alloc_msi_remote_handle( remote_package ); hPackage = alloc_msi_remote_handle( remote_package );
if (hPackage) if (hPackage)
{ {
TRACE("calling %s\n", debugstr_w( function ) ); TRACE("calling %s\n", debugstr_a(proc));
handle_msi_break( function ); handle_msi_break(proc);
__TRY __TRY
{ {
@ -571,7 +554,7 @@ static DWORD ACTION_CallDllFunction( const GUID *guid )
__EXCEPT_PAGE_FAULT __EXCEPT_PAGE_FAULT
{ {
ERR("Custom action (%s:%s) caused a page fault: %08x\n", 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; r = ERROR_SUCCESS;
} }
__ENDTRY; __ENDTRY;
@ -582,13 +565,13 @@ static DWORD ACTION_CallDllFunction( const GUID *guid )
ERR("failed to create handle for %x\n", remote_package ); ERR("failed to create handle for %x\n", remote_package );
} }
else else
ERR("GetProcAddress(%s) failed\n", debugstr_w( function ) ); ERR("GetProcAddress(%s) failed\n", debugstr_a(proc));
FreeLibrary(hModule); FreeLibrary(hModule);
MsiCloseHandle(hPackage); MsiCloseHandle(hPackage);
SysFreeString( dll ); midl_user_free(dll);
SysFreeString( function ); midl_user_free(proc);
return r; return r;
} }
@ -1365,22 +1348,19 @@ void ACTION_FinishCustomActions(const MSIPACKAGE* package)
LeaveCriticalSection( &msi_custom_action_cs ); LeaveCriticalSection( &msi_custom_action_cs );
} }
HRESULT __cdecl remote_GetActionInfo( const GUID *custom_action_guid, UINT __cdecl remote_GetActionInfo(const GUID *guid, int *type, LPWSTR *dll, LPSTR *func, MSIHANDLE *hinst)
INT *type, BSTR *dll, BSTR *func, MSIHANDLE *remote_package )
{ {
msi_custom_action_info *info; msi_custom_action_info *info;
MSIHANDLE handle;
info = find_action_by_guid( custom_action_guid ); info = find_action_by_guid(guid);
if (!info) if (!info)
return E_FAIL; return ERROR_INVALID_DATA;
*type = info->type; *type = info->type;
handle = alloc_msihandle( &info->package->hdr ); *hinst = alloc_msihandle(&info->package->hdr);
*dll = SysAllocString( info->source ); *dll = strdupW(info->source);
*func = SysAllocString( info->target ); *func = strdupWtoA(info->target);
release_custom_action_data( info ); release_custom_action_data(info);
*remote_package = handle; return ERROR_SUCCESS;
return S_OK;
} }

View file

@ -94,7 +94,7 @@ interface IWineMsiRemote
UINT remote_EnumComponentCosts( [in] MSIHANDLE hinst, [in, string, unique] LPCWSTR component, [in] DWORD index, [in] INSTALLSTATE state, 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 ); [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, UINT remote_GetActionInfo( [in] const GUID *guid, [out] int *type, [out, string] LPWSTR *dllname,
[out] BSTR *function, [out] MSIHANDLE *package ); [out, string] LPSTR *function, [out] MSIHANDLE *hinst );
UINT remote_CloseHandle( [in] MSIHANDLE handle ); UINT remote_CloseHandle( [in] MSIHANDLE handle );
} }