Commit 39b87470 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Handle components installed as source in MsiQueryComponentState.

parent b965a74e
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment