Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/package.c | 54 ++++++++++++++++++++++++++++++++++++++++--------- dlls/msi/tests/custom.c | 6 +++--- 2 files changed, 48 insertions(+), 12 deletions(-)
diff --git a/dlls/msi/package.c b/dlls/msi/package.c index a290904..133bfd8 100644 --- a/dlls/msi/package.c +++ b/dlls/msi/package.c @@ -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; }
diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c index 723b2b5..96344eb 100644 --- a/dlls/msi/tests/custom.c +++ b/dlls/msi/tests/custom.c @@ -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");