https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6eaaa698cd058eb289841…
commit 6eaaa698cd058eb28984140b67d8d2ff505480f2
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sun Mar 13 23:59:56 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:28:41 2022 +0100
[WINESYNC] msiexec: Append .msi extension to file name if file is not found.
Fixes Stellaris failing to install launcher at start.
Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com>
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id fd5d942a733bf35b7c6b6644d2aed571c185baba by Paul Gofman
<pgofman(a)codeweavers.com>
---
base/system/msiexec/msiexec.c | 44 +++++++++++++++++++++++++++++++++++--
modules/rostests/winetests/msi/db.c | 18 +++++++++++++++
2 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/base/system/msiexec/msiexec.c b/base/system/msiexec/msiexec.c
index 5e0e1b107e8..2ee7d05427c 100644
--- a/base/system/msiexec/msiexec.c
+++ b/base/system/msiexec/msiexec.c
@@ -588,6 +588,31 @@ static BOOL process_args_from_reg( const WCHAR *ident, int *pargc,
WCHAR ***parg
return ret;
}
+static WCHAR *get_path_with_extension(const WCHAR *package_name)
+{
+ static const WCHAR ext[] = L".msi";
+ unsigned int p;
+ WCHAR *path;
+
+ if (!(path = heap_alloc(lstrlenW(package_name) * sizeof(WCHAR) + sizeof(ext))))
+ {
+ WINE_ERR("No memory.\n");
+ return NULL;
+ }
+
+ lstrcpyW(path, package_name);
+ p = lstrlenW(path);
+ while (p && path[p] != '.' && path[p] != L'\\'
&& path[p] != '/')
+ --p;
+ if (path[p] == '.')
+ {
+ heap_free(path);
+ return NULL;
+ }
+ lstrcatW(path, ext);
+ return path;
+}
+
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int
nCmdShow)
{
int i;
@@ -626,6 +651,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine
DWORD ReturnCode;
int argc;
LPWSTR *argvW = NULL;
+ WCHAR *path;
InitCommonControls();
@@ -1040,14 +1066,28 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine
if(IsProductCode(PackageName))
ReturnCode = MsiConfigureProductExW(PackageName, 0, INSTALLSTATE_DEFAULT,
Properties);
else
- ReturnCode = MsiInstallProductW(PackageName, Properties);
+ {
+ if ((ReturnCode = MsiInstallProductW(PackageName, Properties)) ==
ERROR_FILE_NOT_FOUND
+ && (path = get_path_with_extension(PackageName)))
+ {
+ ReturnCode = MsiInstallProductW(path, Properties);
+ heap_free(path);
+ }
+ }
}
else if(FunctionRepair)
{
if(IsProductCode(PackageName))
WINE_FIXME("Product code treatment not implemented yet\n");
else
- ReturnCode = MsiReinstallProductW(PackageName, RepairMode);
+ {
+ if ((ReturnCode = MsiReinstallProductW(PackageName, RepairMode)) ==
ERROR_FILE_NOT_FOUND
+ && (path = get_path_with_extension(PackageName)))
+ {
+ ReturnCode = MsiReinstallProductW(path, RepairMode);
+ heap_free(path);
+ }
+ }
}
else if(FunctionAdvertise)
{
diff --git a/modules/rostests/winetests/msi/db.c b/modules/rostests/winetests/msi/db.c
index eedfcac486d..b42cc90a955 100644
--- a/modules/rostests/winetests/msi/db.c
+++ b/modules/rostests/winetests/msi/db.c
@@ -64,6 +64,8 @@ static void WINAPIV check_record_(int line, MSIHANDLE rec, UINT count,
...)
static void test_msidatabase(void)
{
MSIHANDLE hdb = 0, hdb2 = 0;
+ WCHAR path[MAX_PATH];
+ DWORD len;
UINT res;
DeleteFileW(msifileW);
@@ -162,6 +164,22 @@ static void test_msidatabase(void)
res = MsiCloseHandle( hdb );
ok( res == ERROR_SUCCESS , "Failed to close database\n" );
+ res = GetCurrentDirectoryW(ARRAY_SIZE(path), path);
+ ok ( res, "Got zero res.\n" );
+ lstrcatW( path, L"\\");
+ lstrcatW( path, msifileW);
+ len = lstrlenW(path);
+ path[len - 4] = 0;
+
+ res = MsiOpenDatabaseW( path, MSIDBOPEN_READONLY, &hdb );
+ ok( res != ERROR_SUCCESS , "Got unexpected res %u.\n", res );
+
+ lstrcpyW( path, msifileW );
+ path[lstrlenW(path) - 4] = 0;
+
+ res = MsiOpenDatabaseW( path, MSIDBOPEN_READONLY, &hdb );
+ ok( res != ERROR_SUCCESS , "Got unexpected res %u.\n", res );
+
res = DeleteFileA( msifile2 );
ok( res == TRUE, "Failed to delete database\n" );