reactos/dll/win32/msi/appsearch.c
Mikhail f4be6dc36f
[MSIEXEC][MSI] Sync msiexec and msi to wine-9.8 (#6897)
* [MSIEXEC] Sync msiexec to wine-9.8

* [WINESYNC] msi: Disable FS redirection for temporary file in cabinet_copy_file().

wine commit id a58c6251870dfb7d214464e709bbbc9ca649b900 by Paul Gofman <pgofman@codeweavers.com>

* [WINESYNC] msi/tests: Correct a couple of failure messages in test_msirecord.

wine commit id 2fde0a3f5c233b0ea1637f409998ce4ee85d28a7 by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Use the wcsdup function instead of reimplementing it.

wine commit id 7cc7a6defc08d4de7574b7a75d574c3ab1f32db8 by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Use _O_* constants from fcntl.h instead of redefining them.

wine commit id b07c95e79cdf6ae26c5170daa481ad160e0ce76a by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Remove wrappers around CRT memory allocation functions.

wine commit id d920aa81ad0c4618c27ebd7e9863618e988328e0 by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Initialize all members of WINTRUST_DATA.

The pSignatureSettings field was not unitilized so it got a random value from
the stack causing a later crash when it was dereferenced in Wintrust
(SoftPubloadSignature).

wine commit id 904bedb3e96bc68101652e151db102532399abe8 by Philip K. Gisslow <ripxorip@gmail.com>

* [WINESYNC] msi: Fix memory leak on realloc failure in create_diff_row_query (cppcheck).

wine commit id 3e231d0f36a56ce991c7edbb6ae7845094e8417e by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Fix memory leak on realloc failure in msi_get_window_text (cppcheck).

wine commit id 6c1dd0f2c5669e084eb1f84571c38761a97c0970 by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Fix memory leak on realloc failure in search_directory (cppcheck).

wine commit id d394df4a30feb685927908fce2887bf5496b5d66 by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] ntdll: Default to Windows 10.

wine commit id 69154f0329aec4fb64886a0689da198b5323dcde by Hans Leidekker <hans@codeweavers.com>

* [MSI] Fix build

* [WINESYNC] Update winesync file

* [WINESYNC] msi/tests: Avoid test failures when running with insufficient rights.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51040

wine commit id 79ec3d9fb8551e84e9ff71dcf18861430246278a by Hans Leidekker <hans@codeweavers.com>

* [WINESYNC] msi: Install and patch global assemblies in InstallFinalize.

Installing global assemblies requires assembly caches to be initialized and
this is no longer the case after the PE conversion (builtin fusion no longer
loads if the dll is not present on disk).

The next patch changes msi to perform late initialization of the assembly
caches so that native fusion can be loaded once it's installed by .NET
installers. However, there's no guarantee that all necessary files and
registry keys are installed before the InstallFiles and PatchFiles actions
are executed. Therefore this patch moves the parts of these actions handling
global assemblies to InstallFinalize.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51345

wine commit id 2c450fd6215c0da4685143f97ece8b6db0f54a0b by Hans Leidekker <hans@codeweavers.com>

* [WINESYNC] msi: Perform late initialization of the assembly caches.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51345

wine commit id d9d700f3328f00ec419571df0e02cef208fa1e7b by Hans Leidekker <hans@codeweavers.com>

* [WINESYNC] msi: Remove msi_ prefix from static functions.

wine commit id 3611398b7575177b91e8162a84ebca977c50c2f5 by Hans Leidekker <hans@codeweavers.com>

* [WINESYNC] msi: Get rid of unnecessary typedefs.

wine commit id 258012742512a4072265fcc47826c52319bd37ab by Hans Leidekker <hans@codeweavers.com>

* [WINESYNC] msi: Handle memory allocation failure in get_link_file (cppcheck).

wine commit id 687c4f5c8dc65def6fc066d5d802d7448db70d7f by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Annotate memory allocation functions with __WINE_(DEALLOC|MALLOC).

wine commit id 9df04bfdb03a3017f532e70a047ee83290dbc257 by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi/tests: Fix the ok() formats so they match the size of their arguments.

wine commit id b6fb1b8983af7644b78bb0ba5fb9d18a1f0822f1 by Francois Gouget <fgouget@codeweavers.com>

* [WINESYNC] msi/tests: Ok_() takes printf-style arguments.

This lets the compiler check that the format and argument sizes match.

wine commit id a80b183af74194a06af3281ee272590a7134b7f1 by Francois Gouget <fgouget@codeweavers.com>

* [WINESYNC] msi: Return ERROR_OUTOFMEMORY if calloc fails in TransformView_Create (scan-build).

Instead of ERROR_SUCCESS.

wine commit id daa20d9d636057d7009ff3652a8577b423d23fcf by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Make TransformView_Create static.

wine commit id 1da5618cbac1214082bfb897dc81804d14fc6e9e by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Fix memory leak in ready_media (scan-build).

base_url was never freed, and can simply be enlarged instead of copying
it to a new buffer.

wine commit id c39f785b34692ee994b2449cc17a96815517e9bf by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Fix memory leak on error path in MSI_ProcessMessage (scan-build).

wine commit id d06b3fd5274b056c720e2fb42eb189052d99404d by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Release record instead of free.

../dlls/msi/dialog.c:4476:11: warning: attempt to call free on non-heap object 'hdr' [-Wfree-nonheap-object]
    free( &rec->hdr );
          ^

wine commit id 7b3690dd7399cd64123554c8a6fc7e35dcbebbe1 by Daniel Lehman <dlehman25@gmail.com>

* [WINESYNC] include: Remove redundant __WINE_USE_MSVCRT checks.

wine commit id 93630ce14ebf16333fda8481b5ede6f587eb32ca by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] msi: Fix memory leak on error path in MSI_OpenPackageW (scan-build).

wine commit id 4db2ffa60e16e06b4f6ef89fcc4c73229f4446b1 by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Fix double free on error paths in TransformView_Create (scan-build).

If TransformView_Create returns an error, it should not return a pointer
that table_load_transform will try to free.

wine commit id 0653409e0631582d89edaab0ac516994710dae1a by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Fix memory leaks in HANDLE_CustomType23 (scan-build).

