[3537] | 1 | /* $Id: SUPLibInternal.h 98103 2023-01-17 14:15:46Z vboxsync $ */
|
---|
[1] | 2 | /** @file
|
---|
[3537] | 3 | * VirtualBox Support Library - Internal header.
|
---|
[1] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[98103] | 7 | * Copyright (C) 2006-2023 Oracle and/or its affiliates.
|
---|
[1] | 8 | *
|
---|
[96407] | 9 | * This file is part of VirtualBox base platform packages, as
|
---|
| 10 | * available from https://www.virtualbox.org.
|
---|
[5999] | 11 | *
|
---|
[96407] | 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 | *
|
---|
[5999] | 25 | * The contents of this file may alternatively be used under the terms
|
---|
| 26 | * of the Common Development and Distribution License Version 1.0
|
---|
[96407] | 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
|
---|
[5999] | 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.
|
---|
[96407] | 33 | *
|
---|
| 34 | * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
[1] | 35 | */
|
---|
| 36 |
|
---|
[76568] | 37 | #ifndef VBOX_INCLUDED_SRC_Support_SUPLibInternal_h
|
---|
| 38 | #define VBOX_INCLUDED_SRC_Support_SUPLibInternal_h
|
---|
[76527] | 39 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 40 | # pragma once
|
---|
| 41 | #endif
|
---|
[1] | 42 |
|
---|
| 43 | #include <VBox/cdefs.h>
|
---|
| 44 | #include <VBox/types.h>
|
---|
[11725] | 45 | #include <iprt/stdarg.h>
|
---|
[1] | 46 |
|
---|
| 47 |
|
---|
[11725] | 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
|
---|
[1] | 62 |
|
---|
[26362] | 63 | #ifdef RT_OS_SOLARIS
|
---|
[26402] | 64 | /** Number of dummy files to open (2:ip4, 1:ip6, 1:extra) see
|
---|
| 65 | * @bugref{4650}. */
|
---|
| 66 | # define SUPLIB_FLT_DUMMYFILES 4
|
---|
[26362] | 67 | #endif
|
---|
| 68 |
|
---|
[11725] | 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 | */
|
---|
[81369] | 80 | #if (!defined(RT_OS_OS2) && !defined(RT_OS_WINDOWS) && !defined(RT_OS_L4)) || defined(DOXYGEN_RUNNING)
|
---|
[11725] | 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
|
---|
[56733] | 94 | # define supR3HardenedPathAppSharedLibs supR3HardenedStaticPathAppSharedLibs
|
---|
[11725] | 95 | # define supR3HardenedPathAppDocs supR3HardenedStaticPathAppDocs
|
---|
[56733] | 96 | # define supR3HardenedPathAppBin supR3HardenedStaticPathAppBin
|
---|
[11725] | 97 | # define supR3HardenedPathFilename supR3HardenedStaticPathFilename
|
---|
| 98 | # define supR3HardenedFatalV supR3HardenedStaticFatalV
|
---|
| 99 | # define supR3HardenedFatal supR3HardenedStaticFatal
|
---|
[13458] | 100 | # define supR3HardenedFatalMsgV supR3HardenedStaticFatalMsgV
|
---|
| 101 | # define supR3HardenedFatalMsg supR3HardenedStaticFatalMsg
|
---|
[11725] | 102 | # define supR3HardenedErrorV supR3HardenedStaticErrorV
|
---|
| 103 | # define supR3HardenedError supR3HardenedStaticError
|
---|
[52169] | 104 | # define supR3HardenedOpenLog supR3HardenedStaticOpenLog
|
---|
| 105 | # define supR3HardenedLogV supR3HardenedStaticLogV
|
---|
| 106 | # define supR3HardenedLog supR3HardenedStaticLog
|
---|
[54998] | 107 | # define supR3HardenedLogFlush supR3HardenedStaticLogFlush
|
---|
[11725] | 108 | # define supR3HardenedVerifyAll supR3HardenedStaticVerifyAll
|
---|
[33701] | 109 | # define supR3HardenedVerifyFixedDir supR3HardenedStaticVerifyFixedDir
|
---|
| 110 | # define supR3HardenedVerifyFixedFile supR3HardenedStaticVerifyFixedFile
|
---|
[11725] | 111 | # define supR3HardenedVerifyDir supR3HardenedStaticVerifyDir
|
---|
[33741] | 112 | # define supR3HardenedVerifyFile supR3HardenedStaticVerifyFile
|
---|
[11725] | 113 | # define supR3HardenedGetPreInitData supR3HardenedStaticGetPreInitData
|
---|
| 114 | # define supR3HardenedRecvPreInitData supR3HardenedStaticRecvPreInitData
|
---|
| 115 | /** @} */
|
---|
| 116 | #endif /* IN_SUP_HARDENED_R3 */
|
---|
| 117 |
|
---|
| 118 |
|
---|
[49211] | 119 | /** @name CRT function mappings (not using CRT on Windows).
|
---|
| 120 | * @{
|
---|
| 121 | */
|
---|
| 122 | #if defined(IN_SUP_HARDENED_R3) && defined(RT_OS_WINDOWS)
|
---|
[51770] | 123 | # define SUP_HARDENED_NEED_CRT_FUNCTIONS
|
---|
[85129] | 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);
|
---|
[49211] | 132 | #else
|
---|
[51770] | 133 | # undef SUP_HARDENED_NEED_CRT_FUNCTIONS
|
---|
| 134 | # define suplibHardenedMemComp memcmp
|
---|
[49211] | 135 | # define suplibHardenedMemCopy memcpy
|
---|
[51770] | 136 | # define suplibHardenedMemSet memset
|
---|
[49211] | 137 | # define suplibHardenedStrCopy strcpy
|
---|
| 138 | # define suplibHardenedStrLen strlen
|
---|
| 139 | # define suplibHardenedStrCat strcat
|
---|
| 140 | # define suplibHardenedStrCmp strcmp
|
---|
| 141 | # define suplibHardenedStrNCmp strncmp
|
---|
| 142 | #endif
|
---|
[85127] | 143 | DECLHIDDEN(DECL_NO_RETURN(void)) suplibHardenedExit(RTEXITCODE rcExit);
|
---|
[85129] | 144 | DECLHIDDEN(void) suplibHardenedPrintF(const char *pszFormat, ...);
|
---|
| 145 | DECLHIDDEN(void) suplibHardenedPrintFV(const char *pszFormat, va_list va);
|
---|
[51770] | 146 |
|
---|
[49211] | 147 | /** @} */
|
---|
| 148 |
|
---|
[51770] | 149 | /** Debug output macro. */
|
---|
[52169] | 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)
|
---|
[51770] | 153 | # else
|
---|
[52169] | 154 | # define SUP_DPRINTF(a) do { supR3HardenedStaticLog a; } while (0)
|
---|
| 155 | # endif
|
---|
| 156 | #else
|
---|
| 157 | # if defined(DEBUG_bird) && defined(RT_OS_WINDOWS)
|
---|
[51770] | 158 | # define SUP_DPRINTF(a) RTLogPrintf a
|
---|
[52169] | 159 | # else
|
---|
| 160 | # define SUP_DPRINTF(a) do { } while (0)
|
---|
[51770] | 161 | # endif
|
---|
| 162 | #endif
|
---|
[49211] | 163 |
|
---|
[51770] | 164 |
|
---|
[1] | 165 | /*******************************************************************************
|
---|
[11725] | 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,
|
---|
[51770] | 176 | kSupIFT_Rc,
|
---|
[11725] | 177 | kSupIFT_Sys,
|
---|
| 178 | kSupIFT_Script,
|
---|
| 179 | kSupIFT_Data,
|
---|
[51909] | 180 | kSupIFT_TestExe,
|
---|
| 181 | kSupIFT_TestDll,
|
---|
[11725] | 182 | kSupIFT_End
|
---|
| 183 | } SUPINSTFILETYPE;
|
---|
[1] | 184 |
|
---|
[11725] | 185 | /**
|
---|
| 186 | * Installation directory specifier.
|
---|
| 187 | */
|
---|
| 188 | typedef enum SUPINSTDIR
|
---|
| 189 | {
|
---|
| 190 | kSupID_Invalid = 0,
|
---|
| 191 | kSupID_AppBin,
|
---|
[56733] | 192 | kSupID_AppSharedLib,
|
---|
[11725] | 193 | kSupID_AppPrivArch,
|
---|
| 194 | kSupID_AppPrivArchComp,
|
---|
| 195 | kSupID_AppPrivNoArch,
|
---|
[51909] | 196 | kSupID_Testcase,
|
---|
[83033] | 197 | #ifdef RT_OS_DARWIN
|
---|
| 198 | kSupID_AppMacHelper,
|
---|
| 199 | #endif
|
---|
[11725] | 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;
|
---|
[52083] | 229 | #ifdef RT_OS_WINDOWS
|
---|
| 230 | /** Whether we've checked the signature of the file. */
|
---|
| 231 | bool fCheckedSignature;
|
---|
| 232 | #endif
|
---|
[11725] | 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. */
|
---|
[37596] | 260 | #if defined(RT_OS_WINDOWS)
|
---|
| 261 | void *hDevice;
|
---|
| 262 | #else
|
---|
| 263 | int hDevice;
|
---|
| 264 | #endif
|
---|
[44173] | 265 | /** Indicates whether we have unrestricted (true) or restricted access to the
|
---|
| 266 | * support device. */
|
---|
| 267 | bool fUnrestricted;
|
---|
[92697] | 268 | /** Set if we're in driverless mode. */
|
---|
| 269 | bool fDriverless;
|
---|
[11725] | 270 | #if defined(RT_OS_DARWIN)
|
---|
| 271 | /** The connection to the VBoxSupDrv service. */
|
---|
[16335] | 272 | uintptr_t uConnection;
|
---|
[11725] | 273 | #elif defined(RT_OS_LINUX)
|
---|
| 274 | /** Indicates whether madvise(,,MADV_DONTFORK) works. */
|
---|
| 275 | bool fSysMadviseWorks;
|
---|
[26362] | 276 | #elif defined(RT_OS_SOLARIS)
|
---|
[26402] | 277 | /** Extra dummy file descriptors to prevent growing file-descriptor table on
|
---|
| 278 | * clean up (see @bugref{4650}). */
|
---|
| 279 | int ahDummy[SUPLIB_FLT_DUMMYFILES];
|
---|
[11725] | 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 |
|
---|
[37596] | 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
|
---|
[11725] | 294 |
|
---|
[37596] | 295 |
|
---|
[11725] | 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 */
|
---|
[85121] | 325 | typedef DECLCALLBACKTYPE(int, FNSUPR3PREINIT,(PSUPPREINITDATA pPreInitData, uint32_t fFlags));
|
---|
[11725] | 326 | /** Pointer to supR3PreInit. */
|
---|
| 327 | typedef FNSUPR3PREINIT *PFNSUPR3PREINIT;
|
---|
| 328 |
|
---|
[51770] | 329 | /** The current SUPR3HardenedMain state / location. */
|
---|
| 330 | typedef enum SUPR3HARDENEDMAINSTATE
|
---|
| 331 | {
|
---|
| 332 | SUPR3HARDENEDMAINSTATE_NOT_YET_CALLED = 0,
|
---|
[52949] | 333 | SUPR3HARDENEDMAINSTATE_WIN_EARLY_INIT_CALLED,
|
---|
[52943] | 334 | SUPR3HARDENEDMAINSTATE_WIN_EARLY_IMPORTS_RESOLVED,
|
---|
[60936] | 335 | SUPR3HARDENEDMAINSTATE_WIN_EARLY_STUB_DEVICE_OPENED,
|
---|
| 336 | SUPR3HARDENEDMAINSTATE_WIN_EARLY_REAL_DEVICE_OPENED,
|
---|
[52941] | 337 | SUPR3HARDENEDMAINSTATE_WIN_EP_CALLED,
|
---|
| 338 | SUPR3HARDENEDMAINSTATE_WIN_IMPORTS_RESOLVED,
|
---|
| 339 | SUPR3HARDENEDMAINSTATE_WIN_VERSION_INITIALIZED,
|
---|
[52943] | 340 | SUPR3HARDENEDMAINSTATE_WIN_VERIFY_TRUST_READY,
|
---|
| 341 | SUPR3HARDENEDMAINSTATE_HARDENED_MAIN_CALLED,
|
---|
[51770] | 342 | SUPR3HARDENEDMAINSTATE_INIT_RUNTIME,
|
---|
| 343 | SUPR3HARDENEDMAINSTATE_GET_TRUSTED_MAIN,
|
---|
| 344 | SUPR3HARDENEDMAINSTATE_CALLED_TRUSTED_MAIN,
|
---|
[52943] | 345 | SUPR3HARDENEDMAINSTATE_END,
|
---|
| 346 | SUPR3HARDENEDMAINSTATE_32BIT_HACK = 0x7fffffff
|
---|
[51770] | 347 | } SUPR3HARDENEDMAINSTATE;
|
---|
[11725] | 348 |
|
---|
[51770] | 349 |
|
---|
[1] | 350 | /*******************************************************************************
|
---|
[19892] | 351 | * Global Variables *
|
---|
| 352 | *******************************************************************************/
|
---|
[85124] | 353 | extern DECL_HIDDEN_DATA(uint32_t) g_u32Cookie;
|
---|
| 354 | extern DECL_HIDDEN_DATA(uint32_t) g_u32SessionCookie;
|
---|
[87700] | 355 | extern DECL_HIDDEN_DATA(uint32_t) g_uSupSessionVersion;
|
---|
[85124] | 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;
|
---|
[76568] | 359 | #ifdef VBOX_INCLUDED_SRC_Support_SUPDrvIOC_h
|
---|
[85124] | 360 | extern DECL_HIDDEN_DATA(PSUPQUERYFUNCS) g_pSupFunctions;
|
---|
[49634] | 361 | #endif
|
---|
[85124] | 362 | extern DECL_HIDDEN_DATA(SUPR3HARDENEDMAINSTATE) g_enmSupR3HardenedMainState;
|
---|
[52943] | 363 | #ifdef RT_OS_WINDOWS
|
---|
[85124] | 364 | extern DECL_HIDDEN_DATA(bool) g_fSupEarlyProcessInit;
|
---|
[52943] | 365 | #endif
|
---|
[19892] | 366 |
|
---|
| 367 |
|
---|
| 368 | /*******************************************************************************
|
---|
[1] | 369 | * OS Specific Function *
|
---|
| 370 | *******************************************************************************/
|
---|
[20374] | 371 | RT_C_DECLS_BEGIN
|
---|
[85129] | 372 | DECLHIDDEN(int) suplibOsInstall(void);
|
---|
| 373 | DECLHIDDEN(int) suplibOsUninstall(void);
|
---|
[92613] | 374 | DECLHIDDEN(int) suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, uint32_t fFlags, SUPINITOP *penmWhat, PRTERRINFO pErrInfo);
|
---|
[85129] | 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);
|
---|
[92556] | 380 | DECLHIDDEN(int) suplibOsPageAlloc(PSUPLIBDATA pThis, size_t cPages, uint32_t fFlags, void **ppvPages);
|
---|
[85129] | 381 | DECLHIDDEN(int) suplibOsPageFree(PSUPLIBDATA pThis, void *pvPages, size_t cPages);
|
---|
| 382 | DECLHIDDEN(int) suplibOsQueryVTxSupported(const char **ppszWhy);
|
---|
| 383 | DECLHIDDEN(bool) suplibOsIsNemSupportedWhenNoVtxOrAmdV(void);
|
---|
[11725] | 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
|
---|
[38636] | 390 | * calls RTR3InitEx and thereby SUPR3Init.
|
---|
[11725] | 391 | *
|
---|
| 392 | * @returns IPRT status code.
|
---|
| 393 | * @param pPreInitData The pre init data.
|
---|
| 394 | * @param fFlags The SUPR3HardenedMain flags.
|
---|
| 395 | */
|
---|
[85093] | 396 | DECL_NOTHROW(DECLEXPORT(int)) supR3PreInit(PSUPPREINITDATA pPreInitData, uint32_t fFlags);
|
---|
[11725] | 397 |
|
---|
| 398 |
|
---|
| 399 | /** @copydoc RTPathAppPrivateNoArch */
|
---|
[85128] | 400 | DECLHIDDEN(int) supR3HardenedPathAppPrivateNoArch(char *pszPath, size_t cchPath);
|
---|
[11725] | 401 | /** @copydoc RTPathAppPrivateArch */
|
---|
[85128] | 402 | DECLHIDDEN(int) supR3HardenedPathAppPrivateArch(char *pszPath, size_t cchPath);
|
---|
[11725] | 403 | /** @copydoc RTPathSharedLibs */
|
---|
[85128] | 404 | DECLHIDDEN(int) supR3HardenedPathAppSharedLibs(char *pszPath, size_t cchPath);
|
---|
[11725] | 405 | /** @copydoc RTPathAppDocs */
|
---|
[85128] | 406 | DECLHIDDEN(int) supR3HardenedPathAppDocs(char *pszPath, size_t cchPath);
|
---|
[19924] | 407 | /** @copydoc RTPathExecDir */
|
---|
[85128] | 408 | DECLHIDDEN(int) supR3HardenedPathAppBin(char *pszPath, size_t cchPath);
|
---|
[11725] | 409 | /** @copydoc RTPathFilename */
|
---|
[85128] | 410 | DECLHIDDEN(char *) supR3HardenedPathFilename(const char *pszPath);
|
---|
[11725] | 411 |
|
---|
| 412 | /**
|
---|
[13458] | 413 | * Display a fatal error and try call TrustedError or quit.
|
---|
| 414 | */
|
---|
[85127] | 415 | DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalMsgV(const char *pszWhere, SUPINITOP enmWhat, int rc,
|
---|
[85129] | 416 | const char *pszMsgFmt, va_list va);
|
---|
[13458] | 417 |
|
---|
| 418 | /**
|
---|
| 419 | * Display a fatal error and try call TrustedError or quit.
|
---|
| 420 | */
|
---|
[85127] | 421 | DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalMsg(const char *pszWhere, SUPINITOP enmWhat, int rc,
|
---|
[85129] | 422 | const char *pszMsgFmt, ...);
|
---|
[13458] | 423 |
|
---|
| 424 | /**
|
---|
[11725] | 425 | * Display a fatal error and quit.
|
---|
| 426 | */
|
---|
[85127] | 427 | DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalV(const char *pszFormat, va_list va);
|
---|
[11725] | 428 |
|
---|
| 429 | /**
|
---|
| 430 | * Display a fatal error and quit.
|
---|
| 431 | */
|
---|
[85127] | 432 | DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatal(const char *pszFormat, ...);
|
---|
[11725] | 433 |
|
---|
| 434 | /**
|
---|
| 435 | * Display an error which may or may not be fatal.
|
---|
| 436 | */
|
---|
[85128] | 437 | DECLHIDDEN(int) supR3HardenedErrorV(int rc, bool fFatal, const char *pszFormat, va_list va);
|
---|
[11725] | 438 |
|
---|
| 439 | /**
|
---|
| 440 | * Display an error which may or may not be fatal.
|
---|
| 441 | */
|
---|
[85128] | 442 | DECLHIDDEN(int) supR3HardenedError(int rc, bool fFatal, const char *pszFormat, ...);
|
---|
[51770] | 443 |
|
---|
[52169] | 444 | /**
|
---|
| 445 | * Open any startup log file specified in the argument.
|
---|
| 446 | */
|
---|
[85128] | 447 | DECLHIDDEN(void) supR3HardenedOpenLog(int *pcArgs, char **papszArgs);
|
---|
[52169] | 448 |
|
---|
| 449 | /**
|
---|
| 450 | * Write to the startup log file.
|
---|
| 451 | */
|
---|
[85128] | 452 | DECLHIDDEN(void) supR3HardenedLogV(const char *pszFormat, va_list va);
|
---|
[52169] | 453 |
|
---|
| 454 | /**
|
---|
| 455 | * Write to the startup log file.
|
---|
| 456 | */
|
---|
[85128] | 457 | DECLHIDDEN(void) supR3HardenedLog(const char *pszFormat, ...);
|
---|
[52169] | 458 |
|
---|
[54998] | 459 | /**
|
---|
| 460 | * Flushes the log file.
|
---|
| 461 | */
|
---|
[85128] | 462 | DECLHIDDEN(void) supR3HardenedLogFlush(void);
|
---|
[52169] | 463 |
|
---|
[54998] | 464 |
|
---|
[85128] | 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);
|
---|
[66632] | 471 | #if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)
|
---|
[85128] | 472 | DECLHIDDEN(int) supR3HardenedVerifyFileFollowSymlinks(const char *pszFilename, RTHCUINTPTR hNativeFile,
|
---|
| 473 | bool fMaybe3rdParty, PRTERRINFO pErrInfo);
|
---|
[66526] | 474 | #endif
|
---|
[85128] | 475 | DECLHIDDEN(void) supR3HardenedGetPreInitData(PSUPPREINITDATA pPreInitData);
|
---|
| 476 | DECLHIDDEN(int) supR3HardenedRecvPreInitData(PCSUPPREINITDATA pPreInitData);
|
---|
[11725] | 477 |
|
---|
[51770] | 478 | #ifdef RT_OS_WINDOWS
|
---|
[85128] | 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);
|
---|
[76557] | 484 | # ifdef IPRT_INCLUDED_nt_nt_h
|
---|
[85128] | 485 | DECLHIDDEN(void) supR3HardenedWinGetVeryEarlyImports(uintptr_t uNtDllAddr, PFNNTWAITFORSINGLEOBJECT *ppfnNtWaitForSingleObject,
|
---|
| 486 | PFNNTSETEVENT *ppfnNtSetEvent);
|
---|
[52969] | 487 | # endif
|
---|
[85128] | 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);
|
---|
[52632] | 496 | # ifdef _WINDEF_
|
---|
[85128] | 497 | DECLHIDDEN(void) supR3HardenedWinCreateParentWatcherThread(HMODULE hVBoxRT);
|
---|
[52632] | 498 | # endif
|
---|
[85128] | 499 | DECLHIDDEN(void *) supR3HardenedWinLoadLibrary(const char *pszName, bool fSystem32Only, uint32_t fMainFlags);
|
---|
[51770] | 500 | extern RTUTF16 g_wszSupLibHardenedExePath[1024];
|
---|
| 501 | # ifdef RTPATH_MAX
|
---|
| 502 | extern char g_szSupLibHardenedExePath[RTPATH_MAX];
|
---|
| 503 | # endif
|
---|
[85128] | 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);
|
---|
[66526] | 509 | #else /* !RT_OS_WINDOWS */
|
---|
[87030] | 510 | # if !defined(RT_OS_DARWIN)
|
---|
[85128] | 511 | DECLHIDDEN(void) supR3HardenedPosixInit(void);
|
---|
[87030] | 512 | # else /* !RT_OS_DARWIN */
|
---|
| 513 | DECLHIDDEN(void) supR3HardenedDarwinInit(void);
|
---|
| 514 | #endif /* !RT_OS_DARWIN */
|
---|
[66526] | 515 | #endif /* !RT_OS_WINDOWS */
|
---|
[11725] | 516 |
|
---|
[85128] | 517 | SUPR3DECL(int) supR3PageLock(void *pvStart, size_t cPages, PSUPPAGE paPages);
|
---|
| 518 | SUPR3DECL(int) supR3PageUnlock(void *pvStart);
|
---|
[20862] | 519 |
|
---|
[20374] | 520 | RT_C_DECLS_END
|
---|
[1] | 521 |
|
---|
| 522 |
|
---|
[76568] | 523 | #endif /* !VBOX_INCLUDED_SRC_Support_SUPLibInternal_h */
|
---|
[1] | 524 |
|
---|