msi: Handle the remote case directly in MsiGetPropertyA().

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>
This commit is contained in:
Zebediah Figura 2018-05-15 23:03:35 -05:00 committed by Alexandre Julliard
parent 6b54a4bc2e
commit 84d972010f
2 changed files with 48 additions and 12 deletions

View File

@ -2410,22 +2410,58 @@ static UINT MSI_GetProperty( MSIHANDLE handle, LPCWSTR name,
return r;
}
UINT WINAPI MsiGetPropertyA( MSIHANDLE hInstall, LPCSTR szName,
LPSTR szValueBuf, LPDWORD pchValueBuf )
UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD *sz)
{
MSIPACKAGE *package;
awstring val;
LPWSTR name;
WCHAR *nameW;
UINT r;
val.unicode = FALSE;
val.str.a = szValueBuf;
if (!name)
return ERROR_INVALID_PARAMETER;
name = strdupAtoW( szName );
if (szName && !name)
if (!(nameW = strdupAtoW(name)))
return ERROR_OUTOFMEMORY;
r = MSI_GetProperty( hInstall, name, &val, pchValueBuf );
msi_free( name );
package = msihandle2msiinfo(hinst, MSIHANDLETYPE_PACKAGE);
if (!package)
{
WCHAR *value = NULL, *tmp;
MSIHANDLE remote;
DWORD len;
if (!(remote = msi_get_remote(hinst)))
return ERROR_INVALID_HANDLE;
r = remote_GetProperty(remote, nameW, &value, &len);
if (!r)
{
/* 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);
r = msi_strncpyWtoA(tmp, len, buf, sz, TRUE);
heap_free(tmp);
}
midl_user_free(value);
heap_free(nameW);
return r;
}
val.unicode = FALSE;
val.str.a = buf;
r = MSI_GetProperty(hinst, nameW, &val, sz);
heap_free(nameW);
msiobj_release(&package->hdr);
return r;
}

View File

@ -168,21 +168,21 @@ static void test_props(MSIHANDLE hinst)
r = MsiGetPropertyA(hinst, "boo", 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 == 6, "got size %u\n", sz);
ok(hinst, sz == 6, "got size %u\n", sz);
sz = 1;
strcpy(buffer,"x");
r = MsiGetPropertyA(hinst, "boo", 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 == 6, "got size %u\n", sz);
ok(hinst, sz == 6, "got size %u\n", sz);
sz = 3;
strcpy(buffer,"x");
r = MsiGetPropertyA(hinst, "boo", buffer, &sz);
ok(hinst, r == ERROR_MORE_DATA, "got %u\n", r);
ok(hinst, !strcmp(buffer, "xy"), "got \"%s\"\n", buffer);
todo_wine_ok(hinst, sz == 6, "got size %u\n", sz);
ok(hinst, sz == 6, "got size %u\n", sz);
sz = 4;
strcpy(buffer,"x");