1 | /* $Id: SUPLibInternal.h 108724 2025-03-24 18:53:21Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Support Library - Internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-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 | * The contents of this file may alternatively be used under the terms
|
---|
26 | * of the Common Development and Distribution License Version 1.0
|
---|
27 | * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
28 | * in the VirtualBox distribution, in which case the provisions of the
|
---|
29 | * CDDL are applicable instead of those of the GPL.
|
---|
30 | *
|
---|
31 | * You may elect to license modified versions of this file under the
|
---|
32 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
33 | *
|
---|
34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
35 | */
|
---|
36 |
|
---|
37 | #ifndef VBOX_INCLUDED_SRC_Support_SUPLibInternal_h
|
---|
38 | #define VBOX_INCLUDED_SRC_Support_SUPLibInternal_h
|
---|
39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
40 | # pragma once
|
---|
41 | #endif
|
---|
42 |
|
---|
43 | #include <VBox/cdefs.h>
|
---|
44 | #include <VBox/types.h>
|
---|
45 | #include <iprt/stdarg.h>
|
---|
46 | #if defined(RT_OS_LINUX) && defined(RT_ARCH_ARM64)
|
---|
47 | # include <iprt/system.h>
|
---|
48 | #endif
|
---|
49 |
|
---|
50 |
|
---|
51 | /*******************************************************************************
|
---|
52 | * Defined Constants And Macros *
|
---|
53 | *******************************************************************************/
|
---|
54 | /** @def SUPLIB_DLL_SUFF
|
---|
55 | * The (typical) DLL/DYLIB/SO suffix. */
|
---|
56 | #if defined(RT_OS_DARWIN)
|
---|
57 | # define SUPLIB_DLL_SUFF ".dylib"
|
---|
58 | #elif defined(RT_OS_L4)
|
---|
59 | # define SUPLIB_DLL_SUFF ".s.so"
|
---|
60 | #elif defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
|
---|
61 | # define SUPLIB_DLL_SUFF ".dll"
|
---|
62 | #else
|
---|
63 | # define SUPLIB_DLL_SUFF ".so"
|
---|
64 | #endif
|
---|
65 |
|
---|
66 | #ifdef RT_OS_SOLARIS
|
---|
67 | /** Number of dummy files to open (2:ip4, 1:ip6, 1:extra) see
|
---|
68 | * @bugref{4650}. */
|
---|
69 | # define SUPLIB_FLT_DUMMYFILES 4
|
---|
70 | #endif
|
---|
71 |
|
---|
72 | /** @def SUPLIB_EXE_SUFF
|
---|
73 | * The (typical) executable suffix. */
|
---|
74 | #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)
|
---|
75 | # define SUPLIB_EXE_SUFF ".exe"
|
---|
76 | #else
|
---|
77 | # define SUPLIB_EXE_SUFF ""
|
---|
78 | #endif
|
---|
79 |
|
---|
80 | /** @def SUP_HARDENED_SUID
|
---|
81 | * Whether we're employing set-user-ID-on-execute in the hardening.
|
---|
82 | */
|
---|
83 | #if (!defined(RT_OS_OS2) && !defined(RT_OS_WINDOWS) && !defined(RT_OS_L4)) || defined(DOXYGEN_RUNNING)
|
---|
84 | # define SUP_HARDENED_SUID
|
---|
85 | #else
|
---|
86 | # undef SUP_HARDENED_SUID
|
---|
87 | #endif
|
---|
88 |
|
---|
89 | /** @def SUP_PAGE_SIZE
|
---|
90 | * Page size of the host, can evaluate to a function call on certain hosts where
|
---|
91 | * the page size is not known during compile time.
|
---|
92 | */
|
---|
93 | #if defined(RT_OS_LINUX) && defined(RT_ARCH_ARM64)
|
---|
94 | # define SUP_PAGE_SIZE RTSystemGetPageSize()
|
---|
95 | #else
|
---|
96 | # define SUP_PAGE_SIZE HOST_PAGE_SIZE
|
---|
97 | #endif
|
---|
98 |
|
---|
99 | /** @def SUP_PAGE_SHIFT
|
---|
100 | * Page shift of the host, can evaluate to a function call on certain hosts where
|
---|
101 | * the page size is not known during compile time.
|
---|
102 | */
|
---|
103 | #if defined(RT_OS_LINUX) && defined(RT_ARCH_ARM64)
|
---|
104 | # define SUP_PAGE_SHIFT RTSystemGetPageShift()
|
---|
105 | #else
|
---|
106 | # define SUP_PAGE_SHIFT HOST_PAGE_SHIFT
|
---|
107 | #endif
|
---|
108 |
|
---|
109 | /** @def SUP_PAGE_OFFSET_MASK
|
---|
110 | * Page shift of the host, can evaluate to a function call on certain hosts where
|
---|
111 | * the page size is not known during compile time.
|
---|
112 | */
|
---|
113 | #if defined(RT_OS_LINUX) && defined(RT_ARCH_ARM64)
|
---|
114 | # define SUP_PAGE_OFFSET_MASK RTSystemGetPageOffsetMask()
|
---|
115 | #else
|
---|
116 | # define SUP_PAGE_OFFSET_MASK HOST_PAGE_OFFSET_MASK
|
---|
117 | #endif
|
---|
118 |
|
---|
119 |
|
---|
120 | #ifdef IN_SUP_HARDENED_R3
|
---|
121 | /** @name Make the symbols in SUPR3HardenedStatic different from the VBoxRT ones.
|
---|
122 | * We cannot rely on DECLHIDDEN to make this separation for us since it doesn't
|
---|
123 | * work with all GCC versions. So, we resort to old fashion precompiler hacking.
|
---|
124 | * @{
|
---|
125 | */
|
---|
126 | # define supR3HardenedPathAppPrivateNoArch supR3HardenedStaticPathAppPrivateNoArch
|
---|
127 | # define supR3HardenedPathAppPrivateArch supR3HardenedStaticPathAppPrivateArch
|
---|
128 | # define supR3HardenedPathAppSharedLibs supR3HardenedStaticPathAppSharedLibs
|
---|
129 | # define supR3HardenedPathAppDocs supR3HardenedStaticPathAppDocs
|
---|
130 | # define supR3HardenedPathAppBin supR3HardenedStaticPathAppBin
|
---|
131 | # define supR3HardenedPathFilename supR3HardenedStaticPathFilename
|
---|
132 | # define supR3HardenedFatalV supR3HardenedStaticFatalV
|
---|
133 | # define supR3HardenedFatal supR3HardenedStaticFatal
|
---|
134 | # define supR3HardenedFatalMsgV supR3HardenedStaticFatalMsgV
|
---|
135 | # define supR3HardenedFatalMsg supR3HardenedStaticFatalMsg
|
---|
136 | # define supR3HardenedErrorV supR3HardenedStaticErrorV
|
---|
137 | # define supR3HardenedError supR3HardenedStaticError
|
---|
138 | # define supR3HardenedOpenLog supR3HardenedStaticOpenLog
|
---|
139 | # define supR3HardenedLogV supR3HardenedStaticLogV
|
---|
140 | # define supR3HardenedLog supR3HardenedStaticLog
|
---|
141 | # define supR3HardenedLogFlush supR3HardenedStaticLogFlush
|
---|
142 | # define supR3HardenedVerifyAll supR3HardenedStaticVerifyAll
|
---|
143 | # define supR3HardenedVerifyFixedDir supR3HardenedStaticVerifyFixedDir
|
---|
144 | # define supR3HardenedVerifyFixedFile supR3HardenedStaticVerifyFixedFile
|
---|
145 | # define supR3HardenedVerifyDir supR3HardenedStaticVerifyDir
|
---|
146 | # define supR3HardenedVerifyFile supR3HardenedStaticVerifyFile
|
---|
147 | # define supR3HardenedGetPreInitData supR3HardenedStaticGetPreInitData
|
---|
148 | # define supR3HardenedRecvPreInitData supR3HardenedStaticRecvPreInitData
|
---|
149 | /** @} */
|
---|
150 | #endif /* IN_SUP_HARDENED_R3 */
|
---|
151 |
|
---|
152 |
|
---|
153 | /** @name CRT function mappings (not using CRT on Windows).
|
---|
154 | * @{
|
---|
155 | */
|
---|
156 | #if defined(IN_SUP_HARDENED_R3) && defined(RT_OS_WINDOWS)
|
---|
157 | # define SUP_HARDENED_NEED_CRT_FUNCTIONS
|
---|
158 | DECLHIDDEN(int) suplibHardenedMemComp(void const *pvDst, const void *pvSrc, size_t cbToComp);
|
---|
159 | DECLHIDDEN(void *) suplibHardenedMemCopy(void *pvDst, const void *pvSrc, size_t cbToCopy);
|
---|
160 | DECLHIDDEN(void *) suplibHardenedMemSet(void *pvDst, int ch, size_t cbToSet);
|
---|
161 | DECLHIDDEN(char *) suplibHardenedStrCopy(char *pszDst, const char *pszSrc);
|
---|
162 | DECLHIDDEN(size_t) suplibHardenedStrLen(const char *psz);
|
---|
163 | DECLHIDDEN(char *) suplibHardenedStrCat(char *pszDst, const char *pszSrc);
|
---|
164 | DECLHIDDEN(int) suplibHardenedStrCmp(const char *psz1, const char *psz2);
|
---|
165 | DECLHIDDEN(int) suplibHardenedStrNCmp(const char *psz1, const char *psz2, size_t cchMax);
|
---|
166 | #else
|
---|
167 | # undef SUP_HARDENED_NEED_CRT_FUNCTIONS
|
---|
168 | # define suplibHardenedMemComp memcmp
|
---|
169 | # define suplibHardenedMemCopy memcpy
|
---|
170 | # define suplibHardenedMemSet memset
|
---|
171 | # define suplibHardenedStrCopy strcpy
|
---|
172 | # define suplibHardenedStrLen strlen
|
---|
173 | # define suplibHardenedStrCat strcat
|
---|
174 | # define suplibHardenedStrCmp strcmp
|
---|
175 | # define suplibHardenedStrNCmp strncmp
|
---|
176 | #endif
|
---|
177 | DECLHIDDEN(DECL_NO_RETURN(void)) suplibHardenedExit(RTEXITCODE rcExit);
|
---|
178 | DECLHIDDEN(void) suplibHardenedPrintF(const char *pszFormat, ...);
|
---|
179 | DECLHIDDEN(void) suplibHardenedPrintFV(const char *pszFormat, va_list va);
|
---|
180 |
|
---|
181 | /** @} */
|
---|
182 |
|
---|
183 | /** Debug output macro. */
|
---|
184 | #ifdef IN_SUP_HARDENED_R3
|
---|
185 | # if defined(DEBUG_bird) && defined(RT_OS_WINDOWS)
|
---|
186 | # define SUP_DPRINTF(a) do { supR3HardenedStaticLog a; suplibHardenedPrintF a; } while (0)
|
---|
187 | # else
|
---|
188 | # define SUP_DPRINTF(a) do { supR3HardenedStaticLog a; } while (0)
|
---|
189 | # endif
|
---|
190 | #else
|
---|
191 | # if defined(DEBUG_bird) && defined(RT_OS_WINDOWS)
|
---|
192 | # define SUP_DPRINTF(a) RTLogPrintf a
|
---|
193 | # else
|
---|
194 | # define SUP_DPRINTF(a) do { } while (0)
|
---|
195 | # endif
|
---|
196 | #endif
|
---|
197 |
|
---|
198 |
|
---|
199 | /*******************************************************************************
|
---|
200 | * Structures and Typedefs *
|
---|
201 | *******************************************************************************/
|
---|
202 | /**
|
---|
203 | * The type of an installed file.
|
---|
204 | */
|
---|
205 | typedef enum SUPINSTFILETYPE
|
---|
206 | {
|
---|
207 | kSupIFT_Invalid = 0,
|
---|
208 | kSupIFT_Exe,
|
---|
209 | kSupIFT_Dll,
|
---|
210 | kSupIFT_Rc,
|
---|
211 | kSupIFT_Sys,
|
---|
212 | kSupIFT_Script,
|
---|
213 | kSupIFT_Data,
|
---|
214 | kSupIFT_TestExe,
|
---|
215 | kSupIFT_TestDll,
|
---|
216 | kSupIFT_End
|
---|
217 | } SUPINSTFILETYPE;
|
---|
218 |
|
---|
219 | /**
|
---|
220 | * Installation directory specifier.
|
---|
221 | */
|
---|
222 | typedef enum SUPINSTDIR
|
---|
223 | {
|
---|
224 | kSupID_Invalid = 0,
|
---|
225 | kSupID_AppBin,
|
---|
226 | kSupID_AppSharedLib,
|
---|
227 | kSupID_AppPrivArch,
|
---|
228 | kSupID_AppPrivArchComp,
|
---|
229 | kSupID_AppPrivNoArch,
|
---|
230 | kSupID_Testcase,
|
---|
231 | #ifdef RT_OS_DARWIN
|
---|
232 | kSupID_AppMacHelper,
|
---|
233 | #endif
|
---|
234 | kSupID_End
|
---|
235 | } SUPINSTDIR;
|
---|
236 |
|
---|
237 | /**
|
---|
238 | * Installed file.
|
---|
239 | */
|
---|
240 | typedef struct SUPINSTFILE
|
---|
241 | {
|
---|
242 | /** File type. */
|
---|
243 | SUPINSTFILETYPE enmType;
|
---|
244 | /** Install directory. */
|
---|
245 | SUPINSTDIR enmDir;
|
---|
246 | /** Optional (true) or mandatory (false. */
|
---|
247 | bool fOptional;
|
---|
248 | /** File name. */
|
---|
249 | const char *pszFile;
|
---|
250 | } SUPINSTFILE;
|
---|
251 | typedef SUPINSTFILE *PSUPINSTFILE;
|
---|
252 | typedef SUPINSTFILE const *PCSUPINSTFILE;
|
---|
253 |
|
---|
254 | /**
|
---|
255 | * Status data for a verified file.
|
---|
256 | */
|
---|
257 | typedef struct SUPVERIFIEDFILE
|
---|
258 | {
|
---|
259 | /** The file handle or descriptor. -1 if not open. */
|
---|
260 | intptr_t hFile;
|
---|
261 | /** Whether the file has been validated. */
|
---|
262 | bool fValidated;
|
---|
263 | #ifdef RT_OS_WINDOWS
|
---|
264 | /** Whether we've checked the signature of the file. */
|
---|
265 | bool fCheckedSignature;
|
---|
266 | #endif
|
---|
267 | } SUPVERIFIEDFILE;
|
---|
268 | typedef SUPVERIFIEDFILE *PSUPVERIFIEDFILE;
|
---|
269 | typedef SUPVERIFIEDFILE const *PCSUPVERIFIEDFILE;
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * Status data for a verified directory.
|
---|
273 | */
|
---|
274 | typedef struct SUPVERIFIEDDIR
|
---|
275 | {
|
---|
276 | /** The directory handle or descriptor. -1 if not open. */
|
---|
277 | intptr_t hDir;
|
---|
278 | /** Whether the directory has been validated. */
|
---|
279 | bool fValidated;
|
---|
280 | } SUPVERIFIEDDIR;
|
---|
281 | typedef SUPVERIFIEDDIR *PSUPVERIFIEDDIR;
|
---|
282 | typedef SUPVERIFIEDDIR const *PCSUPVERIFIEDDIR;
|
---|
283 |
|
---|
284 |
|
---|
285 | /**
|
---|
286 | * SUPLib instance data.
|
---|
287 | *
|
---|
288 | * This is data that is passed from the static to the dynamic SUPLib
|
---|
289 | * in a hardened setup.
|
---|
290 | */
|
---|
291 | typedef struct SUPLIBDATA
|
---|
292 | {
|
---|
293 | /** The device handle. */
|
---|
294 | #if defined(RT_OS_WINDOWS)
|
---|
295 | void *hDevice;
|
---|
296 | #else
|
---|
297 | int hDevice;
|
---|
298 | #endif
|
---|
299 | /** Indicates whether we have unrestricted (true) or restricted access to the
|
---|
300 | * support device. */
|
---|
301 | bool fUnrestricted;
|
---|
302 | /** Set if we're in driverless mode. */
|
---|
303 | bool fDriverless;
|
---|
304 | #if defined(RT_OS_DARWIN)
|
---|
305 | /** The connection to the VBoxSupDrv service. */
|
---|
306 | uintptr_t uConnection;
|
---|
307 | #elif defined(RT_OS_LINUX)
|
---|
308 | /** Indicates whether madvise(,,MADV_DONTFORK) works. */
|
---|
309 | bool fSysMadviseWorks;
|
---|
310 | #elif defined(RT_OS_SOLARIS)
|
---|
311 | /** Extra dummy file descriptors to prevent growing file-descriptor table on
|
---|
312 | * clean up (see @bugref{4650}). */
|
---|
313 | int ahDummy[SUPLIB_FLT_DUMMYFILES];
|
---|
314 | #elif defined(RT_OS_WINDOWS)
|
---|
315 | #endif
|
---|
316 | } SUPLIBDATA;
|
---|
317 | /** Pointer to the pre-init data. */
|
---|
318 | typedef SUPLIBDATA *PSUPLIBDATA;
|
---|
319 | /** Pointer to const pre-init data. */
|
---|
320 | typedef SUPLIBDATA const *PCSUPLIBDATA;
|
---|
321 |
|
---|
322 | /** The NIL value of SUPLIBDATA::hDevice. */
|
---|
323 | #if defined(RT_OS_WINDOWS)
|
---|
324 | # define SUP_HDEVICE_NIL NULL
|
---|
325 | #else
|
---|
326 | # define SUP_HDEVICE_NIL (-1)
|
---|
327 | #endif
|
---|
328 |
|
---|
329 |
|
---|
330 | /**
|
---|
331 | * Pre-init data that is handed over from the hardened executable stub.
|
---|
332 | */
|
---|
333 | typedef struct SUPPREINITDATA
|
---|
334 | {
|
---|
335 | /** Magic value (SUPPREINITDATA_MAGIC). */
|
---|
336 | uint32_t u32Magic;
|
---|
337 | /** The SUPLib instance data. */
|
---|
338 | SUPLIBDATA Data;
|
---|
339 | /** The number of entries in paInstallFiles and paVerifiedFiles. */
|
---|
340 | size_t cInstallFiles;
|
---|
341 | /** g_aSupInstallFiles. */
|
---|
342 | PCSUPINSTFILE paInstallFiles;
|
---|
343 | /** g_aSupVerifiedFiles. */
|
---|
344 | PCSUPVERIFIEDFILE paVerifiedFiles;
|
---|
345 | /** The number of entries in paVerifiedDirs. */
|
---|
346 | size_t cVerifiedDirs;
|
---|
347 | /** g_aSupVerifiedDirs. */
|
---|
348 | PCSUPVERIFIEDDIR paVerifiedDirs;
|
---|
349 | /** Magic value (SUPPREINITDATA_MAGIC). */
|
---|
350 | uint32_t u32EndMagic;
|
---|
351 | } SUPPREINITDATA;
|
---|
352 | typedef SUPPREINITDATA *PSUPPREINITDATA;
|
---|
353 | typedef SUPPREINITDATA const *PCSUPPREINITDATA;
|
---|
354 |
|
---|
355 | /** Magic value for SUPPREINITDATA::u32Magic and SUPPREINITDATA::u32EndMagic. */
|
---|
356 | #define SUPPREINITDATA_MAGIC UINT32_C(0xbeef0001)
|
---|
357 |
|
---|
358 | /** @copydoc supR3PreInit */
|
---|
359 | typedef DECLCALLBACKTYPE(int, FNSUPR3PREINIT,(PSUPPREINITDATA pPreInitData, uint32_t fFlags));
|
---|
360 | /** Pointer to supR3PreInit. */
|
---|
361 | typedef FNSUPR3PREINIT *PFNSUPR3PREINIT;
|
---|
362 |
|
---|
363 | /** The current SUPR3HardenedMain state / location. */
|
---|
364 | typedef enum SUPR3HARDENEDMAINSTATE
|
---|
365 | {
|
---|
366 | SUPR3HARDENEDMAINSTATE_NOT_YET_CALLED = 0,
|
---|
367 | SUPR3HARDENEDMAINSTATE_WIN_EARLY_INIT_CALLED,
|
---|
368 | SUPR3HARDENEDMAINSTATE_WIN_EARLY_IMPORTS_RESOLVED,
|
---|
369 | SUPR3HARDENEDMAINSTATE_WIN_EARLY_STUB_DEVICE_OPENED,
|
---|
370 | SUPR3HARDENEDMAINSTATE_WIN_EARLY_REAL_DEVICE_OPENED,
|
---|
371 | SUPR3HARDENEDMAINSTATE_WIN_EP_CALLED,
|
---|
372 | SUPR3HARDENEDMAINSTATE_WIN_IMPORTS_RESOLVED,
|
---|
373 | SUPR3HARDENEDMAINSTATE_WIN_VERSION_INITIALIZED,
|
---|
374 | SUPR3HARDENEDMAINSTATE_WIN_VERIFY_TRUST_READY,
|
---|
375 | SUPR3HARDENEDMAINSTATE_HARDENED_MAIN_CALLED,
|
---|
376 | SUPR3HARDENEDMAINSTATE_INIT_RUNTIME,
|
---|
377 | SUPR3HARDENEDMAINSTATE_GET_TRUSTED_MAIN,
|
---|
378 | SUPR3HARDENEDMAINSTATE_CALLED_TRUSTED_MAIN,
|
---|
379 | SUPR3HARDENEDMAINSTATE_END,
|
---|
380 | SUPR3HARDENEDMAINSTATE_32BIT_HACK = 0x7fffffff
|
---|
381 | } SUPR3HARDENEDMAINSTATE;
|
---|
382 |
|
---|
383 |
|
---|
384 | /*******************************************************************************
|
---|
385 | * Global Variables *
|
---|
386 | *******************************************************************************/
|
---|
387 | extern DECL_HIDDEN_DATA(uint32_t) g_u32Cookie;
|
---|
388 | extern DECL_HIDDEN_DATA(uint32_t) g_u32SessionCookie;
|
---|
389 | extern DECL_HIDDEN_DATA(uint32_t) g_uSupSessionVersion;
|
---|
390 | extern DECL_HIDDEN_DATA(SUPLIBDATA) g_supLibData;
|
---|
391 | extern DECL_HIDDEN_DATA(uint32_t) g_uSupFakeMode;
|
---|
392 | extern DECL_HIDDEN_DATA(PSUPGLOBALINFOPAGE) g_pSUPGlobalInfoPageR0;
|
---|
393 | #ifdef VBOX_INCLUDED_SRC_Support_SUPDrvIOC_h
|
---|
394 | extern DECL_HIDDEN_DATA(PSUPQUERYFUNCS) g_pSupFunctions;
|
---|
395 | #endif
|
---|
396 | extern DECL_HIDDEN_DATA(SUPR3HARDENEDMAINSTATE) g_enmSupR3HardenedMainState;
|
---|
397 | #ifdef RT_OS_WINDOWS
|
---|
398 | extern DECL_HIDDEN_DATA(bool) g_fSupEarlyProcessInit;
|
---|
399 | #endif
|
---|
400 |
|
---|
401 |
|
---|
402 | /*******************************************************************************
|
---|
403 | * OS Specific Function *
|
---|
404 | *******************************************************************************/
|
---|
405 | RT_C_DECLS_BEGIN
|
---|
406 | DECLHIDDEN(int) suplibOsInstall(void);
|
---|
407 | DECLHIDDEN(int) suplibOsUninstall(void);
|
---|
408 | DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo);
|
---|
409 | DECLHIDDEN(int) suplibOsTerm(PSUPLIBDATA pThis);
|
---|
410 | DECLHIDDEN(int) suplibOsHardenedVerifyInit(void);
|
---|
411 | DECLHIDDEN(int) suplibOsHardenedVerifyTerm(void);
|
---|
412 | DECLHIDDEN(int) suplibOsIOCtl(PSUPLIBDATA pThis, uintptr_t uFunction, void *pvReq, size_t cbReq);
|
---|
413 | DECLHIDDEN(int) suplibOsIOCtlFast(PSUPLIBDATA pThis, uintptr_t uFunction, uintptr_t idCpu);
|
---|
414 | DECLHIDDEN(int) suplibOsPageAlloc(PSUPLIBDATA pThis, size_t cPages, uint32_t fFlags, void **ppvPages);
|
---|
415 | DECLHIDDEN(int) suplibOsPageFree(PSUPLIBDATA pThis, void *pvPages, size_t cPages);
|
---|
416 | DECLHIDDEN(int) suplibOsQueryVTxSupported(const char **ppszWhy);
|
---|
417 | DECLHIDDEN(int) suplibOsQueryMicrocodeRev(uint32_t *puMicrocodeRev);
|
---|
418 | DECLHIDDEN(bool) suplibOsIsNemSupportedWhenNoVtxOrAmdV(void);
|
---|
419 |
|
---|
420 |
|
---|
421 | /**
|
---|
422 | * Performs the pre-initialization of the support library.
|
---|
423 | *
|
---|
424 | * This is dynamically resolved and invoked by the static library before it
|
---|
425 | * calls RTR3InitEx and thereby SUPR3Init.
|
---|
426 | *
|
---|
427 | * @returns IPRT status code.
|
---|
428 | * @param pPreInitData The pre init data.
|
---|
429 | * @param fFlags The SUPR3HardenedMain flags.
|
---|
430 | */
|
---|
431 | DECL_NOTHROW(DECLEXPORT(int)) supR3PreInit(PSUPPREINITDATA pPreInitData, uint32_t fFlags);
|
---|
432 |
|
---|
433 |
|
---|
434 | /** @copydoc RTPathAppPrivateNoArch */
|
---|
435 | DECLHIDDEN(int) supR3HardenedPathAppPrivateNoArch(char *pszPath, size_t cchPath);
|
---|
436 | /** @copydoc RTPathAppPrivateArch */
|
---|
437 | DECLHIDDEN(int) supR3HardenedPathAppPrivateArch(char *pszPath, size_t cchPath);
|
---|
438 | /** @copydoc RTPathSharedLibs */
|
---|
439 | DECLHIDDEN(int) supR3HardenedPathAppSharedLibs(char *pszPath, size_t cchPath);
|
---|
440 | /** @copydoc RTPathAppDocs */
|
---|
441 | DECLHIDDEN(int) supR3HardenedPathAppDocs(char *pszPath, size_t cchPath);
|
---|
442 | /** @copydoc RTPathExecDir */
|
---|
443 | DECLHIDDEN(int) supR3HardenedPathAppBin(char *pszPath, size_t cchPath);
|
---|
444 | /** @copydoc RTPathFilename */
|
---|
445 | DECLHIDDEN(char *) supR3HardenedPathFilename(const char *pszPath);
|
---|
446 |
|
---|
447 | /**
|
---|
448 | * Display a fatal error and try call TrustedError or quit.
|
---|
449 | */
|
---|
450 | DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalMsgV(const char *pszWhere, SUPINITOP enmWhat, int rc,
|
---|
451 | const char *pszMsgFmt, va_list va);
|
---|
452 |
|
---|
453 | /**
|
---|
454 | * Display a fatal error and try call TrustedError or quit.
|
---|
455 | */
|
---|
456 | DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalMsg(const char *pszWhere, SUPINITOP enmWhat, int rc,
|
---|
457 | const char *pszMsgFmt, ...);
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Display a fatal error and quit.
|
---|
461 | */
|
---|
462 | DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalV(const char *pszFormat, va_list va);
|
---|
463 |
|
---|
464 | /**
|
---|
465 | * Display a fatal error and quit.
|
---|
466 | */
|
---|
467 | DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatal(const char *pszFormat, ...);
|
---|
468 |
|
---|
469 | /**
|
---|
470 | * Display an error which may or may not be fatal.
|
---|
471 | */
|
---|
472 | DECLHIDDEN(int) supR3HardenedErrorV(int rc, bool fFatal, const char *pszFormat, va_list va);
|
---|
473 |
|
---|
474 | /**
|
---|
475 | * Display an error which may or may not be fatal.
|
---|
476 | */
|
---|
477 | DECLHIDDEN(int) supR3HardenedError(int rc, bool fFatal, const char *pszFormat, ...);
|
---|
478 |
|
---|
479 | /**
|
---|
480 | * Open any startup log file specified in the argument.
|
---|
481 | */
|
---|
482 | DECLHIDDEN(void) supR3HardenedOpenLog(int *pcArgs, char **papszArgs);
|
---|
483 |
|
---|
484 | /**
|
---|
485 | * Write to the startup log file.
|
---|
486 | */
|
---|
487 | DECLHIDDEN(void) supR3HardenedLogV(const char *pszFormat, va_list va);
|
---|
488 |
|
---|
489 | /**
|
---|
490 | * Write to the startup log file.
|
---|
491 | */
|
---|
492 | DECLHIDDEN(void) supR3HardenedLog(const char *pszFormat, ...);
|
---|
493 |
|
---|
494 | /**
|
---|
495 | * Flushes the log file.
|
---|
496 | */
|
---|
497 | DECLHIDDEN(void) supR3HardenedLogFlush(void);
|
---|
498 |
|
---|
499 |
|
---|
500 | DECLHIDDEN(int) supR3HardenedVerifyAll(bool fFatal, const char *pszProgName, const char *pszExePath, uint32_t fMainFlags);
|
---|
501 | DECLHIDDEN(int) supR3HardenedVerifyFixedDir(SUPINSTDIR enmDir, bool fFatal, PCSUPINSTFILE pFile);
|
---|
502 | DECLHIDDEN(int) supR3HardenedVerifyFixedFile(const char *pszFilename, bool fFatal);
|
---|
503 | DECLHIDDEN(int) supR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo);
|
---|
504 | DECLHIDDEN(int) supR3HardenedVerifyFile(const char *pszFilename, RTHCUINTPTR hNativeFile, bool fMaybe3rdParty,
|
---|
505 | PRTERRINFO pErrInfo);
|
---|
506 | #if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)
|
---|
507 | DECLHIDDEN(int) supR3HardenedVerifyFileFollowSymlinks(const char *pszFilename, RTHCUINTPTR hNativeFile,
|
---|
508 | bool fMaybe3rdParty, PRTERRINFO pErrInfo);
|
---|
509 | #endif
|
---|
510 | DECLHIDDEN(void) supR3HardenedGetPreInitData(PSUPPREINITDATA pPreInitData);
|
---|
511 | DECLHIDDEN(int) supR3HardenedRecvPreInitData(PCSUPPREINITDATA pPreInitData);
|
---|
512 |
|
---|
513 | #ifdef RT_OS_WINDOWS
|
---|
514 | DECLHIDDEN(void) supR3HardenedWinInit(uint32_t fFlags, bool fAvastKludge);
|
---|
515 | DECLHIDDEN(void) supR3HardenedWinInitAppBin(uint32_t fFlags);
|
---|
516 | DECLHIDDEN(void) supR3HardenedWinInitVersion(bool fEarlyInit);
|
---|
517 | DECLHIDDEN(void) supR3HardenedWinInitImports(void);
|
---|
518 | DECLHIDDEN(void) supR3HardenedWinModifyDllSearchPath(uint32_t fFlags, const char *pszAppBinPath);
|
---|
519 | # ifdef IPRT_INCLUDED_nt_nt_h
|
---|
520 | DECLHIDDEN(void) supR3HardenedWinGetVeryEarlyImports(uintptr_t uNtDllAddr, PFNNTWAITFORSINGLEOBJECT *ppfnNtWaitForSingleObject,
|
---|
521 | PFNNTSETEVENT *ppfnNtSetEvent);
|
---|
522 | # endif
|
---|
523 | DECLHIDDEN(void) supR3HardenedWinInitImportsEarly(uintptr_t uNtDllAddr);
|
---|
524 | DECLHIDDEN(void) supR3HardenedWinInitSyscalls(bool fReportErrors, PRTERRINFO pErrInfo);
|
---|
525 | DECLHIDDEN(PFNRT) supR3HardenedWinGetRealDllSymbol(const char *pszDll, const char *pszProcedure);
|
---|
526 | DECLHIDDEN(void) supR3HardenedWinEnableThreadCreation(void);
|
---|
527 | DECLHIDDEN(void) supR3HardenedWinResolveVerifyTrustApiAndHookThreadCreation(const char *pszProgName);
|
---|
528 | DECLHIDDEN(void) supR3HardenedWinFlushLoaderCache();
|
---|
529 | DECLHIDDEN(bool) supR3HardenedWinIsReSpawnNeeded(int iWhich, int cArgs, char **papszArgs);
|
---|
530 | DECLHIDDEN(int) supR3HardenedWinReSpawn(int iWhich);
|
---|
531 | # ifdef _WINDEF_
|
---|
532 | DECLHIDDEN(void) supR3HardenedWinCreateParentWatcherThread(HMODULE hVBoxRT);
|
---|
533 | # endif
|
---|
534 | DECLHIDDEN(void *) supR3HardenedWinLoadLibrary(const char *pszName, bool fSystem32Only, uint32_t fMainFlags);
|
---|
535 | extern RTUTF16 g_wszSupLibHardenedExePath[1024];
|
---|
536 | # ifdef RTPATH_MAX
|
---|
537 | extern char g_szSupLibHardenedExePath[RTPATH_MAX];
|
---|
538 | # endif
|
---|
539 | DECLHIDDEN(void) supR3HardenedWinCompactHeaps(void);
|
---|
540 | DECLHIDDEN(void) supR3HardenedMainOpenDevice(void);
|
---|
541 | DECLHIDDEN(char *) supR3HardenedWinReadErrorInfoDevice(char *pszErrorInfo, size_t cbErrorInfo, const char *pszPrefix);
|
---|
542 | DECLHIDDEN(void) supR3HardenedWinReportErrorToParent(const char *pszWhere, SUPINITOP enmWhat, int rc,
|
---|
543 | const char *pszFormat, va_list va);
|
---|
544 | #else /* !RT_OS_WINDOWS */
|
---|
545 | # if !defined(RT_OS_DARWIN)
|
---|
546 | DECLHIDDEN(void) supR3HardenedPosixInit(void);
|
---|
547 | # else /* !RT_OS_DARWIN */
|
---|
548 | DECLHIDDEN(void) supR3HardenedDarwinInit(void);
|
---|
549 | #endif /* !RT_OS_DARWIN */
|
---|
550 | #endif /* !RT_OS_WINDOWS */
|
---|
551 |
|
---|
552 | SUPR3DECL(int) supR3PageLock(void *pvStart, size_t cPages, PSUPPAGE paPages);
|
---|
553 | SUPR3DECL(int) supR3PageUnlock(void *pvStart);
|
---|
554 |
|
---|
555 | RT_C_DECLS_END
|
---|
556 |
|
---|
557 |
|
---|
558 | #endif /* !VBOX_INCLUDED_SRC_Support_SUPLibInternal_h */
|
---|
559 |
|
---|