VirtualBox

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

Last change on this file since 18478 was 15352, checked in by vboxsync, 16 years ago

Added a RTLogRelPrintf to supR3HardenedErrorV to try get the details in the log...

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