wine commit id 993f4d48d23477e70e92256890c77687a1c4ba08 by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Reject shorter/longer lines in MsiDatabaseImportA.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54532
Signed-off-by: David Kahurani <k.kahurani@gmail.com>

wine commit id e1ddc58a259d80f16bf1e62f23428775e1b070a0 by David Kahurani <k.kahurani@gmail.com>

* [WINESYNC] msi: Convert newlines to alternate representation when exporting.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54532
Signed-off-by: David Kahurani <k.kahurani@gmail.com>

wine commit id 60e4f8a261ae9044aafa9c4eec2a3f2aec6481b5 by David Kahurani <k.kahurani@gmail.com>

* [WINESYNC] msi: Remove DECLSPEC_HIDDEN usage.

wine commit id 51049c95a242f1553562a442142e813e37cee233 by Alistair Leslie-Hughes <leslie_alistair@hotmail.com>

* [MSI] remove DECLSPEC_HIDDEN

* [WINESYNC] msi: Fully initialize the control structure in dialog_line_control().

Fixes: 76606eaea034c51a73190aac92e75d8b20e82164
Fixes: 174b7b51ac9e57c6cfa8f48e62bbf468ae3b1f24

wine commit id 735584076efafc29673e0c9418a64343634f9aa5 by Jinoh Kang <jinoh.kang.kr@gmail.com>

* [WINESYNC] msi: Make insertion order of line controls consistent with other controls.

Fixes: 2c5bd49297f79d9941a256d8ec61e0eb2bf9bf9c

wine commit id 3eceda2f2a77754f0bf93ea33018e8ef49e82669 by Jinoh Kang <jinoh.kang.kr@gmail.com>

* [WINESYNC] msi: Don't open code dialog_add_control() in dialog_line_control().

Commit b1cc87cb656 ("msi: The line control has a height of exactly 2
device units.", 2007-12-16) open-coded the body of
(msi_)dialog_add_control() inside dialog_line_control() modulo the
height override.

Except the fixed height, line controls have nothing special compared to
other controls.  Thus, there is little merit in open-coding it.

Also, dialog_line_control() has bit-rotted over time; it already missed
a few changes that were done to any other controls.

Fix this by just using dialog_add_control().  Also, add a special case
logic just for line controls.

wine commit id 1fca47b724b3835ac0267f58c5b3486fc222fc71 by Jinoh Kang <jinoh.kang.kr@gmail.com>

* [WINESYNC] msi: Use nameless unions/structs.

wine commit id 8de0a9dc740d3ed1e3cf9460852db7e609122f3b by Alexandre Julliard <julliard@winehq.org>

* [MSI] disable nameless structs

* [WINESYNC] msi/tests: Use nameless unions/structs.

wine commit id 490aee03e45222aa9d7e3e7fd6ff80064dc3778d by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] makedep: Use #pragma makedep testdll for TESTDLL resources.

wine commit id 81da9ff0f8dea4932a3afdc4c447c1c9242bb596 by Rémi Bernon <rbernon@codeweavers.com>

* [WINESYNC] msi: Use CreateFileW() for handling path from cabinet_open() instead.

wine commit id 085e95cd5eceb36c3e21cb7d42adab5a6af38a38 by Jactry Zeng <jzeng@codeweavers.com>

* [WINESYNC] msiexec: Use CRT allocation functions.

wine commit id 0f44b3bdcb3d91701a9a8ef1ad07f3e88c08a666 by Alex Henrie <alexhenrie24@gmail.com>

* [WINESYNC] msi: Remove DECLSPEC_HIDDEN usage.

wine commit id 91e81083458374706bbace11114f4ad5e473ac07 by Alistair Leslie-Hughes <leslie_alistair@hotmail.com>

* [WINESYNC] msi: Store Context as MSIINSTALLCONTEXT in MSIPACKAGE.

Avoids casting to enum pointer in msi_locate_product call.

wine commit id 2daa8c9f95b35983c885f5f7efe9e1b48e91f679 by Jacek Caban <jacek@codeweavers.com>

* [WINESYNC] msi/tests: Initialize pathkey in test_installprops.

It could be used uninitialized on early no access return.

wine commit id 93668319dd63add97036fbb79b5745c699117313 by Jacek Caban <jacek@codeweavers.com>

* [WINESYNC] regsvr32: Use message boxes by default for output.

regsvr32 is in GUI subsystem and shouldn't interact with console.
Keeping unix I/O output in silent mode.
Removing -c option as not existing in native.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>

wine commit id ac8da35b87005e45947b8164a4132f3bbb4ec2cc by Eric Pouech <epouech@codeweavers.com>

* [MSI]: Reduce diff

* [WINESYNC] msiexec: No longer use console/file output APIs.

Regular GUI apps don't.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>

wine commit id e048f71ecbb103ae7c1876092cb8244b24a73cb7 by Eric Pouech <epouech@codeweavers.com>

* [WINESYNC] msi: Fix a memory leak (Coverity).

wine commit id 4afca1787febb012d0cdd2c007dd32beba35178d by Zhiyi Zhang <zzhang@codeweavers.com>

* [WINESYNC] msi: Don't write past end of string when selecting parent directory.

wine commit id bbce5d014db7f023b133d6d09e6846e027586f7d by Fabian Maurer <dark.shadow4@web.de>

* [WINESYNC] msi: Avoid leaking stream on DB update.

MSI_RecordGetIStream adds a reference to the stream. This
reference should be negated as we are done setting the stream.

Signed-off-by: David Kahurani <k.kahurani@gmail.com>

wine commit id 386dbe1059ba08485696760c267ef06dbed95bad by David Kahurani <k.kahurani@gmail.com>

* [WINESYNC] msi/tests: Expand costing tests.

wine commit id 674efeb1f7445935cf4f49dd1285727055664ab9 by Zebediah Figura <zfigura@codeweavers.com>

* [WINESYNC] msi: Round costs up to 4096 bytes instead of clamping.

wine commit id 9725a2286acdb791de316295d9bcb11411a3fd56 by Zebediah Figura <zfigura@codeweavers.com>

* [WINESYNC] msi: Store component cost in 512-byte units.

This avoids overflow when component costs exceed 4 GB.

