VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/SUPR3HardenedIPRT.cpp

Last change on this file was 98103, checked in by vboxsync, 16 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
RevLine 
[11725]1/* $Id: SUPR3HardenedIPRT.cpp 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VirtualBox Support Library - Hardened Support Routines using IPRT.
4 */
5
6/*
[98103]7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
[11725]8 *
[96407]9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
[11725]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 *
[11725]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
[11725]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
[11725]35 */
36
[57358]37
38/*********************************************************************************************************************************
39* Header Files *
40*********************************************************************************************************************************/
[11725]41#define LOG_GROUP LOG_GROUP_SUP
42#include <VBox/sup.h>
[76474]43#include <iprt/errcore.h>
[11725]44#include <VBox/log.h>
45#include <iprt/string.h>
46#include <iprt/stdarg.h>
47#include <iprt/assert.h>
48#include <iprt/path.h>
49#include <iprt/param.h>
50
51#include "SUPLibInternal.h"
52
53
[85127]54DECLHIDDEN(char *) supR3HardenedPathFilename(const char *pszPath)
[11725]55{
56 return RTPathFilename(pszPath);
57}
58
59
[85127]60DECLHIDDEN(int) supR3HardenedPathAppPrivateNoArch(char *pszPath, size_t cchPath)
[11725]61{
62 return RTPathAppPrivateNoArch(pszPath, cchPath);
63}
64
65
[85127]66DECLHIDDEN(int) supR3HardenedPathAppPrivateArch(char *pszPath, size_t cchPath)
[11725]67{
68 return RTPathAppPrivateArch(pszPath, cchPath);
69}
70
71
[85127]72DECLHIDDEN(int) supR3HardenedPathAppSharedLibs(char *pszPath, size_t cchPath)
[11725]73{
74 return RTPathSharedLibs(pszPath, cchPath);
75}
76
77
[85127]78DECLHIDDEN(int) supR3HardenedPathAppDocs(char *pszPath, size_t cchPath)
[11725]79{
80 return RTPathAppDocs(pszPath, cchPath);
81}
82
83
[85127]84DECLHIDDEN(int) supR3HardenedPathAppBin(char *pszPath, size_t cchPath)
[11725]85{
[19924]86 return RTPathExecDir(pszPath, cchPath);
[11725]87}
88
89
[85127]90DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalMsgV(const char *pszWhere, SUPINITOP enmWhat, int rc,
91 const char *pszMsgFmt, va_list va)
[13458]92{
93 va_list vaCopy;
94 va_copy(vaCopy, va);
95 AssertFatalMsgFailed(("%s (rc=%Rrc): %N", pszWhere, rc, pszMsgFmt, &vaCopy));
[39091]96 NOREF(enmWhat);
[62675]97 /* not reached */
[13458]98}
[11725]99
[13458]100
[85127]101DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalMsg(const char *pszWhere, SUPINITOP enmWhat, int rc,
102 const char *pszMsgFmt, ...)
[13458]103{
104 va_list va;
105 va_start(va, pszMsgFmt);
106 supR3HardenedFatalMsgV(pszWhere, enmWhat, rc, pszMsgFmt, va);
[62675]107 /* not reached */
[13458]108}
109
110
[85127]111DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalV(const char *pszFormat, va_list va)
[11725]112{
113 va_list vaCopy;
114 va_copy(vaCopy, va);
115 AssertFatalMsgFailed(("%N", pszFormat, &vaCopy));
[62675]116 /* not reached */
[11725]117}
118
119
[85127]120DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatal(const char *pszFormat, ...)
[11725]121{
122 va_list va;
123 va_start(va, pszFormat);
124 supR3HardenedFatalV(pszFormat, va);
[62675]125 /* not reached */
[11725]126}
127
128
[85127]129DECLHIDDEN(int) supR3HardenedErrorV(int rc, bool fFatal, const char *pszFormat, va_list va)
[11725]130{
131 if (fFatal)
132 supR3HardenedFatalV(pszFormat, va);
133
134 va_list vaCopy;
135 va_copy(vaCopy, va);
[15352]136 AssertLogRelMsgFailed(("%N", pszFormat, &vaCopy)); /** @todo figure out why this ain't working, or at seems to be that way... */
[11725]137 va_end(vaCopy);
[15352]138
139 RTLogRelPrintfV(pszFormat, va);
[11725]140 return rc;
141}
142
143
[85127]144DECLHIDDEN(int) supR3HardenedError(int rc, bool fFatal, const char *pszFormat, ...)
[11725]145{
146 va_list va;
147 va_start(va, pszFormat);
148 supR3HardenedErrorV(rc, fFatal, pszFormat, va);
149 va_end(va);
150 return rc;
151}
152
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use