2 * Implementation of the AppSearch action of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Juan Lang
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #include "wine/unicode.h"
32 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(msi);
38 typedef struct tagMSISIGNATURE
40 LPWSTR Name; /* NOT owned by this structure */
41 LPWSTR Property; /* NOT owned by this structure */
54 static void ACTION_VerStrToInteger(LPCWSTR verStr, PDWORD ms, PDWORD ls)
57 int x1 = 0, x2 = 0, x3 = 0, x4 = 0;
60 ptr = strchrW(verStr, '.');
64 ptr = strchrW(ptr + 1, '.');
69 ptr = strchrW(ptr + 1, '.');
73 /* FIXME: byte-order dependent? */
78 /* Fills in sig with the the values from the Signature table, where name is the
79 * signature to find. Upon return, sig->File will be NULL if the record is not
80 * found, and not NULL if it is found.
81 * Warning: clears all fields in sig!
82 * Returns ERROR_SUCCESS upon success (where not finding the record counts as
83 * success), something else on error.
85 static UINT ACTION_AppSearchGetSignature(MSIPACKAGE *package, MSISIGNATURE *sig,
90 static const WCHAR ExecSeqQuery[] = {
91 's','e','l','e','c','t',' ','*',' ',
93 'S','i','g','n','a','t','u','r','e',' ',
94 'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e',' ','=',' ',
97 TRACE("(package %p, sig %p)\n", package, sig);
98 memset(sig, 0, sizeof(*sig));
99 rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, name);
100 if (rc == ERROR_SUCCESS)
104 WCHAR *minVersion, *maxVersion;
106 rc = MSI_ViewExecute(view, 0);
107 if (rc != ERROR_SUCCESS)
109 TRACE("MSI_ViewExecute returned %d\n", rc);
112 rc = MSI_ViewFetch(view,&row);
113 if (rc != ERROR_SUCCESS)
115 TRACE("MSI_ViewFetch returned %d\n", rc);
121 sig->File = load_dynamic_stringW(row,2);
122 minVersion = load_dynamic_stringW(row,3);
125 ACTION_VerStrToInteger(minVersion, &sig->MinVersionMS,
127 msi_free( minVersion);
129 maxVersion = load_dynamic_stringW(row,4);
132 ACTION_VerStrToInteger(maxVersion, &sig->MaxVersionMS,
134 msi_free( maxVersion);
136 sig->MinSize = MSI_RecordGetInteger(row,5);
137 if (sig->MinSize == MSI_NULL_INTEGER)
139 sig->MaxSize = MSI_RecordGetInteger(row,6);
140 if (sig->MaxSize == MSI_NULL_INTEGER)
142 sig->Languages = load_dynamic_stringW(row,9);
143 time = MSI_RecordGetInteger(row,7);
144 if (time != MSI_NULL_INTEGER)
145 DosDateTimeToFileTime(HIWORD(time), LOWORD(time), &sig->MinTime);
146 time = MSI_RecordGetInteger(row,8);
147 if (time != MSI_NULL_INTEGER)
148 DosDateTimeToFileTime(HIWORD(time), LOWORD(time), &sig->MaxTime);
149 TRACE("Found file name %s for Signature_ %s;\n",
150 debugstr_w(sig->File), debugstr_w(name));
151 TRACE("MinVersion is %d.%d.%d.%d\n", HIWORD(sig->MinVersionMS),
152 LOWORD(sig->MinVersionMS), HIWORD(sig->MinVersionLS),
153 LOWORD(sig->MinVersionLS));
154 TRACE("MaxVersion is %d.%d.%d.%d\n", HIWORD(sig->MaxVersionMS),
155 LOWORD(sig->MaxVersionMS), HIWORD(sig->MaxVersionLS),
156 LOWORD(sig->MaxVersionLS));
157 TRACE("MinSize is %ld, MaxSize is %ld;\n", sig->MinSize, sig->MaxSize);
158 TRACE("Languages is %s\n", debugstr_w(sig->Languages));
161 msiobj_release(&row->hdr);
163 msiobj_release(&view->hdr);
167 TRACE("MSI_OpenQuery returned %d\n", rc);
171 TRACE("returning %d\n", rc);
175 static UINT ACTION_AppSearchComponents(MSIPACKAGE *package, BOOL *appFound,
180 static const WCHAR ExecSeqQuery[] = {
181 's','e','l','e','c','t',' ','*',' ',
183 'C','o','m','p','L','o','c','a','t','o','r',' ',
184 'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e','_',' ','=',' ',
185 '\'','%','s','\'',0};
187 TRACE("(package %p, appFound %p, sig %p)\n", package, appFound, sig);
189 rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, sig->Name);
190 if (rc == ERROR_SUCCESS)
196 rc = MSI_ViewExecute(view, 0);
197 if (rc != ERROR_SUCCESS)
199 TRACE("MSI_ViewExecute returned %d\n", rc);
202 rc = MSI_ViewFetch(view,&row);
203 if (rc != ERROR_SUCCESS)
205 TRACE("MSI_ViewFetch returned %d\n", rc);
212 sz=sizeof(guid)/sizeof(guid[0]);
213 rc = MSI_RecordGetStringW(row,2,guid,&sz);
214 if (rc != ERROR_SUCCESS)
216 ERR("Error is %x\n",rc);
219 FIXME("AppSearch unimplemented for CompLocator table (GUID %s)\n",
223 msiobj_release(&row->hdr);
225 msiobj_release(&view->hdr);
229 TRACE("MSI_OpenQuery returned %d\n", rc);
233 TRACE("returning %d\n", rc);
237 static UINT ACTION_AppSearchReg(MSIPACKAGE *package, BOOL *appFound,
242 static const WCHAR ExecSeqQuery[] = {
243 's','e','l','e','c','t',' ','*',' ',
245 'R','e','g','L','o','c','a','t','o','r',' ',
246 'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e','_',' ','=',' ',
247 '\'','%','s','\'',0};
248 static const WCHAR dwordFmt[] = { '#','%','d','\0' };
249 static const WCHAR expandSzFmt[] = { '#','%','%','%','s','\0' };
250 static const WCHAR binFmt[] = { '#','x','%','x','\0' };
252 TRACE("(package %p, appFound %p, sig %p)\n", package, appFound, sig);
254 rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, sig->Name);
255 if (rc == ERROR_SUCCESS)
258 LPWSTR keyPath = NULL, valueName = NULL, propertyValue = NULL;
260 HKEY rootKey, key = NULL;
261 DWORD sz = 0, regType, i;
264 rc = MSI_ViewExecute(view, 0);
265 if (rc != ERROR_SUCCESS)
267 TRACE("MSI_ViewExecute returned %d\n", rc);
270 rc = MSI_ViewFetch(view,&row);
271 if (rc != ERROR_SUCCESS)
273 TRACE("MSI_ViewFetch returned %d\n", rc);
278 root = MSI_RecordGetInteger(row,2);
279 keyPath = load_dynamic_stringW(row,3);
280 /* FIXME: keyPath needs to be expanded for properties */
281 valueName = load_dynamic_stringW(row,4);
282 /* FIXME: valueName probably does too */
283 type = MSI_RecordGetInteger(row,5);
285 if ((type & 0x0f) != msidbLocatorTypeRawValue)
287 FIXME("AppSearch unimplemented for type %d (key path %s, value %s)\n",
288 type, debugstr_w(keyPath), debugstr_w(valueName));
294 case msidbRegistryRootClassesRoot:
295 rootKey = HKEY_CLASSES_ROOT;
297 case msidbRegistryRootCurrentUser:
298 rootKey = HKEY_CURRENT_USER;
300 case msidbRegistryRootLocalMachine:
301 rootKey = HKEY_LOCAL_MACHINE;
303 case msidbRegistryRootUsers:
304 rootKey = HKEY_USERS;
307 WARN("Unknown root key %d\n", root);
311 rc = RegCreateKeyW(rootKey, keyPath, &key);
314 TRACE("RegCreateKeyW returned %d\n", rc);
318 rc = RegQueryValueExW(key, valueName, NULL, NULL, NULL, &sz);
321 TRACE("RegQueryValueExW returned %d\n", rc);
325 /* FIXME: sanity-check sz before allocating (is there an upper-limit
326 * on the value of a property?)
328 value = msi_alloc( sz);
329 rc = RegQueryValueExW(key, valueName, NULL, ®Type, value, &sz);
332 TRACE("RegQueryValueExW returned %d\n", rc);
337 /* bail out if the registry key is empty */
347 if (*(LPWSTR)value == '#')
349 /* escape leading pound with another */
350 propertyValue = msi_alloc( sz + sizeof(WCHAR));
351 propertyValue[0] = '#';
352 strcpyW(propertyValue + 1, (LPWSTR)value);
356 propertyValue = msi_alloc( sz);
357 strcpyW(propertyValue, (LPWSTR)value);
361 /* 7 chars for digits, 1 for NULL, 1 for #, and 1 for sign
364 propertyValue = msi_alloc( 10 * sizeof(WCHAR));
365 sprintfW(propertyValue, dwordFmt, *(DWORD *)value);
368 /* space for extra #% characters in front */
369 propertyValue = msi_alloc( sz + 2 * sizeof(WCHAR));
370 sprintfW(propertyValue, expandSzFmt, (LPWSTR)value);
373 /* 3 == length of "#x<nibble>" */
374 propertyValue = msi_alloc( (sz * 3 + 1) * sizeof(WCHAR));
375 for (i = 0; i < sz; i++)
376 sprintfW(propertyValue + i * 3, binFmt, value[i]);
379 WARN("unimplemented for values of type %ld\n", regType);
383 TRACE("found registry value, setting %s to %s\n",
384 debugstr_w(sig->Property), debugstr_w(propertyValue));
385 rc = MSI_SetPropertyW(package, sig->Property, propertyValue);
389 msi_free( propertyValue);
394 msi_free( valueName);
396 msiobj_release(&row->hdr);
398 msiobj_release(&view->hdr);
402 TRACE("MSI_OpenQuery returned %d\n", rc);
406 TRACE("returning %d\n", rc);
410 static UINT ACTION_AppSearchIni(MSIPACKAGE *package, BOOL *appFound,
415 static const WCHAR ExecSeqQuery[] = {
416 's','e','l','e','c','t',' ','*',' ',
418 'I','n','i','L','o','c','a','t','o','r',' ',
419 'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e','_',' ','=',' ',
420 '\'','%','s','\'',0};
422 TRACE("(package %p, appFound %p, sig %p)\n", package, appFound, sig);
424 rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, sig->Name);
425 if (rc == ERROR_SUCCESS)
430 rc = MSI_ViewExecute(view, 0);
431 if (rc != ERROR_SUCCESS)
433 TRACE("MSI_ViewExecute returned %d\n", rc);
436 rc = MSI_ViewFetch(view,&row);
437 if (rc != ERROR_SUCCESS)
439 TRACE("MSI_ViewFetch returned %d\n", rc);
445 fileName = load_dynamic_stringW(row,2);
446 FIXME("AppSearch unimplemented for IniLocator (ini file name %s)\n",
447 debugstr_w(fileName));
451 msiobj_release(&row->hdr);
453 msiobj_release(&view->hdr);
457 TRACE("MSI_OpenQuery returned %d\n", rc);
462 TRACE("returning %d\n", rc);
466 /* Expands the value in src into a path without property names and only
467 * containing long path names into dst. Replaces at most len characters of dst,
468 * and always NULL-terminates dst if dst is not NULL and len >= 1.
470 * Assumes src and dst are non-overlapping.
471 * FIXME: return code probably needed:
472 * - what does AppSearch return if the table values are invalid?
473 * - what if dst is too small?
475 static void ACTION_ExpandAnyPath(MSIPACKAGE *package, WCHAR *src, WCHAR *dst,
481 if (!src || !dst || !len)
484 /* Ignore the short portion of the path, don't think we can use it anyway */
485 if ((ptr = strchrW(src, '|')))
489 while (*ptr && copied < len - 1)
491 WCHAR *prop = strchrW(ptr, '[');
495 WCHAR *propEnd = strchrW(prop + 1, ']');
499 WARN("Unterminated property name in AnyPath: %s\n",
508 propLen = len - copied - 1;
509 MSI_GetPropertyW(package, prop + 1, dst + copied, &propLen);
516 size_t toCopy = min(strlenW(ptr) + 1, len - copied - 1);
518 memcpy(dst + copied, ptr, toCopy * sizeof(WCHAR));
523 *(dst + copied) = '\0';
526 /* Sets *matches to whether the file (whose path is filePath) matches the
527 * versions set in sig.
528 * Return ERROR_SUCCESS in case of success (whether or not the file matches),
529 * something else if an install-halting error occurs.
531 static UINT ACTION_FileVersionMatches(MSISIGNATURE *sig, LPCWSTR filePath,
534 UINT rc = ERROR_SUCCESS;
539 FIXME(": need to check version for languages %s\n",
540 debugstr_w(sig->Languages));
544 DWORD zero, size = GetFileVersionInfoSizeW(filePath, &zero);
548 LPVOID buf = msi_alloc( size);
552 static const WCHAR rootW[] = { '\\',0 };
554 LPVOID subBlock = NULL;
556 if (GetFileVersionInfoW(filePath, 0, size, buf))
557 VerQueryValueW(buf, rootW, &subBlock, &versionLen);
560 VS_FIXEDFILEINFO *info =
561 (VS_FIXEDFILEINFO *)subBlock;
563 TRACE("Comparing file version %d.%d.%d.%d:\n",
564 HIWORD(info->dwFileVersionMS),
565 LOWORD(info->dwFileVersionMS),
566 HIWORD(info->dwFileVersionLS),
567 LOWORD(info->dwFileVersionLS));
568 if (info->dwFileVersionMS < sig->MinVersionMS
569 || (info->dwFileVersionMS == sig->MinVersionMS &&
570 info->dwFileVersionLS < sig->MinVersionLS))
572 TRACE("Less than minimum version %d.%d.%d.%d\n",
573 HIWORD(sig->MinVersionMS),
574 LOWORD(sig->MinVersionMS),
575 HIWORD(sig->MinVersionLS),
576 LOWORD(sig->MinVersionLS));
578 else if (info->dwFileVersionMS < sig->MinVersionMS
579 || (info->dwFileVersionMS == sig->MinVersionMS &&
580 info->dwFileVersionLS < sig->MinVersionLS))
582 TRACE("Greater than minimum version %d.%d.%d.%d\n",
583 HIWORD(sig->MaxVersionMS),
584 LOWORD(sig->MaxVersionMS),
585 HIWORD(sig->MaxVersionLS),
586 LOWORD(sig->MaxVersionLS));
594 rc = ERROR_OUTOFMEMORY;
600 /* Sets *matches to whether the file in findData matches that in sig.
601 * fullFilePath is assumed to be the full path of the file specified in
602 * findData, which may be necessary to compare the version.
603 * Return ERROR_SUCCESS in case of success (whether or not the file matches),
604 * something else if an install-halting error occurs.
606 static UINT ACTION_FileMatchesSig(MSISIGNATURE *sig,
607 LPWIN32_FIND_DATAW findData, LPCWSTR fullFilePath, BOOL *matches)
609 UINT rc = ERROR_SUCCESS;
612 /* assumes the caller has already ensured the filenames match, so check
615 if (sig->MinTime.dwLowDateTime || sig->MinTime.dwHighDateTime)
617 if (findData->ftCreationTime.dwHighDateTime <
618 sig->MinTime.dwHighDateTime ||
619 (findData->ftCreationTime.dwHighDateTime == sig->MinTime.dwHighDateTime
620 && findData->ftCreationTime.dwLowDateTime <
621 sig->MinTime.dwLowDateTime))
624 if (*matches && (sig->MaxTime.dwLowDateTime || sig->MaxTime.dwHighDateTime))
626 if (findData->ftCreationTime.dwHighDateTime >
627 sig->MaxTime.dwHighDateTime ||
628 (findData->ftCreationTime.dwHighDateTime == sig->MaxTime.dwHighDateTime
629 && findData->ftCreationTime.dwLowDateTime >
630 sig->MaxTime.dwLowDateTime))
633 if (*matches && sig->MinSize && findData->nFileSizeLow < sig->MinSize)
635 if (*matches && sig->MaxSize && findData->nFileSizeLow > sig->MaxSize)
637 if (*matches && (sig->MinVersionMS || sig->MinVersionLS ||
638 sig->MaxVersionMS || sig->MaxVersionLS))
639 rc = ACTION_FileVersionMatches(sig, fullFilePath, matches);
643 /* Recursively searches the directory dir for files that match the signature
644 * sig, up to (depth + 1) levels deep. That is, if depth is 0, it searches dir
645 * (and only dir). If depth is 1, searches dir and its immediate
647 * Assumes sig->File is not NULL.
648 * Returns ERROR_SUCCESS on success (which may include non-critical errors),
649 * something else on failures which should halt the install.
651 static UINT ACTION_RecurseSearchDirectory(MSIPACKAGE *package, BOOL *appFound,
652 MSISIGNATURE *sig, LPCWSTR dir, int depth)
654 static const WCHAR starDotStarW[] = { '*','.','*',0 };
655 UINT rc = ERROR_SUCCESS;
656 size_t dirLen = lstrlenW(dir), fileLen = lstrlenW(sig->File);
659 TRACE("Searching directory %s for file %s, depth %d\n", debugstr_w(dir),
660 debugstr_w(sig->File), depth);
663 return ERROR_INVALID_PARAMETER;
666 /* We need the buffer in both paths below, so go ahead and allocate it
667 * here. Add two because we might need to add a backslash if the dir name
668 * isn't backslash-terminated.
670 buf = msi_alloc( (dirLen + max(fileLen, lstrlenW(starDotStarW)) + 2) * sizeof(WCHAR));
673 /* a depth of 0 implies we should search dir, so go ahead and search */
675 WIN32_FIND_DATAW findData;
677 memcpy(buf, dir, dirLen * sizeof(WCHAR));
678 if (buf[dirLen - 1] != '\\')
679 buf[dirLen++ - 1] = '\\';
680 memcpy(buf + dirLen, sig->File, (fileLen + 1) * sizeof(WCHAR));
681 hFind = FindFirstFileW(buf, &findData);
682 if (hFind != INVALID_HANDLE_VALUE)
686 /* assuming Signature can't contain wildcards for the file name,
687 * so don't bother with FindNextFileW here.
689 if (!(rc = ACTION_FileMatchesSig(sig, &findData, buf, &matches))
692 TRACE("found file, setting %s to %s\n",
693 debugstr_w(sig->Property), debugstr_w(buf));
694 rc = MSI_SetPropertyW(package, sig->Property, buf);
699 if (rc == ERROR_SUCCESS && !*appFound && depth > 0)
702 WIN32_FIND_DATAW findData;
704 memcpy(buf, dir, dirLen * sizeof(WCHAR));
705 if (buf[dirLen - 1] != '\\')
706 buf[dirLen++ - 1] = '\\';
707 lstrcpyW(buf + dirLen, starDotStarW);
708 hFind = FindFirstFileW(buf, &findData);
709 if (hFind != INVALID_HANDLE_VALUE)
711 if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
712 rc = ACTION_RecurseSearchDirectory(package, appFound,
713 sig, findData.cFileName, depth - 1);
714 while (rc == ERROR_SUCCESS && !*appFound &&
715 FindNextFileW(hFind, &findData) != 0)
717 if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
718 rc = ACTION_RecurseSearchDirectory(package, appFound,
719 sig, findData.cFileName, depth - 1);
727 rc = ERROR_OUTOFMEMORY;
732 static UINT ACTION_CheckDirectory(MSIPACKAGE *package, MSISIGNATURE *sig,
735 UINT rc = ERROR_SUCCESS;
737 if (GetFileAttributesW(dir) & FILE_ATTRIBUTE_DIRECTORY)
739 TRACE("directory exists, setting %s to %s\n",
740 debugstr_w(sig->Property), debugstr_w(dir));
741 rc = MSI_SetPropertyW(package, sig->Property, dir);
746 static BOOL ACTION_IsFullPath(LPCWSTR path)
748 WCHAR first = toupperW(path[0]);
751 if (first >= 'A' && first <= 'Z' && path[1] == ':')
753 else if (path[0] == '\\' && path[1] == '\\')
760 static UINT ACTION_SearchDirectory(MSIPACKAGE *package, MSISIGNATURE *sig,
761 LPCWSTR expanded, int depth)
766 TRACE("%p, %p, %s, %d\n", package, sig, debugstr_w(expanded), depth);
767 if (ACTION_IsFullPath(expanded))
770 rc = ACTION_RecurseSearchDirectory(package, &found, sig,
774 /* Recursively searching a directory makes no sense when the
775 * directory to search is the thing you're trying to find.
777 rc = ACTION_CheckDirectory(package, sig, expanded);
782 WCHAR pathWithDrive[MAX_PATH] = { 'C',':','\\',0 };
783 DWORD drives = GetLogicalDrives();
788 for (i = 0; rc == ERROR_SUCCESS && !found && i < 26; i++)
789 if (drives & (1 << drives))
791 pathWithDrive[0] = 'A' + i;
792 if (GetDriveTypeW(pathWithDrive) == DRIVE_FIXED)
794 lstrcpynW(pathWithDrive + 3, expanded,
795 sizeof(pathWithDrive) / sizeof(pathWithDrive[0]) - 3);
797 rc = ACTION_RecurseSearchDirectory(package, &found, sig,
798 pathWithDrive, depth);
800 rc = ACTION_CheckDirectory(package, sig, pathWithDrive);
804 TRACE("returning %d\n", rc);
808 static UINT ACTION_AppSearchDr(MSIPACKAGE *package, MSISIGNATURE *sig)
812 static const WCHAR ExecSeqQuery[] = {
813 's','e','l','e','c','t',' ','*',' ',
815 'D','r','L','o','c','a','t','o','r',' ',
816 'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e','_',' ','=',' ',
817 '\'','%','s','\'',0};
819 TRACE("(package %p, sig %p)\n", package, sig);
820 rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery, sig->Name);
821 if (rc == ERROR_SUCCESS)
824 WCHAR buffer[MAX_PATH], expanded[MAX_PATH];
828 rc = MSI_ViewExecute(view, 0);
829 if (rc != ERROR_SUCCESS)
831 TRACE("MSI_ViewExecute returned %d\n", rc);
834 rc = MSI_ViewFetch(view,&row);
835 if (rc != ERROR_SUCCESS)
837 TRACE("MSI_ViewFetch returned %d\n", rc);
842 /* check whether parent is set */
844 sz=sizeof(buffer)/sizeof(buffer[0]);
845 rc = MSI_RecordGetStringW(row,2,buffer,&sz);
846 if (rc != ERROR_SUCCESS)
848 ERR("Error is %x\n",rc);
853 FIXME(": searching parent (%s) unimplemented\n",
857 /* no parent, now look for path */
859 sz=sizeof(buffer)/sizeof(buffer[0]);
860 rc = MSI_RecordGetStringW(row,3,buffer,&sz);
861 if (rc != ERROR_SUCCESS)
863 ERR("Error is %x\n",rc);
866 if (MSI_RecordIsNull(row,4))
869 depth = MSI_RecordGetInteger(row,4);
870 ACTION_ExpandAnyPath(package, buffer, expanded,
871 sizeof(expanded) / sizeof(expanded[0]));
872 rc = ACTION_SearchDirectory(package, sig, expanded, depth);
875 msiobj_release(&row->hdr);
877 msiobj_release(&view->hdr);
881 TRACE("MSI_OpenQuery returned %d\n", rc);
886 TRACE("returning %d\n", rc);
890 /* http://msdn.microsoft.com/library/en-us/msi/setup/appsearch_table.asp
891 * is the best reference for the AppSearch table and how it's used.
893 UINT ACTION_AppSearch(MSIPACKAGE *package)
897 static const WCHAR ExecSeqQuery[] = {
898 's','e','l','e','c','t',' ','*',' ',
900 'A','p','p','S','e','a','r','c','h',0};
902 rc = MSI_OpenQuery(package->db, &view, ExecSeqQuery);
903 if (rc == ERROR_SUCCESS)
906 WCHAR propBuf[0x100], sigBuf[0x100];
909 BOOL appFound = FALSE;
911 rc = MSI_ViewExecute(view, 0);
912 if (rc != ERROR_SUCCESS)
917 rc = MSI_ViewFetch(view,&row);
918 if (rc != ERROR_SUCCESS)
924 /* get property and signature */
926 sz=sizeof(propBuf)/sizeof(propBuf[0]);
927 rc = MSI_RecordGetStringW(row,1,propBuf,&sz);
928 if (rc != ERROR_SUCCESS)
930 ERR("Error is %x\n",rc);
931 msiobj_release(&row->hdr);
935 sz=sizeof(sigBuf)/sizeof(sigBuf[0]);
936 rc = MSI_RecordGetStringW(row,2,sigBuf,&sz);
937 if (rc != ERROR_SUCCESS)
939 ERR("Error is %x\n",rc);
940 msiobj_release(&row->hdr);
943 TRACE("Searching for Property %s, Signature_ %s\n",
944 debugstr_w(propBuf), debugstr_w(sigBuf));
945 /* This clears all the fields, so set Name and Property afterward */
946 rc = ACTION_AppSearchGetSignature(package, &sig, sigBuf);
948 sig.Property = propBuf;
949 if (rc == ERROR_SUCCESS)
951 rc = ACTION_AppSearchComponents(package, &appFound, &sig);
952 if (rc == ERROR_SUCCESS && !appFound)
954 rc = ACTION_AppSearchReg(package, &appFound, &sig);
955 if (rc == ERROR_SUCCESS && !appFound)
957 rc = ACTION_AppSearchIni(package, &appFound, &sig);
958 if (rc == ERROR_SUCCESS && !appFound)
959 rc = ACTION_AppSearchDr(package, &sig);
964 msi_free( sig.Languages);
965 msiobj_release(&row->hdr);
970 msiobj_release(&view->hdr);