[PATCH 3/3] msi: Convert the IWineMsiRemote* remote interfaces to RPC stubs.

Zebediah Figura z.figura12 at gmail.com
Sun Apr 15 20:52:10 CDT 2018


This patch is large, so I'll try to provide a summary of what it's doing:

1. Move the COM interface declarations from msiserver.idl to a private
winemsi.idl. Currently this file isn't doing anything besides providing a
header, but once all further preparation is made it'll provide the client and
server stubs.

2. Change usage of IWineMsiRemote* interfaces to plain MSIHANDLEs. That is, an
MSIHANDLE on the client side gets translated into a different MSIHANDLE on the
server side. This means:
    a) adding a MSIHANDLE parameter as a first argument to most remote APIs,
       corresponding to the This parameter
    b) changing other IWineMsiRemote* parameters to MSIHANDLE
    c) changing msi_get_remote() and msi_alloc_remote_handle() to deal in
       MSIHANDLEs

3. As a result, get rid of the reference counting and IUnknown methods of the
server-side interfaces.

4. Add a remote_CloseHandle() method replacing IWineMsiRemote*::Release().

5. Stop vending the WineMsiRemoteCustomAction class since it doesn't exist
anymore.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/msi/Makefile.in   |   4 +-
 dlls/msi/cond.y        |  13 +--
 dlls/msi/custom.c      | 117 ++------------------
 dlls/msi/database.c    | 121 ++-------------------
 dlls/msi/dialog.c      |   5 +-
 dlls/msi/format.c      |  11 +-
 dlls/msi/handle.c      |  30 +++---
 dlls/msi/install.c     | 149 ++++++++------------------
 dlls/msi/msi.c         |  17 ++-
 dlls/msi/msi_main.c    |   7 --
 dlls/msi/msipriv.h     |   7 +-
 dlls/msi/msiquery.c    |  41 +++-----
 dlls/msi/msiserver.idl |  64 -----------
 dlls/msi/package.c     | 281 +++++++++++--------------------------------------
 dlls/msi/suminfo.c     |  14 ++-
 dlls/msi/winemsi.idl   |  68 ++++++++++++
 16 files changed, 256 insertions(+), 693 deletions(-)
 create mode 100644 dlls/msi/winemsi.idl

diff --git a/dlls/msi/Makefile.in b/dlls/msi/Makefile.in
index 79704ad..37c9a7a 100644
--- a/dlls/msi/Makefile.in
+++ b/dlls/msi/Makefile.in
@@ -44,7 +44,9 @@ C_SRCS = \
 	upgrade.c \
 	where.c
 
-IDL_SRCS = msiserver.idl
+IDL_SRCS = \
+	msiserver.idl \
+	winemsi.idl
 
 BISON_SRCS = \
 	cond.y \
diff --git a/dlls/msi/cond.y b/dlls/msi/cond.y
index 6ee6ab9..8a3373f 100644
--- a/dlls/msi/cond.y
+++ b/dlls/msi/cond.y
@@ -37,7 +37,7 @@
 #include "oleauto.h"
 
 #include "msipriv.h"
-#include "msiserver.h"
+#include "winemsi.h"
 #include "wine/debug.h"
 #include "wine/unicode.h"
 #include "wine/list.h"
