1 | # $Id: Makefile.kmk 96571 2022-09-01 20:34:00Z vboxsync $
|
---|
2 | ## @file
|
---|
3 | # Sub-Makefile for the stub installer.
|
---|
4 | #
|
---|
5 |
|
---|
6 | #
|
---|
7 | # Copyright (C) 2009-2022 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 |
|
---|
28 | SUB_DEPTH = ../../../../..
|
---|
29 | include $(KBUILD_PATH)/subheader.kmk
|
---|
30 |
|
---|
31 | TEMPLATE_VBOXSTUB = Drop the signing, we will sign it later.
|
---|
32 | TEMPLATE_VBOXSTUB_EXTENDS = VBOXR3STATIC
|
---|
33 | TEMPLATE_VBOXSTUB_POST_CMDS = $(NO_SUCH_VARIABLE)
|
---|
34 |
|
---|
35 | #
|
---|
36 | # Installer stub program
|
---|
37 | #
|
---|
38 | PROGRAMS += VBoxStub
|
---|
39 | VBoxStub_TEMPLATE= VBOXSTUB
|
---|
40 | VBoxStub_BLD_TRG_ARCH = x86
|
---|
41 | VBoxStub_DEFS = _WIN32_WINNT=0x0501 IN_RT_R3
|
---|
42 |
|
---|
43 | VBoxStub_SOURCES = \
|
---|
44 | VBoxStub.cpp \
|
---|
45 | VBoxStub.rc
|
---|
46 |
|
---|
47 | VBoxStub_SDKS += \
|
---|
48 | VBOX_NTDLL
|
---|
49 | ifeq ($(KBUILD_TARGET_ARCH),x86)
|
---|
50 | VBoxStub_LIBS += \
|
---|
51 | $(PATH_TOOL_$(VBOX_VCC_TOOL)_LIB)/delayimp.lib \
|
---|
52 | $(VBOX_LIB_RUNTIME_STATIC)
|
---|
53 | else
|
---|
54 | VBoxStub_LIBS += \
|
---|
55 | $(PATH_TOOL_$(VBOX_VCC_TOOL_STEM)X86_LIB)/delayimp.lib \
|
---|
56 | $(PATH_STAGE_LIB)/RuntimeR3-x86.lib
|
---|
57 | endif
|
---|
58 |
|
---|
59 | VBoxStub_LDFLAGS = -SubSystem:Windows -DelayLoad:comctl32.dll
|
---|
60 | VBoxStub_POST_CMDS = $(VBOX_CHECK_IMPORTS) --image $(out) ntdll.dll kernel32.dll
|
---|
61 | ifeq ($(KBUILD_TYPE),asan)
|
---|
62 | VBoxStub_POST_CMDS += advapi32.dll
|
---|
63 | endif
|
---|
64 | VBoxStub_LNK_DEPS = $(VBOX_CHECK_IMPORTS)
|
---|
65 |
|
---|
66 | VBoxStub.cpp_DEFS += VBOX_SVN_REV=$(VBOX_SVN_REV)
|
---|
67 | VBoxStub.cpp_DEPS = $(VBOX_SVN_REV_KMK)
|
---|
68 |
|
---|
69 | # If signing mode is enabled, then add the possibility to install the code
|
---|
70 | # signing certificates (public key only) automatically in /silent mode.
|
---|
71 | ifdef VBOX_SIGNING_MODE
|
---|
72 |
|
---|
73 | VBoxStub_SOURCES += VBoxStubCertUtil.cpp
|
---|
74 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h
|
---|
75 | VBoxStub.cpp_DEPS += $(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h
|
---|
76 | VBoxStub.cpp_INCS += $(VBoxStub_0_OUTDIR)
|
---|
77 | VBoxStub.cpp_DEFS += VBOX_WITH_CODE_SIGNING
|
---|
78 | ifdef VBOX_WITH_VBOX_LEGACY_TS_CA
|
---|
79 | VBoxStub.cpp_DEFS += VBOX_WITH_VBOX_LEGACY_TS_CA
|
---|
80 | endif
|
---|
81 |
|
---|
82 | $$(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h: | $$(dir $$@) $(VBOX_RTSIGNTOOL) $(VBOX_BIN2C) $(PATH_STAGE_SYS)/VBoxSup.sys
|
---|
83 | $(RM) -f -- "$@" "$@.cer0" "$@.cer1" "$@.cer2" "$@.array"
|
---|
84 |
|
---|
85 | $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --signature-index 0 --exe "$(PATH_STAGE_SYS)/VBoxSup.sys" --output "$@.cer0" --der
|
---|
86 | $(VBOX_BIN2C) -ascii --append VBoxStubTrustedCert0 "$@.cer0" $@
|
---|
87 | $(APPEND) "$@.array" " { g_abVBoxStubTrustedCert0, sizeof(g_abVBoxStubTrustedCert0) }, "
|
---|
88 | if defined(VBOX_CERTIFICATE_SUBJECT_NAME) && defined(VBOX_CERTIFICATE_SHA2_SUBJECT_NAME)
|
---|
89 | $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --signature-index 1 --exe "$(PATH_STAGE_SYS)/VBoxSup.sys" --output "$@.cer1" --der
|
---|
90 | $(VBOX_BIN2C) -ascii --append VBoxStubTrustedCert1 "$@.cer1" $@
|
---|
91 | $(APPEND) "$@.array" " { g_abVBoxStubTrustedCert1, sizeof(g_abVBoxStubTrustedCert1) }, "
|
---|
92 | endif
|
---|
93 | if $(intersects win_planb,$(VBOX_WITH_CORP_CODE_SIGNING))
|
---|
94 | $(VBOX_RTSIGNTOOL) extract-exe-signer-cert --signature-index 1 --exe "$(VBOX_RTSIGNTOOL)" --output "$@.cer2" --der
|
---|
95 | $(VBOX_BIN2C) -ascii --append VBoxStubTrustedCert2 "$@.cer2" $@
|
---|
96 | $(APPEND) "$@.array" " { g_abVBoxStubTrustedCert2, sizeof(g_abVBoxStubTrustedCert2) }, "
|
---|
97 | endif
|
---|
98 | $(APPEND) -n "$@" \
|
---|
99 | "" \
|
---|
100 | "struct { uint8_t const *pab; uint32_t cb; }" "g_aVBoxStubTrustedCerts[] = " \
|
---|
101 | "{"
|
---|
102 | $(SED) --append "$@" -e "" "$@.array"
|
---|
103 | $(APPEND) -n "$@" \
|
---|
104 | "};"
|
---|
105 | $(RM) -f -- "$@.cer0" "$@.cer1" "$@.cer2" "$@.array"
|
---|
106 | ifdef VBOX_WITH_VBOX_LEGACY_TS_CA
|
---|
107 | $(VBOX_BIN2C) -ascii --append VBoxLegacyWinCA "$(VBOX_LEGACY_TS_CA_FILE)" $@
|
---|
108 | endif
|
---|
109 |
|
---|
110 | VBoxStubPublicCert.h:: $$(VBoxStub_0_OUTDIR)/VBoxStubPublicCert.h
|
---|
111 |
|
---|
112 | endif
|
---|
113 |
|
---|
114 | # The icon location is configurable.
|
---|
115 | VBoxStub.rc_INCS += $(VBoxStub_0_OUTDIR)
|
---|
116 | VBoxStub.rc_DEPS += \
|
---|
117 | $(VBoxStub_0_OUTDIR)/VBoxStub-icon.rc \
|
---|
118 | $(VBoxStub_0_OUTDIR)/VBoxStub-manifest.rc
|
---|
119 | VBoxStub_CLEAN += \
|
---|
120 | $(VBoxStub_0_OUTDIR)/VBoxStub-icon.rc \
|
---|
121 | $(VBoxStub_0_OUTDIR)/VBoxStub-manifest.rc
|
---|
122 |
|
---|
123 | # Icon include file.
|
---|
124 | $$(VBoxStub_0_OUTDIR)/VBoxStub-icon.rc: $(VBOX_WINDOWS_ICON_FILE) $(MAKEFILE_CURRENT) | $$(dir $$@)
|
---|
125 | $(APPEND) -t $@ 'IDI_VIRTUALBOX ICON DISCARDABLE "$(subst /,\\,$(VBOX_WINDOWS_ICON_FILE))"'
|
---|
126 |
|
---|
127 | # Manifest.
|
---|
128 | VBOX_STUB_MANIFEST_FILE := $(PATH_SUB_CURRENT)/VBoxStub.manifest
|
---|
129 | $$(VBoxStub_0_OUTDIR)/VBoxStub-manifest.rc: $(VBOX_STUB_MANIFEST_FILE) $(MAKEFILE_CURRENT) | $$(dir $$@)
|
---|
130 | $(APPEND) -t $@ 'APP_MANIFEST RT_MANIFEST "$(subst /,\\,$(VBOX_STUB_MANIFEST_FILE))"'
|
---|
131 |
|
---|
132 | # Dynamic import no. 1: MSI.DLL
|
---|
133 | VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm
|
---|
134 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm
|
---|
135 | $$(VBoxStub_0_OUTDIR)/MsiLazyLoad.asm: $(PATH_SUB_CURRENT)/msi.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
|
---|
136 | $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
|
---|
137 | $(QUIET)$(RM) -f -- "$@"
|
---|
138 | $(VBOX_DEF_2_LAZY_LOAD) --system --library MSI.DLL --output "$@" $(filter %.def, $^)
|
---|
139 |
|
---|
140 | # Dynamic import no. 2: CRYPTO32.DLL
|
---|
141 | VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm
|
---|
142 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm
|
---|
143 | $$(VBoxStub_0_OUTDIR)/Crypt32LazyLoad.asm: $(PATH_SUB_CURRENT)/crypt32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
|
---|
144 | $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
|
---|
145 | $(QUIET)$(RM) -f -- "$@"
|
---|
146 | $(VBOX_DEF_2_LAZY_LOAD) --system --library CRYPT32.DLL --output "$@" $(filter %.def, $^)
|
---|
147 |
|
---|
148 | # Dynamic import no. 3: WS2_32.DLL
|
---|
149 | VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm
|
---|
150 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm
|
---|
151 | $$(VBoxStub_0_OUTDIR)/Ws232LazyLoad.asm: $(PATH_SUB_CURRENT)/ws2_32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
|
---|
152 | $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
|
---|
153 | $(QUIET)$(RM) -f -- "$@"
|
---|
154 | $(VBOX_DEF_2_LAZY_LOAD) --system --library WS2_32.DLL --output "$@" $(filter %.def, $^)
|
---|
155 |
|
---|
156 | # Dynamic import no. 4: USER32.DLL
|
---|
157 | VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/User32LazyLoad.asm
|
---|
158 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/User32LazyLoad.asm
|
---|
159 | $$(VBoxStub_0_OUTDIR)/User32LazyLoad.asm: $(PATH_SUB_CURRENT)/user32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
|
---|
160 | $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
|
---|
161 | $(QUIET)$(RM) -f -- "$@"
|
---|
162 | $(VBOX_DEF_2_LAZY_LOAD) --system --library USER32.DLL --output "$@" $(filter %.def, $^)
|
---|
163 |
|
---|
164 | # Dynamic import no. 5: SHELL32.DLL
|
---|
165 | VBoxStub_SOURCES += $(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm
|
---|
166 | VBoxStub_CLEAN += $(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm
|
---|
167 | $$(VBoxStub_0_OUTDIR)/Shell32LazyLoad.asm: $(PATH_SUB_CURRENT)/shell32.def $(VBOX_DEF_2_LAZY_LOAD) | $$(dir $$@)
|
---|
168 | $(call MSG_TOOL,VBoxDef2LazyLoad,VBoxStub,$(filter %.def, $^),$@)
|
---|
169 | $(QUIET)$(RM) -f -- "$@"
|
---|
170 | $(VBOX_DEF_2_LAZY_LOAD) --system --library SHELL32.DLL --output "$@" $(filter %.def, $^)
|
---|
171 |
|
---|
172 | include $(FILE_KBUILD_SUB_FOOTER)
|
---|
173 |
|
---|