James Hawkins : msi: Handle components installed as source in MsiQueryComponentState.
Alexandre Julliard
julliard at winehq.org
Thu Aug 21 10:02:27 CDT 2008
Module: wine
Branch: master
Commit: 39b874706c4509b222de01e77a3a09d2c1049d07
URL: http://source.winehq.org/git/wine.git/?a=commit;h=39b874706c4509b222de01e77a3a09d2c1049d07
Author: James Hawkins <jhawkins at codeweavers.com>
Date: Thu Aug 21 02:16:03 2008 -0500
msi: Handle components installed as source in MsiQueryComponentState.
---
dlls/msi/msi.c | 19 ++++++++++++++-----
dlls/msi/tests/msi.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 5 deletions(-)
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 9055c59..f86f194 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -1299,7 +1299,7 @@ static BOOL msi_comp_find_package(LPCWSTR prodcode, MSIINSTALLCONTEXT context)
static BOOL msi_comp_find_prodcode(LPWSTR squished_pc,
MSIINSTALLCONTEXT context,
- LPCWSTR comp, DWORD *sz)
+ LPCWSTR comp, LPWSTR val, DWORD *sz)
{
HKEY hkey;
LONG res;
@@ -1313,8 +1313,7 @@ static BOOL msi_comp_find_prodcode(LPWSTR squished_pc,
if (r != ERROR_SUCCESS)
return FALSE;
- *sz = 0;
- res = RegQueryValueExW(hkey, squished_pc, NULL, NULL, NULL, sz);
+ res = RegQueryValueExW(hkey, squished_pc, NULL, NULL, (BYTE *)val, sz);
if (res != ERROR_SUCCESS)
return FALSE;
@@ -1327,6 +1326,7 @@ UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode,
LPCWSTR szComponent, INSTALLSTATE *pdwState)
{
WCHAR squished_pc[GUID_SIZE];
+ WCHAR val[MAX_PATH];
BOOL found;
DWORD sz;
@@ -1357,13 +1357,22 @@ UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode,
*pdwState = INSTALLSTATE_UNKNOWN;
- if (!msi_comp_find_prodcode(squished_pc, dwContext, szComponent, &sz))
+ sz = MAX_PATH;
+ if (!msi_comp_find_prodcode(squished_pc, dwContext, szComponent, val, &sz))
return ERROR_UNKNOWN_COMPONENT;
if (sz == 0)
*pdwState = INSTALLSTATE_NOTUSED;
else
- *pdwState = INSTALLSTATE_LOCAL;
+ {
+ if (lstrlenW(val) > 2 &&
+ val[0] >= '0' && val[0] <= '9' && val[1] >= '0' && val[1] <= '9')
+ {
+ *pdwState = INSTALLSTATE_SOURCE;
+ }
+ else
+ *pdwState = INSTALLSTATE_LOCAL;
+ }
return ERROR_SUCCESS;
}
diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c
index 0e262ae..bafcddc 100644
--- a/dlls/msi/tests/msi.c
+++ b/dlls/msi/tests/msi.c
@@ -1237,6 +1237,43 @@ static void test_MsiQueryComponentState(void)
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+ /* INSTALLSTATE_LOCAL */
+ state = MAGIC_ERROR;
+ r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* INSTALLSTATE_SOURCE */
+ state = MAGIC_ERROR;
+ r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* bad INSTALLSTATE_SOURCE */
+ state = MAGIC_ERROR;
+ r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* INSTALLSTATE_SOURCE */
+ state = MAGIC_ERROR;
+ r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
+
+ res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ /* bad INSTALLSTATE_SOURCE */
state = MAGIC_ERROR;
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
More information about the wine-cvs
mailing list