@@ -850,25 +850,20 @@ MSICONDITION WINAPI MsiEvaluateConditionW( MSIHANDLE hInstall, LPCWSTR szConditi
     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
     if( !package )
     {
+        MSIHANDLE remote;
         HRESULT hr;
         BSTR condition;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return MSICONDITION_ERROR;
 
         condition = SysAllocString( szCondition );
         if (!condition)
-        {
-            IWineMsiRemotePackage_Release( remote_package );
             return ERROR_OUTOFMEMORY;
-        }
 
-        hr = IWineMsiRemotePackage_EvaluateCondition( remote_package, condition );
+        hr = remote_EvaluateCondition(remote, condition);
 
         SysFreeString( condition );
-        IWineMsiRemotePackage_Release( remote_package );
 
         if (FAILED(hr))
         {
diff --git a/dlls/msi/custom.c b/dlls/msi/custom.c
index def36e3..e2ed5a4 100644
--- a/dlls/msi/custom.c
+++ b/dlls/msi/custom.c
@@ -33,7 +33,7 @@
 #include "oleauto.h"
 
 #include "msipriv.h"
-#include "msiserver.h"
+#include "winemsi.h"
 #include "wine/debug.h"
 #include "wine/unicode.h"
 #include "wine/exception.h"
@@ -490,40 +490,6 @@ static void handle_msi_break( LPCWSTR target )
     DebugBreak();
 }
 
-static UINT get_action_info( const GUID *guid, INT *type,
-                             BSTR *dll, BSTR *funcname,
-                             IWineMsiRemotePackage **package )
-{
-    IClassFactory *cf = NULL;
-    IWineMsiRemoteCustomAction *rca = NULL;
-    HRESULT r;
-
-    r = DllGetClassObject( &CLSID_WineMsiRemoteCustomAction,
-                           &IID_IClassFactory, (LPVOID *)&cf );
-    if (FAILED(r))
-    {
-        ERR("failed to get IClassFactory interface\n");
-        return ERROR_FUNCTION_FAILED;
-    }
-
-    r = IClassFactory_CreateInstance( cf, NULL, &IID_IWineMsiRemoteCustomAction, (LPVOID *)&rca );
-    if (FAILED(r))
-    {
-        ERR("failed to get IWineMsiRemoteCustomAction interface\n");
-        return ERROR_FUNCTION_FAILED;
-    }
-
-    r = IWineMsiRemoteCustomAction_GetActionInfo( rca, guid, type, dll, funcname, package );
-    IWineMsiRemoteCustomAction_Release( rca );
-    if (FAILED(r))
-    {
-        ERR("GetActionInfo failed\n");
-        return ERROR_FUNCTION_FAILED;
-    }
-
-    return ERROR_SUCCESS;
-}
-
 #ifdef __i386__
 extern UINT CUSTOMPROC_wrapper( MsiCustomActionEntryPoint proc, MSIHANDLE handle );
 __ASM_GLOBAL_FUNC( CUSTOMPROC_wrapper,
@@ -550,17 +516,17 @@ static inline UINT CUSTOMPROC_wrapper( MsiCustomActionEntryPoint proc, MSIHANDLE
 static DWORD ACTION_CallDllFunction( const GUID *guid )
 {
     MsiCustomActionEntryPoint fn;
+    MSIHANDLE remote_package = 0;
     MSIHANDLE hPackage;
     HANDLE hModule;
     LPSTR proc;
     UINT r = ERROR_FUNCTION_FAILED;
     BSTR dll = NULL, function = NULL;
     INT type;
-    IWineMsiRemotePackage *remote_package = NULL;
 
     TRACE("%s\n", debugstr_guid( guid ));
 
-    r = get_action_info( guid, &type, &dll, &function, &remote_package );
+    r = remote_GetActionInfo( guid, &type, &dll, &function, &remote_package );
     if (r != ERROR_SUCCESS)
         return r;
 
@@ -576,7 +542,7 @@ static DWORD ACTION_CallDllFunction( const GUID *guid )
     msi_free( proc );
     if (fn)
     {
-        hPackage = alloc_msi_remote_handle( (IUnknown *)remote_package );
+        hPackage = alloc_msi_remote_handle( remote_package );
         if (hPackage)
         {
             TRACE("calling %s\n", debugstr_w( function ) );
@@ -597,14 +563,14 @@ static DWORD ACTION_CallDllFunction( const GUID *guid )
             MsiCloseHandle( hPackage );
         }
         else
-            ERR("failed to create handle for %p\n", remote_package );
+            ERR("failed to create handle for %x\n", remote_package );
     }
     else
         ERR("GetProcAddress(%s) failed\n", debugstr_w( function ) );
 
     FreeLibrary(hModule);
 
-    IWineMsiRemotePackage_Release( remote_package );
+    MsiCloseHandle(hPackage);
     SysFreeString( dll );
     SysFreeString( function );
 
@@ -1383,50 +1349,8 @@ void ACTION_FinishCustomActions(const MSIPACKAGE* package)
     LeaveCriticalSection( &msi_custom_action_cs );
 }
 
-typedef struct _msi_custom_remote_impl {
-    IWineMsiRemoteCustomAction IWineMsiRemoteCustomAction_iface;
-    LONG refs;
-} msi_custom_remote_impl;
-
-static inline msi_custom_remote_impl *impl_from_IWineMsiRemoteCustomAction( IWineMsiRemoteCustomAction *iface )
-{
-    return CONTAINING_RECORD(iface, msi_custom_remote_impl, IWineMsiRemoteCustomAction_iface);
-}
-
-static HRESULT WINAPI mcr_QueryInterface( IWineMsiRemoteCustomAction *iface,
-                REFIID riid,LPVOID *ppobj)
-{
-    if( IsEqualCLSID( riid, &IID_IUnknown ) ||
-        IsEqualCLSID( riid, &IID_IWineMsiRemoteCustomAction ) )
-    {
-        IWineMsiRemoteCustomAction_AddRef( iface );
-        *ppobj = iface;
-        return S_OK;
-    }
-
-    return E_NOINTERFACE;
-}
-
-static ULONG WINAPI mcr_AddRef( IWineMsiRemoteCustomAction *iface )
-{
-    msi_custom_remote_impl* This = impl_from_IWineMsiRemoteCustomAction( iface );
-
-    return InterlockedIncrement( &This->refs );
-}
-
-static ULONG WINAPI mcr_Release( IWineMsiRemoteCustomAction *iface )
-{
-    msi_custom_remote_impl* This = impl_from_IWineMsiRemoteCustomAction( iface );
-    ULONG r;
-
-    r = InterlockedDecrement( &This->refs );
-    if (r == 0)
-        msi_free( This );
-    return r;
-}
-
-static HRESULT WINAPI mcr_GetActionInfo( IWineMsiRemoteCustomAction *iface, LPCGUID custom_action_guid,
-         INT *type, BSTR *dll, BSTR *func, IWineMsiRemotePackage **remote_package )
+HRESULT __cdecl remote_GetActionInfo( const GUID *custom_action_guid,
+         INT *type, BSTR *dll, BSTR *func, MSIHANDLE *remote_package )
 {
     msi_custom_action_info *info;
     MSIHANDLE handle;
@@ -1441,29 +1365,6 @@ static HRESULT WINAPI mcr_GetActionInfo( IWineMsiRemoteCustomAction *iface, LPCG
     *func = SysAllocString( info->target );
 
     release_custom_action_data( info );
-    return create_msi_remote_package( handle, remote_package );
-}
-
-static const IWineMsiRemoteCustomActionVtbl msi_custom_remote_vtbl =
-{
-    mcr_QueryInterface,
-    mcr_AddRef,
-    mcr_Release,
-    mcr_GetActionInfo,
-};
-
-HRESULT create_msi_custom_remote( IUnknown *pOuter, LPVOID *ppObj )
-{
-    msi_custom_remote_impl* This;
-
-    This = msi_alloc( sizeof *This );
-    if (!This)
-        return E_OUTOFMEMORY;
-
-    This->IWineMsiRemoteCustomAction_iface.lpVtbl = &msi_custom_remote_vtbl;
-    This->refs = 1;
-
-    *ppObj = &This->IWineMsiRemoteCustomAction_iface;
-
+    *remote_package = handle;
     return S_OK;
 }
diff --git a/dlls/msi/database.c b/dlls/msi/database.c
index 85e8306..d3eb910 100644
--- a/dlls/msi/database.c
+++ b/dlls/msi/database.c
@@ -873,13 +873,10 @@ UINT WINAPI MsiDatabaseImportW(MSIHANDLE handle, LPCWSTR szFolder, LPCWSTR szFil
     db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
     if( !db )
     {
-        IWineMsiRemoteDatabase *remote_database;
-
-        remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( handle );
+        MSIHANDLE remote_database = msi_get_remote( handle );
         if ( !remote_database )
             return ERROR_INVALID_HANDLE;
 
-        IWineMsiRemoteDatabase_Release( remote_database );
         WARN("MsiDatabaseImport not allowed during a custom action!\n");
 
         return ERROR_SUCCESS;
@@ -1094,13 +1091,10 @@ UINT WINAPI MsiDatabaseExportW( MSIHANDLE handle, LPCWSTR szTable,
     db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
     if( !db )
     {
-        IWineMsiRemoteDatabase *remote_database;
-
-        remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( handle );
+        MSIHANDLE remote_database = msi_get_remote(handle);
         if ( !remote_database )
             return ERROR_INVALID_HANDLE;
 
-        IWineMsiRemoteDatabase_Release( remote_database );
         WARN("MsiDatabaseExport not allowed during a custom action!\n");
 
         return ERROR_SUCCESS;
@@ -1896,13 +1890,10 @@ MSIDBSTATE WINAPI MsiGetDatabaseState( MSIHANDLE handle )
     db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
     if( !db )
     {
-        IWineMsiRemoteDatabase *remote_database;
-
-        remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( handle );
+        MSIHANDLE remote_database = msi_get_remote(handle);
         if ( !remote_database )
             return MSIDBSTATE_ERROR;
 
-        IWineMsiRemoteDatabase_Release( remote_database );
         WARN("MsiGetDatabaseState not allowed during a custom action!\n");
 
         return MSIDBSTATE_READ;
@@ -1915,116 +1906,26 @@ MSIDBSTATE WINAPI MsiGetDatabaseState( MSIHANDLE handle )
     return ret;
 }
 
-typedef struct _msi_remote_database_impl {
-    IWineMsiRemoteDatabase IWineMsiRemoteDatabase_iface;
-    MSIHANDLE database;
-    LONG refs;
-} msi_remote_database_impl;
-
-static inline msi_remote_database_impl *impl_from_IWineMsiRemoteDatabase( IWineMsiRemoteDatabase *iface )
+HRESULT __cdecl remote_DatabaseIsTablePersistent(MSIHANDLE db, LPCWSTR table, MSICONDITION *persistent)
 {
-    return CONTAINING_RECORD(iface, msi_remote_database_impl, IWineMsiRemoteDatabase_iface);
-}
-
-static HRESULT WINAPI mrd_QueryInterface( IWineMsiRemoteDatabase *iface,
-                                          REFIID riid,LPVOID *ppobj)
-{
-    if( IsEqualCLSID( riid, &IID_IUnknown ) ||
-        IsEqualCLSID( riid, &IID_IWineMsiRemoteDatabase ) )
-    {
-        IWineMsiRemoteDatabase_AddRef( iface );
-        *ppobj = iface;
-        return S_OK;
-    }
-
-    return E_NOINTERFACE;
-}
-
-static ULONG WINAPI mrd_AddRef( IWineMsiRemoteDatabase *iface )
-{
-    msi_remote_database_impl* This = impl_from_IWineMsiRemoteDatabase( iface );
-
-    return InterlockedIncrement( &This->refs );
-}
-
-static ULONG WINAPI mrd_Release( IWineMsiRemoteDatabase *iface )
-{
-    msi_remote_database_impl* This = impl_from_IWineMsiRemoteDatabase( iface );
-    ULONG r;
-
-    r = InterlockedDecrement( &This->refs );
-    if (r == 0)
-    {
-        MsiCloseHandle( This->database );
-        msi_free( This );
-    }
-    return r;
-}
-
-static HRESULT WINAPI mrd_IsTablePersistent( IWineMsiRemoteDatabase *iface,
-                                             LPCWSTR table, MSICONDITION *persistent )
-{
-    msi_remote_database_impl *This = impl_from_IWineMsiRemoteDatabase( iface );
-    *persistent = MsiDatabaseIsTablePersistentW(This->database, table);
+    *persistent = MsiDatabaseIsTablePersistentW(db, table);
     return S_OK;
 }
 
-static HRESULT WINAPI mrd_GetPrimaryKeys( IWineMsiRemoteDatabase *iface,
-                                          LPCWSTR table, MSIHANDLE *keys )
+HRESULT __cdecl remote_DatabaseGetPrimaryKeys(MSIHANDLE db, LPCWSTR table, MSIHANDLE *keys)
 {
-    msi_remote_database_impl *This = impl_from_IWineMsiRemoteDatabase( iface );
-    UINT r = MsiDatabaseGetPrimaryKeysW(This->database, table, keys);
+    UINT r = MsiDatabaseGetPrimaryKeysW(db, table, keys);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrd_GetSummaryInformation( IWineMsiRemoteDatabase *iface,
-                                                UINT updatecount, MSIHANDLE *suminfo )
+HRESULT __cdecl remote_DatabaseGetSummaryInformation(MSIHANDLE db, UINT updatecount, MSIHANDLE *suminfo)
 {
-    msi_remote_database_impl *This = impl_from_IWineMsiRemoteDatabase( iface );
-    UINT r = MsiGetSummaryInformationW(This->database, NULL, updatecount, suminfo);
+    UINT r = MsiGetSummaryInformationW(db, NULL, updatecount, suminfo);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrd_OpenView( IWineMsiRemoteDatabase *iface,
-                                    LPCWSTR query, MSIHANDLE *view )
+HRESULT __cdecl remote_DatabaseOpenView(MSIHANDLE db, LPCWSTR query, MSIHANDLE *view)
 {
-    msi_remote_database_impl *This = impl_from_IWineMsiRemoteDatabase( iface );
-    UINT r = MsiDatabaseOpenViewW(This->database, query, view);
+    UINT r = MsiDatabaseOpenViewW(db, query, view);
     return HRESULT_FROM_WIN32(r);
 }
-
-static HRESULT WINAPI mrd_SetMsiHandle( IWineMsiRemoteDatabase *iface, MSIHANDLE handle )
-{
-    msi_remote_database_impl* This = impl_from_IWineMsiRemoteDatabase( iface );
-    This->database = handle;
-    return S_OK;
-}
-
-static const IWineMsiRemoteDatabaseVtbl msi_remote_database_vtbl =
-{
-    mrd_QueryInterface,
-    mrd_AddRef,
-    mrd_Release,
-    mrd_IsTablePersistent,
-    mrd_GetPrimaryKeys,
-    mrd_GetSummaryInformation,
-    mrd_OpenView,
-    mrd_SetMsiHandle,
-};
-
-HRESULT create_msi_remote_database( IUnknown *pOuter, LPVOID *ppObj )
-{
-    msi_remote_database_impl *This;
-
-    This = msi_alloc( sizeof *This );
-    if (!This)
-        return E_OUTOFMEMORY;
-
-    This->IWineMsiRemoteDatabase_iface.lpVtbl = &msi_remote_database_vtbl;
-    This->database = 0;
-    This->refs = 1;
-
-    *ppObj = &This->IWineMsiRemoteDatabase_iface;
-
-    return S_OK;
-}
diff --git a/dlls/msi/dialog.c b/dlls/msi/dialog.c
index 8825c28..ec32581 100644
--- a/dlls/msi/dialog.c
+++ b/dlls/msi/dialog.c
@@ -4138,15 +4138,12 @@ UINT WINAPI MsiEnableUIPreview( MSIHANDLE hdb, MSIHANDLE *phPreview )
     db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
     if (!db)
     {
-        IWineMsiRemoteDatabase *remote_database;
-
-        remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( hdb );
+        MSIHANDLE remote_database = msi_get_remote( hdb );
         if (!remote_database)
             return ERROR_INVALID_HANDLE;
 
         *phPreview = 0;
 
-        IWineMsiRemoteDatabase_Release( remote_database );
         WARN("MsiEnableUIPreview not allowed during a custom action!\n");
 
         return ERROR_FUNCTION_FAILED;
diff --git a/dlls/msi/format.c b/dlls/msi/format.c
index 3bcd0b8..f15c4ce 100644
--- a/dlls/msi/format.c
+++ b/dlls/msi/format.c
@@ -34,7 +34,7 @@
 #include "oleauto.h"
 
 #include "msipriv.h"
-#include "msiserver.h"
+#include "winemsi.h"
 #include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msi);
@@ -911,15 +911,13 @@ UINT WINAPI MsiFormatRecordW( MSIHANDLE hInstall, MSIHANDLE hRecord,
     if (!package)
     {
         HRESULT hr;
-        IWineMsiRemotePackage *remote_package;
+        MSIHANDLE remote;
         BSTR value = NULL;
         awstring wstr;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
-        if (remote_package)
+        if ((remote = msi_get_remote(hInstall)))
         {
-            hr = IWineMsiRemotePackage_FormatRecord( remote_package, hRecord,
-                                                     &value );
+            hr = remote_FormatRecord(remote, hRecord, &value);
             if (FAILED(hr))
                 goto done;
 
@@ -928,7 +926,6 @@ UINT WINAPI MsiFormatRecordW( MSIHANDLE hInstall, MSIHANDLE hRecord,
             r = msi_strcpy_to_awstring( value, SysStringLen(value), &wstr, sz );
 
 done:
-            IWineMsiRemotePackage_Release( remote_package );
             SysFreeString( value );
 
             if (FAILED(hr))
diff --git a/dlls/msi/handle.c b/dlls/msi/handle.c
index 80c6873..1002f9d 100644
--- a/dlls/msi/handle.c
+++ b/dlls/msi/handle.c
@@ -29,7 +29,9 @@
 #include "wine/debug.h"
 #include "msi.h"
 #include "msiquery.h"
+
 #include "msipriv.h"
+#include "winemsi.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msi);
 
@@ -58,7 +60,7 @@ typedef struct msi_handle_info_t
     BOOL remote;
     union {
         MSIOBJECTHDR *obj;
-        IUnknown *unk;
+        MSIHANDLE rem;
     } u;
     DWORD dwThreadId;
 } msi_handle_info;
@@ -81,7 +83,7 @@ static MSIHANDLE alloc_handle_table_entry(void)
 
     /* find a slot */
     for(i=0; i<msihandletable_size; i++)
-        if( !msihandletable[i].u.obj && !msihandletable[i].u.unk )
+        if( !msihandletable[i].u.obj && !msihandletable[i].u.rem )
             break;
     if( i==msihandletable_size )
     {
@@ -130,7 +132,7 @@ MSIHANDLE alloc_msihandle( MSIOBJECTHDR *obj )
     return ret;
 }
 
-MSIHANDLE alloc_msi_remote_handle( IUnknown *unk )
+MSIHANDLE alloc_msi_remote_handle(MSIHANDLE remote)
 {
     msi_handle_info *entry;
     MSIHANDLE ret;
@@ -141,15 +143,14 @@ MSIHANDLE alloc_msi_remote_handle( IUnknown *unk )
     if (ret)
     {
         entry = &msihandletable[ ret - 1 ];
-        IUnknown_AddRef( unk );
-        entry->u.unk = unk;
+        entry->u.rem = remote;
         entry->dwThreadId = GetCurrentThreadId();
         entry->remote = TRUE;
     }
 
     LeaveCriticalSection( &MSI_handle_cs );
 
-    TRACE("%p -> %d\n", unk, ret);
+    TRACE("%d -> %d\n", remote, ret);
 
     return ret;
 }
@@ -179,9 +180,9 @@ out:
     return ret;
 }
 
-IUnknown *msi_get_remote( MSIHANDLE handle )
+MSIHANDLE msi_get_remote( MSIHANDLE handle )
 {
-    IUnknown *unk = NULL;
+    MSIHANDLE ret = 0;
 
     EnterCriticalSection( &MSI_handle_cs );
     handle--;
@@ -189,14 +190,12 @@ IUnknown *msi_get_remote( MSIHANDLE handle )
         goto out;
     if( !msihandletable[handle].remote)
         goto out;
-    unk = msihandletable[handle].u.unk;
-    if( unk )
-        IUnknown_AddRef( unk );
+    ret = msihandletable[handle].u.rem;
 
 out:
     LeaveCriticalSection( &MSI_handle_cs );
 
-    return unk;
+    return ret;
 }
 
 void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy )
@@ -285,7 +284,7 @@ UINT WINAPI MsiCloseHandle(MSIHANDLE handle)
 
     if (msihandletable[handle].remote)
     {
-        IUnknown_Release( msihandletable[handle].u.unk );
+        remote_CloseHandle( msihandletable[handle].u.rem );
     }
     else
     {
@@ -344,3 +343,8 @@ UINT WINAPI MsiCloseAllHandles(void)
 
     return n;
 }
+
+UINT __cdecl remote_CloseHandle(MSIHANDLE handle)
+{
+    return MsiCloseHandle(handle);
+}
diff --git a/dlls/msi/install.c b/dlls/msi/install.c
index 261a259..65840e2 100644
--- a/dlls/msi/install.c
+++ b/dlls/msi/install.c
@@ -34,7 +34,7 @@
 #include "oleauto.h"
 
 #include "msipriv.h"
-#include "msiserver.h"
+#include "winemsi.h"
 #include "wine/unicode.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msi);
@@ -74,25 +74,20 @@ UINT WINAPI MsiDoActionW( MSIHANDLE hInstall, LPCWSTR szAction )
     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
         BSTR action;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         action = SysAllocString( szAction );
         if (!action)
-        {
-            IWineMsiRemotePackage_Release( remote_package );
             return ERROR_OUTOFMEMORY;
-        }
 
-        hr = IWineMsiRemotePackage_DoAction( remote_package, action );
+        hr = remote_DoAction(remote, action);
 
         SysFreeString( action );
-        IWineMsiRemotePackage_Release( remote_package );
 
         if (FAILED(hr))
         {
@@ -143,25 +138,20 @@ UINT WINAPI MsiSequenceW( MSIHANDLE hInstall, LPCWSTR szTable, INT iSequenceMode
     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
         BSTR table;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         table = SysAllocString( szTable );
         if (!table)
-        {
-            IWineMsiRemotePackage_Release( remote_package );
             return ERROR_OUTOFMEMORY;
-        }
 
-        hr = IWineMsiRemotePackage_Sequence( remote_package, table, iSequenceMode );
+        hr = remote_Sequence(remote, table, iSequenceMode);
 
         SysFreeString( table );
-        IWineMsiRemotePackage_Release( remote_package );
 
         if (FAILED(hr))
         {
@@ -239,25 +229,21 @@ static UINT MSI_GetTargetPath( MSIHANDLE hInstall, LPCWSTR szFolder,
     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
-        IWineMsiRemotePackage *remote_package;
         LPWSTR value = NULL;
         BSTR folder;
         DWORD len;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         folder = SysAllocString( szFolder );
         if (!folder)
-        {
-            IWineMsiRemotePackage_Release( remote_package );
             return ERROR_OUTOFMEMORY;
-        }
 
         len = 0;
-        hr = IWineMsiRemotePackage_GetTargetPath( remote_package, folder, NULL, &len );
+        hr = remote_GetTargetPath(remote, folder, NULL, &len);
         if (FAILED(hr))
             goto done;
 
@@ -269,14 +255,13 @@ static UINT MSI_GetTargetPath( MSIHANDLE hInstall, LPCWSTR szFolder,
             goto done;
         }
 
-        hr = IWineMsiRemotePackage_GetTargetPath( remote_package, folder, value, &len );
+        hr = remote_GetTargetPath(remote, folder, value, &len);
         if (FAILED(hr))
             goto done;
 
         r = msi_strcpy_to_awstring( value, len, szPathBuf, pcchPathBuf );
 
 done:
-        IWineMsiRemotePackage_Release( remote_package );
         SysFreeString( folder );
         msi_free( value );
 
@@ -409,24 +394,20 @@ static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
     if (!package)
     {
         HRESULT hr;
-        IWineMsiRemotePackage *remote_package;
         LPWSTR value = NULL;
+        MSIHANDLE remote;
         BSTR folder;
         DWORD len;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         folder = SysAllocString( szFolder );
         if (!folder)
-        {
-            IWineMsiRemotePackage_Release( remote_package );
             return ERROR_OUTOFMEMORY;
-        }
 
         len = 0;
-        hr = IWineMsiRemotePackage_GetSourcePath( remote_package, folder, NULL, &len );
+        hr = remote_GetSourcePath(remote, folder, NULL, &len);
         if (FAILED(hr))
             goto done;
 
@@ -438,14 +419,13 @@ static UINT MSI_GetSourcePath( MSIHANDLE hInstall, LPCWSTR szFolder,
             goto done;
         }
 
-        hr = IWineMsiRemotePackage_GetSourcePath( remote_package, folder, value, &len );
+        hr = remote_GetSourcePath(remote, folder, value, &len);
         if (FAILED(hr))
             goto done;
 
         r = msi_strcpy_to_awstring( value, len, szPathBuf, pcchPathBuf );
 
 done:
-        IWineMsiRemotePackage_Release( remote_package );
         SysFreeString( folder );
         msi_free( value );
 
@@ -616,10 +596,9 @@ UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder,
     {
         HRESULT hr;
         BSTR folder, path;
-        IWineMsiRemotePackage *remote_package;
+        MSIHANDLE remote;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         folder = SysAllocString( szFolder );
@@ -628,15 +607,13 @@ UINT WINAPI MsiSetTargetPathW(MSIHANDLE hInstall, LPCWSTR szFolder,
         {
             SysFreeString(folder);
             SysFreeString(path);
-            IWineMsiRemotePackage_Release( remote_package );
             return ERROR_OUTOFMEMORY;
         }
 
-        hr = IWineMsiRemotePackage_SetTargetPath( remote_package, folder, path );
+        hr = remote_SetTargetPath(remote, folder, path);
 
         SysFreeString(folder);
         SysFreeString(path);
-        IWineMsiRemotePackage_Release( remote_package );
 
         if (FAILED(hr))
         {
@@ -697,16 +674,14 @@ BOOL WINAPI MsiGetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode)
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     if (!package)
     {
+        MSIHANDLE remote;
         BOOL ret;
         HRESULT hr;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return FALSE;
 
-        hr = IWineMsiRemotePackage_GetMode(remote_package, iRunMode, &ret);
-        IWineMsiRemotePackage_Release(remote_package);
+        hr = remote_GetMode(remote, iRunMode, &ret);
 
         if (hr == S_OK)
             return ret;
@@ -789,15 +764,13 @@ UINT WINAPI MsiSetMode(MSIHANDLE hInstall, MSIRUNMODE iRunMode, BOOL fState)
     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return FALSE;
 
-        hr = IWineMsiRemotePackage_SetMode( remote_package, iRunMode, fState );
-        IWineMsiRemotePackage_Release( remote_package );
+        hr = remote_SetMode(remote, iRunMode, fState);
 
         if (FAILED(hr))
         {
@@ -980,25 +953,20 @@ UINT WINAPI MsiSetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature,
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
         BSTR feature;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         feature = SysAllocString(szFeature);
         if (!feature)
-        {
-            IWineMsiRemotePackage_Release(remote_package);
             return ERROR_OUTOFMEMORY;
-        }
 
-        hr = IWineMsiRemotePackage_SetFeatureState(remote_package, feature, iState);
+        hr = remote_SetFeatureState(remote, feature, iState);
 
         SysFreeString(feature);
-        IWineMsiRemotePackage_Release(remote_package);
 
         if (FAILED(hr))
         {
@@ -1131,26 +1099,20 @@ UINT WINAPI MsiGetFeatureStateW(MSIHANDLE hInstall, LPCWSTR szFeature,
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
         BSTR feature;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         feature = SysAllocString(szFeature);
         if (!feature)
-        {
-            IWineMsiRemotePackage_Release(remote_package);
             return ERROR_OUTOFMEMORY;
-        }
 
-        hr = IWineMsiRemotePackage_GetFeatureState(remote_package, feature,
-                                                   piInstalled, piAction);
+        hr = remote_GetFeatureState(remote, feature, piInstalled, piAction);
 
         SysFreeString(feature);
-        IWineMsiRemotePackage_Release(remote_package);
 
         if (FAILED(hr))
         {
@@ -1263,26 +1225,20 @@ UINT WINAPI MsiGetFeatureCostW(MSIHANDLE hInstall, LPCWSTR szFeature,
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
         BSTR feature;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         feature = SysAllocString(szFeature);
         if (!feature)
-        {
-            IWineMsiRemotePackage_Release(remote_package);
             return ERROR_OUTOFMEMORY;
-        }
 
-        hr = IWineMsiRemotePackage_GetFeatureCost(remote_package, feature,
-                                                  iCostTree, iState, piCost);
+        hr = remote_GetFeatureCost(remote, feature, iCostTree, iState, piCost);
 
         SysFreeString(feature);
-        IWineMsiRemotePackage_Release(remote_package);
 
         if (FAILED(hr))
         {
@@ -1521,25 +1477,20 @@ UINT WINAPI MsiSetComponentStateW(MSIHANDLE hInstall, LPCWSTR szComponent,
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
         BSTR component;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         component = SysAllocString(szComponent);
         if (!component)
-        {
-            IWineMsiRemotePackage_Release(remote_package);
             return ERROR_OUTOFMEMORY;
-        }
 
-        hr = IWineMsiRemotePackage_SetComponentState(remote_package, component, iState);
+        hr = remote_SetComponentState(remote, component, iState);
 
         SysFreeString(component);
-        IWineMsiRemotePackage_Release(remote_package);
 
         if (FAILED(hr))
         {
@@ -1572,26 +1523,20 @@ UINT WINAPI MsiGetComponentStateW(MSIHANDLE hInstall, LPCWSTR szComponent,
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
         BSTR component;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         component = SysAllocString(szComponent);
         if (!component)
-        {
-            IWineMsiRemotePackage_Release(remote_package);
             return ERROR_OUTOFMEMORY;
-        }
 
-        hr = IWineMsiRemotePackage_GetComponentState(remote_package, component,
-                                                     piInstalled, piAction);
+        hr = remote_GetComponentState(remote, component, piInstalled, piAction);
 
         SysFreeString(component);
-        IWineMsiRemotePackage_Release(remote_package);
 
         if (FAILED(hr))
         {
@@ -1620,15 +1565,14 @@ LANGID WINAPI MsiGetLanguage(MSIHANDLE hInstall)
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
         LANGID lang;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
-        hr = IWineMsiRemotePackage_GetLanguage(remote_package, &lang);
+        hr = remote_GetLanguage(remote, &lang);
 
         if (SUCCEEDED(hr))
             return lang;
@@ -1677,16 +1621,13 @@ UINT WINAPI MsiSetInstallLevel(MSIHANDLE hInstall, int iInstallLevel)
     package = msihandle2msiinfo(hInstall, MSIHANDLETYPE_PACKAGE);
     if (!package)
     {
+        MSIHANDLE remote;
         HRESULT hr;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote(hInstall);
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
-        hr = IWineMsiRemotePackage_SetInstallLevel(remote_package, iInstallLevel);
-
-        IWineMsiRemotePackage_Release(remote_package);
+        hr = remote_SetInstallLevel(remote, iInstallLevel);
 
         if (FAILED(hr))
         {
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 7e5e23f..c0af7f5 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -31,8 +31,6 @@
 #include "msi.h"
 #include "msidefs.h"
 #include "msiquery.h"
-#include "msipriv.h"
-#include "msiserver.h"
 #include "wincrypt.h"
 #include "winver.h"
 #include "winuser.h"
@@ -42,6 +40,9 @@
 #include "wintrust.h"
 #include "softpub.h"
 
+#include "msipriv.h"
+#include "winemsi.h"
+
 #include "initguid.h"
 #include "msxml2.h"
 
@@ -2004,20 +2005,18 @@ UINT WINAPI MsiEnumComponentCostsW( MSIHANDLE handle, LPCWSTR component, DWORD i
     if (!drive || !buflen || !cost || !temp) return ERROR_INVALID_PARAMETER;
     if (!(package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE )))
     {
+        MSIHANDLE remote;
         HRESULT hr;
-        IWineMsiRemotePackage *remote_package;
         BSTR bname = NULL;
 
-        if (!(remote_package = (IWineMsiRemotePackage *)msi_get_remote( handle )))
+        if (!(remote = msi_get_remote(handle)))
             return ERROR_INVALID_HANDLE;
 
         if (component && !(bname = SysAllocString( component )))
-        {
-            IWineMsiRemotePackage_Release( remote_package );
             return ERROR_OUTOFMEMORY;
-        }
-        hr = IWineMsiRemotePackage_EnumComponentCosts( remote_package, bname, index, state, drive, buflen, cost, temp );
-        IWineMsiRemotePackage_Release( remote_package );
+
+        hr = remote_EnumComponentCosts(remote, bname, index, state, drive, buflen, cost, temp);
+
         SysFreeString( bname );
         if (FAILED(hr))
         {
diff --git a/dlls/msi/msi_main.c b/dlls/msi/msi_main.c
index 9f5b2c4..0e436b0 100644
--- a/dlls/msi/msi_main.c
+++ b/dlls/msi/msi_main.c
@@ -166,7 +166,6 @@ static const IClassFactoryVtbl MsiCF_Vtbl =
 };
 
 static IClassFactoryImpl MsiServer_CF = { { &MsiCF_Vtbl }, create_msiserver };
-static IClassFactoryImpl WineMsiCustomRemote_CF = { { &MsiCF_Vtbl }, create_msi_custom_remote };
 
 /******************************************************************
  * DllGetClassObject          [MSI.@]
@@ -181,12 +180,6 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
         return S_OK;
     }
 
-    if ( IsEqualCLSID (rclsid, &CLSID_WineMsiRemoteCustomAction) )
-    {
-        *ppv = &WineMsiCustomRemote_CF;
-        return S_OK;
-    }
-
     if( IsEqualCLSID (rclsid, &CLSID_MsiServerMessage) ||
         IsEqualCLSID (rclsid, &CLSID_MsiServer) ||
         IsEqualCLSID (rclsid, &CLSID_PSFactoryBuffer) ||
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 54acbc7..b2b3e7c 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -734,15 +734,12 @@ typedef struct {
 UINT msi_strcpy_to_awstring(const WCHAR *, int, awstring *, DWORD *) DECLSPEC_HIDDEN;
 
 /* msi server interface */
-extern HRESULT create_msi_custom_remote( IUnknown *pOuter, LPVOID *ppObj ) DECLSPEC_HIDDEN;
-extern HRESULT create_msi_remote_package( MSIHANDLE handle, IWineMsiRemotePackage **package ) DECLSPEC_HIDDEN;
-extern HRESULT create_msi_remote_database( IUnknown *pOuter, LPVOID *ppObj ) DECLSPEC_HIDDEN;
-extern IUnknown *msi_get_remote(MSIHANDLE handle) DECLSPEC_HIDDEN;
+extern MSIHANDLE msi_get_remote(MSIHANDLE handle) DECLSPEC_HIDDEN;
 
 /* handle functions */
 extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type) DECLSPEC_HIDDEN;
 extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * ) DECLSPEC_HIDDEN;
-extern MSIHANDLE alloc_msi_remote_handle( IUnknown *unk ) DECLSPEC_HIDDEN;
+extern MSIHANDLE alloc_msi_remote_handle(MSIHANDLE remote) DECLSPEC_HIDDEN;
 extern void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy ) DECLSPEC_HIDDEN;
 extern void msiobj_addref(MSIOBJECTHDR *) DECLSPEC_HIDDEN;
 extern int msiobj_release(MSIOBJECTHDR *) DECLSPEC_HIDDEN;
diff --git a/dlls/msi/msiquery.c b/dlls/msi/msiquery.c
index d73e5fe..f8ed4ce 100644
--- a/dlls/msi/msiquery.c
+++ b/dlls/msi/msiquery.c
@@ -31,11 +31,11 @@
 #include "msiquery.h"
 #include "objbase.h"
 #include "objidl.h"
-#include "msipriv.h"
 #include "winnls.h"
 
+#include "msipriv.h"
 #include "query.h"
-#include "msiserver.h"
+#include "winemsi.h"
 
 #include "initguid.h"
 
@@ -250,15 +250,13 @@ UINT WINAPI MsiDatabaseOpenViewW(MSIHANDLE hdb,
     db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
     if( !db )
     {
+        MSIHANDLE remote;
         HRESULT hr;
-        IWineMsiRemoteDatabase *remote_database;
 
-        remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( hdb );
-        if ( !remote_database )
+        if (!(remote = msi_get_remote(hdb)))
             return ERROR_INVALID_HANDLE;
 
-        hr = IWineMsiRemoteDatabase_OpenView( remote_database, szQuery, phView );
-        IWineMsiRemoteDatabase_Release( remote_database );
+        hr = remote_DatabaseOpenView(remote, szQuery, phView);
 
         if (FAILED(hr))
         {
@@ -758,13 +756,11 @@ UINT WINAPI MsiDatabaseApplyTransformW( MSIHANDLE hdb,
     db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
     if( !db )
     {
-        IWineMsiRemoteDatabase *remote_database;
+        MSIHANDLE remote;
 
-        remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( hdb );
-        if ( !remote_database )
+        if (!(remote = msi_get_remote(hdb)))
             return ERROR_INVALID_HANDLE;
 
-        IWineMsiRemoteDatabase_Release( remote_database );
         WARN("MsiDatabaseApplyTransform not allowed during a custom action!\n");
 
         return ERROR_SUCCESS;
@@ -820,13 +816,11 @@ UINT WINAPI MsiDatabaseCommit( MSIHANDLE hdb )
     db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
     if( !db )
     {
-        IWineMsiRemoteDatabase *remote_database;
+        MSIHANDLE remote;
 
-        remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( hdb );
-        if ( !remote_database )
+        if (!(remote = msi_get_remote(hdb)))
             return ERROR_INVALID_HANDLE;
 
-        IWineMsiRemoteDatabase_Release( remote_database );
         WARN("not allowed during a custom action!\n");
 
         return ERROR_SUCCESS;
@@ -946,15 +940,13 @@ UINT WINAPI MsiDatabaseGetPrimaryKeysW( MSIHANDLE hdb,
     db = msihandle2msiinfo( hdb, MSIHANDLETYPE_DATABASE );
     if( !db )
     {
+        MSIHANDLE remote;
         HRESULT hr;
-        IWineMsiRemoteDatabase *remote_database;
 
-        remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( hdb );
-        if ( !remote_database )
+        if (!(remote = msi_get_remote(hdb)))
             return ERROR_INVALID_HANDLE;
 
-        hr = IWineMsiRemoteDatabase_GetPrimaryKeys( remote_database, table, phRec );
-        IWineMsiRemoteDatabase_Release( remote_database );
+        hr = remote_DatabaseGetPrimaryKeys(remote, table, phRec);
 
         if (FAILED(hr))
         {
@@ -1033,15 +1025,12 @@ MSICONDITION WINAPI MsiDatabaseIsTablePersistentW(
     {
         HRESULT hr;
         MSICONDITION condition;
-        IWineMsiRemoteDatabase *remote_database;
+        MSIHANDLE remote;
 
-        remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( hDatabase );
-        if ( !remote_database )
+        if (!(remote = msi_get_remote(hDatabase)))
             return MSICONDITION_ERROR;
 
-        hr = IWineMsiRemoteDatabase_IsTablePersistent( remote_database,
-                                                       szTableName, &condition );
-        IWineMsiRemoteDatabase_Release( remote_database );
+        hr = remote_DatabaseIsTablePersistent(remote, szTableName, &condition);
 
         if (FAILED(hr))
             return MSICONDITION_ERROR;
diff --git a/dlls/msi/msiserver.idl b/dlls/msi/msiserver.idl
index 704f6ea..4eb33fe 100644
--- a/dlls/msi/msiserver.idl
+++ b/dlls/msi/msiserver.idl
@@ -27,70 +27,6 @@ import "wtypes.idl";
 import "objidl.idl";
 import "oaidl.idl";
 
-cpp_quote("#if 0")
-typedef unsigned long MSIHANDLE;
-typedef int INSTALLMESSAGE;
-typedef int MSICONDITION;
-typedef int MSIRUNMODE;
-typedef int INSTALLSTATE;
-cpp_quote("#endif")
-
-[
-    uuid(7BDE2046-D03B-4ffc-B84C-A098F38CFF0B),
-    oleautomation,
-    object
-]
-interface IWineMsiRemoteDatabase : IUnknown
-{
-    HRESULT IsTablePersistent( [in] LPCWSTR table, [out] MSICONDITION *persistent );
-    HRESULT GetPrimaryKeys( [in] LPCWSTR table, [out] MSIHANDLE *keys );
-    HRESULT GetSummaryInformation( [in] UINT updatecount, [out] MSIHANDLE *suminfo );
-    HRESULT OpenView( [in] LPCWSTR query, [out] MSIHANDLE *view );
-    HRESULT SetMsiHandle( [in] MSIHANDLE handle );
-}
-
-[
-    uuid(902B3592-9D08-4dfd-A593-D07C52546421),
-    oleautomation,
-    object
-]
-interface IWineMsiRemotePackage : IUnknown
-{
-    HRESULT GetActiveDatabase( [out] MSIHANDLE *handle );
-    HRESULT GetProperty( [in] BSTR property, [out, size_is(*size)] BSTR value, [in, out] DWORD *size );
-    HRESULT SetProperty( [in] BSTR property, [in] BSTR value );
-    HRESULT ProcessMessage( [in] INSTALLMESSAGE message, [in] MSIHANDLE record );
-    HRESULT DoAction( [in] BSTR action );
-    HRESULT Sequence( [in] BSTR table, [in] int sequence );
-    HRESULT GetTargetPath( [in] BSTR folder, [out, size_is(*size)] BSTR value, [in, out] DWORD *size );
-    HRESULT SetTargetPath( [in] BSTR folder, [in] BSTR value );
-    HRESULT GetSourcePath( [in] BSTR folder, [out, size_is(*size)] BSTR value, [in, out] DWORD *size );
-    HRESULT GetMode( [in] MSIRUNMODE mode, [out] BOOL *ret );
-    HRESULT SetMode( [in] MSIRUNMODE mode, [in] BOOL state );
-    HRESULT GetFeatureState( [in] BSTR feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
-    HRESULT SetFeatureState( [in] BSTR feature, [in] INSTALLSTATE state );
-    HRESULT GetComponentState( [in] BSTR component, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
-    HRESULT SetComponentState( [in] BSTR component, [in] INSTALLSTATE state );
-    HRESULT GetLanguage( [out] LANGID *language );
-    HRESULT SetInstallLevel( [in] int level );
-    HRESULT FormatRecord( [in] MSIHANDLE record, [out] BSTR *value );
-    HRESULT EvaluateCondition( [in] BSTR condition );
-    HRESULT GetFeatureCost( [in] BSTR feature, [in] INT cost_tree, [in] INSTALLSTATE state, [out] INT *cost );
-    HRESULT EnumComponentCosts( [in] BSTR component, [in] DWORD index, [in] INSTALLSTATE state,
-                                [out, size_is(*buflen)] BSTR drive, [in, out] DWORD *buflen, [out] INT *cost, [out] INT *temp );
-}
-
-[
-    uuid(56D58B64-8780-4c22-A8BC-8B0B29E4A9F8),
-    oleautomation,
-    object
-]
-interface IWineMsiRemoteCustomAction : IUnknown
-{
-    HRESULT GetActionInfo( [in] LPCGUID guid, [out] INT *type, [out] BSTR *dllname,
-                           [out] BSTR *function, [out] IWineMsiRemotePackage **package );
-}
-
 [
     uuid(000c101c-0000-0000-c000-000000000046),
     oleautomation,
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index 2d11ea8..4e1ac2f 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -45,7 +45,7 @@
 #include "sddl.h"
 
 #include "msipriv.h"
-#include "msiserver.h"
+#include "winemsi.h"
 #include "resource.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msi);
@@ -1466,13 +1466,11 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
         db = msihandle2msiinfo( handle, MSIHANDLETYPE_DATABASE );
         if( !db )
         {
-            IWineMsiRemoteDatabase *remote_database;
+            MSIHANDLE remote;
 
-            remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( handle );
-            if ( !remote_database )
+            if (!(remote = msi_get_remote(handle)))
                 return ERROR_INVALID_HANDLE;
 
-            IWineMsiRemoteDatabase_Release( remote_database );
             WARN("MsiOpenPackage not allowed during a custom action!\n");
 
             return ERROR_FUNCTION_FAILED;
@@ -1693,8 +1691,7 @@ MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall)
 {
     MSIPACKAGE *package;
     MSIHANDLE handle = 0;
-    IUnknown *remote_unk;
-    IWineMsiRemotePackage *remote_package;
+    MSIHANDLE remote;
 
     TRACE("(%d)\n",hInstall);
 
@@ -1704,19 +1701,9 @@ MSIHANDLE WINAPI MsiGetActiveDatabase(MSIHANDLE hInstall)
         handle = alloc_msihandle( &package->db->hdr );
         msiobj_release( &package->hdr );
     }
-    else if ((remote_unk = msi_get_remote(hInstall)))
+    else if ((remote = msi_get_remote(hInstall)))
     {
-        if (IUnknown_QueryInterface(remote_unk, &IID_IWineMsiRemotePackage,
-                                        (LPVOID *)&remote_package) == S_OK)
-        {
-            IWineMsiRemotePackage_GetActiveDatabase(remote_package, &handle);
-            IWineMsiRemotePackage_Release(remote_package);
-        }
-        else
-        {
-            WARN("remote handle %d is not a package\n", hInstall);
-        }
-        IUnknown_Release(remote_unk);
+        remote_GetActiveDatabase(remote, &handle);
     }
 
     return handle;
@@ -2067,16 +2054,13 @@ INT WINAPI MsiProcessMessage( MSIHANDLE hInstall, INSTALLMESSAGE eMessageType,
     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE );
     if( !package )
     {
+        MSIHANDLE remote;
         HRESULT hr;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
-        hr = IWineMsiRemotePackage_ProcessMessage( remote_package, eMessageType, hRecord );
-
-        IWineMsiRemotePackage_Release( remote_package );
+        hr = remote_ProcessMessage(remote, eMessageType, hRecord);
 
         if (FAILED(hr))
         {
@@ -2216,12 +2200,11 @@ UINT WINAPI MsiSetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, LPCWSTR szValue
     package = msihandle2msiinfo( hInstall, MSIHANDLETYPE_PACKAGE);
     if( !package )
     {
+        MSIHANDLE remote;
         HRESULT hr;
         BSTR name = NULL, value = NULL;
-        IWineMsiRemotePackage *remote_package;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
-        if (!remote_package)
+        if (!(remote = msi_get_remote(hInstall)))
             return ERROR_INVALID_HANDLE;
 
         name = SysAllocString( szName );
@@ -2230,15 +2213,13 @@ UINT WINAPI MsiSetPropertyW( MSIHANDLE hInstall, LPCWSTR szName, LPCWSTR szValue
         {
             SysFreeString( name );
             SysFreeString( value );
-            IWineMsiRemotePackage_Release( remote_package );
             return ERROR_OUTOFMEMORY;
         }
 
-        hr = IWineMsiRemotePackage_SetProperty( remote_package, name, value );
+        hr = remote_SetProperty(remote, name, value);
 
         SysFreeString( name );
         SysFreeString( value );
-        IWineMsiRemotePackage_Release( remote_package );
 
         if (FAILED(hr))
         {
@@ -2416,22 +2397,18 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
     if (!package)
     {
         HRESULT hr;
-        IWineMsiRemotePackage *remote_package;
         LPWSTR value = NULL;
+        MSIHANDLE remote;
         BSTR bname;
 
-        remote_package = (IWineMsiRemotePackage *)msi_get_remote( handle );
-        if (!remote_package)
+        if (!(remote = msi_get_remote(handle)))
             return ERROR_INVALID_HANDLE;
 
         bname = SysAllocString( name );
         if (!bname)
-        {
-            IWineMsiRemotePackage_Release( remote_package );
             return ERROR_OUTOFMEMORY;
-        }
 
-        hr = IWineMsiRemotePackage_GetProperty( remote_package, bname, NULL, &len );
+        hr = remote_GetProperty(remote, bname, NULL, &len);
         if (FAILED(hr))
             goto done;
 
@@ -2443,7 +2420,7 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
             goto done;
         }
 
-        hr = IWineMsiRemotePackage_GetProperty( remote_package, bname, value, &len );
+        hr = remote_GetProperty(remote, bname, value, &len);
         if (FAILED(hr))
             goto done;
 
@@ -2454,7 +2431,6 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
             *pchValueBuf *= sizeof(WCHAR);
 
 done:
-        IWineMsiRemotePackage_Release(remote_package);
         SysFreeString(bname);
         msi_free(value);
 
@@ -2515,280 +2491,149 @@ UINT WINAPI MsiGetPropertyW( MSIHANDLE hInstall, LPCWSTR szName,
     return MSI_GetProperty( hInstall, szName, &val, pchValueBuf );
 }
 
-typedef struct _msi_remote_package_impl {
-    IWineMsiRemotePackage IWineMsiRemotePackage_iface;
-    MSIHANDLE package;
-    LONG refs;
-} msi_remote_package_impl;
-
-static inline msi_remote_package_impl *impl_from_IWineMsiRemotePackage( IWineMsiRemotePackage *iface )
+HRESULT __cdecl remote_GetActiveDatabase(MSIHANDLE hinst, MSIHANDLE *handle)
 {
-    return CONTAINING_RECORD(iface, msi_remote_package_impl, IWineMsiRemotePackage_iface);
-}
+    *handle = MsiGetActiveDatabase(hinst);
 
-static HRESULT WINAPI mrp_QueryInterface( IWineMsiRemotePackage *iface,
-                REFIID riid,LPVOID *ppobj)
-{
-    if( IsEqualCLSID( riid, &IID_IUnknown ) ||
-        IsEqualCLSID( riid, &IID_IWineMsiRemotePackage ) )
-    {
-        IWineMsiRemotePackage_AddRef( iface );
-        *ppobj = iface;
-        return S_OK;
-    }
-
-    return E_NOINTERFACE;
-}
-
-static ULONG WINAPI mrp_AddRef( IWineMsiRemotePackage *iface )
-{
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-
-    return InterlockedIncrement( &This->refs );
-}
-
-static ULONG WINAPI mrp_Release( IWineMsiRemotePackage *iface )
-{
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    ULONG r;
-
-    r = InterlockedDecrement( &This->refs );
-    if (r == 0)
-    {
-        MsiCloseHandle( This->package );
-        msi_free( This );
-    }
-    return r;
-}
-
-static HRESULT WINAPI mrp_GetActiveDatabase( IWineMsiRemotePackage *iface, MSIHANDLE *handle )
-{
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    IWineMsiRemoteDatabase *rdb = NULL;
-    HRESULT hr;
-    MSIHANDLE hdb;
-
-    hr = create_msi_remote_database( NULL, (LPVOID *)&rdb );
-    if (FAILED(hr) || !rdb)
-    {
-        ERR("Failed to create remote database\n");
-        return hr;
-    }
-
-    hdb = MsiGetActiveDatabase(This->package);
-
-    hr = IWineMsiRemoteDatabase_SetMsiHandle( rdb, hdb );
-    if (FAILED(hr))
-    {
-        ERR("Failed to set the database handle\n");
-        return hr;
-    }
-
-    *handle = alloc_msi_remote_handle( (IUnknown *)rdb );
     return S_OK;
 }
 
-static HRESULT WINAPI mrp_GetProperty( IWineMsiRemotePackage *iface, BSTR property, BSTR value, DWORD *size )
+HRESULT __cdecl remote_GetProperty(MSIHANDLE hinst, BSTR property, BSTR value, DWORD *size)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiGetPropertyW(This->package, property, value, size);
+    UINT r = MsiGetPropertyW(hinst, property, value, size);
     if (r != ERROR_SUCCESS) return HRESULT_FROM_WIN32(r);
     return S_OK;
 }
 
-static HRESULT WINAPI mrp_SetProperty( IWineMsiRemotePackage *iface, BSTR property, BSTR value )
+HRESULT __cdecl remote_SetProperty(MSIHANDLE hinst, BSTR property, BSTR value)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiSetPropertyW(This->package, property, value);
+    UINT r = MsiSetPropertyW(hinst, property, value);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_ProcessMessage( IWineMsiRemotePackage *iface, INSTALLMESSAGE message, MSIHANDLE record )
+HRESULT __cdecl remote_ProcessMessage(MSIHANDLE hinst, INSTALLMESSAGE message, MSIHANDLE record)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiProcessMessage(This->package, message, record);
+    UINT r = MsiProcessMessage(hinst, message, record);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_DoAction( IWineMsiRemotePackage *iface, BSTR action )
+HRESULT __cdecl remote_DoAction(MSIHANDLE hinst, BSTR action)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiDoActionW(This->package, action);
+    UINT r = MsiDoActionW(hinst, action);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_Sequence( IWineMsiRemotePackage *iface, BSTR table, int sequence )
+HRESULT __cdecl remote_Sequence(MSIHANDLE hinst, BSTR table, int sequence)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiSequenceW(This->package, table, sequence);
+    UINT r = MsiSequenceW(hinst, table, sequence);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_GetTargetPath( IWineMsiRemotePackage *iface, BSTR folder, BSTR value, DWORD *size )
+HRESULT __cdecl remote_GetTargetPath(MSIHANDLE hinst, BSTR folder, BSTR value, DWORD *size)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiGetTargetPathW(This->package, folder, value, size);
+    UINT r = MsiGetTargetPathW(hinst, folder, value, size);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_SetTargetPath( IWineMsiRemotePackage *iface, BSTR folder, BSTR value)
+HRESULT __cdecl remote_SetTargetPath(MSIHANDLE hinst, BSTR folder, BSTR value)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiSetTargetPathW(This->package, folder, value);
+    UINT r = MsiSetTargetPathW(hinst, folder, value);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_GetSourcePath( IWineMsiRemotePackage *iface, BSTR folder, BSTR value, DWORD *size )
+HRESULT __cdecl remote_GetSourcePath(MSIHANDLE hinst, BSTR folder, BSTR value, DWORD *size)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiGetSourcePathW(This->package, folder, value, size);
+    UINT r = MsiGetSourcePathW(hinst, folder, value, size);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_GetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL *ret )
+HRESULT __cdecl remote_GetMode(MSIHANDLE hinst, MSIRUNMODE mode, BOOL *ret)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    *ret = MsiGetMode(This->package, mode);
+    *ret = MsiGetMode(hinst, mode);
     return S_OK;
 }
 
-static HRESULT WINAPI mrp_SetMode( IWineMsiRemotePackage *iface, MSIRUNMODE mode, BOOL state )
+HRESULT __cdecl remote_SetMode(MSIHANDLE hinst, MSIRUNMODE mode, BOOL state)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiSetMode(This->package, mode, state);
+    UINT r = MsiSetMode(hinst, mode, state);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_GetFeatureState( IWineMsiRemotePackage *iface, BSTR feature,
-                                    INSTALLSTATE *installed, INSTALLSTATE *action )
+HRESULT __cdecl remote_GetFeatureState(MSIHANDLE hinst, BSTR feature,
+                                    INSTALLSTATE *installed, INSTALLSTATE *action)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiGetFeatureStateW(This->package, feature, installed, action);
+    UINT r = MsiGetFeatureStateW(hinst, feature, installed, action);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_SetFeatureState( IWineMsiRemotePackage *iface, BSTR feature, INSTALLSTATE state )
+HRESULT __cdecl remote_SetFeatureState(MSIHANDLE hinst, BSTR feature, INSTALLSTATE state)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiSetFeatureStateW(This->package, feature, state);
+    UINT r = MsiSetFeatureStateW(hinst, feature, state);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_GetComponentState( IWineMsiRemotePackage *iface, BSTR component,
-                                      INSTALLSTATE *installed, INSTALLSTATE *action )
+HRESULT __cdecl remote_GetComponentState(MSIHANDLE hinst, BSTR component,
+                                      INSTALLSTATE *installed, INSTALLSTATE *action)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiGetComponentStateW(This->package, component, installed, action);
+    UINT r = MsiGetComponentStateW(hinst, component, installed, action);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_SetComponentState( IWineMsiRemotePackage *iface, BSTR component, INSTALLSTATE state )
+HRESULT __cdecl remote_SetComponentState(MSIHANDLE hinst, BSTR component, INSTALLSTATE state)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiSetComponentStateW(This->package, component, state);
+    UINT r = MsiSetComponentStateW(hinst, component, state);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_GetLanguage( IWineMsiRemotePackage *iface, LANGID *language )
+HRESULT __cdecl remote_GetLanguage(MSIHANDLE hinst, LANGID *language)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    *language = MsiGetLanguage(This->package);
+    *language = MsiGetLanguage(hinst);
     return S_OK;
 }
 
-static HRESULT WINAPI mrp_SetInstallLevel( IWineMsiRemotePackage *iface, int level )
+HRESULT __cdecl remote_SetInstallLevel(MSIHANDLE hinst, int level)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiSetInstallLevel(This->package, level);
+    UINT r = MsiSetInstallLevel(hinst, level);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_FormatRecord( IWineMsiRemotePackage *iface, MSIHANDLE record,
+HRESULT __cdecl remote_FormatRecord(MSIHANDLE hinst, MSIHANDLE record,
                                         BSTR *value)
 {
     DWORD size = 0;
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiFormatRecordW(This->package, record, NULL, &size);
+    UINT r = MsiFormatRecordW(hinst, record, NULL, &size);
     if (r == ERROR_SUCCESS)
     {
         *value = SysAllocStringLen(NULL, size);
         if (!*value)
             return E_OUTOFMEMORY;
         size++;
-        r = MsiFormatRecordW(This->package, record, *value, &size);
+        r = MsiFormatRecordW(hinst, record, *value, &size);
     }
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_EvaluateCondition( IWineMsiRemotePackage *iface, BSTR condition )
+HRESULT __cdecl remote_EvaluateCondition(MSIHANDLE hinst, BSTR condition)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiEvaluateConditionW(This->package, condition);
+    UINT r = MsiEvaluateConditionW(hinst, condition);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_GetFeatureCost( IWineMsiRemotePackage *iface, BSTR feature,
-                                          INT cost_tree, INSTALLSTATE state, INT *cost )
+HRESULT __cdecl remote_GetFeatureCost(MSIHANDLE hinst, BSTR feature,
+                                          INT cost_tree, INSTALLSTATE state, INT *cost)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiGetFeatureCostW(This->package, feature, cost_tree, state, cost);
+    UINT r = MsiGetFeatureCostW(hinst, feature, cost_tree, state, cost);
     return HRESULT_FROM_WIN32(r);
 }
 
-static HRESULT WINAPI mrp_EnumComponentCosts( IWineMsiRemotePackage *iface, BSTR component,
+HRESULT __cdecl remote_EnumComponentCosts(MSIHANDLE hinst, BSTR component,
                                               DWORD index, INSTALLSTATE state, BSTR drive,
-                                              DWORD *buflen, INT *cost, INT *temp )
+                                              DWORD *buflen, INT *cost, INT *temp)
 {
-    msi_remote_package_impl* This = impl_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiEnumComponentCostsW(This->package, component, index, state, drive, buflen, cost, temp);
+    UINT r = MsiEnumComponentCostsW(hinst, component, index, state, drive, buflen, cost, temp);
     return HRESULT_FROM_WIN32(r);
 }
 
-static const IWineMsiRemotePackageVtbl msi_remote_package_vtbl =
-{
-    mrp_QueryInterface,
-    mrp_AddRef,
-    mrp_Release,
-    mrp_GetActiveDatabase,
-    mrp_GetProperty,
-    mrp_SetProperty,
-    mrp_ProcessMessage,
-    mrp_DoAction,
-    mrp_Sequence,
-    mrp_GetTargetPath,
-    mrp_SetTargetPath,
-    mrp_GetSourcePath,
-    mrp_GetMode,
-    mrp_SetMode,
-    mrp_GetFeatureState,
-    mrp_SetFeatureState,
-    mrp_GetComponentState,
-    mrp_SetComponentState,
-    mrp_GetLanguage,
-    mrp_SetInstallLevel,
-    mrp_FormatRecord,
-    mrp_EvaluateCondition,
-    mrp_GetFeatureCost,
-    mrp_EnumComponentCosts
-};
-
-HRESULT create_msi_remote_package( MSIHANDLE handle, IWineMsiRemotePackage **ppObj )
-{
-    msi_remote_package_impl* This;
-
-    This = msi_alloc( sizeof *This );
-    if (!This)
-        return E_OUTOFMEMORY;
-
-    This->IWineMsiRemotePackage_iface.lpVtbl = &msi_remote_package_vtbl;
-    This->package = handle;
-    This->refs = 1;
-
-    *ppObj = &This->IWineMsiRemotePackage_iface;
-
-    return S_OK;
-}
-
 UINT msi_package_add_info(MSIPACKAGE *package, DWORD context, DWORD options,
                           LPCWSTR property, LPWSTR value)
 {
diff --git a/dlls/msi/suminfo.c b/dlls/msi/suminfo.c
index 451fd16b..782ad6e 100644
--- a/dlls/msi/suminfo.c
+++ b/dlls/msi/suminfo.c
@@ -33,10 +33,11 @@
 #include "msi.h"
 #include "msiquery.h"
 #include "msidefs.h"
-#include "msipriv.h"
 #include "objidl.h"
 #include "propvarutil.h"
-#include "msiserver.h"
+
+#include "msipriv.h"
+#include "winemsi.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(msi);
 
@@ -522,16 +523,13 @@ UINT WINAPI MsiGetSummaryInformationW( MSIHANDLE hDatabase,
         db = msihandle2msiinfo( hDatabase, MSIHANDLETYPE_DATABASE );
         if( !db )
         {
+            MSIHANDLE remote;
             HRESULT hr;
-            IWineMsiRemoteDatabase *remote_database;
 
-            remote_database = (IWineMsiRemoteDatabase *)msi_get_remote( hDatabase );
-            if ( !remote_database )
+            if (!(remote = msi_get_remote(hDatabase)))
                 return ERROR_INVALID_HANDLE;
 
-            hr = IWineMsiRemoteDatabase_GetSummaryInformation( remote_database,
-                                                               uiUpdateCount, pHandle );
-            IWineMsiRemoteDatabase_Release( remote_database );
+            hr = remote_DatabaseGetSummaryInformation(remote, uiUpdateCount, pHandle);
 
             if (FAILED(hr))
             {
diff --git a/dlls/msi/winemsi.idl b/dlls/msi/winemsi.idl
new file mode 100644
index 0000000..706eb99
--- /dev/null
+++ b/dlls/msi/winemsi.idl
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2007 James Hawkins
+ * Copyright (C) 2018 Zebediah Figura
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+import "objidl.idl";
+
+cpp_quote("#if 0")
+typedef unsigned long MSIHANDLE;
+typedef int INSTALLMESSAGE;
+typedef int MSICONDITION;
+typedef int MSIRUNMODE;
+typedef int INSTALLSTATE;
+
+cpp_quote("#endif")
+cpp_quote("#include \"msiquery.h\"")
+
+[
+    uuid(56D58B64-8780-4c22-A8BC-8B0B29E4A9F8)
+]
+interface IWineMsiRemote
+{
+    HRESULT remote_DatabaseIsTablePersistent( [in] MSIHANDLE db, [in] LPCWSTR table, [out] MSICONDITION *persistent );
+    HRESULT remote_DatabaseGetPrimaryKeys( [in] MSIHANDLE db, [in] LPCWSTR table, [out] MSIHANDLE *keys );
+    HRESULT remote_DatabaseGetSummaryInformation( [in] MSIHANDLE db, [in] UINT updatecount, [out] MSIHANDLE *suminfo );
+    HRESULT remote_DatabaseOpenView( [in] MSIHANDLE db, [in] LPCWSTR query, [out] MSIHANDLE *view );
+
+    HRESULT remote_GetActiveDatabase( [in] MSIHANDLE hinst, [out] MSIHANDLE *handle );
+    HRESULT remote_GetProperty( [in] MSIHANDLE hinst, [in] BSTR property, [out, size_is(*size)] BSTR value, [in, out] DWORD *size );
+    HRESULT remote_SetProperty( [in] MSIHANDLE hinst, [in] BSTR property, [in] BSTR value );
+    HRESULT remote_ProcessMessage( [in] MSIHANDLE hinst, [in] INSTALLMESSAGE message, [in] MSIHANDLE record );
+    HRESULT remote_DoAction( [in] MSIHANDLE hinst, [in] BSTR action );
+    HRESULT remote_Sequence( [in] MSIHANDLE hinst, [in] BSTR table, [in] int sequence );
+    HRESULT remote_GetTargetPath( [in] MSIHANDLE hinst, [in] BSTR folder, [out, size_is(*size)] BSTR value, [in, out] DWORD *size );
+    HRESULT remote_SetTargetPath( [in] MSIHANDLE hinst, [in] BSTR folder, [in] BSTR value );
+    HRESULT remote_GetSourcePath( [in] MSIHANDLE hinst, [in] BSTR folder, [out, size_is(*size)] BSTR value, [in, out] DWORD *size );
+    HRESULT remote_GetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [out] BOOL *ret );
+    HRESULT remote_SetMode( [in] MSIHANDLE hinst, [in] MSIRUNMODE mode, [in] BOOL state );
+    HRESULT remote_GetFeatureState( [in] MSIHANDLE hinst, [in] BSTR feature, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
+    HRESULT remote_SetFeatureState( [in] MSIHANDLE hinst, [in] BSTR feature, [in] INSTALLSTATE state );
+    HRESULT remote_GetComponentState( [in] MSIHANDLE hinst, [in] BSTR component, [out] INSTALLSTATE *installed, [out] INSTALLSTATE *action );
+    HRESULT remote_SetComponentState( [in] MSIHANDLE hinst, [in] BSTR component, [in] INSTALLSTATE state );
+    HRESULT remote_GetLanguage( [in] MSIHANDLE hinst, [out] LANGID *language );
+    HRESULT remote_SetInstallLevel( [in] MSIHANDLE hinst, [in] int level );
+    HRESULT remote_FormatRecord( [in] MSIHANDLE hinst, [in] MSIHANDLE record, [out] BSTR *value );
+    HRESULT remote_EvaluateCondition( [in] MSIHANDLE hinst, [in] BSTR condition );
+    HRESULT remote_GetFeatureCost( [in] MSIHANDLE hinst, [in] BSTR feature, [in] INT cost_tree, [in] INSTALLSTATE state, [out] INT *cost );
+    HRESULT remote_EnumComponentCosts( [in] MSIHANDLE hinst, [in] BSTR component, [in] DWORD index, [in] INSTALLSTATE state,
+                                       [out, size_is(*buflen)] BSTR drive, [in, out] DWORD *buflen, [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_CloseHandle( [in] MSIHANDLE handle );
+}
-- 
2.7.4




More information about the wine-devel mailing list