VirtualBox

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

Last change on this file since 57358 was 57358, checked in by vboxsync, 9 years ago

*: scm cleanup run.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1/* $Id: SUPR3HardenedIPRT.cpp 57358 2015-08-14 15:16:38Z vboxsync $ */
2/** @file
3 * VirtualBox Support Library - Hardened Support Routines using IPRT.
4 */
5
6/*
7 * Copyright (C) 2006-2015 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 <VBox/err.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
44/**
45 * @copydoc RTPathFilename
46 */
47DECLHIDDEN(char *) supR3HardenedPathFilename(const char *pszPath)
48{
49 return RTPathFilename(pszPath);
50}
51
52
53/**
54 * @copydoc RTPathAppPrivateNoArch
55 */
56DECLHIDDEN(int) supR3HardenedPathAppPrivateNoArch(char *pszPath, size_t cchPath)
57{
58 return RTPathAppPrivateNoArch(pszPath, cchPath);
59}
60
61
62/**
63 * @copydoc RTPathAppPrivateArch
64 */
65DECLHIDDEN(int) supR3HardenedPathAppPrivateArch(char *pszPath, size_t cchPath)
66{
67 return RTPathAppPrivateArch(pszPath, cchPath);
68}
69
70
71/**
72 * @copydoc RTPathSharedLibs
73 */
74DECLHIDDEN(int) supR3HardenedPathAppSharedLibs(char *pszPath, size_t cchPath)
75{
76 return RTPathSharedLibs(pszPath, cchPath);
77}
78
79
80/**
81 * @copydoc RTPathAppDocs
82 */
83DECLHIDDEN(int) supR3HardenedPathAppDocs(char *pszPath, size_t cchPath)
84{
85 return RTPathAppDocs(pszPath, cchPath);
86}
87
88
89/**
90 * @copydoc RTPathExecDir
91 */
92DECLHIDDEN(int) supR3HardenedPathAppBin(char *pszPath, size_t cchPath)
93{
94 return RTPathExecDir(pszPath, cchPath);
95}
96
97
98DECLHIDDEN(void) supR3HardenedFatalMsgV(const char *pszWhere, SUPINITOP enmWhat, int rc, const char *pszMsgFmt, va_list va)
99{
100 va_list vaCopy;
101 va_copy(vaCopy, va);
102 AssertFatalMsgFailed(("%s (rc=%Rrc): %N", pszWhere, rc, pszMsgFmt, &vaCopy));
103 va_end(vaCopy);
104 NOREF(enmWhat);
105}
106
107
108DECLHIDDEN(void) supR3HardenedFatalMsg(const char *pszWhere, SUPINITOP enmWhat, int rc, const char *pszMsgFmt, ...)
109{
110 va_list va;
111 va_start(va, pszMsgFmt);
112 supR3HardenedFatalMsgV(pszWhere, enmWhat, rc, pszMsgFmt, va);
113 va_end(va);
114}
115
116
117DECLHIDDEN(void) supR3HardenedFatalV(const char *pszFormat, va_list va)
118{
119 va_list vaCopy;
120 va_copy(vaCopy, va);
121 AssertFatalMsgFailed(("%N", pszFormat, &vaCopy));
122 va_end(vaCopy);
123}
124
125
126DECLHIDDEN(void) supR3HardenedFatal(const char *pszFormat, ...)
127{
128 va_list va;
129 va_start(va, pszFormat);
130 supR3HardenedFatalV(pszFormat, va);
131 va_end(va);
132}
133
134
135DECLHIDDEN(int) supR3HardenedErrorV(int rc, bool fFatal, const char *pszFormat, va_list va)
136{
137 if (fFatal)
138 supR3HardenedFatalV(pszFormat, va);
139
140 va_list vaCopy;
141 va_copy(vaCopy, va);
142 AssertLogRelMsgFailed(("%N", pszFormat, &vaCopy)); /** @todo figure out why this ain't working, or at seems to be that way... */
143 va_end(vaCopy);
144
145 RTLogRelPrintfV(pszFormat, va);
146 return rc;
147}
148
149
150DECLHIDDEN(int) supR3HardenedError(int rc, bool fFatal, const char *pszFormat, ...)
151{
152 va_list va;
153 va_start(va, pszFormat);
154 supR3HardenedErrorV(rc, fFatal, pszFormat, va);
155 va_end(va);
156 return rc;
157}
158
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