wine commit id d7bbe884ef29215f4db2027f450fb959314f5383 by Zebediah Figura <zfigura@codeweavers.com>

* [MSI] store component cost in 512-byte units

* [WINESYNC] msi: Multiply by 512 in dialog_vcl_add_drives().

The main motivation here is to avoid overflow, and multiplying in one place seems simpler.

wine commit id 4a227c62a59a55aff9bacf1473c7f478f5c83294 by Zebediah Figura <zfigura@codeweavers.com>

* [MSI] reduce diff

* [WINESYNC] msi: Create the custom action server as an elevated process.

Dragon Naturally Speaking 12.5 manually validates that the custom action server
is elevated.

One might imagine that the right approach here is to add a manifest to msiexec;
however, msiexec does not always trigger a UAC prompt on Windows.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51143

wine commit id 366398cc53c76028c8dfe8d8a16c78a6a10ce962 by Zebediah Figura <z.figura12@gmail.com>

* [WINESYNC] msi/tests: Delete the temp .msi file in all failure cases.

wine commit id 43fb0ecd0717ad1a6aa0702ed68368ee35d3ecda by Alexandre Julliard <julliard@winehq.org>

* [WINESYNC] msi/tests: Use the helpers from utils.h in more modules.

wine commit id b3f11ceb7a0ddcf5fe742377f99c947b0b56a051 by Hans Leidekker <hans@codeweavers.com>

* [MSITEST] include util header

* [WINESYNC] msi/tests: Try restarting tests elevated.

Wine starts processes non-elevated since e92ba2de43d7afbe0704b11b29f7c30f44dfaeca
which means that many tests are skipped now.

wine commit id a6eb51f0e595b2e5ddc521fb61b10d72849dd0f2 by Hans Leidekker <hans@codeweavers.com>

* [MSITEST] try restarting for tests elevated

* [WINESYNC] msi/tests: Get rid of workarounds for old Windows versions.

wine commit id 738ec8285583248a84349939734ed600a47ba73d by Hans Leidekker <hans@codeweavers.com>

* [MSI] fix patch failed

* [WINESYNC] msi: Install global assemblies before running deferred custom actions.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56493

wine commit id 7f0ca9c284d15d03f14a8fefefac834990d622cd by Hans Leidekker <hans@codeweavers.com>

* [WINESYNC] msi: Install global assemblies after install custom actions and before commit custom actions.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56609

wine commit id 27f5470ff4c20121b9eacd702c888400191c7d9e by Hans Leidekker <hans@codeweavers.com>

* [WINESYNC]: msi is now in sync with wine-staging wine-9.8

* [MSI] Fix build

* [WINESYNC] Update WINESYNC doc

* [MSI] Remove nonameless* defines

* [MSIEXEC] Fix build

* [MSIEXEC] Fix build

* [MSI] Fix vcl_get_cost
2024-09-29 10:24:15 -07:00

1145 lines
32 KiB
C

