Commit 54ab47ef authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

msi: Use MSI_QueryGetRecord in ACTION_AppSearchReg.

parent fa6bc9e5
...@@ -235,139 +235,112 @@ static void ACTION_ConvertRegValue(DWORD regType, const BYTE *value, DWORD sz, ...@@ -235,139 +235,112 @@ static void ACTION_ConvertRegValue(DWORD regType, const BYTE *value, DWORD sz,
static UINT ACTION_SearchDirectory(MSIPACKAGE *package, MSISIGNATURE *sig, static UINT ACTION_SearchDirectory(MSIPACKAGE *package, MSISIGNATURE *sig,
LPCWSTR path, int depth, LPWSTR *appValue); LPCWSTR path, int depth, LPWSTR *appValue);
static UINT ACTION_AppSearchReg(MSIPACKAGE *package, LPWSTR *appValue, static UINT ACTION_AppSearchReg(MSIPACKAGE *package, LPWSTR *appValue, MSISIGNATURE *sig)
MSISIGNATURE *sig)
{ {
MSIQUERY *view; static const WCHAR query[] = {
's','e','l','e','c','t',' ','*',' ',
'f','r','o','m',' ',
'R','e','g','L','o','c','a','t','o','r',' ',
'w','h','e','r','e',' ',
'S','i','g','n','a','t','u','r','e','_',' ','=',' ', '\'','%','s','\'',0};
LPWSTR keyPath = NULL, valueName = NULL;
int root, type;
HKEY rootKey, key = NULL;
DWORD sz = 0, regType;
LPBYTE value = NULL;
MSIRECORD *row;
UINT rc; UINT rc;
static const WCHAR ExecSeqQuery[] = {
's','e','l','e','c','t',' ','*',' ',
'f','r','o','m',' ',
'R','e','g','L','o','c','a','t','o','r',' ',
'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e','_',' ','=',' ',
'\'','%','s','\'',0};
TRACE("(package %p, appValue %p, sig %p)\n", package, appValue, sig); TRACE("%s\n", debugstr_w(sig->Name));
*appValue = NULL; *appValue = NULL;
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, sig->Name);
if (rc == ERROR_SUCCESS) row = MSI_QueryGetRecord( package->db, query, sig->Name );
if (!row)
{ {
MSIRECORD *row = 0; TRACE("failed to query RegLocator for %s\n", debugstr_w(sig->Name));
LPWSTR keyPath = NULL, valueName = NULL; return ERROR_SUCCESS;
int root, type; }
HKEY rootKey, key = NULL;
DWORD sz = 0, regType;
LPBYTE value = NULL;
rc = MSI_ViewExecute(view, 0); root = MSI_RecordGetInteger(row,2);
if (rc != ERROR_SUCCESS) keyPath = msi_dup_record_field(row,3);
{ /* FIXME: keyPath needs to be expanded for properties */
TRACE("MSI_ViewExecute returned %d\n", rc); valueName = msi_dup_record_field(row,4);
goto end; /* FIXME: valueName probably does too */
} type = MSI_RecordGetInteger(row,5);
rc = MSI_ViewFetch(view,&row);
if (rc != ERROR_SUCCESS)
{
TRACE("MSI_ViewFetch returned %d\n", rc);
rc = ERROR_SUCCESS;
goto end;
}
root = MSI_RecordGetInteger(row,2); switch (root)
keyPath = msi_dup_record_field(row,3); {
/* FIXME: keyPath needs to be expanded for properties */ case msidbRegistryRootClassesRoot:
valueName = msi_dup_record_field(row,4); rootKey = HKEY_CLASSES_ROOT;
/* FIXME: valueName probably does too */ break;
type = MSI_RecordGetInteger(row,5); case msidbRegistryRootCurrentUser:
rootKey = HKEY_CURRENT_USER;
break;
case msidbRegistryRootLocalMachine:
rootKey = HKEY_LOCAL_MACHINE;
break;
case msidbRegistryRootUsers:
rootKey = HKEY_USERS;
break;
default:
WARN("Unknown root key %d\n", root);
goto end;
}
switch (root) rc = RegOpenKeyW(rootKey, keyPath, &key);
{ if (rc)
case msidbRegistryRootClassesRoot: {
rootKey = HKEY_CLASSES_ROOT; TRACE("RegOpenKeyW returned %d\n", rc);
break; goto end;
case msidbRegistryRootCurrentUser: }
rootKey = HKEY_CURRENT_USER;
break;
case msidbRegistryRootLocalMachine:
rootKey = HKEY_LOCAL_MACHINE;
break;
case msidbRegistryRootUsers:
rootKey = HKEY_USERS;
break;
default:
WARN("Unknown root key %d\n", root);
goto end;
}
rc = RegOpenKeyW(rootKey, keyPath, &key); rc = RegQueryValueExW(key, valueName, NULL, NULL, NULL, &sz);
if (rc) if (rc)
{ {
TRACE("RegOpenKeyW returned %d\n", rc); TRACE("RegQueryValueExW returned %d\n", rc);
rc = ERROR_SUCCESS; goto end;
goto end; }
} /* FIXME: sanity-check sz before allocating (is there an upper-limit
rc = RegQueryValueExW(key, valueName, NULL, NULL, NULL, &sz); * on the value of a property?)
if (rc) */
{ value = msi_alloc( sz );
TRACE("RegQueryValueExW returned %d\n", rc); rc = RegQueryValueExW(key, valueName, NULL, &regType, value, &sz);
rc = ERROR_SUCCESS; if (rc)
goto end; {
} TRACE("RegQueryValueExW returned %d\n", rc);
/* FIXME: sanity-check sz before allocating (is there an upper-limit goto end;
* on the value of a property?) }
*/
value = msi_alloc( sz);
rc = RegQueryValueExW(key, valueName, NULL, &regType, value, &sz);
if (rc)
{
TRACE("RegQueryValueExW returned %d\n", rc);
rc = ERROR_SUCCESS;
goto end;
}
/* bail out if the registry key is empty */ /* bail out if the registry key is empty */
if (sz == 0) if (sz == 0)
{ goto end;
rc = ERROR_SUCCESS;
goto end;
}
switch (type & 0x0f) switch (type & 0x0f)
{ {
case msidbLocatorTypeDirectory: case msidbLocatorTypeDirectory:
rc = ACTION_SearchDirectory(package, sig, (LPCWSTR)value, 0, rc = ACTION_SearchDirectory(package, sig, (LPWSTR)value, 0, appValue);
appValue); break;
break; case msidbLocatorTypeFileName:
case msidbLocatorTypeFileName: *appValue = strdupW((LPWSTR)value);
*appValue = strdupW((LPCWSTR)value); break;
break; case msidbLocatorTypeRawValue:
case msidbLocatorTypeRawValue: ACTION_ConvertRegValue(regType, value, sz, appValue);
ACTION_ConvertRegValue(regType, value, sz, appValue); break;
break; default:
default: FIXME("AppSearch unimplemented for type %d (key path %s, value %s)\n",
FIXME("AppSearch unimplemented for type %d (key path %s, value %s)\n", type, debugstr_w(keyPath), debugstr_w(valueName));
type, debugstr_w(keyPath), debugstr_w(valueName)); }
}
end: end:
msi_free( value); msi_free( value );
RegCloseKey(key); RegCloseKey( key );
msi_free( keyPath); msi_free( keyPath );
msi_free( valueName); msi_free( valueName );
if (row) msiobj_release(&row->hdr);
msiobj_release(&row->hdr);
MSI_ViewClose(view);
msiobj_release(&view->hdr);
}
else
{
TRACE("MSI_OpenQuery returned %d\n", rc);
rc = ERROR_SUCCESS;
}
TRACE("returning %d\n", rc); return ERROR_SUCCESS;
return rc;
} }
static UINT ACTION_AppSearchIni(MSIPACKAGE *package, LPWSTR *appValue, static UINT ACTION_AppSearchIni(MSIPACKAGE *package, LPWSTR *appValue,
......
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