Hi,

Currently, the [out] value parameter for IWineMsiRemotePackage::FormatRecord doesn't have a level of indirection associated with it and so I would be very surprised if the typelib marshaller actually does the right thing in this case. Compiling with MIDL and with a future update to widl causes an error for this parameter. I'm proposing the attached patch to fix things, but I'm not able to test that this works correctly.

Thanks,

--
Rob Shearman

>From 6e1a75e76dbf402b05b9475eaf74b7b1341919ea Mon Sep 17 00:00:00 2001
From: Robert Shearman <[EMAIL PROTECTED]>
Date: Tue, 15 Apr 2008 11:33:43 +0100
Subject: msi: Fix the value parameter of IWineMsiRemotePackage::FormatRecord to have the right level of indirection for an [out] parameter.
To: wine-patches <[EMAIL PROTECTED]>

Remove the redundant size parameter and simplify the client code such that the remote function is only called once, with the value being automatically allocated. Add corresponding code on the server side to automatically allocate said value.
---
 dlls/msi/format.c      |   17 +----------------
 dlls/msi/msiserver.idl |    2 +-
 dlls/msi/package.c     |   13 +++++++++++--
 3 files changed, 13 insertions(+), 19 deletions(-)

diff --git a/dlls/msi/format.c b/dlls/msi/format.c
index f58f517..454142a 100644
--- a/dlls/msi/format.c
+++ b/dlls/msi/format.c
@@ -921,28 +921,13 @@ UINT WINAPI MsiFormatRecordW( MSIHANDLE hInstall, MSIHANDLE hRecord,
         HRESULT hr;
         IWineMsiRemotePackage *remote_package;
         BSTR value = NULL;
-        DWORD len;
         awstring wstr;
 
         remote_package = (IWineMsiRemotePackage *)msi_get_remote( hInstall );
         if (remote_package)
         {
-            len = 0;
             hr = IWineMsiRemotePackage_FormatRecord( remote_package, hRecord,
-                                                     NULL, &len );
-            if (FAILED(hr))
-                goto done;
-
-            len++;
-            value = SysAllocStringLen( NULL, len );
-            if (!value)
-            {
-                r = ERROR_OUTOFMEMORY;
-                goto done;
-            }
-
-            hr = IWineMsiRemotePackage_FormatRecord( remote_package, hRecord,
-                                                     value, &len );
+                                                     &value );
             if (FAILED(hr))
                 goto done;
 
diff --git a/dlls/msi/msiserver.idl b/dlls/msi/msiserver.idl
index d5b47ac..37aa91e 100644
--- a/dlls/msi/msiserver.idl
+++ b/dlls/msi/msiserver.idl
@@ -70,7 +70,7 @@ interface IWineMsiRemotePackage : IUnknown
     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, [out] DWORD *size );
+    HRESULT FormatRecord( [in] MSIHANDLE record, [out] BSTR *value );
     HRESULT EvaluateCondition( [in] BSTR condition );
 }
 
diff --git a/dlls/msi/package.c b/dlls/msi/package.c
index a587a63..f11b068 100644
--- a/dlls/msi/package.c
+++ b/dlls/msi/package.c
@@ -1812,10 +1812,19 @@ static HRESULT WINAPI mrp_SetInstallLevel( IWineMsiRemotePackage *iface, int lev
 }
 
 static HRESULT WINAPI mrp_FormatRecord( IWineMsiRemotePackage *iface, MSIHANDLE record,
-                                 BSTR value, DWORD *size )
+                                        BSTR *value)
 {
+    DWORD size = 0;
     msi_remote_package_impl* This = mrp_from_IWineMsiRemotePackage( iface );
-    UINT r = MsiFormatRecordW(This->package, record, (LPWSTR)value, size);
+    UINT r = MsiFormatRecordW(This->package, record, NULL, &size);
+    if (r == ERROR_SUCCESS)
+    {
+        *value = SysAllocStringLen(NULL, size);
+        if (!*value)
+            return E_OUTOFMEMORY;
+        size++;
+        r = MsiFormatRecordW(This->package, record, *value, &size);
+    }
     return HRESULT_FROM_WIN32(r);
 }
 
-- 
1.5.3.8



Reply via email to