/*
* Implementation of the AppSearch action of the Microsoft Installer (msi.dll)
*
* Copyright 2005 Juan Lang
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "msi.h"
#include "msiquery.h"
#include "msidefs.h"
#include "winver.h"
#include "shlwapi.h"
#include "wine/debug.h"
#include "msipriv.h"
WINE_DEFAULT_DEBUG_CHANNEL(msi);
struct signature
{
LPCWSTR Name; /* NOT owned by this structure */
LPWSTR File;
DWORD MinVersionMS;
DWORD MinVersionLS;
DWORD MaxVersionMS;
DWORD MaxVersionLS;
DWORD MinSize;
DWORD MaxSize;
FILETIME MinTime;
FILETIME MaxTime;
LPWSTR Languages;
};
void msi_parse_version_string(LPCWSTR verStr, PDWORD ms, PDWORD ls)
{
const WCHAR *ptr;
int x1 = 0, x2 = 0, x3 = 0, x4 = 0;
x1 = wcstol(verStr, NULL, 10);
ptr = wcschr(verStr, '.');
if (ptr)
{
x2 = wcstol(ptr + 1, NULL, 10);
ptr = wcschr(ptr + 1, '.');
}
if (ptr)
{
x3 = wcstol(ptr + 1, NULL, 10);
ptr = wcschr(ptr + 1, '.');
}
if (ptr)
x4 = wcstol(ptr + 1, NULL, 10);
/* FIXME: byte-order dependent? */
*ms = x1 << 16 | x2;
if (ls) *ls = x3 << 16 | x4;
}
/* Fills in sig with the values from the Signature table, where name is the
* signature to find. Upon return, sig->File will be NULL if the record is not
* found, and not NULL if it is found.
* Warning: clears all fields in sig!
* Returns ERROR_SUCCESS upon success (where not finding the record counts as
* success), something else on error.
*/
static UINT get_signature( MSIPACKAGE *package, struct signature *sig, const WCHAR *name )
{
WCHAR *minVersion, *maxVersion, *p;
MSIRECORD *row;
DWORD time;
TRACE("package %p, sig %p\n", package, sig);
memset(sig, 0, sizeof(*sig));
sig->Name = name;
row = MSI_QueryGetRecord( package->db, L"SELECT * FROM `Signature` WHERE `Signature` = '%s'", name );
if (!row)
{
TRACE("failed to query signature for %s\n", debugstr_w(name));
return ERROR_SUCCESS;
}
/* get properties */
sig->File = msi_dup_record_field(row,2);
if ((p = wcschr(sig->File, '|')))
{
p++;
memmove(sig->File, p, (lstrlenW(p) + 1) * sizeof(WCHAR));
}
minVersion = msi_dup_record_field(row,3);
if (minVersion)
{
msi_parse_version_string( minVersion, &sig->MinVersionMS, &sig->MinVersionLS );
free( minVersion );
}
maxVersion = msi_dup_record_field(row,4);
if (maxVersion)
{
msi_parse_version_string( maxVersion, &sig->MaxVersionMS, &sig->MaxVersionLS );
free( maxVersion );
}
sig->MinSize = MSI_RecordGetInteger(row,5);
if (sig->MinSize == MSI_NULL_INTEGER)
sig->MinSize = 0;
sig->MaxSize = MSI_RecordGetInteger(row,6);
if (sig->MaxSize == MSI_NULL_INTEGER)
sig->MaxSize = 0;
sig->Languages = msi_dup_record_field(row,9);
time = MSI_RecordGetInteger(row,7);
if (time != MSI_NULL_INTEGER)
DosDateTimeToFileTime(HIWORD(time), LOWORD(time), &sig->MinTime);
time = MSI_RecordGetInteger(row,8);
if (time != MSI_NULL_INTEGER)
DosDateTimeToFileTime(HIWORD(time), LOWORD(time), &sig->MaxTime);
TRACE("Found file name %s for Signature_ %s;\n",
debugstr_w(sig->File), debugstr_w(name));
TRACE("MinVersion is %d.%d.%d.%d\n", HIWORD(sig->MinVersionMS),
LOWORD(sig->MinVersionMS), HIWORD(sig->MinVersionLS),
LOWORD(sig->MinVersionLS));
TRACE("MaxVersion is %d.%d.%d.%d\n", HIWORD(sig->MaxVersionMS),
LOWORD(sig->MaxVersionMS), HIWORD(sig->MaxVersionLS),
LOWORD(sig->MaxVersionLS));
TRACE("MinSize is %lu, MaxSize is %lu\n", sig->MinSize, sig->MaxSize);
TRACE("Languages is %s\n", debugstr_w(sig->Languages));
msiobj_release( &row->hdr );
return ERROR_SUCCESS;
}
/* Frees any memory allocated in sig */
static void free_signature( struct signature *sig )
{
free(sig->File);
free(sig->Languages);
}
static WCHAR *search_file( MSIPACKAGE *package, WCHAR *path, struct signature *sig )
{
VS_FIXEDFILEINFO *info;
DWORD attr;
UINT size;
LPWSTR val = NULL;
LPBYTE buffer;
if (!sig->File)
{
PathRemoveFileSpecW(path);
PathAddBackslashW(path);
attr = msi_get_file_attributes( package, path );
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY))
return wcsdup(path);
return NULL;
}
attr = msi_get_file_attributes( package, path );
if (attr == INVALID_FILE_ATTRIBUTES || (attr & FILE_ATTRIBUTE_DIRECTORY))
return NULL;
size = msi_get_file_version_info( package, path, 0, NULL );
if (!size)
return wcsdup(path);
buffer = malloc(size);
if (!buffer)
return NULL;
size = msi_get_file_version_info( package, path, size, buffer );
if (!size)
goto done;
if (!VerQueryValueW(buffer, L"\\", (LPVOID)&info, &size) || !info)
goto done;
if (sig->MinVersionLS || sig->MinVersionMS)
{
if (info->dwFileVersionMS < sig->MinVersionMS)
goto done;
if (info->dwFileVersionMS == sig->MinVersionMS &&
info->dwFileVersionLS < sig->MinVersionLS)
goto done;
}
if (sig->MaxVersionLS || sig->MaxVersionMS)
{
if (info->dwFileVersionMS > sig->MaxVersionMS)
goto done;
if (info->dwFileVersionMS == sig->MaxVersionMS &&
info->dwFileVersionLS > sig->MaxVersionLS)
goto done;
}
val = wcsdup(path);
done:
free(buffer);
return val;
}
static UINT search_components( MSIPACKAGE *package, WCHAR **appValue, struct signature *sig )
{
MSIRECORD *row, *rec;
LPCWSTR signature, guid;
BOOL sigpresent = TRUE;
BOOL isdir;
UINT type;
WCHAR path[MAX_PATH];
DWORD size = MAX_PATH;
LPWSTR ptr;
DWORD attr;
TRACE("%s\n", debugstr_w(sig->Name));
*appValue = NULL;
row = MSI_QueryGetRecord(package->db, L"SELECT * FROM `CompLocator` WHERE `Signature_` = '%s'", sig->Name);
if (!row)
{
TRACE("failed to query CompLocator for %s\n", debugstr_w(sig->Name));
return ERROR_SUCCESS;
}
signature = MSI_RecordGetString(row, 1);
guid = MSI_RecordGetString(row, 2);
type = MSI_RecordGetInteger(row, 3);
rec = MSI_QueryGetRecord(package->db, L"SELECT * FROM `Signature` WHERE `Signature` = '%s'", signature);
if (!rec)
sigpresent = FALSE;
*path = '\0';
MsiLocateComponentW(guid, path, &size);
if (!*path)
goto done;
attr = msi_get_file_attributes( package, path );
if (attr == INVALID_FILE_ATTRIBUTES)
goto done;
isdir = (attr & FILE_ATTRIBUTE_DIRECTORY);
if (type != msidbLocatorTypeDirectory && sigpresent && !isdir)
{
*appValue = search_file( package, path, sig );
}
else if (!sigpresent && (type != msidbLocatorTypeDirectory || isdir))
{
if (type == msidbLocatorTypeFileName)
{
ptr = wcsrchr(path, '\\');
*(ptr + 1) = '\0';
}
else
PathAddBackslashW(path);
*appValue = wcsdup(path);
}
else if (sigpresent)
{
PathAddBackslashW(path);
lstrcatW(path, MSI_RecordGetString(rec, 2));
attr = msi_get_file_attributes( package, path );
if (attr != INVALID_FILE_ATTRIBUTES && !(attr & FILE_ATTRIBUTE_DIRECTORY))
*appValue = wcsdup(path);
}
done:
if (rec) msiobj_release(&rec->hdr);
msiobj_release(&row->hdr);
return ERROR_SUCCESS;
}
static void convert_reg_value( DWORD regType, const BYTE *value, DWORD sz, WCHAR **appValue )
{
LPWSTR ptr;
DWORD i;
switch (regType)
{
case REG_SZ:
if (*(LPCWSTR)value == '#')
{
/* escape leading pound with another */
*appValue = malloc(sz + sizeof(WCHAR));
(*appValue)[0] = '#';
lstrcpyW(*appValue + 1, (LPCWSTR)value);
}
else
{
*appValue = malloc(sz);
lstrcpyW(*appValue, (LPCWSTR)value);
}
break;
case REG_DWORD:
/* 7 chars for digits, 1 for NULL, 1 for #, and 1 for sign
* char if needed
*/
*appValue = malloc(10 * sizeof(WCHAR));
swprintf(*appValue, 10, L"#%d", *(const DWORD *)value);
break;
case REG_EXPAND_SZ:
sz = ExpandEnvironmentStringsW((LPCWSTR)value, NULL, 0);
*appValue = malloc(sz * sizeof(WCHAR));
ExpandEnvironmentStringsW((LPCWSTR)value, *appValue, sz);
break;
case REG_BINARY:
/* #x<nibbles>\0 */
*appValue = malloc((sz * 2 + 3) * sizeof(WCHAR));
lstrcpyW(*appValue, L"#x");
ptr = *appValue + lstrlenW(L"#x");
for (i = 0; i < sz; i++, ptr += 2)
swprintf(ptr, 3, L"%02X", value[i]);
break;
default:
WARN( "unimplemented for values of type %lu\n", regType );
*appValue = NULL;
}
}
static UINT search_directory( MSIPACKAGE *, struct signature *, const WCHAR *, int, WCHAR ** );
static UINT search_reg( MSIPACKAGE *package, WCHAR **appValue, struct signature *sig )
{
const WCHAR *keyPath, *valueName;
WCHAR *deformatted = NULL, *ptr = NULL, *end;
int root, type;
REGSAM access = KEY_READ;
HKEY rootKey, key = NULL;
DWORD sz = 0, regType;
LPBYTE value = NULL;
MSIRECORD *row;
UINT rc;
TRACE("%s\n", debugstr_w(sig->Name));
*appValue = NULL;
row = MSI_QueryGetRecord( package->db, L"SELECT * FROM `RegLocator` WHERE `Signature_` = '%s'", sig->Name );
if (!row)
{
TRACE("failed to query RegLocator for %s\n", debugstr_w(sig->Name));
return ERROR_SUCCESS;
}
root = MSI_RecordGetInteger(row, 2);
keyPath = MSI_RecordGetString(row, 3);
valueName = MSI_RecordGetString(row, 4);
type = MSI_RecordGetInteger(row, 5);
deformat_string(package, keyPath, &deformatted);
switch (root)
{
case msidbRegistryRootClassesRoot:
rootKey = HKEY_CLASSES_ROOT;
break;
case msidbRegistryRootCurrentUser:
rootKey = HKEY_CURRENT_USER;
break;
case msidbRegistryRootLocalMachine:
rootKey = HKEY_LOCAL_MACHINE;
if (type & msidbLocatorType64bit) access |= KEY_WOW64_64KEY;
else access |= KEY_WOW64_32KEY;
break;
case msidbRegistryRootUsers:
rootKey = HKEY_USERS;
break;
default:
WARN("Unknown root key %d\n", root);
goto end;
}
rc = RegOpenKeyExW( rootKey, deformatted, 0, access, &key );
if (rc)
{
TRACE("RegOpenKeyExW returned %d\n", rc);
goto end;
}
free(deformatted);
deformat_string(package, valueName, &deformatted);
rc = RegQueryValueExW(key, deformatted, NULL, NULL, NULL, &sz);
if (rc)
{
TRACE("RegQueryValueExW returned %d\n", rc);
goto end;
}
/* FIXME: sanity-check sz before allocating (is there an upper-limit
* on the value of a property?)
*/
value = malloc(sz);
rc = RegQueryValueExW(key, deformatted, NULL, &regType, value, &sz);
if (rc)
{
TRACE("RegQueryValueExW returned %d\n", rc);
goto end;
}
/* bail out if the registry key is empty */
if (sz == 0)
goto end;
/* expand if needed */
if (regType == REG_EXPAND_SZ)
{
sz = ExpandEnvironmentStringsW((LPCWSTR)value, NULL, 0);
if (sz)
{
WCHAR *buf = malloc(sz * sizeof(WCHAR));
ExpandEnvironmentStringsW((LPCWSTR)value, buf, sz);
free(value);
value = (LPBYTE)buf;
}
}
if ((regType == REG_SZ || regType == REG_EXPAND_SZ) &&
(ptr = wcschr((LPWSTR)value, '"')) && (end = wcschr(++ptr, '"')))
*end = '\0';
else
ptr = (LPWSTR)value;
switch (type & 0x0f)
{
case msidbLocatorTypeDirectory:
search_directory( package, sig, ptr, 0, appValue );
break;
case msidbLocatorTypeFileName:
*appValue = search_file( package, ptr, sig );
break;
case msidbLocatorTypeRawValue:
convert_reg_value( regType, value, sz, appValue );
break;
default:
FIXME("unimplemented for type %d (key path %s, value %s)\n",
type, debugstr_w(keyPath), debugstr_w(valueName));
}
end:
free( value );
RegCloseKey( key );
free( deformatted );
msiobj_release(&row->hdr);
return ERROR_SUCCESS;
}
static LPWSTR get_ini_field(LPWSTR buf, int field)
{
LPWSTR beg, end;
int i = 1;
if (field == 0)
return wcsdup(buf);
beg = buf;
while ((end = wcschr(beg, ',')) && i < field)
{
beg = end + 1;
while (*beg == ' ')
beg++;
i++;
}
end = wcschr(beg, ',');
if (!end)
end = beg + lstrlenW(beg);
*end = '\0';
return wcsdup(beg);
}
static UINT search_ini( MSIPACKAGE *package, WCHAR **appValue, struct signature *sig )
{
MSIRECORD *row;
LPWSTR fileName, section, key;
int field, type;
WCHAR buf[MAX_PATH];
TRACE("%s\n", debugstr_w(sig->Name));
*appValue = NULL;
row = MSI_QueryGetRecord( package->db, L"SELECT * FROM `IniLocator` WHERE `Signature_` = '%s'", sig->Name );
if (!row)
{
TRACE("failed to query IniLocator for %s\n", debugstr_w(sig->Name));
return ERROR_SUCCESS;
}
fileName = msi_dup_record_field(row, 2);
section = msi_dup_record_field(row, 3);
key = msi_dup_record_field(row, 4);
field = MSI_RecordGetInteger(row, 5);
type = MSI_RecordGetInteger(row, 6);
if (field == MSI_NULL_INTEGER)
field = 0;
if (type == MSI_NULL_INTEGER)
type = 0;
GetPrivateProfileStringW(section, key, NULL, buf, MAX_PATH, fileName);
if (buf[0])
{
switch (type & 0x0f)
{
case msidbLocatorTypeDirectory:
search_directory( package, sig, buf, 0, appValue );
break;
case msidbLocatorTypeFileName:
*appValue = search_file( package, buf, sig );
break;
case msidbLocatorTypeRawValue:
*appValue = get_ini_field(buf, field);
break;
}
}
free(fileName);
free(section);
free(key);
msiobj_release(&row->hdr);
return ERROR_SUCCESS;
}
/* Expands the value in src into a path without property names and only
* containing long path names into dst. Replaces at most len characters of dst,
* and always NULL-terminates dst if dst is not NULL and len >= 1.
* May modify src.
* Assumes src and dst are non-overlapping.
* FIXME: return code probably needed:
* - what does AppSearch return if the table values are invalid?
* - what if dst is too small?
*/
static void expand_any_path( MSIPACKAGE *package, WCHAR *src, WCHAR *dst, size_t len )
{
WCHAR *ptr, *deformatted;
if (!src || !dst || !len)
{
if (dst) *dst = '\0';
return;
}
dst[0] = '\0';
/* Ignore the short portion of the path */
if ((ptr = wcschr(src, '|')))
ptr++;
else
ptr = src;
deformat_string(package, ptr, &deformatted);
if (!deformatted || lstrlenW(deformatted) > len - 1)
{
free(deformatted);
return;
}
lstrcpyW(dst, deformatted);
dst[lstrlenW(deformatted)] = '\0';
free(deformatted);
}
static LANGID *parse_languages( const WCHAR *languages, DWORD *num_ids )
{
UINT i, count = 1;
WCHAR *str = wcsdup( languages ), *p, *q;
LANGID *ret;
if (!str) return NULL;
for (p = q = str; (q = wcschr( q, ',' )); q++) count++;
if (!(ret = malloc( count * sizeof(LANGID) )))
{
free( str );
return NULL;
}
i = 0;
while (*p)
{
q = wcschr( p, ',' );
if (q) *q = 0;
ret[i] = wcstol( p, NULL, 10 );
if (!q) break;
p = q + 1;
i++;
}
free( str );
*num_ids = count;
return ret;
}
static BOOL match_languages( const void *version, const WCHAR *languages )
{
struct lang
{
USHORT id;
USHORT codepage;
} *lang;
UINT len, j;
DWORD num_ids, i;
BOOL found = FALSE;
LANGID *ids;
if (!languages || !languages[0]) return TRUE;
if (!VerQueryValueW( version, L"\\VarFileInfo\\Translation", (void **)&lang, &len )) return FALSE;
if (!(ids = parse_languages( languages, &num_ids ))) return FALSE;
for (i = 0; i < num_ids; i++)
{
found = FALSE;
for (j = 0; j < len / sizeof(struct lang); j++)
{
if (!ids[i] || ids[i] == lang[j].id) found = TRUE;
}
if (!found) goto done;
}
done:
free( ids );
return found;
}
/* Sets *matches to whether the file (whose path is filePath) matches the
* versions set in sig.
* Return ERROR_SUCCESS in case of success (whether or not the file matches),
* something else if an install-halting error occurs.
*/
static UINT file_version_matches( MSIPACKAGE *package, const struct signature *sig, const WCHAR *filePath,
BOOL *matches )
{
UINT len;
void *version;
VS_FIXEDFILEINFO *info = NULL;
DWORD size = msi_get_file_version_info( package, filePath, 0, NULL );
*matches = FALSE;
if (!size) return ERROR_SUCCESS;
if (!(version = malloc( size ))) return ERROR_OUTOFMEMORY;
if (msi_get_file_version_info( package, filePath, size, version ))
VerQueryValueW( version, L"\\", (void **)&info, &len );
if (info)
{
TRACE("comparing file version %d.%d.%d.%d:\n",
HIWORD(info->dwFileVersionMS),
LOWORD(info->dwFileVersionMS),
HIWORD(info->dwFileVersionLS),
LOWORD(info->dwFileVersionLS));
if (info->dwFileVersionMS < sig->MinVersionMS
|| (info->dwFileVersionMS == sig->MinVersionMS &&
info->dwFileVersionLS < sig->MinVersionLS))
{
TRACE("less than minimum version %d.%d.%d.%d\n",
HIWORD(sig->MinVersionMS),
LOWORD(sig->MinVersionMS),
HIWORD(sig->MinVersionLS),
LOWORD(sig->MinVersionLS));
}
else if ((sig->MaxVersionMS || sig->MaxVersionLS) &&
(info->dwFileVersionMS > sig->MaxVersionMS ||
(info->dwFileVersionMS == sig->MaxVersionMS &&
info->dwFileVersionLS > sig->MaxVersionLS)))
{
TRACE("greater than maximum version %d.%d.%d.%d\n",
HIWORD(sig->MaxVersionMS),
LOWORD(sig->MaxVersionMS),
HIWORD(sig->MaxVersionLS),
LOWORD(sig->MaxVersionLS));
}
else if (!match_languages( version, sig->Languages ))
{
TRACE("languages %s not supported\n", debugstr_w( sig->Languages ));
}
else *matches = TRUE;
}
free( version );
return ERROR_SUCCESS;
}
/* Sets *matches to whether the file in findData matches that in sig.
* fullFilePath is assumed to be the full path of the file specified in
* findData, which may be necessary to compare the version.
* Return ERROR_SUCCESS in case of success (whether or not the file matches),
* something else if an install-halting error occurs.
*/
static UINT file_matches_sig( MSIPACKAGE *package, const struct signature *sig, const WIN32_FIND_DATAW *findData,
const WCHAR *fullFilePath, BOOL *matches )
{
UINT rc = ERROR_SUCCESS;
*matches = TRUE;
/* assumes the caller has already ensured the filenames match, so check
* the other fields..
*/
if (sig->MinTime.dwLowDateTime || sig->MinTime.dwHighDateTime)
{
if (findData->ftCreationTime.dwHighDateTime <
sig->MinTime.dwHighDateTime ||
(findData->ftCreationTime.dwHighDateTime == sig->MinTime.dwHighDateTime
&& findData->ftCreationTime.dwLowDateTime <
sig->MinTime.dwLowDateTime))
*matches = FALSE;
}
if (*matches && (sig->MaxTime.dwLowDateTime || sig->MaxTime.dwHighDateTime))
{
if (findData->ftCreationTime.dwHighDateTime >
sig->MaxTime.dwHighDateTime ||
(findData->ftCreationTime.dwHighDateTime == sig->MaxTime.dwHighDateTime
&& findData->ftCreationTime.dwLowDateTime >
sig->MaxTime.dwLowDateTime))
*matches = FALSE;
}
if (*matches && sig->MinSize && findData->nFileSizeLow < sig->MinSize)
*matches = FALSE;
if (*matches && sig->MaxSize && findData->nFileSizeLow > sig->MaxSize)
*matches = FALSE;
if (*matches && (sig->MinVersionMS || sig->MinVersionLS ||
sig->MaxVersionMS || sig->MaxVersionLS))
rc = file_version_matches( package, sig, fullFilePath, matches );
return rc;
}
/* Recursively searches the directory dir for files that match the signature
* sig, up to (depth + 1) levels deep. That is, if depth is 0, it searches dir
* (and only dir). If depth is 1, searches dir and its immediate
* subdirectories.
* Assumes sig->File is not NULL.
* Returns ERROR_SUCCESS on success (which may include non-critical errors),
* something else on failures which should halt the install.
*/
static UINT recurse_search_directory( MSIPACKAGE *package, WCHAR **appValue, struct signature *sig, const WCHAR *dir,
int depth )
{
HANDLE hFind;
WIN32_FIND_DATAW findData;
UINT rc = ERROR_SUCCESS;
size_t dirLen = lstrlenW(dir), fileLen = lstrlenW(sig->File);
WCHAR subpath[MAX_PATH];
WCHAR *buf;
DWORD len;
TRACE("Searching directory %s for file %s, depth %d\n", debugstr_w(dir), debugstr_w(sig->File), depth);
if (depth < 0)
return ERROR_SUCCESS;
*appValue = NULL;
/* We need the buffer in both paths below, so go ahead and allocate it
* here. Add two because we might need to add a backslash if the dir name
* isn't backslash-terminated.
*/
len = dirLen + max(fileLen, lstrlenW(L"*.*")) + 2;
buf = malloc(len * sizeof(WCHAR));
if (!buf)
return ERROR_OUTOFMEMORY;
lstrcpyW(buf, dir);
PathAddBackslashW(buf);
lstrcatW(buf, sig->File);
hFind = msi_find_first_file( package, buf, &findData );
if (hFind != INVALID_HANDLE_VALUE)
{
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
{
BOOL matches;
rc = file_matches_sig( package, sig, &findData, buf, &matches );
if (rc == ERROR_SUCCESS && matches)
{
TRACE("found file, returning %s\n", debugstr_w(buf));
*appValue = buf;
}
}
FindClose(hFind);
}
if (rc == ERROR_SUCCESS && !*appValue)
{
lstrcpyW(buf, dir);
PathAddBackslashW(buf);
lstrcatW(buf, L"*.*");
hFind = msi_find_first_file( package, buf, &findData );
if (hFind != INVALID_HANDLE_VALUE)
{
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
wcscmp( findData.cFileName, L"." ) &&
wcscmp( findData.cFileName, L".." ))
{
lstrcpyW(subpath, dir);
PathAppendW(subpath, findData.cFileName);
rc = recurse_search_directory( package, appValue, sig, subpath, depth - 1 );
}
while (rc == ERROR_SUCCESS && !*appValue && msi_find_next_file( package, hFind, &findData ))
{
if (!wcscmp( findData.cFileName, L"." ) ||
!wcscmp( findData.cFileName, L".." ))
continue;
lstrcpyW(subpath, dir);
PathAppendW(subpath, findData.cFileName);
if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
rc = recurse_search_directory( package, appValue, sig, subpath, depth - 1 );
}
FindClose(hFind);
}
}
if (*appValue != buf)
free(buf);
return rc;
}
static UINT check_directory( MSIPACKAGE *package, const WCHAR *dir, WCHAR **appValue )
{
DWORD attr = msi_get_file_attributes( package, dir );
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY))
{
TRACE("directory exists, returning %s\n", debugstr_w(dir));
*appValue = wcsdup(dir);
}
return ERROR_SUCCESS;
}
static BOOL is_full_path( const WCHAR *path )
{
WCHAR first = towupper(path[0]);
BOOL ret;
if (first >= 'A' && first <= 'Z' && path[1] == ':')
ret = TRUE;
else if (path[0] == '\\' && path[1] == '\\')
ret = TRUE;
else
ret = FALSE;
return ret;
}
static UINT search_directory( MSIPACKAGE *package, struct signature *sig, const WCHAR *path, int depth, WCHAR **appValue )
{
UINT rc;
DWORD attr;
WCHAR *val = NULL, *new_val;
TRACE("%p, %p, %s, %d, %p\n", package, sig, debugstr_w(path), depth, appValue);
if (is_full_path( path ))
{
if (sig->File)
rc = recurse_search_directory( package, &val, sig, path, depth );
else
{
/* Recursively searching a directory makes no sense when the
* directory to search is the thing you're trying to find.
*/
rc = check_directory( package, path, &val );
}
}
else
{
WCHAR pathWithDrive[MAX_PATH] = { 'C',':','\\',0 };
DWORD drives = GetLogicalDrives();
int i;
rc = ERROR_SUCCESS;
for (i = 0; rc == ERROR_SUCCESS && !val && i < 26; i++)
{
if (!(drives & (1 << i)))
continue;
pathWithDrive[0] = 'A' + i;
if (GetDriveTypeW(pathWithDrive) != DRIVE_FIXED)
continue;
lstrcpynW(pathWithDrive + 3, path, ARRAY_SIZE(pathWithDrive) - 3);
if (sig->File)
rc = recurse_search_directory( package, &val, sig, pathWithDrive, depth );
else
rc = check_directory( package, pathWithDrive, &val );
}
}
attr = msi_get_file_attributes( package, val );
if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY) &&
val && val[lstrlenW(val) - 1] != '\\')
{
new_val = realloc(val, (wcslen(val) + 2) * sizeof(WCHAR));
if (!new_val)
{
free(val);
val = NULL;
rc = ERROR_OUTOFMEMORY;
}
else
{
val = new_val;
PathAddBackslashW(val);
}
}
*appValue = val;
TRACE("returning %d\n", rc);
return rc;
}
static UINT search_sig_name( MSIPACKAGE *, const WCHAR *, struct signature *, WCHAR ** );
static UINT search_dr( MSIPACKAGE *package, WCHAR **appValue, struct signature *sig )
{
LPWSTR parent = NULL;
LPCWSTR parentName;
WCHAR path[MAX_PATH];
WCHAR expanded[MAX_PATH];
MSIRECORD *row;
int depth;
DWORD sz, attr;
UINT rc;
TRACE("%s\n", debugstr_w(sig->Name));
*appValue = NULL;
row = MSI_QueryGetRecord( package->db, L"SELECT * FROM `DrLocator` WHERE `Signature_` = '%s'", sig->Name );
if (!row)
{
TRACE("failed to query DrLocator for %s\n", debugstr_w(sig->Name));
return ERROR_SUCCESS;
}
/* check whether parent is set */
parentName = MSI_RecordGetString(row, 2);
if (parentName)
{
struct signature parentSig;
search_sig_name( package, parentName, &parentSig, &parent );
free_signature( &parentSig );
if (!parent)
{
msiobj_release(&row->hdr);
return ERROR_SUCCESS;
}
}
sz = MAX_PATH;
MSI_RecordGetStringW(row, 3, path, &sz);
if (MSI_RecordIsNull(row,4))
depth = 0;
else
depth = MSI_RecordGetInteger(row,4);
if (sz)
expand_any_path( package, path, expanded, MAX_PATH );
else
lstrcpyW(expanded, path);
if (parent)
{
attr = msi_get_file_attributes( package, parent );
if (attr != INVALID_FILE_ATTRIBUTES &&
!(attr & FILE_ATTRIBUTE_DIRECTORY))
{
PathRemoveFileSpecW(parent);
PathAddBackslashW(parent);
}
lstrcpyW(path, parent);
lstrcatW(path, expanded);
}
else if (sz) lstrcpyW(path, expanded);
PathAddBackslashW(path);
rc = search_directory( package, sig, path, depth, appValue );
free(parent);
msiobj_release(&row->hdr);
TRACE("returning %d\n", rc);
return rc;
}
static UINT search_sig_name( MSIPACKAGE *package, const WCHAR *sigName, struct signature *sig, WCHAR **appValue )
{
UINT rc;
*appValue = NULL;
rc = get_signature( package, sig, sigName );
if (rc == ERROR_SUCCESS)
{
rc = search_components( package, appValue, sig );
if (rc == ERROR_SUCCESS && !*appValue)
{
rc = search_reg( package, appValue, sig );
if (rc == ERROR_SUCCESS && !*appValue)
{
rc = search_ini( package, appValue, sig );
if (rc == ERROR_SUCCESS && !*appValue)
rc = search_dr( package, appValue, sig );
}
}
}
return rc;
}
static UINT ITERATE_AppSearch(MSIRECORD *row, LPVOID param)
{
MSIPACKAGE *package = param;
LPCWSTR propName, sigName;
LPWSTR value = NULL;
struct signature sig;
MSIRECORD *uirow;
UINT r;
/* get property and signature */
propName = MSI_RecordGetString(row, 1);
sigName = MSI_RecordGetString(row, 2);
TRACE("%s %s\n", debugstr_w(propName), debugstr_w(sigName));
r = search_sig_name( package, sigName, &sig, &value );
if (value)
{
r = msi_set_property( package->db, propName, value, -1 );
if (r == ERROR_SUCCESS && !wcscmp( propName, L"SourceDir" ))
msi_reset_source_folders( package );
free(value);
}
free_signature( &sig );
uirow = MSI_CreateRecord( 2 );
MSI_RecordSetStringW( uirow, 1, propName );
MSI_RecordSetStringW( uirow, 2, sigName );
MSI_ProcessMessage(package, INSTALLMESSAGE_ACTIONDATA, uirow);
msiobj_release( &uirow->hdr );
return r;
}
UINT ACTION_AppSearch(MSIPACKAGE *package)
{
MSIQUERY *view;
UINT r;
if (msi_action_is_unique(package, L"AppSearch"))
{
TRACE("Skipping AppSearch action: already done in UI sequence\n");
return ERROR_SUCCESS;
}
else
msi_register_unique_action(package, L"AppSearch");
r = MSI_OpenQuery( package->db, &view, L"SELECT * FROM `AppSearch`" );
if (r != ERROR_SUCCESS)
return ERROR_SUCCESS;
r = MSI_IterateRecords( view, NULL, ITERATE_AppSearch, package );
msiobj_release( &view->hdr );
return r;
}
static UINT ITERATE_CCPSearch(MSIRECORD *row, LPVOID param)
{
MSIPACKAGE *package = param;
LPCWSTR signature;
LPWSTR value = NULL;
struct signature sig;
UINT r = ERROR_SUCCESS;
signature = MSI_RecordGetString(row, 1);
TRACE("%s\n", debugstr_w(signature));
search_sig_name( package, signature, &sig, &value );
if (value)
{
TRACE("Found signature %s\n", debugstr_w(signature));
msi_set_property( package->db, L"CCP_Success", L"1", -1 );
free(value);
r = ERROR_NO_MORE_ITEMS;
}
free_signature(&sig);
return r;
}
UINT ACTION_CCPSearch(MSIPACKAGE *package)
{
MSIQUERY *view;
UINT r;
if (msi_action_is_unique(package, L"CCPSearch"))
{
TRACE("Skipping AppSearch action: already done in UI sequence\n");
return ERROR_SUCCESS;
}
else
msi_register_unique_action(package, L"CCPSearch");
r = MSI_OpenQuery(package->db, &view, L"SELECT * FROM `CCPSearch`");
if (r != ERROR_SUCCESS)
return ERROR_SUCCESS;
r = MSI_IterateRecords(view, NULL, ITERATE_CCPSearch, package);
msiobj_release(&view->hdr);
return r;
}