msi: Use MSI_QueryGetRecord in ACTION_AppSearchReg.
This commit is contained in:
parent
fa6bc9e50b
commit
54ab47ef59
|
@ -235,42 +235,31 @@ 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[] = {
|
||||||
UINT rc;
|
|
||||||
static const WCHAR ExecSeqQuery[] = {
|
|
||||||
's','e','l','e','c','t',' ','*',' ',
|
's','e','l','e','c','t',' ','*',' ',
|
||||||
'f','r','o','m',' ',
|
'f','r','o','m',' ',
|
||||||
'R','e','g','L','o','c','a','t','o','r',' ',
|
'R','e','g','L','o','c','a','t','o','r',' ',
|
||||||
'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e','_',' ','=',' ',
|
'w','h','e','r','e',' ',
|
||||||
'\'','%','s','\'',0};
|
'S','i','g','n','a','t','u','r','e','_',' ','=',' ', '\'','%','s','\'',0};
|
||||||
|
|
||||||
TRACE("(package %p, appValue %p, sig %p)\n", package, appValue, sig);
|
|
||||||
*appValue = NULL;
|
|
||||||
rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, sig->Name);
|
|
||||||
if (rc == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
MSIRECORD *row = 0;
|
|
||||||
LPWSTR keyPath = NULL, valueName = NULL;
|
LPWSTR keyPath = NULL, valueName = NULL;
|
||||||
int root, type;
|
int root, type;
|
||||||
HKEY rootKey, key = NULL;
|
HKEY rootKey, key = NULL;
|
||||||
DWORD sz = 0, regType;
|
DWORD sz = 0, regType;
|
||||||
LPBYTE value = NULL;
|
LPBYTE value = NULL;
|
||||||
|
MSIRECORD *row;
|
||||||
|
UINT rc;
|
||||||
|
|
||||||
rc = MSI_ViewExecute(view, 0);
|
TRACE("%s\n", debugstr_w(sig->Name));
|
||||||
if (rc != ERROR_SUCCESS)
|
|
||||||
|
*appValue = NULL;
|
||||||
|
|
||||||
|
row = MSI_QueryGetRecord( package->db, query, sig->Name );
|
||||||
|
if (!row)
|
||||||
{
|
{
|
||||||
TRACE("MSI_ViewExecute returned %d\n", rc);
|
TRACE("failed to query RegLocator for %s\n", debugstr_w(sig->Name));
|
||||||
goto end;
|
return ERROR_SUCCESS;
|
||||||
}
|
|
||||||
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);
|
root = MSI_RecordGetInteger(row,2);
|
||||||
|
@ -303,43 +292,37 @@ static UINT ACTION_AppSearchReg(MSIPACKAGE *package, LPWSTR *appValue,
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
TRACE("RegOpenKeyW returned %d\n", rc);
|
TRACE("RegOpenKeyW returned %d\n", rc);
|
||||||
rc = ERROR_SUCCESS;
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = RegQueryValueExW(key, valueName, NULL, NULL, NULL, &sz);
|
rc = RegQueryValueExW(key, valueName, NULL, NULL, NULL, &sz);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
TRACE("RegQueryValueExW 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
|
/* FIXME: sanity-check sz before allocating (is there an upper-limit
|
||||||
* on the value of a property?)
|
* on the value of a property?)
|
||||||
*/
|
*/
|
||||||
value = msi_alloc( sz);
|
value = msi_alloc( sz );
|
||||||
rc = RegQueryValueExW(key, valueName, NULL, ®Type, value, &sz);
|
rc = RegQueryValueExW(key, valueName, NULL, ®Type, value, &sz);
|
||||||
if (rc)
|
if (rc)
|
||||||
{
|
{
|
||||||
TRACE("RegQueryValueExW returned %d\n", rc);
|
TRACE("RegQueryValueExW returned %d\n", rc);
|
||||||
rc = ERROR_SUCCESS;
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bail out if the registry key is empty */
|
/* bail out if the registry key is empty */
|
||||||
if (sz == 0)
|
if (sz == 0)
|
||||||
{
|
|
||||||
rc = ERROR_SUCCESS;
|
|
||||||
goto end;
|
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((LPCWSTR)value);
|
*appValue = strdupW((LPWSTR)value);
|
||||||
break;
|
break;
|
||||||
case msidbLocatorTypeRawValue:
|
case msidbLocatorTypeRawValue:
|
||||||
ACTION_ConvertRegValue(regType, value, sz, appValue);
|
ACTION_ConvertRegValue(regType, value, sz, appValue);
|
||||||
|
@ -349,25 +332,15 @@ static UINT ACTION_AppSearchReg(MSIPACKAGE *package, LPWSTR *appValue,
|
||||||
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,
|
||||||
|
|
Loading…
Reference in New Issue