VirtualBox

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

Last change on this file since 90520 was 87593, checked in by vboxsync, 4 years ago

SUP: doxygen fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.1 KB
Line 
1/* $Id: SUPR3HardenedIPRT.cpp 87593 2021-02-03 20:21:54Z vboxsync $ */
2/** @file
3 * VirtualBox Support Library - Hardened Support Routines using IPRT.
4 */
5
6/*
7 * Copyright (C) 2006-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27
28/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#define LOG_GROUP LOG_GROUP_SUP
32#include <VBox/sup.h>
33#include <iprt/errcore.h>
34#include <VBox/log.h>
35#include <iprt/string.h>
36#include <iprt/stdarg.h>
37#include <iprt/assert.h>
38#include <iprt/path.h>
39#include <iprt/param.h>
40
41#include "SUPLibInternal.h"
42
43
44DECLHIDDEN(char *) supR3HardenedPathFilename(const char *pszPath)
45{
46 return RTPathFilename(pszPath);
47}
48
49
50DECLHIDDEN(int) supR3HardenedPathAppPrivateNoArch(char *pszPath, size_t cchPath)
51{
52 return RTPathAppPrivateNoArch(pszPath, cchPath);
53}
54
55
56DECLHIDDEN(int) supR3HardenedPathAppPrivateArch(char *pszPath, size_t cchPath)
57{
58 return RTPathAppPrivateArch(pszPath, cchPath);
59}
60
61
62DECLHIDDEN(int) supR3HardenedPathAppSharedLibs(char *pszPath, size_t cchPath)
63{
64 return RTPathSharedLibs(pszPath, cchPath);
65}
66
67
68DECLHIDDEN(int) supR3HardenedPathAppDocs(char *pszPath, size_t cchPath)
69{
70 return RTPathAppDocs(pszPath, cchPath);
71}
72
73
74DECLHIDDEN(int) supR3HardenedPathAppBin(char *pszPath, size_t cchPath)
75{
76 return RTPathExecDir(pszPath, cchPath);
77}
78
79
80DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalMsgV(const char *pszWhere, SUPINITOP enmWhat, int rc,
81 const char *pszMsgFmt, va_list va)
82{
83 va_list vaCopy;
84 va_copy(vaCopy, va);
85 AssertFatalMsgFailed(("%s (rc=%Rrc): %N", pszWhere, rc, pszMsgFmt, &vaCopy));
86 NOREF(enmWhat);
87 /* not reached */
88}
89
90
91DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalMsg(const char *pszWhere, SUPINITOP enmWhat, int rc,
92 const char *pszMsgFmt, ...)
93{
94 va_list va;
95 va_start(va, pszMsgFmt);
96 supR3HardenedFatalMsgV(pszWhere, enmWhat, rc, pszMsgFmt, va);
97 /* not reached */
98}
99
100
101DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatalV(const char *pszFormat, va_list va)
102{
103 va_list vaCopy;
104 va_copy(vaCopy, va);
105 AssertFatalMsgFailed(("%N", pszFormat, &vaCopy));
106 /* not reached */
107}
108
109
110DECL_NO_RETURN(DECLHIDDEN(void)) supR3HardenedFatal(const char *pszFormat, ...)
111{
112 va_list va;
113 va_start(va, pszFormat);
114 supR3HardenedFatalV(pszFormat, va);
115 /* not reached */
116}
117
118
119DECLHIDDEN(int) supR3HardenedErrorV(int rc, bool fFatal, const char *pszFormat, va_list va)
120{
121 if (fFatal)
122 supR3HardenedFatalV(pszFormat, va);
123
124 va_list vaCopy;
125 va_copy(vaCopy, va);
126 AssertLogRelMsgFailed(("%N", pszFormat, &vaCopy)); /** @todo figure out why this ain't working, or at seems to be that way... */
127 va_end(vaCopy);
128
129 RTLogRelPrintfV(pszFormat, va);
130 return rc;
131}
132
133
134DECLHIDDEN(int) supR3HardenedError(int rc, bool fFatal, const char *pszFormat, ...)
135{
136 va_list va;
137 va_start(va, pszFormat);
138 supR3HardenedErrorV(rc, fFatal, pszFormat, va);
139 va_end(va);
140 return rc;
141}
142
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette