Rebase against b448a8ba7b619c082f639f1b61987bf5c0f322fd.

This commit is contained in:
Alistair Leslie-Hughes
2025-11-07 09:50:06 +11:00
parent 66e568f047
commit e61b45155f
2 changed files with 78 additions and 79 deletions

View File

@@ -1,4 +1,4 @@
From b2b7c4c294cc7ea290250c419720899d457f63ec Mon Sep 17 00:00:00 2001
From ec240b5cd624f7a16a00ce98ff72188aba1a6524 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Mon, 5 Sep 2016 15:31:29 +0200
Subject: [PATCH] inseng: Implement CIF reader and download functions.
@@ -10,9 +10,9 @@ FIXME: Needs splitting.
dlls/inseng/inf.c | 443 +++++++++
dlls/inseng/inseng.spec | 4 +-
dlls/inseng/inseng_main.c | 989 ++++++++++++++++++-
dlls/inseng/inseng_private.h | 79 ++
dlls/inseng/inseng_private.h | 78 ++
include/inseng.idl | 276 +++++-
7 files changed, 3488 insertions(+), 52 deletions(-)
7 files changed, 3487 insertions(+), 52 deletions(-)
create mode 100644 dlls/inseng/icif.c
create mode 100644 dlls/inseng/inf.c
create mode 100644 dlls/inseng/inseng_private.h
@@ -35,7 +35,7 @@ index 40eda55661a..72fa3533930 100644
inseng_main.c
diff --git a/dlls/inseng/icif.c b/dlls/inseng/icif.c
new file mode 100644
index 00000000000..27f6f6dfd93
index 00000000000..e65463f1d8d
--- /dev/null
+++ b/dlls/inseng/icif.c
@@ -0,0 +1,1745 @@
@@ -243,14 +243,14 @@ index 00000000000..27f6f6dfd93
+
+static void url_entry_free(struct url_info *url)
+{
+ heap_free(url->url);
+ heap_free(url);
+ HeapFree(GetProcessHeap(), 0, url->url);
+ HeapFree(GetProcessHeap(), 0, url);
+}
+
+static void dependency_entry_free(struct dependency_info *dependency)
+{
+ heap_free(dependency->id);
+ heap_free(dependency);
+ HeapFree(GetProcessHeap(), 0, dependency->id);
+ HeapFree(GetProcessHeap(), 0, dependency);
+}
+
+static void component_free(struct cifcomponent *comp)
@@ -258,20 +258,20 @@ index 00000000000..27f6f6dfd93
+ struct dependency_info *dependency, *dependency_next;
+ struct url_info *url, *url_next;
+
+ heap_free(comp->id);
+ heap_free(comp->guid);
+ heap_free(comp->description);
+ heap_free(comp->details);
+ heap_free(comp->group);
+ HeapFree(GetProcessHeap(), 0, comp->id);
+ HeapFree(GetProcessHeap(), 0, comp->guid);
+ HeapFree(GetProcessHeap(), 0, comp->description);
+ HeapFree(GetProcessHeap(), 0, comp->details);
+ HeapFree(GetProcessHeap(), 0, comp->group);
+
+ heap_free(comp->patchid);
+ HeapFree(GetProcessHeap(), 0, comp->patchid);
+
+ heap_free(comp->locale);
+ heap_free(comp->key_uninstall);
+ HeapFree(GetProcessHeap(), 0, comp->locale);
+ HeapFree(GetProcessHeap(), 0, comp->key_uninstall);
+
+ heap_free(comp->key_success);
+ heap_free(comp->key_progress);
+ heap_free(comp->key_cancel);
+ HeapFree(GetProcessHeap(), 0, comp->key_success);
+ HeapFree(GetProcessHeap(), 0, comp->key_progress);
+ HeapFree(GetProcessHeap(), 0, comp->key_cancel);
+
+ LIST_FOR_EACH_ENTRY_SAFE(dependency, dependency_next, &comp->dependencies, struct dependency_info, entry)
+ {
@@ -285,14 +285,14 @@ index 00000000000..27f6f6dfd93
+ url_entry_free(url);
+ }
+
+ heap_free(comp);
+ HeapFree(GetProcessHeap(), 0, comp);
+}
+
+static void group_free(struct cifgroup *group)
+{
+ heap_free(group->id);
+ heap_free(group->description);
+ heap_free(group);
+ HeapFree(GetProcessHeap(), 0, group->id);
+ HeapFree(GetProcessHeap(), 0, group->description);
+ HeapFree(GetProcessHeap(), 0, group);
+}
+
+static HRESULT WINAPI group_GetID(ICifGroup *iface, char *id, DWORD size)
@@ -872,7 +872,7 @@ index 00000000000..27f6f6dfd93
+ if(!ref)
+ {
+ ICifFile_Release(This->file);
+ heap_free(This);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ return ref;
@@ -933,7 +933,7 @@ index 00000000000..27f6f6dfd93
+{
+ struct ciffenum_components *enumerator;
+
+ enumerator = heap_alloc_zero(sizeof(*enumerator));
+ enumerator = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(*enumerator));
+ if (!enumerator) return E_OUTOFMEMORY;
+
+ enumerator->IEnumCifComponents_iface.lpVtbl = &enum_componentsVtbl;
@@ -996,7 +996,7 @@ index 00000000000..27f6f6dfd93
+ if(!ref)
+ {
+ ICifFile_Release(This->file);
+ heap_free(This);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ return ref;
@@ -1045,7 +1045,7 @@ index 00000000000..27f6f6dfd93
+{
+ struct ciffenum_groups *enumerator;
+
+ enumerator = heap_alloc_zero(sizeof(*enumerator));
+ enumerator = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(*enumerator));
+ if (!enumerator) return E_OUTOFMEMORY;
+
+ enumerator->IEnumCifGroups_iface.lpVtbl = &enum_groupsVtbl;
@@ -1107,7 +1107,7 @@ index 00000000000..27f6f6dfd93
+ struct cifcomponent *comp, *comp_next;
+ struct cifgroup *group, *group_next;
+
+ heap_free(This->name);
+ HeapFree(GetProcessHeap(), 0, This->name);
+
+ LIST_FOR_EACH_ENTRY_SAFE(comp, comp_next, &This->components, struct cifcomponent, entry)
+ {
@@ -1121,7 +1121,7 @@ index 00000000000..27f6f6dfd93
+ group_free(group);
+ }
+
+ heap_free(This);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ return ref;
@@ -1306,7 +1306,7 @@ index 00000000000..27f6f6dfd93
+ if (field == i)
+ {
+ BOOL ret = copy_string(value, str);
+ heap_free(line);
+ HeapFree(GetProcessHeap(), 0, line);
+ return ret;
+ }
+
@@ -1344,7 +1344,7 @@ index 00000000000..27f6f6dfd93
+ if (!str) return FALSE;
+
+ *value = atoi(str);
+ heap_free(str);
+ HeapFree(GetProcessHeap(), 0, str);
+
+ return TRUE;
+}
@@ -1363,7 +1363,7 @@ index 00000000000..27f6f6dfd93
+ }
+
+ *value = atoi(value_str);
+ heap_free(value_str);
+ HeapFree(GetProcessHeap(), 0, value_str);
+
+ return TRUE;
+}
@@ -1421,7 +1421,7 @@ index 00000000000..27f6f6dfd93
+ build |= atoi(str) & 0xffff;
+
+done:
+ heap_free(line);
+ HeapFree(GetProcessHeap(), 0, line);
+ *ret_ver = version;
+ *ret_build = build;
+ return TRUE;
@@ -1463,7 +1463,7 @@ index 00000000000..27f6f6dfd93
+ } while (str);
+
+done:
+ heap_free(line);
+ HeapFree(GetProcessHeap(), 0, line);
+ *ret_platform = platform;
+ return TRUE;
+}
@@ -1484,13 +1484,13 @@ index 00000000000..27f6f6dfd93
+ {
+ next = next_part(&str, TRUE);
+
+ dependency = heap_alloc_zero(sizeof(*dependency));
+ dependency = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(*dependency));
+ if (!dependency) goto done;
+
+ dependency->id = strdupA(str);
+ if (!dependency->id)
+ {
+ heap_free(dependency);
+ HeapFree(GetProcessHeap(), 0, dependency);
+ goto done;
+ }
+
@@ -1505,7 +1505,7 @@ index 00000000000..27f6f6dfd93
+ ret = TRUE;
+
+done:
+ heap_free(line);
+ HeapFree(GetProcessHeap(), 0, line);
+ return ret;
+}
+
@@ -1532,7 +1532,7 @@ index 00000000000..27f6f6dfd93
+ goto next;
+ index--;
+
+ url_entry = heap_alloc_zero(sizeof(*url_entry));
+ url_entry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(*url_entry));
+ if (!url_entry) goto error;
+
+ url_entry->index = index;
@@ -1551,13 +1551,13 @@ index 00000000000..27f6f6dfd93
+ list_add_tail(&component->urls, &url_entry->entry);
+
+ next:
+ heap_free(str);
+ HeapFree(GetProcessHeap(), 0, str);
+ }
+
+ return TRUE;
+
+error:
+ heap_free(str);
+ HeapFree(GetProcessHeap(), 0, str);
+ url_entry_free(url_entry);
+ return FALSE;
+};
@@ -1583,7 +1583,7 @@ index 00000000000..27f6f6dfd93
+ struct cifcomponent *component;
+ HRESULT hr = E_OUTOFMEMORY;
+
+ component = heap_alloc_zero(sizeof(*component));
+ component = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(*component));
+ if (!component) return E_OUTOFMEMORY;
+
+ component->ICifComponent_iface.lpVtbl = &cifcomponentVtbl;
@@ -1662,7 +1662,7 @@ index 00000000000..27f6f6dfd93
+ struct cifgroup *group;
+ HRESULT hr = E_OUTOFMEMORY;
+
+ group = heap_alloc_zero(sizeof(*group));
+ group = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(*group));
+ if (!group) return E_OUTOFMEMORY;
+
+ group->ICifGroup_iface.lpVtbl = &cifgroupVtbl;
@@ -1699,7 +1699,7 @@ index 00000000000..27f6f6dfd93
+ else
+ FIXME("Don't know how to process %s\n", debugstr_a(type));
+
+ heap_free(type);
+ HeapFree(GetProcessHeap(), 0, type);
+ return hr;
+}
+
@@ -1727,7 +1727,7 @@ index 00000000000..27f6f6dfd93
+ hr = process_section(file, section, section_name);
+
+ TRACE("Finished processing section %s, hr %#lx.\n", debugstr_a(section_name), hr);
+ heap_free(section_name);
+ HeapFree(GetProcessHeap(), 0, section_name);
+ }
+
+ /* In case there was no version section, set the default installer description */
@@ -1746,7 +1746,7 @@ index 00000000000..27f6f6dfd93
+ struct ciffile *file;
+ HRESULT hr = E_FAIL;
+
+ file = heap_alloc_zero(sizeof(*file));
+ file = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(*file));
+ if(!file) return E_OUTOFMEMORY;
+
+ file->ICifFile_iface.lpVtbl = &ciffileVtbl;
@@ -1786,7 +1786,7 @@ index 00000000000..27f6f6dfd93
+}
diff --git a/dlls/inseng/inf.c b/dlls/inseng/inf.c
new file mode 100644
index 00000000000..bead72c082c
index 00000000000..d803d7c1693
--- /dev/null
+++ b/dlls/inseng/inf.c
@@ -0,0 +1,443 @@
@@ -1846,7 +1846,7 @@ index 00000000000..bead72c082c
+
+static void inf_value_free(struct inf_value *value)
+{
+ heap_free(value);
+ HeapFree(GetProcessHeap(), 0, value);
+}
+
+static void inf_section_free(struct inf_section *section)
@@ -1858,7 +1858,7 @@ index 00000000000..bead72c082c
+ inf_value_free(val);
+ }
+
+ heap_free(section);
+ HeapFree(GetProcessHeap(), 0, section);
+}
+
+static const char *get_substitution(struct inf_file *inf, const char *name, int len)
@@ -1954,7 +1954,7 @@ index 00000000000..bead72c082c
+ int len;
+
+ len = expand_variables_buffer(inf, str, NULL);
+ buffer = heap_alloc(len);
+ buffer = HeapAlloc(GetProcessHeap(), 0, len);
+ if (!len) return NULL;
+
+ expand_variables_buffer(inf, str, buffer);
@@ -1970,8 +1970,8 @@ index 00000000000..bead72c082c
+ inf_section_free(sec);
+ }
+
+ heap_free(inf->content);
+ heap_free(inf);
+ HeapFree(GetProcessHeap(), 0, inf->content);
+ HeapFree(GetProcessHeap(), 0, inf);
+}
+
+BOOL inf_next_section(struct inf_file *inf, struct inf_section **sec)
@@ -2137,7 +2137,7 @@ index 00000000000..bead72c082c
+ name = trim(line, NULL, FALSE);
+ if (!name) return S_OK;
+
+ sec = heap_alloc_zero(sizeof(*sec));
+ sec = HeapAlloc(GetProcessHeap(), 0, sizeof(*sec));
+ if (!sec) return E_OUTOFMEMORY;
+
+ sec->name = name;
@@ -2165,7 +2165,7 @@ index 00000000000..bead72c082c
+ key = trim(key, NULL, FALSE);
+ value = trim(value, NULL, TRUE);
+
+ key_val = heap_alloc_zero(sizeof(*key_val));
+ key_val = HeapAlloc(GetProcessHeap(), 0, sizeof(*key_val));
+ if (!key_val) return E_OUTOFMEMORY;
+
+ key_val->key = key;
@@ -2205,7 +2205,7 @@ index 00000000000..bead72c082c
+ file = CreateFileA(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
+ if (file == INVALID_HANDLE_VALUE) return E_FAIL;
+
+ inf = heap_alloc_zero(sizeof(*inf));
+ inf = HeapAlloc(GetProcessHeap(), 0, sizeof(*inf));
+ if (!inf) goto error;
+
+ if (!GetFileSizeEx(file, &file_size))
@@ -2213,7 +2213,7 @@ index 00000000000..bead72c082c
+
+ inf->size = file_size.QuadPart;
+
+ inf->content = heap_alloc_zero(inf->size);
+ inf->content = HeapAlloc(GetProcessHeap(), 0, inf->size);
+ if (!inf->content) goto error;
+
+ list_init(&inf->sections);
@@ -2247,7 +2247,7 @@ index 82c0b4d5fe1..7ae46fad3a7 100644
+@ stdcall GetICifRWFileFromFile(ptr str)
@ stub PurgeDownloadDirectory
diff --git a/dlls/inseng/inseng_main.c b/dlls/inseng/inseng_main.c
index f7ce3f173c2..ad6fe6b4de8 100644
index f7ce3f173c2..0b6c9841b68 100644
--- a/dlls/inseng/inseng_main.c
+++ b/dlls/inseng/inseng_main.c
@@ -2,6 +2,7 @@
@@ -2385,11 +2385,11 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+
+ if (!ref)
+ {
+ heap_free(This->file_name);
+ heap_free(This->cache_file);
+ HeapFree(GetProcessHeap(), 0, This->file_name);
+ HeapFree(GetProcessHeap(), 0, This->cache_file);
+
+ IInstallEngine2_Release(&This->engine->IInstallEngine2_iface);
+ heap_free(This);
+ HeapFree(GetProcessHeap(), 0, This);
+ }
+
+ return ref;
@@ -2550,7 +2550,7 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+{
+ struct downloadcb *cb;
+
+ cb = heap_alloc_zero(sizeof(*cb));
+ cb = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,sizeof(*cb));
+ if (!cb) return E_OUTOFMEMORY;
+
+ cb->IBindStatusCallback_iface.lpVtbl = &BindStatusCallbackVtbl;
@@ -2565,7 +2565,7 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+ cb->file_name = strAtoW(file_name);
+ if (!cb->file_name)
+ {
+ heap_free(cb);
+ HeapFree(GetProcessHeap(), 0, cb);
+ return E_OUTOFMEMORY;
+ }
+
@@ -2702,14 +2702,14 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+ do
+ {
+ size *= 2;
+ heap_free(url_temp);
+ url_temp = heap_alloc(size);
+ HeapFree(GetProcessHeap(), 0, url_temp);
+ url_temp = HeapAlloc(GetProcessHeap(), 0, size);
+ if (!url_temp) return E_OUTOFMEMORY;
+
+ hr = ICifComponent_GetUrl(comp, index, url_temp, size, flags);
+ if (FAILED(hr))
+ {
+ heap_free(url_temp);
+ HeapFree(GetProcessHeap(), 0, url_temp);
+ return hr;
+ }
+ }
@@ -2725,7 +2725,7 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+ int len_url = strlen(url);
+ char *combined;
+
+ combined = heap_alloc(len_base + len_url + 2);
+ combined = HeapAlloc(GetProcessHeap(), 0, len_base + len_url + 2);
+ if (!combined) return NULL;
+
+ strcpy(combined, baseurl);
@@ -2751,7 +2751,7 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+ if (!combined) return E_OUTOFMEMORY;
+
+ urlW = strAtoW(combined);
+ heap_free(combined);
+ HeapFree(GetProcessHeap(), 0, combined);
+ if (!urlW) return E_OUTOFMEMORY;
+ }
+ else
@@ -2761,14 +2761,14 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+ }
+
+ hr = CreateURLMoniker(NULL, urlW, moniker);
+ heap_free(urlW);
+ HeapFree(GetProcessHeap(), 0, urlW);
+ return hr;
+}
+
+static char *merge_path(char *path1, char *path2)
+{
+ int len = strlen(path1) + strlen(path2) + 2;
+ char *combined = heap_alloc(len);
+ char *combined = HeapAlloc(GetProcessHeap(), 0, len);
+
+ if (!combined) return NULL;
+ strcpy(combined, path1);
@@ -2828,7 +2828,7 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+ if (FAILED(hr)) goto error;
+ if (unk) IUnknown_Release(unk);
+
+ heap_free(filename);
+ HeapFree(GetProcessHeap(), 0, filename);
+ IMoniker_Release(mon);
+ IBindCtx_Release(bindctx);
+
@@ -2844,7 +2844,7 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+ if (event) CloseHandle(event);
+ if (callback) IBindStatusCallback_Release(&callback->IBindStatusCallback_iface);
+ if (bindctx) IBindCtx_Release(bindctx);
+ if (filename) heap_free(filename);
+ if (filename) HeapFree(GetProcessHeap(), 0, filename);
+ return hr;
+}
+
@@ -2912,7 +2912,7 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+ TRACE("processing url %s\n", debugstr_a(url));
+
+ hr = download_url(This, id, display, url, flags, size_dl);
+ heap_free(url);
+ HeapFree(GetProcessHeap(), 0, url);
+ if (FAILED(hr))
+ {
+ DWORD retry = 0;
@@ -3222,7 +3222,7 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+ TRACE("(%p)->(%s)\n", This, debugstr_a(base_name));
+
+ if (This->baseurl)
+ heap_free(This->baseurl);
+ HeapFree(GetProcessHeap(), 0, This->baseurl);
+
+ This->baseurl = strdupA(base_name);
+ return This->baseurl ? S_OK : E_OUTOFMEMORY;
@@ -3237,7 +3237,7 @@ index f7ce3f173c2..ad6fe6b4de8 100644
+ TRACE("(%p)->(%s)\n", This, debugstr_a(download_dir));
+
+ if (This->downloaddir)
+ heap_free(This->downloaddir);
+ HeapFree(GetProcessHeap(), 0, This->downloaddir);
+
+ This->downloaddir = strdupA(download_dir);
+ return This->downloaddir ? S_OK : E_OUTOFMEMORY;
@@ -3449,10 +3449,10 @@ index f7ce3f173c2..ad6fe6b4de8 100644
IInstallEngine2_Release(&engine->IInstallEngine2_iface);
diff --git a/dlls/inseng/inseng_private.h b/dlls/inseng/inseng_private.h
new file mode 100644
index 00000000000..49d4241d65e
index 00000000000..33f7869195b
--- /dev/null
+++ b/dlls/inseng/inseng_private.h
@@ -0,0 +1,79 @@
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2016 Michael Müller
+ *
@@ -3477,12 +3477,11 @@ index 00000000000..49d4241d65e
+#include "ole2.h"
+#include "rpcproxy.h"
+#include "inseng.h"
+#include "wine/heap.h"
+
+
+static inline char *strdupA(const char *src)
+{
+ char *dest = heap_alloc(strlen(src) + 1);
+ char *dest = HeapAlloc(GetProcessHeap(), 0, strlen(src) + 1);
+ if (dest) strcpy(dest, src);
+ return dest;
+}
@@ -3859,5 +3858,5 @@ index 8a3f4c4d270..82927418a99 100644
+cpp_quote("HRESULT WINAPI GetICifFileFromFile(ICifFile **, const char *);")
+cpp_quote("HRESULT WINAPI GetICifRWFileFromFile(ICifRWFile **, const char *);")
--
2.42.0
2.51.0

View File

@@ -1 +1 @@
839f8fc3e0302980772e1d31f5b761446cdf8406
b448a8ba7b619c082f639f1b61987bf5c0f322fd