VirtualBox

source: vbox/trunk/src/VBox/Installer/win/Stub/Makefile.kmk@ 108546

Last change on this file since 108546 was 108546, checked in by vboxsync, 6 weeks ago

Windows host installer stub (VBoxStub): GdiplusShutdown() apparently forgets to uninit COM, so we have to do that ourselves via CoUninitialize(). Not doing that will result in a debug assertion in experimental code in rtThreadNativeUninitComAndOle() where we check for dangling COM inits. Sigh. bugref:10870

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.1 KB
Line 
1# $Id: Makefile.kmk 108546 2025-03-13 09:28:55Z vboxsync $
2## @file
3# Sub-Makefile for the stub installer.
4#
5
6#
7# Copyright (C) 2009-2024 Oracle and/or its affiliates.
8#
9# This file is part of VirtualBox base platform packages, as
10# available from https://www.virtualbox.org.
11#
12# This program is free software; you can redistribute it and/or
13# modify it under the terms of the GNU General Public License
14# as published by the Free Software Foundation, in version 3 of the
15# License.
16#
17# This program is distributed in the hope that it will be useful, but
18# WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20# General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, see <https://www.gnu.org/licenses>.
24#
25# SPDX-License-Identifier: GPL-3.0-only
26#
27
28SUB_DEPTH = ../../../../..
29include $(KBUILD_PATH)/subheader.kmk
30
31
32#
33# Special template variation.
34#
35TEMPLATE_VBoxStubTemplate := Drop the signing, we will sign it later.
36TEMPLATE_VBoxStubTemplate_EXTENDS := VBoxR3Static
37TEMPLATE_VBoxStubTemplate_POST_CMDS = $(NO_SUCH_VARIABLE)
38
39
40#
41# Installer stub program
42#
43if1of ($(KBUILD_TARGET_ARCH), x86 amd64) # don't care for this on arm64
44 PROGRAMS += VBoxStub
45 VBoxStub_TEMPLATE := VBoxStubTemplate
46 VBoxStub_BLD_TRG_ARCH := x86
47 VBoxStub_DEFS := IN_RT_R3 _WIN32_WINNT=0x0501
48endif
49
50VBoxStub_SOURCES = \
51 VBoxStub.cpp \
52 VBoxStub.rc
53
54VBoxStub_SDKS = \
55 VBoxNtDll
56
57# Enables splash screen support.
58VBOX_STUB_WITH_SPLASH = 1
59
60ifdef VBOX_STUB_WITH_SPLASH
61 VBoxStub.cpp_DEFS += VBOX_STUB_WITH_SPLASH
62 VBoxStub.rc_DEFS += VBOX_STUB_WITH_SPLASH
63 VBoxStub_CXXFLAGS += -wd5039 # pointer or reference to potentially throwing function passed to 'extern "C"' function under -EHc. Undefined behavior may occur if this function throws an exception.
64 VBOX_STUB_IMPORTS += user32.dll shlwapi.dll gdi32.dll
65 # gdiplus apparently forgets to uninit COM in GdiplusShutdown(), so we have to do that ourselves via CoUninitialize().
66 # Not doing that will result in a debug assertion in experimental code in rtThreadNativeUninitComAndOle()
67 # where we check for dangling COM inits.
68 VBOX_STUB_IMPORTS += ole32.dll
69endif
70
71VBoxStub_LDFLAGS = -SubSystem:Windows
72VBoxStub_POST_CMDS = $(VBOX_CHECK_IMPORTS) --image $(out) ntdll.dll kernel32.dll $(VBOX_STUB_IMPORTS)
73ifeq ($(KBUILD_TYPE),asan)
74 VBoxStub_POST_CMDS += advapi32.dll clang_rt.asan_dynamic-i386.dll
75endif
76VBoxStub_LNK_DEPS = $(VBOX_CHECK_IMPORTS)
77
78VBoxStub.cpp_DEFS += VBOX_SVN_REV=$(VBOX_SVN_REV)
79VBoxStub.cpp_DEPS = $(VBOX_SVN_REV_KMK)
80
81# If signing mode is enabled, then add the possibility to install the code
82# signing certificates (public key only) automatically in /silent mode.
83ifdef VBOX_SIGNING_MODE
84
85 VBoxStub_SOURCES += VBoxStubCertUtil.cpp
86 VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h
87 VBoxStub.cpp_DEPS += $(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h
88 VBoxStub.cpp_INCS += $(VBoxStub_0_OUTDIR)
89 VBoxStub.cpp_DEFS += VBOX_WITH_CODE_SIGNING
90 ifdef VBOX_WITH_VBOX_LEGACY_TS_CA
91 VBoxStub.cpp_DEFS += VBOX_WITH_VBOX_LEGACY_TS_CA
92 endif
93
94 $$(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h: | $$(dir $$@) $(VBOX_RTSIGNTOOL) $(VBOX_BIN2C) $(PATH_STAGE_SYS)/VBoxSup.sys
95 $(RM) -f -- "$@" "[email protected]" "[email protected]" "[email protected]" "[email protected]"
96
97 $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --signature-index 0 --exe "$(PATH_STAGE_SYS)/VBoxSup.sys" --output "[email protected]" --der
98 $(VBOX_BIN2C) -ascii --append VBoxStubTrustedCert0 "[email protected]" $@
99 $(APPEND) "[email protected]" " { g_abVBoxStubTrustedCert0, sizeof(g_abVBoxStubTrustedCert0) }, "
100 if defined(VBOX_CERTIFICATE_SUBJECT_NAME) && defined(VBOX_CERTIFICATE_SHA2_SUBJECT_NAME) && !$(intersects win_planc,$(VBOX_WITH_CORP_CODE_SIGNING))
101 $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --signature-index 1 --exe "$(PATH_STAGE_SYS)/VBoxSup.sys" --output "[email protected]" --der
102 $(VBOX_BIN2C) -ascii --append VBoxStubTrustedCert1 "[email protected]" $@
103 $(APPEND) "[email protected]" " { g_abVBoxStubTrustedCert1, sizeof(g_abVBoxStubTrustedCert1) }, "
104 endif
105 if !$(intersects win,$(VBOX_WITH_CORP_CODE_SIGNING)) && $(intersects win_planb,$(VBOX_WITH_CORP_CODE_SIGNING))
106 $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --signature-index 1 --exe "$(VBOX_RTSIGNTOOL)" --output "[email protected]" --der
107 $(VBOX_BIN2C) -ascii --append VBoxStubTrustedCert2 "[email protected]" $@
108 $(APPEND) "[email protected]" " { g_abVBoxStubTrustedCert2, sizeof(g_abVBoxStubTrustedCert2) }, "
109 endif
110 $(APPEND) -n "$@" \
111 "" \
112 "struct { uint8_t const *pab; uint32_t cb; }" "g_aVBoxStubTrustedCerts[] = " \
113 "{"
114 $(SED) --append "$@" -e "" "[email protected]"
115 $(APPEND) -n "$@" \
116 "};"
117 $(RM) -f -- "[email protected]" "[email protected]" "[email protected]" "[email protected]"
118 ifdef VBOX_WITH_VBOX_LEGACY_TS_CA
119 $(RM) -f -- "[email protected]_tsca"
120 $(VBOX_RTSIGNTOOL) extract-timestamp-root --self-signed-roots-from-system --signature-index 0 --input "$(PATH_STAGE_SYS)/VBoxSup.sys" --output "[email protected]_tsca"
121 $(VBOX_BIN2C) -ascii --append VBoxLegacyWinCA "[email protected]_tsca" $@
122 $(RM) -f -- "[email protected]_tsca"
123 endif
124
125 VBoxStubPublicCert.h:: $$(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h
126
127endif
128
129# The icon location is configurable.
130VBoxStub.rc_INCS += $(VBoxStub_0_OUTDIR)
131VBoxStub.rc_DEPS += \
132 $(VBoxStub_0_OUTDIR)/VBoxStub-icon.rc \
133 $(VBoxStub_0_OUTDIR)/VBoxStub-manifest.rc
134VBoxStub_CLEAN += \
135 $(VBoxStub_0_OUTDIR)/VBoxStub-icon.rc \
136 $(VBoxStub_0_OUTDIR)/VBoxStub-manifest.rc
137
138# Icon include file.
139$$(VBoxStub_0_OUTDIR)/VBoxStub-icon.rc: $(VBOX_WINDOWS_ICON_FILE) $(MAKEFILE_CURRENT) | $$(dir $$@)
140 $(APPEND) -t $@ 'IDI_VIRTUALBOX ICON DISCARDABLE "$(subst /,\\,$(VBOX_WINDOWS_ICON_FILE))"'
141
142# Manifest.
143VBOX_STUB_MANIFEST_FILE := $(PATH_SUB_CURRENT)/VBoxStub.manifest
144$$(VBoxStub_0_OUTDIR)/VBoxStub-manifest.rc: $(VBOX_STUB_MANIFEST_FILE) $(MAKEFILE_CURRENT) | $$(dir $$@)
145 $(APPEND) -t $@ 'APP_MANIFEST RT_MANIFEST "$(subst /,\\,$(VBOX_STUB_MANIFEST_FILE))"'
146
147# Dynamic import no. 1: MSI.DLL
148VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm
149VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm
150$$(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm: $(PATH_SUB_CURRENT)/msi.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
151 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
152 $(QUIET)$(RM) -f -- "$@"
153 $(VBOX_DEF_2_LAZY_LOAD) --target "$(VBoxStub_BLD_TRG_ARCH)" --system --library MSI.DLL --output "$@" $(filter %.def, $^)
154
155# Dynamic import no. 2: CRYPTO32.DLL
156VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm
157VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm
158$$(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm: $(PATH_SUB_CURRENT)/crypt32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
159 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
160 $(QUIET)$(RM) -f -- "$@"
161 $(VBOX_DEF_2_LAZY_LOAD) --target "$(VBoxStub_BLD_TRG_ARCH)" --system --library CRYPT32.DLL --output "$@" $(filter %.def, $^)
162
163# Dynamic import no. 3: WS2_32.DLL
164VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm
165VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm
166$$(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm: $(PATH_SUB_CURRENT)/ws2_32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
167 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
168 $(QUIET)$(RM) -f -- "$@"
169 $(VBOX_DEF_2_LAZY_LOAD) --target "$(VBoxStub_BLD_TRG_ARCH)" --system --library WS2_32.DLL --output "$@" $(filter %.def, $^)
170
171# Dynamic import no. 4: USER32.DLL
172VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/User32LazyLoad.asm
173VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/User32LazyLoad.asm
174$$(VBoxStub_0_OUTDIR)/User32LazyLoad.asm: $(PATH_SUB_CURRENT)/user32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
175 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
176 $(QUIET)$(RM) -f -- "$@"
177 $(VBOX_DEF_2_LAZY_LOAD) --target "$(VBoxStub_BLD_TRG_ARCH)" --system --library USER32.DLL --output "$@" $(filter %.def, $^)
178
179# Dynamic import no. 5: SHELL32.DLL
180VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm
181VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm
182$$(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm: $(PATH_SUB_CURRENT)/shell32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
183 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
184 $(QUIET)$(RM) -f -- "$@"
185 $(VBOX_DEF_2_LAZY_LOAD) --target "$(VBoxStub_BLD_TRG_ARCH)" --system --library SHELL32.DLL --output "$@" $(filter %.def, $^)
186
187# Dynamic import no. 6: COMCTL32.DLL
188VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/ComCtl32LazyLoad.asm
189VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/ComCtl32LazyLoad.asm
190$$(VBoxStub_0_OUTDIR)/ComCtl32LazyLoad.asm: $(PATH_SUB_CURRENT)/comctl32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
191 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
192 $(QUIET)$(RM) -f -- "$@"
193 $(VBOX_DEF_2_LAZY_LOAD) --target "$(VBoxStub_BLD_TRG_ARCH)" --system --library COMCTL32.DLL --output "$@" $(filter %.def, $^)
194
195# Dynamic import no. 7: GDIPLUS.DLL
196ifdef VBOX_STUB_WITH_SPLASH
197 VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/GdiPlusLazyLoad.asm
198 VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/GdiPlusLazyLoad.asm
199 $$(VBoxStub_0_OUTDIR)/GdiPlusLazyLoad.asm: $(PATH_SUB_CURRENT)/gdiplus.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
200 $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
201 $(QUIET)$(RM) -f -- "$@"
202 $(VBOX_DEF_2_LAZY_LOAD) --target "$(VBoxStub_BLD_TRG_ARCH)" --system --library GDIPLUS.DLL --output "$@" $(filter %.def, $^)
203endif
204
205include $(FILE_KBUILD_SUB_FOOTER)
206
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette