1 | /* $Id: SUPR3HardenedIPRT.cpp 11725 2008-08-27 22:21:47Z 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 | */
|
---|
50 | DECLHIDDEN(char *) supR3HardenedPathFilename(const char *pszPath)
|
---|
51 | {
|
---|
52 | return RTPathFilename(pszPath);
|
---|
53 | }
|
---|
54 |
|
---|
55 |
|
---|
56 | /**
|
---|
57 | * @copydoc RTPathAppPrivateNoArch
|
---|
58 | */
|
---|
59 | DECLHIDDEN(int) supR3HardenedPathAppPrivateNoArch(char *pszPath, size_t cchPath)
|
---|
60 | {
|
---|
61 | return RTPathAppPrivateNoArch(pszPath, cchPath);
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | /**
|
---|
66 | * @copydoc RTPathAppPrivateArch
|
---|
67 | */
|
---|
68 | DECLHIDDEN(int) supR3HardenedPathAppPrivateArch(char *pszPath, size_t cchPath)
|
---|
69 | {
|
---|
70 | return RTPathAppPrivateArch(pszPath, cchPath);
|
---|
71 | }
|
---|
72 |
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * @copydoc RTPathSharedLibs
|
---|
76 | */
|
---|
77 | DECLHIDDEN(int) supR3HardenedPathSharedLibs(char *pszPath, size_t cchPath)
|
---|
78 | {
|
---|
79 | return RTPathSharedLibs(pszPath, cchPath);
|
---|
80 | }
|
---|
81 |
|
---|
82 |
|
---|
83 | /**
|
---|
84 | * @copydoc RTPathAppDocs
|
---|
85 | */
|
---|
86 | DECLHIDDEN(int) supR3HardenedPathAppDocs(char *pszPath, size_t cchPath)
|
---|
87 | {
|
---|
88 | return RTPathAppDocs(pszPath, cchPath);
|
---|
89 | }
|
---|
90 |
|
---|
91 |
|
---|
92 | /**
|
---|
93 | * @copydoc RTPathProgram
|
---|
94 | */
|
---|
95 | DECLHIDDEN(int) supR3HardenedPathProgram(char *pszPath, size_t cchPath)
|
---|
96 | {
|
---|
97 | return RTPathProgram(pszPath, cchPath);
|
---|
98 | }
|
---|
99 |
|
---|
100 |
|
---|
101 |
|
---|
102 | DECLHIDDEN(void) supR3HardenedFatalV(const char *pszFormat, va_list va)
|
---|
103 | {
|
---|
104 | va_list vaCopy;
|
---|
105 | va_copy(vaCopy, va);
|
---|
106 | AssertFatalMsgFailed(("%N", pszFormat, &vaCopy));
|
---|
107 | va_end(vaCopy);
|
---|
108 | }
|
---|
109 |
|
---|
110 |
|
---|
111 | DECLHIDDEN(void) supR3HardenedFatal(const char *pszFormat, ...)
|
---|
112 | {
|
---|
113 | va_list va;
|
---|
114 | va_start(va, pszFormat);
|
---|
115 | supR3HardenedFatalV(pszFormat, va);
|
---|
116 | va_end(va);
|
---|
117 | }
|
---|
118 |
|
---|
119 |
|
---|
120 | DECLHIDDEN(int) supR3HardenedErrorV(int rc, bool fFatal, const char *pszFormat, va_list va)
|
---|
121 | {
|
---|
122 | if (fFatal)
|
---|
123 | supR3HardenedFatalV(pszFormat, va);
|
---|
124 |
|
---|
125 | va_list vaCopy;
|
---|
126 | va_copy(vaCopy, va);
|
---|
127 | AssertLogRelMsgFailed(("%N", pszFormat, &vaCopy));
|
---|
128 | va_end(vaCopy);
|
---|
129 | return rc;
|
---|
130 | }
|
---|
131 |
|
---|
132 |
|
---|
133 | DECLHIDDEN(int) supR3HardenedError(int rc, bool fFatal, const char *pszFormat, ...)
|
---|
134 | {
|
---|
135 | va_list va;
|
---|
136 | va_start(va, pszFormat);
|
---|
137 | supR3HardenedErrorV(rc, fFatal, pszFormat, va);
|
---|
138 | va_end(va);
|
---|
139 | return rc;
|
---|
140 | }
|
---|
141 |
|
---|