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