VirtualBox

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

Last change on this file since 38876 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

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