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 HeapFree(GetProcessHeap(), 0, minVersion
);
129 maxVersion
= load_dynamic_stringW(row
,4);
132 ACTION_VerStrToInteger(maxVersion
, &sig
->MaxVersionMS
,
134 HeapFree(GetProcessHeap(), 0, 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
= HeapAlloc(GetProcessHeap(), 0, sz
);
329 rc
= RegQueryValueExW(key
, valueName
, NULL
, ®Type
, value
, &sz
);
332 TRACE("RegQueryValueExW returned %d\n", rc
);
340 if (*(LPWSTR
)value
== '#')
342 /* escape leading pound with another */
343 propertyValue
= HeapAlloc(GetProcessHeap(), 0,
345 propertyValue
[0] = '#';
346 strcpyW(propertyValue
+ 1, (LPWSTR
)value
);
350 propertyValue
= HeapAlloc(GetProcessHeap(), 0, sz
);
351 strcpyW(propertyValue
, (LPWSTR
)value
);
355 /* 7 chars for digits, 1 for NULL, 1 for #, and 1 for sign
358 propertyValue
= HeapAlloc(GetProcessHeap(), 0,
360 sprintfW(propertyValue
, dwordFmt
, *(DWORD
*)value
);
363 /* space for extra #% characters in front */
364 propertyValue
= HeapAlloc(GetProcessHeap(), 0,
365 sz
+ 2 * sizeof(WCHAR
));
366 sprintfW(propertyValue
, expandSzFmt
, (LPWSTR
)value
);
369 /* 3 == length of "#x<nibble>" */
370 propertyValue
= HeapAlloc(GetProcessHeap(), 0,
371 (sz
* 3 + 1) * sizeof(WCHAR
));
372 for (i
= 0; i
< sz
; i
++)
373 sprintfW(propertyValue
+ i
* 3, binFmt
, value
[i
]);
376 WARN("unimplemented for values of type %ld\n", regType
);
380 TRACE("found registry value, setting %s to %s\n",
381 debugstr_w(sig
->Property
), debugstr_w(propertyValue
));
382 rc
= MSI_SetPropertyW(package
, sig
->Property
, propertyValue
);
386 HeapFree(GetProcessHeap(), 0, propertyValue
);
387 HeapFree(GetProcessHeap(), 0, value
);
390 HeapFree(GetProcessHeap(), 0, keyPath
);
391 HeapFree(GetProcessHeap(), 0, valueName
);
393 msiobj_release(&row
->hdr
);
395 msiobj_release(&view
->hdr
);
399 TRACE("MSI_OpenQuery returned %d\n", rc
);
403 TRACE("returning %d\n", rc
);
407 static UINT
ACTION_AppSearchIni(MSIPACKAGE
*package
, BOOL
*appFound
,
412 static const WCHAR ExecSeqQuery
[] = {
413 's','e','l','e','c','t',' ','*',' ',
415 'I','n','i','L','o','c','a','t','o','r',' ',
416 'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e','_',' ','=',' ',
417 '\'','%','s','\'',0};
419 TRACE("(package %p, appFound %p, sig %p)\n", package
, appFound
, sig
);
421 rc
= MSI_OpenQuery(package
->db
, &view
, ExecSeqQuery
, sig
->Name
);
422 if (rc
== ERROR_SUCCESS
)
427 rc
= MSI_ViewExecute(view
, 0);
428 if (rc
!= ERROR_SUCCESS
)
430 TRACE("MSI_ViewExecute returned %d\n", rc
);
433 rc
= MSI_ViewFetch(view
,&row
);
434 if (rc
!= ERROR_SUCCESS
)
436 TRACE("MSI_ViewFetch returned %d\n", rc
);
442 fileName
= load_dynamic_stringW(row
,2);
443 FIXME("AppSearch unimplemented for IniLocator (ini file name %s)\n",
444 debugstr_w(fileName
));
445 HeapFree(GetProcessHeap(), 0, fileName
);
448 msiobj_release(&row
->hdr
);
450 msiobj_release(&view
->hdr
);
454 TRACE("MSI_OpenQuery returned %d\n", rc
);
459 TRACE("returning %d\n", rc
);
463 /* Expands the value in src into a path without property names and only
464 * containing long path names into dst. Replaces at most len characters of dst,
465 * and always NULL-terminates dst if dst is not NULL and len >= 1.
467 * Assumes src and dst are non-overlapping.
468 * FIXME: return code probably needed:
469 * - what does AppSearch return if the table values are invalid?
470 * - what if dst is too small?
472 static void ACTION_ExpandAnyPath(MSIPACKAGE
*package
, WCHAR
*src
, WCHAR
*dst
,
478 if (!src
|| !dst
|| !len
)
481 /* Ignore the short portion of the path, don't think we can use it anyway */
482 if ((ptr
= strchrW(src
, '|')))
486 while (*ptr
&& copied
< len
- 1)
488 WCHAR
*prop
= strchrW(ptr
, '[');
492 WCHAR
*propEnd
= strchrW(prop
+ 1, ']');
496 WARN("Unterminated property name in AnyPath: %s\n",
505 propLen
= len
- copied
- 1;
506 MSI_GetPropertyW(package
, prop
+ 1, dst
+ copied
, &propLen
);
513 size_t toCopy
= min(strlenW(ptr
) + 1, len
- copied
- 1);
515 memcpy(dst
+ copied
, ptr
, toCopy
* sizeof(WCHAR
));
520 *(dst
+ copied
) = '\0';
523 /* Sets *matches to whether the file (whose path is filePath) matches the
524 * versions set in sig.
525 * Return ERROR_SUCCESS in case of success (whether or not the file matches),
526 * something else if an install-halting error occurs.
528 static UINT
ACTION_FileVersionMatches(MSISIGNATURE
*sig
, LPCWSTR filePath
,
531 UINT rc
= ERROR_SUCCESS
;
536 FIXME(": need to check version for languages %s\n",
537 debugstr_w(sig
->Languages
));
541 DWORD zero
, size
= GetFileVersionInfoSizeW(filePath
, &zero
);
545 LPVOID buf
= HeapAlloc(GetProcessHeap(), 0, size
);
549 static const WCHAR rootW
[] = { '\\',0 };
551 LPVOID subBlock
= NULL
;
553 if (GetFileVersionInfoW(filePath
, 0, size
, buf
))
554 VerQueryValueW(buf
, rootW
, &subBlock
, &versionLen
);
557 VS_FIXEDFILEINFO
*info
=
558 (VS_FIXEDFILEINFO
*)subBlock
;
560 TRACE("Comparing file version %d.%d.%d.%d:\n",
561 HIWORD(info
->dwFileVersionMS
),
562 LOWORD(info
->dwFileVersionMS
),
563 HIWORD(info
->dwFileVersionLS
),
564 LOWORD(info
->dwFileVersionLS
));
565 if (info
->dwFileVersionMS
< sig
->MinVersionMS
566 || (info
->dwFileVersionMS
== sig
->MinVersionMS
&&
567 info
->dwFileVersionLS
< sig
->MinVersionLS
))
569 TRACE("Less than minimum version %d.%d.%d.%d\n",
570 HIWORD(sig
->MinVersionMS
),
571 LOWORD(sig
->MinVersionMS
),
572 HIWORD(sig
->MinVersionLS
),
573 LOWORD(sig
->MinVersionLS
));
575 else if (info
->dwFileVersionMS
< sig
->MinVersionMS
576 || (info
->dwFileVersionMS
== sig
->MinVersionMS
&&
577 info
->dwFileVersionLS
< sig
->MinVersionLS
))
579 TRACE("Greater than minimum version %d.%d.%d.%d\n",
580 HIWORD(sig
->MaxVersionMS
),
581 LOWORD(sig
->MaxVersionMS
),
582 HIWORD(sig
->MaxVersionLS
),
583 LOWORD(sig
->MaxVersionLS
));
588 HeapFree(GetProcessHeap(), 0, buf
);
591 rc
= ERROR_OUTOFMEMORY
;
597 /* Sets *matches to whether the file in findData matches that in sig.
598 * fullFilePath is assumed to be the full path of the file specified in
599 * findData, which may be necessary to compare the version.
600 * Return ERROR_SUCCESS in case of success (whether or not the file matches),
601 * something else if an install-halting error occurs.
603 static UINT
ACTION_FileMatchesSig(MSISIGNATURE
*sig
,
604 LPWIN32_FIND_DATAW findData
, LPCWSTR fullFilePath
, BOOL
*matches
)
606 UINT rc
= ERROR_SUCCESS
;
609 /* assumes the caller has already ensured the filenames match, so check
612 if (sig
->MinTime
.dwLowDateTime
|| sig
->MinTime
.dwHighDateTime
)
614 if (findData
->ftCreationTime
.dwHighDateTime
<
615 sig
->MinTime
.dwHighDateTime
||
616 (findData
->ftCreationTime
.dwHighDateTime
== sig
->MinTime
.dwHighDateTime
617 && findData
->ftCreationTime
.dwLowDateTime
<
618 sig
->MinTime
.dwLowDateTime
))
621 if (*matches
&& (sig
->MaxTime
.dwLowDateTime
|| sig
->MaxTime
.dwHighDateTime
))
623 if (findData
->ftCreationTime
.dwHighDateTime
>
624 sig
->MaxTime
.dwHighDateTime
||
625 (findData
->ftCreationTime
.dwHighDateTime
== sig
->MaxTime
.dwHighDateTime
626 && findData
->ftCreationTime
.dwLowDateTime
>
627 sig
->MaxTime
.dwLowDateTime
))
630 if (*matches
&& sig
->MinSize
&& findData
->nFileSizeLow
< sig
->MinSize
)
632 if (*matches
&& sig
->MaxSize
&& findData
->nFileSizeLow
> sig
->MaxSize
)
634 if (*matches
&& (sig
->MinVersionMS
|| sig
->MinVersionLS
||
635 sig
->MaxVersionMS
|| sig
->MaxVersionLS
))
636 rc
= ACTION_FileVersionMatches(sig
, fullFilePath
, matches
);
640 /* Recursively searches the directory dir for files that match the signature
641 * sig, up to (depth + 1) levels deep. That is, if depth is 0, it searches dir
642 * (and only dir). If depth is 1, searches dir and its immediate
644 * Assumes sig->File is not NULL.
645 * Returns ERROR_SUCCESS on success (which may include non-critical errors),
646 * something else on failures which should halt the install.
648 static UINT
ACTION_RecurseSearchDirectory(MSIPACKAGE
*package
, BOOL
*appFound
,
649 MSISIGNATURE
*sig
, LPCWSTR dir
, int depth
)
651 static const WCHAR starDotStarW
[] = { '*','.','*',0 };
652 UINT rc
= ERROR_SUCCESS
;
653 size_t dirLen
= lstrlenW(dir
), fileLen
= lstrlenW(sig
->File
);
656 TRACE("Searching directory %s for file %s, depth %d\n", debugstr_w(dir
),
657 debugstr_w(sig
->File
), depth
);
660 return ERROR_INVALID_PARAMETER
;
663 /* We need the buffer in both paths below, so go ahead and allocate it
664 * here. Add two because we might need to add a backslash if the dir name
665 * isn't backslash-terminated.
667 buf
= HeapAlloc(GetProcessHeap(), 0,
668 (dirLen
+ max(fileLen
, lstrlenW(starDotStarW
)) + 2) * sizeof(WCHAR
));
671 /* a depth of 0 implies we should search dir, so go ahead and search */
673 WIN32_FIND_DATAW findData
;
675 memcpy(buf
, dir
, dirLen
* sizeof(WCHAR
));
676 if (buf
[dirLen
- 1] != '\\')
677 buf
[dirLen
++ - 1] = '\\';
678 memcpy(buf
+ dirLen
, sig
->File
, (fileLen
+ 1) * sizeof(WCHAR
));
679 hFind
= FindFirstFileW(buf
, &findData
);
680 if (hFind
!= INVALID_HANDLE_VALUE
)
684 /* assuming Signature can't contain wildcards for the file name,
685 * so don't bother with FindNextFileW here.
687 if (!(rc
= ACTION_FileMatchesSig(sig
, &findData
, buf
, &matches
))
690 TRACE("found file, setting %s to %s\n",
691 debugstr_w(sig
->Property
), debugstr_w(buf
));
692 rc
= MSI_SetPropertyW(package
, sig
->Property
, buf
);
697 if (rc
== ERROR_SUCCESS
&& !*appFound
&& depth
> 0)
700 WIN32_FIND_DATAW findData
;
702 memcpy(buf
, dir
, dirLen
* sizeof(WCHAR
));
703 if (buf
[dirLen
- 1] != '\\')
704 buf
[dirLen
++ - 1] = '\\';
705 lstrcpyW(buf
+ dirLen
, starDotStarW
);
706 hFind
= FindFirstFileW(buf
, &findData
);
707 if (hFind
!= INVALID_HANDLE_VALUE
)
709 if (findData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
710 rc
= ACTION_RecurseSearchDirectory(package
, appFound
,
711 sig
, findData
.cFileName
, depth
- 1);
712 while (rc
== ERROR_SUCCESS
&& !*appFound
&&
713 FindNextFileW(hFind
, &findData
) != 0)
715 if (findData
.dwFileAttributes
& FILE_ATTRIBUTE_DIRECTORY
)
716 rc
= ACTION_RecurseSearchDirectory(package
, appFound
,
717 sig
, findData
.cFileName
, depth
- 1);
722 HeapFree(GetProcessHeap(), 0, buf
);
725 rc
= ERROR_OUTOFMEMORY
;
730 static UINT
ACTION_CheckDirectory(MSIPACKAGE
*package
, MSISIGNATURE
*sig
,
733 UINT rc
= ERROR_SUCCESS
;
735 if (GetFileAttributesW(dir
) & FILE_ATTRIBUTE_DIRECTORY
)
737 TRACE("directory exists, setting %s to %s\n",
738 debugstr_w(sig
->Property
), debugstr_w(dir
));
739 rc
= MSI_SetPropertyW(package
, sig
->Property
, dir
);
744 static BOOL
ACTION_IsFullPath(LPCWSTR path
)
746 WCHAR first
= toupperW(path
[0]);
749 if (first
>= 'A' && first
<= 'Z' && path
[1] == ':')
751 else if (path
[0] == '\\' && path
[1] == '\\')
758 static UINT
ACTION_SearchDirectory(MSIPACKAGE
*package
, MSISIGNATURE
*sig
,
759 LPCWSTR expanded
, int depth
)
764 TRACE("%p, %p, %s, %d\n", package
, sig
, debugstr_w(expanded
), depth
);
765 if (ACTION_IsFullPath(expanded
))
768 rc
= ACTION_RecurseSearchDirectory(package
, &found
, sig
,
772 /* Recursively searching a directory makes no sense when the
773 * directory to search is the thing you're trying to find.
775 rc
= ACTION_CheckDirectory(package
, sig
, expanded
);
780 WCHAR pathWithDrive
[MAX_PATH
] = { 'C',':','\\',0 };
781 DWORD drives
= GetLogicalDrives();
786 for (i
= 0; rc
== ERROR_SUCCESS
&& !found
&& i
< 26; i
++)
787 if (drives
& (1 << drives
))
789 pathWithDrive
[0] = 'A' + i
;
790 if (GetDriveTypeW(pathWithDrive
) == DRIVE_FIXED
)
792 lstrcpynW(pathWithDrive
+ 3, expanded
,
793 sizeof(pathWithDrive
) / sizeof(pathWithDrive
[0]) - 3);
795 rc
= ACTION_RecurseSearchDirectory(package
, &found
, sig
,
796 pathWithDrive
, depth
);
798 rc
= ACTION_CheckDirectory(package
, sig
, pathWithDrive
);
802 TRACE("returning %d\n", rc
);
806 static UINT
ACTION_AppSearchDr(MSIPACKAGE
*package
, MSISIGNATURE
*sig
)
810 static const WCHAR ExecSeqQuery
[] = {
811 's','e','l','e','c','t',' ','*',' ',
813 'D','r','L','o','c','a','t','o','r',' ',
814 'w','h','e','r','e',' ','S','i','g','n','a','t','u','r','e','_',' ','=',' ',
815 '\'','%','s','\'',0};
817 TRACE("(package %p, sig %p)\n", package
, sig
);
818 rc
= MSI_OpenQuery(package
->db
, &view
, ExecSeqQuery
, sig
->Name
);
819 if (rc
== ERROR_SUCCESS
)
822 WCHAR buffer
[MAX_PATH
], expanded
[MAX_PATH
];
826 rc
= MSI_ViewExecute(view
, 0);
827 if (rc
!= ERROR_SUCCESS
)
829 TRACE("MSI_ViewExecute returned %d\n", rc
);
832 rc
= MSI_ViewFetch(view
,&row
);
833 if (rc
!= ERROR_SUCCESS
)
835 TRACE("MSI_ViewFetch returned %d\n", rc
);
840 /* check whether parent is set */
842 sz
=sizeof(buffer
)/sizeof(buffer
[0]);
843 rc
= MSI_RecordGetStringW(row
,2,buffer
,&sz
);
844 if (rc
!= ERROR_SUCCESS
)
846 ERR("Error is %x\n",rc
);
851 FIXME(": searching parent (%s) unimplemented\n",
855 /* no parent, now look for path */
857 sz
=sizeof(buffer
)/sizeof(buffer
[0]);
858 rc
= MSI_RecordGetStringW(row
,3,buffer
,&sz
);
859 if (rc
!= ERROR_SUCCESS
)
861 ERR("Error is %x\n",rc
);
864 if (MSI_RecordIsNull(row
,4))
867 depth
= MSI_RecordGetInteger(row
,4);
868 ACTION_ExpandAnyPath(package
, buffer
, expanded
,
869 sizeof(expanded
) / sizeof(expanded
[0]));
870 rc
= ACTION_SearchDirectory(package
, sig
, expanded
, depth
);
873 msiobj_release(&row
->hdr
);
875 msiobj_release(&view
->hdr
);
879 TRACE("MSI_OpenQuery returned %d\n", rc
);
884 TRACE("returning %d\n", rc
);
888 /* http://msdn.microsoft.com/library/en-us/msi/setup/appsearch_table.asp
889 * is the best reference for the AppSearch table and how it's used.
891 UINT
ACTION_AppSearch(MSIPACKAGE
*package
)
895 static const WCHAR ExecSeqQuery
[] = {
896 's','e','l','e','c','t',' ','*',' ',
898 'A','p','p','S','e','a','r','c','h',0};
900 rc
= MSI_OpenQuery(package
->db
, &view
, ExecSeqQuery
);
901 if (rc
== ERROR_SUCCESS
)
904 WCHAR propBuf
[0x100], sigBuf
[0x100];
907 BOOL appFound
= FALSE
;
909 rc
= MSI_ViewExecute(view
, 0);
910 if (rc
!= ERROR_SUCCESS
)
915 rc
= MSI_ViewFetch(view
,&row
);
916 if (rc
!= ERROR_SUCCESS
)
922 /* get property and signature */
924 sz
=sizeof(propBuf
)/sizeof(propBuf
[0]);
925 rc
= MSI_RecordGetStringW(row
,1,propBuf
,&sz
);
926 if (rc
!= ERROR_SUCCESS
)
928 ERR("Error is %x\n",rc
);
929 msiobj_release(&row
->hdr
);
933 sz
=sizeof(sigBuf
)/sizeof(sigBuf
[0]);
934 rc
= MSI_RecordGetStringW(row
,2,sigBuf
,&sz
);
935 if (rc
!= ERROR_SUCCESS
)
937 ERR("Error is %x\n",rc
);
938 msiobj_release(&row
->hdr
);
941 TRACE("Searching for Property %s, Signature_ %s\n",
942 debugstr_w(propBuf
), debugstr_w(sigBuf
));
943 /* This clears all the fields, so set Name and Property afterward */
944 rc
= ACTION_AppSearchGetSignature(package
, &sig
, sigBuf
);
946 sig
.Property
= propBuf
;
947 if (rc
== ERROR_SUCCESS
)
949 rc
= ACTION_AppSearchComponents(package
, &appFound
, &sig
);
950 if (rc
== ERROR_SUCCESS
&& !appFound
)
952 rc
= ACTION_AppSearchReg(package
, &appFound
, &sig
);
953 if (rc
== ERROR_SUCCESS
&& !appFound
)
955 rc
= ACTION_AppSearchIni(package
, &appFound
, &sig
);
956 if (rc
== ERROR_SUCCESS
&& !appFound
)
957 rc
= ACTION_AppSearchDr(package
, &sig
);
961 HeapFree(GetProcessHeap(), 0, sig
.File
);
962 HeapFree(GetProcessHeap(), 0, sig
.Languages
);
963 msiobj_release(&row
->hdr
);
968 msiobj_release(&view
->hdr
);