Skip to content

Commit

Permalink
[MSIEXEC][MSI] Sync msiexec and msi to wine-9.8 (reactos#6897)
Browse files Browse the repository at this point in the history
* [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 <[email protected]>

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

wine commit id 2fde0a3f5c233b0ea1637f409998ce4ee85d28a7 by Alex Henrie <[email protected]>

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

wine commit id 7cc7a6defc08d4de7574b7a75d574c3ab1f32db8 by Alex Henrie <[email protected]>

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

wine commit id b07c95e79cdf6ae26c5170daa481ad160e0ce76a by Alex Henrie <[email protected]>

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

wine commit id d920aa81ad0c4618c27ebd7e9863618e988328e0 by Alex Henrie <[email protected]>

* [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 <[email protected]>

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

wine commit id 3e231d0f36a56ce991c7edbb6ae7845094e8417e by Alex Henrie <[email protected]>

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

wine commit id 6c1dd0f2c5669e084eb1f84571c38761a97c0970 by Alex Henrie <[email protected]>

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

wine commit id d394df4a30feb685927908fce2887bf5496b5d66 by Alex Henrie <[email protected]>

* [WINESYNC] ntdll: Default to Windows 10.

wine commit id 69154f0329aec4fb64886a0689da198b5323dcde by Hans Leidekker <[email protected]>

* [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 <[email protected]>

* [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 <[email protected]>

* [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 <[email protected]>

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

wine commit id 3611398b7575177b91e8162a84ebca977c50c2f5 by Hans Leidekker <[email protected]>

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

wine commit id 258012742512a4072265fcc47826c52319bd37ab by Hans Leidekker <[email protected]>

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

wine commit id 687c4f5c8dc65def6fc066d5d802d7448db70d7f by Alex Henrie <[email protected]>

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

wine commit id 9df04bfdb03a3017f532e70a047ee83290dbc257 by Alex Henrie <[email protected]>

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

wine commit id b6fb1b8983af7644b78bb0ba5fb9d18a1f0822f1 by Francois Gouget <[email protected]>

* [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 <[email protected]>

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

Instead of ERROR_SUCCESS.

wine commit id daa20d9d636057d7009ff3652a8577b423d23fcf by Alex Henrie <[email protected]>

* [WINESYNC] msi: Make TransformView_Create static.

wine commit id 1da5618cbac1214082bfb897dc81804d14fc6e9e by Alex Henrie <[email protected]>

* [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 <[email protected]>

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

wine commit id d06b3fd5274b056c720e2fb42eb189052d99404d by Alex Henrie <[email protected]>

* [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 <[email protected]>

* [WINESYNC] include: Remove redundant __WINE_USE_MSVCRT checks.

wine commit id 93630ce14ebf16333fda8481b5ede6f587eb32ca by Alexandre Julliard <[email protected]>

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

wine commit id 4db2ffa60e16e06b4f6ef89fcc4c73229f4446b1 by Alex Henrie <[email protected]>

* [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 <[email protected]>

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

wine commit id 993f4d48d23477e70e92256890c77687a1c4ba08 by Alex Henrie <[email protected]>

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

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54532
Signed-off-by: David Kahurani <[email protected]>

wine commit id e1ddc58a259d80f16bf1e62f23428775e1b070a0 by David Kahurani <[email protected]>

* [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 <[email protected]>

wine commit id 60e4f8a261ae9044aafa9c4eec2a3f2aec6481b5 by David Kahurani <[email protected]>

* [WINESYNC] msi: Remove DECLSPEC_HIDDEN usage.

wine commit id 51049c95a242f1553562a442142e813e37cee233 by Alistair Leslie-Hughes <[email protected]>

* [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 <[email protected]>

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

Fixes: 2c5bd49297f79d9941a256d8ec61e0eb2bf9bf9c

wine commit id 3eceda2f2a77754f0bf93ea33018e8ef49e82669 by Jinoh Kang <[email protected]>

* [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 <[email protected]>

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

wine commit id 8de0a9dc740d3ed1e3cf9460852db7e609122f3b by Alexandre Julliard <[email protected]>

* [MSI] disable nameless structs

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

wine commit id 490aee03e45222aa9d7e3e7fd6ff80064dc3778d by Alexandre Julliard <[email protected]>

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

wine commit id 81da9ff0f8dea4932a3afdc4c447c1c9242bb596 by Rémi Bernon <[email protected]>

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

wine commit id 085e95cd5eceb36c3e21cb7d42adab5a6af38a38 by Jactry Zeng <[email protected]>

* [WINESYNC] msiexec: Use CRT allocation functions.

wine commit id 0f44b3bdcb3d91701a9a8ef1ad07f3e88c08a666 by Alex Henrie <[email protected]>

* [WINESYNC] msi: Remove DECLSPEC_HIDDEN usage.

wine commit id 91e81083458374706bbace11114f4ad5e473ac07 by Alistair Leslie-Hughes <[email protected]>

* [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 <[email protected]>

* [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 <[email protected]>

* [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 <[email protected]>

wine commit id ac8da35b87005e45947b8164a4132f3bbb4ec2cc by Eric Pouech <[email protected]>

* [MSI]: Reduce diff

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

Regular GUI apps don't.

Signed-off-by: Eric Pouech <[email protected]>

wine commit id e048f71ecbb103ae7c1876092cb8244b24a73cb7 by Eric Pouech <[email protected]>

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

wine commit id 4afca1787febb012d0cdd2c007dd32beba35178d by Zhiyi Zhang <[email protected]>

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

wine commit id bbce5d014db7f023b133d6d09e6846e027586f7d by Fabian Maurer <[email protected]>

* [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 <[email protected]>

wine commit id 386dbe1059ba08485696760c267ef06dbed95bad by David Kahurani <[email protected]>

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

wine commit id 674efeb1f7445935cf4f49dd1285727055664ab9 by Zebediah Figura <[email protected]>

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

wine commit id 9725a2286acdb791de316295d9bcb11411a3fd56 by Zebediah Figura <[email protected]>

* [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 <[email protected]>

* [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 <[email protected]>

* [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 <[email protected]>

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

wine commit id 43fb0ecd0717ad1a6aa0702ed68368ee35d3ecda by Alexandre Julliard <[email protected]>

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

wine commit id b3f11ceb7a0ddcf5fe742377f99c947b0b56a051 by Hans Leidekker <[email protected]>

* [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 <[email protected]>

* [MSITEST] try restarting for tests elevated

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

wine commit id 738ec8285583248a84349939734ed600a47ba73d by Hans Leidekker <[email protected]>

* [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 <[email protected]>

* [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 <[email protected]>

* [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
  • Loading branch information
MishaProductions authored Sep 29, 2024
1 parent 1176530 commit f4be6dc
Show file tree
Hide file tree
Showing 65 changed files with 6,328 additions and 8,545 deletions.
100 changes: 58 additions & 42 deletions base/system/msiexec/msiexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
#include <msi.h>
#include <winsvc.h>
#include <objbase.h>
#include <stdio.h>

#include "wine/debug.h"
#include "wine/heap.h"
#include "msiexec_internal.h"

#include "initguid.h"
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
Expand All @@ -40,13 +39,29 @@ typedef HRESULT (WINAPI *DLLREGISTERSERVER)(void);
typedef HRESULT (WINAPI *DLLUNREGISTERSERVER)(void);

DWORD DoService(void);
static BOOL silent;

struct string_list
{
struct string_list *next;
WCHAR str[1];
};

void report_error(const char* msg, ...)
{
char buffer[2048];
va_list va_args;

va_start(va_args, msg);
vsnprintf(buffer, sizeof(buffer), msg, va_args);
va_end(va_args);

if (silent)
MESSAGE("%s", buffer);
else
MsiMessageBoxA(NULL, buffer, "MsiExec", 0, GetUserDefaultLangID(), 0);
}

static void ShowUsage(int ExitCode)
{
WCHAR msiexec_version[40];
Expand All @@ -73,17 +88,17 @@ static void ShowUsage(int ExitCode)
No typo: The LPWSTR parameter must be a LPWSTR * for this mode */
len = LoadStringW(hmsi, 10, (LPWSTR) &msi_res, 0);

msi_res = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
msiexec_help = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) + sizeof(msiexec_version));
msi_res = malloc((len + 1) * sizeof(WCHAR));
msiexec_help = malloc((len + 1) * sizeof(WCHAR) + sizeof(msiexec_version));
if (msi_res && msiexec_help) {
*msi_res = 0;
LoadStringW(hmsi, 10, msi_res, len + 1);

swprintf(msiexec_help, len + 1 + ARRAY_SIZE(msiexec_version), msi_res, msiexec_version);
MsiMessageBoxW(0, msiexec_help, NULL, 0, GetUserDefaultLangID(), 0);
}
HeapFree(GetProcessHeap(), 0, msi_res);
HeapFree(GetProcessHeap(), 0, msiexec_help);
free(msi_res);
free(msiexec_help);
ExitProcess(ExitCode);
}

Expand All @@ -101,7 +116,7 @@ static VOID StringListAppend(struct string_list **list, LPCWSTR str)
{
struct string_list *entry;

entry = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(struct string_list, str[lstrlenW(str) + 1]));
entry = malloc(FIELD_OFFSET(struct string_list, str[wcslen(str) + 1]));
if(!entry)
{
WINE_ERR("Out of memory!\n");
Expand Down Expand Up @@ -134,7 +149,7 @@ static LPWSTR build_properties(struct string_list *property_list)
for(list = property_list; list; list = list->next)
len += lstrlenW(list->str) + 3;

ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
ret = malloc(len * sizeof(WCHAR));

/* add a space before each string, and quote the value */
p = ret;
Expand Down Expand Up @@ -178,7 +193,7 @@ static LPWSTR build_transforms(struct string_list *transform_list)
for(list = transform_list; list; list = list->next)
len += lstrlenW(list->str) + 1;

ret = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
ret = malloc(len * sizeof(WCHAR));

/* add all the transforms with a semicolon between each one */
p = ret;
Expand Down Expand Up @@ -218,10 +233,10 @@ static BOOL msi_strequal(LPCWSTR str1, LPCSTR str2)
return FALSE;
if( lstrlenW(str1) != (len-1) )
return FALSE;
strW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
strW = malloc(sizeof(WCHAR) * len);
MultiByteToWideChar( CP_ACP, 0, str2, -1, strW, len);
ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, str1, len, strW, len);
HeapFree(GetProcessHeap(), 0, strW);
free(strW);
return (ret == CSTR_EQUAL);
}

Expand All @@ -246,10 +261,10 @@ static BOOL msi_strprefix(LPCWSTR str1, LPCSTR str2)
return FALSE;
if( lstrlenW(str1) < (len-1) )
return FALSE;
strW = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
strW = malloc(sizeof(WCHAR) * len);
MultiByteToWideChar( CP_ACP, 0, str2, -1, strW, len);
ret = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, str1, len-1, strW, len-1);
HeapFree(GetProcessHeap(), 0, strW);
free(strW);
return (ret == CSTR_EQUAL);
}

Expand All @@ -270,14 +285,14 @@ static VOID *LoadProc(LPCWSTR DllName, LPCSTR ProcName, HMODULE* DllHandle)
*DllHandle = LoadLibraryExW(DllName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if(!*DllHandle)
{
fprintf(stderr, "Unable to load dll %s\n", wine_dbgstr_w(DllName));
report_error("Unable to load dll %s\n", wine_dbgstr_w(DllName));
ExitProcess(1);
}
proc = (VOID *) GetProcAddress(*DllHandle, ProcName);
if(!proc)
{
fprintf(stderr, "Dll %s does not implement function %s\n",
wine_dbgstr_w(DllName), ProcName);
report_error("Dll %s does not implement function %s\n",
wine_dbgstr_w(DllName), ProcName);
FreeLibrary(*DllHandle);
ExitProcess(1);
}
Expand All @@ -296,10 +311,10 @@ static DWORD DoDllRegisterServer(LPCWSTR DllName)
hr = pfDllRegisterServer();
if(FAILED(hr))
{
fprintf(stderr, "Failed to register dll %s\n", wine_dbgstr_w(DllName));
report_error("Failed to register dll %s\n", wine_dbgstr_w(DllName));
return 1;
}
printf("Successfully registered dll %s\n", wine_dbgstr_w(DllName));
MESSAGE("Successfully registered dll %s\n", wine_dbgstr_w(DllName));
if(DllHandle)
FreeLibrary(DllHandle);
return 0;
Expand All @@ -316,10 +331,10 @@ static DWORD DoDllUnregisterServer(LPCWSTR DllName)
hr = pfDllUnregisterServer();
if(FAILED(hr))
{
fprintf(stderr, "Failed to unregister dll %s\n", wine_dbgstr_w(DllName));
report_error("Failed to unregister dll %s\n", wine_dbgstr_w(DllName));
return 1;
}
printf("Successfully unregistered dll %s\n", wine_dbgstr_w(DllName));
MESSAGE("Successfully unregistered dll %s\n", wine_dbgstr_w(DllName));
if(DllHandle)
FreeLibrary(DllHandle);
return 0;
Expand All @@ -333,7 +348,7 @@ static DWORD DoRegServer(void)

if (!(scm = OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASEW, SC_MANAGER_CREATE_SERVICE)))
{
fprintf(stderr, "Failed to open the service control manager.\n");
report_error("Failed to open the service control manager.\n");
return 1;
}
len = GetSystemDirectoryW(path, MAX_PATH);
Expand All @@ -346,7 +361,7 @@ static DWORD DoRegServer(void)
}
else if (GetLastError() != ERROR_SERVICE_EXISTS)
{
fprintf(stderr, "Failed to create MSI service\n");
report_error("Failed to create MSI service\n");
ret = 1;
}
CloseServiceHandle(scm);
Expand All @@ -360,21 +375,21 @@ static DWORD DoUnregServer(void)

if (!(scm = OpenSCManagerW(NULL, SERVICES_ACTIVE_DATABASEW, SC_MANAGER_CONNECT)))
{
fprintf(stderr, "Failed to open service control manager\n");
report_error("Failed to open service control manager\n");
return 1;
}
if ((service = OpenServiceW(scm, L"MSIServer", DELETE)))
{
if (!DeleteService(service))
{
fprintf(stderr, "Failed to delete MSI service\n");
report_error("Failed to delete MSI service\n");
ret = 1;
}
CloseServiceHandle(service);
}
else if (GetLastError() != ERROR_SERVICE_DOES_NOT_EXIST)
{
fprintf(stderr, "Failed to open MSI service\n");
report_error("Failed to open MSI service\n");
ret = 1;
}
CloseServiceHandle(scm);
Expand All @@ -388,7 +403,7 @@ static DWORD client_pid;
static DWORD CALLBACK custom_action_thread(void *arg)
{
GUID guid = *(GUID *)arg;
heap_free(arg);
free(arg);
return __wine_msi_call_dll_function(client_pid, &guid);
}

Expand Down Expand Up @@ -429,7 +444,7 @@ static int custom_action_server(const WCHAR *arg)
return 0;
}

thread_guid = heap_alloc(sizeof(GUID));
thread_guid = malloc(sizeof(GUID));
memcpy(thread_guid, &guid, sizeof(GUID));
thread = CreateThread(NULL, 0, custom_action_thread, thread_guid, 0, NULL);

Expand Down Expand Up @@ -533,13 +548,13 @@ static void process_args( WCHAR *cmdline, int *pargc, WCHAR ***pargv )
*pargv = NULL;

count = chomp( cmdline, NULL );
if (!(p = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(cmdline) + count + 1) * sizeof(WCHAR) )))
if (!(p = malloc( (wcslen(cmdline) + count + 1) * sizeof(WCHAR) )))
return;

count = chomp( cmdline, p );
if (!(argv = HeapAlloc( GetProcessHeap(), 0, (count + 1) * sizeof(WCHAR *) )))
if (!(argv = malloc( (count + 1) * sizeof(WCHAR *) )))
{
HeapFree( GetProcessHeap(), 0, p );
free( p );
return;
}
for (i = 0; i < count; i++)
Expand Down Expand Up @@ -569,7 +584,7 @@ static BOOL process_args_from_reg( const WCHAR *ident, int *pargc, WCHAR ***parg
if(r == ERROR_SUCCESS && type == REG_SZ)
{
int len = lstrlenW( *pargv[0] );
if (!(buf = HeapAlloc( GetProcessHeap(), 0, sz + (len + 1) * sizeof(WCHAR) )))
if (!(buf = malloc( (len + 1) * sizeof(WCHAR) )))
{
RegCloseKey( hkey );
return FALSE;
Expand All @@ -582,7 +597,7 @@ static BOOL process_args_from_reg( const WCHAR *ident, int *pargc, WCHAR ***parg
process_args(buf, pargc, pargv);
ret = TRUE;
}
HeapFree(GetProcessHeap(), 0, buf);
free(buf);
}
RegCloseKey(hkey);
return ret;
Expand All @@ -594,7 +609,7 @@ static WCHAR *get_path_with_extension(const WCHAR *package_name)
unsigned int p;
WCHAR *path;

if (!(path = heap_alloc(lstrlenW(package_name) * sizeof(WCHAR) + sizeof(ext))))
if (!(path = malloc(wcslen(package_name) * sizeof(WCHAR) + sizeof(ext))))
{
WINE_ERR("No memory.\n");
return NULL;
Expand All @@ -606,7 +621,7 @@ static WCHAR *get_path_with_extension(const WCHAR *package_name)
--p;
if (path[p] == '.')
{
heap_free(path);
free(path);
return NULL;
}
lstrcatW(path, ext);
Expand Down Expand Up @@ -766,7 +781,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
RepairMode |= REINSTALLMODE_PACKAGE;
break;
default:
fprintf(stderr, "Unknown option \"%c\" in Repair mode\n", argvW[i][j]);
report_error("Unknown option \"%c\" in Repair mode\n", argvW[i][j]);
break;
}
}
Expand Down Expand Up @@ -816,7 +831,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
AdvertiseMode = ADVERTISEFLAGS_MACHINEASSIGN;
break;
default:
fprintf(stderr, "Unknown option \"%c\" in Advertise mode\n", argvW[i][j]);
report_error("Unknown option \"%c\" in Advertise mode\n", argvW[i][j]);
break;
}
}
Expand Down Expand Up @@ -948,8 +963,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
LogFileName = argvW[i];
if(MsiEnableLogW(LogMode, LogFileName, LogAttributes) != ERROR_SUCCESS)
{
fprintf(stderr, "Logging in %s (0x%08x, %u) failed\n",
wine_dbgstr_w(LogFileName), LogMode, LogAttributes);
report_error("Logging in %s (0x%08lx, %lu) failed\n",
wine_dbgstr_w(LogFileName), LogMode, LogAttributes);
ExitProcess(1);
}
}
Expand All @@ -967,6 +982,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
if(lstrlenW(argvW[i]) == 2 || msi_strequal(argvW[i]+2, "n") ||
msi_strequal(argvW[i] + 2, "uiet"))
{
silent = TRUE;
InstallUILevel = INSTALLUILEVEL_NONE;
}
else if(msi_strequal(argvW[i]+2, "r"))
Expand Down Expand Up @@ -1003,8 +1019,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
}
else
{
fprintf(stderr, "Unknown option \"%s\" for UI level\n",
wine_dbgstr_w(argvW[i]+2));
report_error("Unknown option \"%s\" for UI level\n",
wine_dbgstr_w(argvW[i]+2));
}
}
else if(msi_option_equal(argvW[i], "passive"))
Expand Down Expand Up @@ -1071,7 +1087,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
&& (path = get_path_with_extension(PackageName)))
{
ReturnCode = MsiInstallProductW(path, Properties);
heap_free(path);
free(path);
}
}
}
Expand All @@ -1085,7 +1101,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
&& (path = get_path_with_extension(PackageName)))
{
ReturnCode = MsiReinstallProductW(path, RepairMode);
heap_free(path);
free(path);
}
}
}
Expand Down
25 changes: 25 additions & 0 deletions base/system/msiexec/msiexec_internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* msiexec.exe internal definitions
*
* Copyright 2023 Eric Pouech for CodeWeavers
*
* 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
*/

#ifdef __WINE_CRT_PRINTF_ATTR
extern void report_error(const char* msg, ...) __WINE_CRT_PRINTF_ATTR(1, 2);
#else
extern void report_error(const char* msg, ...);
#endif
Loading

0 comments on commit f4be6dc

Please sign in to comment.