forked from wine-compholio/wine-staging
/
0001-inseng-Implement-CIF-reader-and-download-functions.patch
3863 lines (3811 loc) · 103 KB
/
0001-inseng-Implement-CIF-reader-and-download-functions.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From b2b7c4c294cc7ea290250c419720899d457f63ec 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.
FIXME: Needs splitting.
---
dlls/inseng/Makefile.in | 4 +-
dlls/inseng/icif.c | 1745 ++++++++++++++++++++++++++++++++++
dlls/inseng/inf.c | 443 +++++++++
dlls/inseng/inseng.spec | 4 +-
dlls/inseng/inseng_main.c | 989 ++++++++++++++++++-
dlls/inseng/inseng_private.h | 79 ++
include/inseng.idl | 276 +++++-
7 files changed, 3488 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
diff --git a/dlls/inseng/Makefile.in b/dlls/inseng/Makefile.in
index 40eda55661a..72fa3533930 100644
--- a/dlls/inseng/Makefile.in
+++ b/dlls/inseng/Makefile.in
@@ -1,8 +1,10 @@
MODULE = inseng.dll
-IMPORTS = uuid ole32 advapi32
+IMPORTS = uuid ole32 advapi32 urlmon shlwapi
EXTRADLLFLAGS = -Wb,--prefer-native
SOURCES = \
+ icif.c \
+ inf.c \
inseng_classes.idl \
inseng_main.c
diff --git a/dlls/inseng/icif.c b/dlls/inseng/icif.c
new file mode 100644
index 00000000000..27f6f6dfd93
--- /dev/null
+++ b/dlls/inseng/icif.c
@@ -0,0 +1,1745 @@
+/*
+ * Copyright 2016 Michael Müller
+ *
+ * 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
+ */
+
+#define COBJMACROS
+
+
+
+#include <stdarg.h>
+#include <string.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "winuser.h"
+#include "ole2.h"
+#include "rpcproxy.h"
+#include "inseng.h"
+
+#include "inseng_private.h"
+
+#include "wine/list.h"
+#include "wine/debug.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(inseng);
+
+#define DEFAULT_INSTALLER_DESC "Active Setup Installation"
+
+struct cifgroup
+{
+ ICifGroup ICifGroup_iface;
+
+ struct list entry;
+
+ ICifFile *parent;
+
+ char *id;
+ char *description;
+ DWORD priority;
+};
+
+struct ciffenum_components
+{
+ IEnumCifComponents IEnumCifComponents_iface;
+ LONG ref;
+
+ ICifFile *file;
+ struct list *start;
+ struct list *position;
+
+ char *group_id;
+};
+
+struct ciffenum_groups
+{
+ IEnumCifGroups IEnumCifGroups_iface;
+ LONG ref;
+
+ ICifFile *file;
+ struct list *start;
+ struct list *position;
+};
+
+struct url_info
+{
+ struct list entry;
+ INT index;
+ char *url;
+ DWORD flags;
+};
+
+struct dependency_info
+{
+ struct list entry;
+ char *id;
+ char *type;
+};
+
+struct cifcomponent
+{
+ ICifComponent ICifComponent_iface;
+
+ struct list entry;
+
+ ICifFile *parent;
+
+ char *id;
+ char *guid;
+ char *description;
+ char *details;
+ char *group;
+
+
+ DWORD version;
+ DWORD build;
+ char *patchid;
+
+ char *locale;
+ char *key_uninstall;
+
+ DWORD size_win;
+ DWORD size_app;
+ DWORD size_download;
+ DWORD size_extracted;
+
+ char *key_success;
+ char *key_progress;
+ char *key_cancel;
+
+ DWORD as_aware;
+ DWORD reboot;
+ DWORD admin;
+ DWORD visibleui;
+
+ DWORD priority;
+ DWORD platform;
+
+ struct list dependencies;
+ struct list urls;
+
+ /* mode */
+ /* det version */
+ /* one component */
+ /* custom data */
+
+ /* in memory state */
+ DWORD queue_state;
+ DWORD current_priority;
+ DWORD size_actual_download;
+ BOOL downloaded;
+ BOOL installed;
+};
+
+struct ciffile
+{
+ ICifFile ICifFile_iface;
+ LONG ref;
+
+ struct list components;
+ struct list groups;
+
+ char *name;
+};
+
+static inline struct ciffile *impl_from_ICiffile(ICifFile *iface)
+{
+ return CONTAINING_RECORD(iface, struct ciffile, ICifFile_iface);
+}
+
+static inline struct cifcomponent *impl_from_ICifComponent(ICifComponent *iface)
+{
+ return CONTAINING_RECORD(iface, struct cifcomponent, ICifComponent_iface);
+}
+
+static inline struct cifgroup *impl_from_ICifGroup(ICifGroup *iface)
+{
+ return CONTAINING_RECORD(iface, struct cifgroup, ICifGroup_iface);
+}
+
+static inline struct ciffenum_components *impl_from_IEnumCifComponents(IEnumCifComponents *iface)
+{
+ return CONTAINING_RECORD(iface, struct ciffenum_components, IEnumCifComponents_iface);
+}
+
+static inline struct ciffenum_groups *impl_from_IEnumCifGroups(IEnumCifGroups *iface)
+{
+ return CONTAINING_RECORD(iface, struct ciffenum_groups, IEnumCifGroups_iface);
+}
+
+static HRESULT enum_components_create(ICifFile *file, struct list *start, char *group_id, IEnumCifComponents **iface);
+
+static HRESULT copy_substring_null(char *dest, int max_len, char *src)
+{
+ if (!src)
+ return E_FAIL;
+
+ if (max_len <= 0)
+ return S_OK;
+
+ if (!dest)
+ return E_FAIL;
+
+ while (*src && max_len-- > 1)
+ *dest++ = *src++;
+ *dest = 0;
+
+ return S_OK;
+}
+
+static void url_entry_free(struct url_info *url)
+{
+ heap_free(url->url);
+ heap_free(url);
+}
+
+static void dependency_entry_free(struct dependency_info *dependency)
+{
+ heap_free(dependency->id);
+ heap_free(dependency);
+}
+
+static void component_free(struct cifcomponent *comp)
+{
+ 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);
+
+ heap_free(comp->patchid);
+
+ heap_free(comp->locale);
+ heap_free(comp->key_uninstall);
+
+ heap_free(comp->key_success);
+ heap_free(comp->key_progress);
+ heap_free(comp->key_cancel);
+
+ LIST_FOR_EACH_ENTRY_SAFE(dependency, dependency_next, &comp->dependencies, struct dependency_info, entry)
+ {
+ list_remove(&dependency->entry);
+ dependency_entry_free(dependency);
+ }
+
+ LIST_FOR_EACH_ENTRY_SAFE(url, url_next, &comp->urls, struct url_info, entry)
+ {
+ list_remove(&url->entry);
+ url_entry_free(url);
+ }
+
+ heap_free(comp);
+}
+
+static void group_free(struct cifgroup *group)
+{
+ heap_free(group->id);
+ heap_free(group->description);
+ heap_free(group);
+}
+
+static HRESULT WINAPI group_GetID(ICifGroup *iface, char *id, DWORD size)
+{
+ struct cifgroup *This = impl_from_ICifGroup(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, id, size);
+
+ return copy_substring_null(id, size, This->id);
+}
+
+static HRESULT WINAPI group_GetDescription(ICifGroup *iface, char *desc, DWORD size)
+{
+ struct cifgroup *This = impl_from_ICifGroup(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, desc, size);
+
+ return copy_substring_null(desc, size, This->description);
+}
+
+static DWORD WINAPI group_GetPriority(ICifGroup *iface)
+{
+ struct cifgroup *This = impl_from_ICifGroup(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->priority;
+}
+
+static HRESULT WINAPI group_EnumComponents(ICifGroup *iface, IEnumCifComponents **enum_components, DWORD filter, LPVOID pv)
+{
+ struct cifgroup *This = impl_from_ICifGroup(iface);
+ struct ciffile *file;
+
+ TRACE("(%p)->(%p, %#lx, %p)\n", This, enum_components, filter, pv);
+
+ if (filter)
+ FIXME("filter (%#lx) not supported\n", filter);
+ if (pv)
+ FIXME("how to handle pv (%p)?\n", pv);
+
+ file = impl_from_ICiffile(This->parent);
+ return enum_components_create(This->parent, &file->components, This->id, enum_components);
+}
+
+static DWORD WINAPI group_GetCurrentPriority(ICifGroup *iface)
+{
+ struct cifgroup *This = impl_from_ICifGroup(iface);
+
+ FIXME("(%p): stub\n", This);
+
+ return 0;
+}
+
+static const ICifGroupVtbl cifgroupVtbl =
+{
+ group_GetID,
+ group_GetDescription,
+ group_GetPriority,
+ group_EnumComponents,
+ group_GetCurrentPriority,
+};
+
+void component_set_actual_download_size(ICifComponent *iface, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ This->size_actual_download = size;
+}
+
+void component_set_downloaded(ICifComponent *iface, BOOL value)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ This->downloaded = value;
+}
+
+void component_set_installed(ICifComponent *iface, BOOL value)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ This->installed = value;
+}
+
+char *component_get_id(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ return This->id;
+}
+
+static HRESULT WINAPI component_GetID(ICifComponent *iface, char *id, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, id, size);
+
+ return copy_substring_null(id, size, This->id);
+}
+
+static HRESULT WINAPI component_GetGUID(ICifComponent *iface, char *guid, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, guid, size);
+
+ return copy_substring_null(guid, size, This->guid);
+}
+
+static HRESULT WINAPI component_GetDescription(ICifComponent *iface, char *desc, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, desc, size);
+
+ return copy_substring_null(desc, size, This->description);
+}
+
+static HRESULT WINAPI component_GetDetails(ICifComponent *iface, char *details, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, details, size);
+
+ return copy_substring_null(details, size, This->details);
+}
+
+static HRESULT WINAPI component_GetUrl(ICifComponent *iface, UINT index, char *url, DWORD size, DWORD *flags)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+ struct url_info *entry;
+
+ TRACE("(%p)->(%u, %p, %lu, %p)\n", This, index, url, size, flags);
+
+ /* FIXME: check how functions behaves for url == NULL */
+
+ if (!flags)
+ return E_FAIL;
+
+ LIST_FOR_EACH_ENTRY(entry, &This->urls, struct url_info, entry)
+ {
+ if (entry->index != index)
+ continue;
+
+ *flags = entry->flags;
+ return copy_substring_null(url, size, entry->url);
+ }
+
+ return E_FAIL;
+}
+
+static HRESULT WINAPI component_GetFileExtractList(ICifComponent *iface, UINT index, char *list, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ FIXME("(%p)->(%u, %p, %lu): stub\n", This, index, list, size);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI component_GetUrlCheckRange(ICifComponent *iface, UINT index, DWORD *min, DWORD *max)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ FIXME("(%p)->(%u, %p, %p): stub\n", This, index, min, max);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI component_GetCommand(ICifComponent *iface, UINT index, char *cmd, DWORD cmd_size, char *switches, DWORD switch_size, DWORD *type)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ FIXME("(%p)->(%u, %p, %lu, %p, %lu, %p): stub\n", This, index, cmd, cmd_size, switches, switch_size, type);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI component_GetVersion(ICifComponent *iface, DWORD *version, DWORD *build)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %p)\n", This, version, build);
+
+ if (!version || !build)
+ return E_FAIL;
+
+ *version = This->version;
+ *build = This->build;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI component_GetLocale(ICifComponent *iface, char *locale, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, locale, size);
+
+ return copy_substring_null(locale, size, This->locale);
+}
+
+static HRESULT WINAPI component_GetUninstallKey(ICifComponent *iface, char *key, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, key, size);
+
+ return copy_substring_null(key, size, This->key_uninstall);
+}
+
+static HRESULT WINAPI component_GetInstalledSize(ICifComponent *iface, DWORD *win, DWORD *app)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %p)\n", This, win, app);
+
+ if (!win || !app)
+ return E_FAIL;
+
+ *win = This->size_win;
+ *app = This->size_app;
+
+ return S_OK;
+}
+
+static DWORD WINAPI component_GetDownloadSize(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->size_download;
+}
+
+static DWORD WINAPI component_GetExtractSize(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->size_extracted;
+}
+
+static HRESULT WINAPI component_GetSuccessKey(ICifComponent *iface, char *key, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, key, size);
+
+ return copy_substring_null(key, size, This->key_success);
+}
+
+static HRESULT WINAPI component_GetProgressKeys(ICifComponent *iface, char *progress, DWORD progress_size,
+ char *cancel, DWORD cancel_size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+ HRESULT hr;
+
+ TRACE("(%p)->(%p, %lu, %p, %lu): semi-stub\n", This, progress, progress_size, cancel, cancel_size);
+
+ hr = copy_substring_null(progress, progress_size, This->key_progress);
+ if (hr != S_OK) return hr;
+
+ if (cancel_size > 0 && cancel)
+ *cancel = 0;
+
+ return S_OK;
+}
+
+static HRESULT WINAPI component_IsActiveSetupAware(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->as_aware ? S_OK : S_FALSE;
+}
+
+static HRESULT WINAPI component_IsRebootRequired(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->reboot ? S_OK : S_FALSE;
+}
+
+static HRESULT WINAPI component_RequiresAdminRights(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->admin ? S_OK : S_FALSE;
+}
+
+static DWORD WINAPI component_GetPriority(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->priority;
+}
+
+static HRESULT WINAPI component_GetDependency(ICifComponent *iface, UINT index, char *id, DWORD id_size, char *type, DWORD *ver, DWORD *build)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+ struct dependency_info *entry;
+ ICifComponent *dependency;
+ int pos = 0;
+
+ TRACE("(%p)->(%u, %p, %lu, %p, %p, %p)\n", This, index, id, id_size, type, ver, build);
+
+ if (!id || !ver || !build)
+ return E_FAIL;
+
+ LIST_FOR_EACH_ENTRY(entry, &This->dependencies, struct dependency_info, entry)
+ {
+ if (pos++ < index)
+ continue;
+
+ if (ICifFile_FindComponent(This->parent, entry->id, &dependency) == S_OK)
+ {
+ ICifComponent_GetVersion(dependency, ver, build);
+ }
+ else
+ {
+ *ver = -1;
+ *build = -1;
+ }
+
+ if (entry->type)
+ *type = *entry->type;
+ else
+ *type = 'I';
+
+ return copy_substring_null(id, id_size, entry->id);
+ }
+
+ return E_FAIL;
+}
+
+static DWORD WINAPI component_GetPlatform(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->platform;
+}
+
+static HRESULT WINAPI component_GetMode(ICifComponent *iface, UINT index, char *mode, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ FIXME("(%p)->(%u, %p, %lu): stub\n", This, index, mode, size);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI component_GetGroup(ICifComponent *iface, char *id, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, id, size);
+
+ return copy_substring_null(id, size, This->group);
+}
+
+static HRESULT WINAPI component_IsUIVisible(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->visibleui ? S_OK : S_FALSE;
+}
+
+static HRESULT WINAPI component_GetPatchID(ICifComponent *iface, char *id, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%p, %lu)\n", This, id, size);
+
+ return copy_substring_null(id, size, This->patchid);
+}
+
+static HRESULT WINAPI component_GetDetVersion(ICifComponent *iface, char *dll, DWORD dll_size, char *entry, DWORD entry_size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ FIXME("(%p)->(%p, %lu, %p, %lu): stub\n", This, dll, dll_size, entry, entry_size);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI component_GetTreatAsOneComponents(ICifComponent *iface, UINT index, char *id, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ FIXME("(%p)->(%u, %p, %lu): stub\n", This, index, id, size);
+
+ return E_NOTIMPL;
+}
+
+static HRESULT WINAPI component_GetCustomData(ICifComponent *iface, char *key, char *data, DWORD size)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ FIXME("(%p)->(%s, %p, %lu): stub\n", This, debugstr_a(key), data, size);
+
+ return E_NOTIMPL;
+}
+
+static DWORD WINAPI component_IsComponentInstalled(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->installed;
+}
+
+static HRESULT WINAPI component_IsComponentDownloaded(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->downloaded ? S_OK : S_FALSE;
+}
+
+static DWORD WINAPI component_IsThisVersionInstalled(ICifComponent *iface, DWORD version, DWORD build, DWORD *ret_version, DWORD *ret_build)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ FIXME("(%p)->(%lu, %lu, %p, %p): stub\n", This, version, build, ret_version, ret_build);
+
+ return 0;
+}
+
+static DWORD WINAPI component_GetInstallQueueState(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->queue_state;
+}
+
+static HRESULT WINAPI component_SetInstallQueueState(ICifComponent *iface, DWORD state)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%lu)\n", This, state);
+
+ This->queue_state = state;
+ return S_OK;
+}
+
+static DWORD WINAPI component_GetActualDownloadSize(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->size_download;
+}
+
+static DWORD WINAPI component_GetCurrentPriority(ICifComponent *iface)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)\n", This);
+
+ return This->current_priority;
+}
+
+
+static HRESULT WINAPI component_SetCurrentPriority(ICifComponent *iface, DWORD priority)
+{
+ struct cifcomponent *This = impl_from_ICifComponent(iface);
+
+ TRACE("(%p)->(%lu)\n", This, priority);
+
+ This->current_priority = priority;
+ return S_OK;
+}
+
+static const ICifComponentVtbl cifcomponentVtbl =
+{
+ component_GetID,
+ component_GetGUID,
+ component_GetDescription,
+ component_GetDetails,
+ component_GetUrl,
+ component_GetFileExtractList,
+ component_GetUrlCheckRange,
+ component_GetCommand,
+ component_GetVersion,
+ component_GetLocale,
+ component_GetUninstallKey,
+ component_GetInstalledSize,
+ component_GetDownloadSize,
+ component_GetExtractSize,
+ component_GetSuccessKey,
+ component_GetProgressKeys,
+ component_IsActiveSetupAware,
+ component_IsRebootRequired,
+ component_RequiresAdminRights,
+ component_GetPriority,
+ component_GetDependency,
+ component_GetPlatform,
+ component_GetMode,
+ component_GetGroup,
+ component_IsUIVisible,
+ component_GetPatchID,
+ component_GetDetVersion,
+ component_GetTreatAsOneComponents,
+ component_GetCustomData,
+ component_IsComponentInstalled,
+ component_IsComponentDownloaded,
+ component_IsThisVersionInstalled,
+ component_GetInstallQueueState,
+ component_SetInstallQueueState,
+ component_GetActualDownloadSize,
+ component_GetCurrentPriority,
+ component_SetCurrentPriority,
+};
+
+static HRESULT WINAPI enum_components_QueryInterface(IEnumCifComponents *iface, REFIID riid, void **ppv)
+{
+ struct ciffenum_components *This = impl_from_IEnumCifComponents(iface);
+
+ if (IsEqualGUID(&IID_IUnknown, riid))
+ {
+ TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
+ *ppv = &This->IEnumCifComponents_iface;
+ }
+ /*
+ else if (IsEqualGUID(&IID_IEnumCifComponents, riid))
+ {
+ TRACE("(%p)->(IID_ICifFile %p)\n", This, ppv);
+ *ppv = &This->IEnumCifComponents_iface;
+ }
+ */
+ else
+ {
+ FIXME("(%p)->(%s %p) not found\n", This, debugstr_guid(riid), ppv);
+ *ppv = NULL;
+ return E_NOINTERFACE;
+ }
+
+ IUnknown_AddRef((IUnknown *)*ppv);
+ return S_OK;
+}
+
+static ULONG WINAPI enum_components_AddRef(IEnumCifComponents *iface)
+{
+ struct ciffenum_components *This = impl_from_IEnumCifComponents(iface);
+ LONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) ref=%ld\n", This, ref);
+
+ return ref;
+}
+
+static ULONG WINAPI enum_components_Release(IEnumCifComponents *iface)
+{
+ struct ciffenum_components *This = impl_from_IEnumCifComponents(iface);
+ LONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) ref=%ld\n", This, ref);
+
+ if(!ref)
+ {
+ ICifFile_Release(This->file);
+ heap_free(This);
+ }
+
+ return ref;
+}
+
+static HRESULT WINAPI enum_components_Next(IEnumCifComponents *iface, ICifComponent **component)
+{
+ struct ciffenum_components *This = impl_from_IEnumCifComponents(iface);
+ struct cifcomponent *comp;
+
+ TRACE("(%p)->(%p)\n", This, component);
+
+ if (!component)
+ return E_FAIL;
+
+ if (!This->position)
+ {
+ *component = NULL;
+ return E_FAIL;
+ }
+
+ do
+ {
+ This->position = list_next(This->start, This->position);
+ if (!This->position)
+ {
+ *component = NULL;
+ return E_FAIL;
+ }
+
+ comp = CONTAINING_RECORD(This->position, struct cifcomponent, entry);
+ } while (This->group_id && (!comp->group || strcmp(This->group_id, comp->group)));
+
+ *component = &comp->ICifComponent_iface;
+ return S_OK;
+}
+
+static HRESULT WINAPI enum_components_Reset(IEnumCifComponents *iface)
+{
+ struct ciffenum_components *This = impl_from_IEnumCifComponents(iface);
+
+ TRACE("(%p)\n", This);
+
+ This->position = This->start;
+ return S_OK;
+}
+
+static const IEnumCifComponentsVtbl enum_componentsVtbl =
+{
+ enum_components_QueryInterface,
+ enum_components_AddRef,
+ enum_components_Release,
+ enum_components_Next,
+ enum_components_Reset,
+};
+
+static HRESULT enum_components_create(ICifFile *file, struct list *start, char *group_id, IEnumCifComponents **iface)
+{
+ struct ciffenum_components *enumerator;
+
+ enumerator = heap_alloc_zero(sizeof(*enumerator));
+ if (!enumerator) return E_OUTOFMEMORY;
+
+ enumerator->IEnumCifComponents_iface.lpVtbl = &enum_componentsVtbl;
+ enumerator->ref = 1;
+ enumerator->file = file;
+ enumerator->start = start;
+ enumerator->position = start;
+ enumerator->group_id = group_id;
+
+ ICifFile_AddRef(file);
+
+ *iface = &enumerator->IEnumCifComponents_iface;
+ return S_OK;
+}
+
+static HRESULT WINAPI enum_groups_QueryInterface(IEnumCifGroups *iface, REFIID riid, void **ppv)
+{
+ struct ciffenum_groups *This = impl_from_IEnumCifGroups(iface);
+
+ if (IsEqualGUID(&IID_IUnknown, riid))
+ {
+ TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
+ *ppv = &This->IEnumCifGroups_iface;
+ }
+ /*
+ else if (IsEqualGUID(&IID_IEnumCifGroups, riid))
+ {
+ TRACE("(%p)->(IID_ICifFile %p)\n", This, ppv);
+ *ppv = &This->IEnumCifGroups_iface;
+ }
+ */
+ else
+ {
+ FIXME("(%p)->(%s %p) not found\n", This, debugstr_guid(riid), ppv);
+ *ppv = NULL;
+ return E_NOINTERFACE;
+ }
+
+ IUnknown_AddRef((IUnknown *)*ppv);
+ return S_OK;
+}
+
+static ULONG WINAPI enum_groups_AddRef(IEnumCifGroups *iface)
+{
+ struct ciffenum_groups *This = impl_from_IEnumCifGroups(iface);
+ LONG ref = InterlockedIncrement(&This->ref);
+
+ TRACE("(%p) ref=%ld\n", This, ref);
+
+ return ref;
+}
+
+static ULONG WINAPI enum_groups_Release(IEnumCifGroups *iface)
+{
+ struct ciffenum_groups *This = impl_from_IEnumCifGroups(iface);
+ LONG ref = InterlockedDecrement(&This->ref);
+
+ TRACE("(%p) ref=%ld\n", This, ref);
+
+ if(!ref)
+ {
+ ICifFile_Release(This->file);
+ heap_free(This);
+ }