https://git.reactos.org/?p=reactos.git;a=commitdiff;h=4748b312842a54ea5fcec…
commit 4748b312842a54ea5fcec293d26aeaebe6a30b61
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sat Mar 12 15:12:16 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:27:45 2022 +0100
[WINESYNC] msi: Avoid using awstring in MsiGetPropertyA/W().
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 389ad808d2ac1a443d4a4190928e665b25214c1a by Zebediah Figura
<z.figura12(a)gmail.com>
---
dll/win32/msi/package.c | 109 +++++++++++++-------------------
modules/rostests/winetests/msi/custom.c | 6 ++
2 files changed, 51 insertions(+), 64 deletions(-)
diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c
index c112b6fae2c..c3bc9dcde62 100644
--- a/dll/win32/msi/package.c
+++ b/dll/win32/msi/package.c
@@ -2352,84 +2352,76 @@ int msi_get_property_int( MSIDATABASE *db, LPCWSTR prop, int def
)
return val;
}
-static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
- awstring *szValueBuf, LPDWORD pchValueBuf )
+UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD *sz)
{
+ const WCHAR *value = szEmpty;
MSIPACKAGE *package;
- MSIRECORD *row = NULL;
- UINT r = ERROR_FUNCTION_FAILED;
- LPCWSTR val = NULL;
- DWORD len = 0;
-
- TRACE("%u %s %p %p\n", handle, debugstr_w(name),
- szValueBuf->str.w, pchValueBuf );
+ MSIRECORD *row;
+ WCHAR *nameW;
+ int len = 0;
+ UINT r;
if (!name)
return ERROR_INVALID_PARAMETER;
- package = msihandle2msiinfo( handle, MSIHANDLETYPE_PACKAGE );
+ if (!(nameW = strdupAtoW(name)))
+ return ERROR_OUTOFMEMORY;
+
+ package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE);
if (!package)
{
- LPWSTR value = NULL, buffer;
+ WCHAR *value = NULL, *tmp;
MSIHANDLE remote;
+ DWORD len;
- if (!(remote = msi_get_remote(handle)))
+ if (!(remote = msi_get_remote(hinst)))
return ERROR_INVALID_HANDLE;
- r = remote_GetProperty(remote, name, &value, &len);
- if (r != ERROR_SUCCESS)
- return r;
-
- /* String might contain embedded nulls.
- * Native returns the correct size but truncates the string. */
- buffer = heap_alloc_zero((len + 1) * sizeof(WCHAR));
- if (!buffer)
+ r = remote_GetProperty(remote, nameW, &value, &len);
+ if (!r)
{
- midl_user_free(value);
- return ERROR_OUTOFMEMORY;
- }
- strcpyW(buffer, value);
-
- r = msi_strcpy_to_awstring(buffer, len, szValueBuf, pchValueBuf);
+ /* String might contain embedded nulls.
+ * Native returns the correct size but truncates the string. */
+ tmp = heap_alloc_zero((len + 1) * sizeof(WCHAR));
+ if (!tmp)
+ {
+ midl_user_free(value);
+ return ERROR_OUTOFMEMORY;
+ }
+ strcpyW(tmp, value);
- /* Bug required by Adobe installers */
- if (pchValueBuf && !szValueBuf->unicode &&
!szValueBuf->str.a)
- *pchValueBuf *= sizeof(WCHAR);
+ r = msi_strncpyWtoA(tmp, len, buf, sz, TRUE);
- heap_free(buffer);
+ heap_free(tmp);
+ }
midl_user_free(value);
+ heap_free(nameW);
return r;
}
- row = msi_get_property_row( package->db, name );
+ row = msi_get_property_row(package->db, nameW);
if (row)
- val = msi_record_get_string( row, 1, (int *)&len );
-
- if (!val)
- val = szEmpty;
+ value = msi_record_get_string(row, 1, &len);
- r = msi_strcpy_to_awstring( val, len, szValueBuf, pchValueBuf );
-
- if (row)
- msiobj_release( &row->hdr );
- msiobj_release( &package->hdr );
+ r = msi_strncpyWtoA(value, len, buf, sz, FALSE);
+ heap_free(nameW);
+ if (row) msiobj_release(&row->hdr);
+ msiobj_release(&package->hdr);
return r;
}
-UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD *sz)
+UINT WINAPI MsiGetPropertyW(MSIHANDLE hinst, const WCHAR *name, WCHAR *buf, DWORD *sz)
{
+ const WCHAR *value = szEmpty;
MSIPACKAGE *package;
- awstring val;
- WCHAR *nameW;
+ MSIRECORD *row;
+ int len = 0;
UINT r;
if (!name)
return ERROR_INVALID_PARAMETER;
- if (!(nameW = strdupAtoW(name)))
- return ERROR_OUTOFMEMORY;
-
package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE);
if (!package)
{
@@ -2440,7 +2432,7 @@ UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char
*buf, DWORD
if (!(remote = msi_get_remote(hinst)))
return ERROR_INVALID_HANDLE;
- r = remote_GetProperty(remote, nameW, &value, &len);
+ r = remote_GetProperty(remote, name, &value, &len);
if (!r)
{
/* String might contain embedded nulls.
@@ -2453,36 +2445,25 @@ UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name,
char *buf, DWORD
}
strcpyW(tmp, value);
- r = msi_strncpyWtoA(tmp, len, buf, sz, TRUE);
+ r = msi_strncpyW(tmp, len, buf, sz);
heap_free(tmp);
}
midl_user_free(value);
- heap_free(nameW);
return r;
}
- val.unicode = FALSE;
- val.str.a = buf;
+ row = msi_get_property_row(package->db, name);
+ if (row)
+ value = msi_record_get_string(row, 1, &len);
- r = MSI_GetProperty(hinst, nameW, &val, sz);
+ r = msi_strncpyW(value, len, buf, sz);
- heap_free(nameW);
+ if (row) msiobj_release(&row->hdr);
msiobj_release(&package->hdr);
return r;
}
-UINT WINAPI MsiGetPropertyW( MSIHANDLE hInstall, LPCWSTR szName,
- LPWSTR szValueBuf, LPDWORD pchValueBuf )
-{
- awstring val;
-
- val.unicode = TRUE;
- val.str.w = szValueBuf;
-
- return MSI_GetProperty( hInstall, szName, &val, pchValueBuf );
-}
-
MSIHANDLE __cdecl s_remote_GetActiveDatabase(MSIHANDLE hinst)
{
return MsiGetActiveDatabase(hinst);
diff --git a/modules/rostests/winetests/msi/custom.c
b/modules/rostests/winetests/msi/custom.c
index 96344ebc6eb..d240964aae7 100644
--- a/modules/rostests/winetests/msi/custom.c
+++ b/modules/rostests/winetests/msi/custom.c
@@ -191,6 +191,12 @@ static void test_props(MSIHANDLE hinst)
ok(hinst, !strcmp(buffer, "xyz"), "got \"%s\"\n",
buffer);
ok(hinst, sz == 3, "got size %u\n", sz);
+ r = MsiGetPropertyW(hinst, booW, NULL, NULL);
+ ok(hinst, !r, "got %u\n", r);
+
+ r = MsiGetPropertyW(hinst, booW, bufferW, NULL );
+ ok(hinst, r == ERROR_INVALID_PARAMETER, "got %u\n", r);
+
sz = 0;
r = MsiGetPropertyW(hinst, booW, NULL, &sz);
ok(hinst, !r, "got %u\n", r);