https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d5e04177e7301aeb51e34…
commit d5e04177e7301aeb51e34694be93b3fa75824951
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 15:12:15 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:27:45 2022 +0100
[WINESYNC] msi: Handle the remote case directly in MsiFormatRecordA().
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 75aa132b521f426fa670c05774a50c87247e9834 by Zebediah Figura
<z.figura12(a)gmail.com>
---
dll/win32/msi/format.c | 59 +++++++++++++++++----------------
dll/win32/msi/install.c | 23 +++++++++++++
dll/win32/msi/msipriv.h | 1 +
modules/rostests/winetests/msi/custom.c | 8 ++---
4 files changed, 59 insertions(+), 32 deletions(-)
diff --git a/dll/win32/msi/format.c b/dll/win32/msi/format.c
index 6f187581516..98ee320ce59 100644
--- a/dll/win32/msi/format.c
+++ b/dll/win32/msi/format.c
@@ -952,52 +952,55 @@ UINT WINAPI MsiFormatRecordW( MSIHANDLE hInstall, MSIHANDLE
hRecord,
return r;
}
-UINT WINAPI MsiFormatRecordA( MSIHANDLE hInstall, MSIHANDLE hRecord,
- LPSTR szResult, LPDWORD sz )
+UINT WINAPI MsiFormatRecordA(MSIHANDLE hinst, MSIHANDLE hrec, char *buf, DWORD *sz)
{
- UINT r;
- DWORD len, save;
+ MSIPACKAGE *package;
+ MSIRECORD *rec;
LPWSTR value;
+ DWORD len;
+ UINT r;
- TRACE("%d %d %p %p\n", hInstall, hRecord, szResult, sz);
+ TRACE("%d %d %p %p\n", hinst, hrec, buf, sz);
- if (!hRecord)
+ rec = msihandle2msiinfo(hrec, MSIHANDLETYPE_RECORD);
+ if (!rec)
return ERROR_INVALID_HANDLE;
- if (!sz)
+ package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE);
+ if (!package)
{
- if (szResult)
- return ERROR_INVALID_PARAMETER;
- else
- return ERROR_SUCCESS;
+ LPWSTR value = NULL;
+ MSIHANDLE remote;
+
+ if ((remote = msi_get_remote(hinst)))
+ {
+ r = remote_FormatRecord(remote, (struct wire_record *)&rec->count,
&value);
+
+ if (!r)
+ r = msi_strncpyWtoA(value, -1, buf, sz, TRUE);
+
+ midl_user_free(value);
+ msiobj_release(&rec->hdr);
+ return r;
+ }
}
- r = MsiFormatRecordW( hInstall, hRecord, NULL, &len );
+ r = MSI_FormatRecordW(package, rec, NULL, &len);
if (r != ERROR_SUCCESS)
return r;
value = msi_alloc(++len * sizeof(WCHAR));
if (!value)
- return ERROR_OUTOFMEMORY;
-
- r = MsiFormatRecordW( hInstall, hRecord, value, &len );
- if (r != ERROR_SUCCESS)
goto done;
- save = len + 1;
- len = WideCharToMultiByte(CP_ACP, 0, value, len + 1, NULL, 0, NULL, NULL);
- WideCharToMultiByte(CP_ACP, 0, value, len, szResult, *sz, NULL, NULL);
-
- if (szResult && len > *sz)
- {
- if (*sz) szResult[*sz - 1] = '\0';
- r = ERROR_MORE_DATA;
- }
+ r = MSI_FormatRecordW(package, rec, value, &len);
+ if (!r)
+ r = msi_strncpyWtoA(value, len, buf, sz, FALSE);
- *sz = save - 1;
-
-done:
msi_free(value);
+done:
+ msiobj_release(&rec->hdr);
+ if (package) msiobj_release(&package->hdr);
return r;
}
diff --git a/dll/win32/msi/install.c b/dll/win32/msi/install.c
index 382f20b7aa0..9ade59804d7 100644
--- a/dll/win32/msi/install.c
+++ b/dll/win32/msi/install.c
@@ -168,6 +168,29 @@ UINT msi_strcpy_to_awstring( const WCHAR *str, int len, awstring
*awbuf, DWORD *
return r;
}
+UINT msi_strncpyWtoA(const WCHAR *str, int lenW, char *buf, DWORD *sz, BOOL remote)
+{
+ UINT r = ERROR_SUCCESS;
+ DWORD lenA;
+
+ if (!sz)
+ return buf ? ERROR_INVALID_PARAMETER : ERROR_SUCCESS;
+
+ if (lenW < 0) lenW = strlenW(str);
+ lenA = WideCharToMultiByte(CP_ACP, 0, str, lenW + 1, NULL, 0, NULL, NULL);
+ WideCharToMultiByte(CP_ACP, 0, str, lenW + 1, buf, *sz, NULL, NULL);
+ lenA--;
+ if (buf && lenA >= *sz)
+ {
+ if (*sz) buf[*sz - 1] = 0;
+ r = ERROR_MORE_DATA;
+ }
+ if (remote && lenA >= *sz)
+ lenA *= 2;
+ *sz = lenA;
+ return r;
+}
+
const WCHAR *msi_get_target_folder( MSIPACKAGE *package, const WCHAR *name )
{
MSIFOLDER *folder = msi_get_loaded_folder( package, name );
diff --git a/dll/win32/msi/msipriv.h b/dll/win32/msi/msipriv.h
index ca4c5cfc083..a8140bb8cdf 100644
--- a/dll/win32/msi/msipriv.h
+++ b/dll/win32/msi/msipriv.h
@@ -1046,6 +1046,7 @@ extern WCHAR *msi_font_version_from_file(const WCHAR *)
DECLSPEC_HIDDEN;
extern WCHAR **msi_split_string(const WCHAR *, WCHAR) DECLSPEC_HIDDEN;
extern UINT msi_set_original_database_property(MSIDATABASE *, const WCHAR *)
DECLSPEC_HIDDEN;
extern WCHAR *msi_get_error_message(MSIDATABASE *, int) DECLSPEC_HIDDEN;
+extern UINT msi_strncpyWtoA(const WCHAR *str, int len, char *buf, DWORD *sz, BOOL remote)
DECLSPEC_HIDDEN;
/* media */
diff --git a/modules/rostests/winetests/msi/custom.c
b/modules/rostests/winetests/msi/custom.c
index 04946d907d3..320aa6f30e5 100644
--- a/modules/rostests/winetests/msi/custom.c
+++ b/modules/rostests/winetests/msi/custom.c
@@ -785,28 +785,28 @@ static void test_format_record(MSIHANDLE hinst)
sz = 0;
r = MsiFormatRecordA(hinst, rec, NULL, &sz);
ok(hinst, !r, "got %u\n", r);
- todo_wine_ok(hinst, sz == 14, "got size %u\n", sz);
+ ok(hinst, sz == 14, "got size %u\n", sz);
sz = 0;
strcpy(buffer,"q");
r = MsiFormatRecordA(hinst, rec, buffer, &sz);
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
ok(hinst, !strcmp(buffer, "q"), "got \"%s\"\n",
buffer);
- todo_wine_ok(hinst, sz == 14, "got size %u\n", sz);
+ ok(hinst, sz == 14, "got size %u\n", sz);
sz = 1;
strcpy(buffer,"x");
r = MsiFormatRecordA(hinst, rec, buffer, &sz);
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
ok(hinst, !buffer[0], "got \"%s\"\n", buffer);
- todo_wine_ok(hinst, sz == 14, "got size %u\n", sz);
+ ok(hinst, sz == 14, "got size %u\n", sz);
sz = 7;
strcpy(buffer,"x");
r = MsiFormatRecordA(hinst, rec, buffer, &sz);
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
ok(hinst, !strcmp(buffer, "foo 12"), "got \"%s\"\n",
buffer);
- todo_wine_ok(hinst, sz == 14, "got size %u\n", sz);
+ ok(hinst, sz == 14, "got size %u\n", sz);
sz = 8;
strcpy(buffer,"x");