VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibInternal.h

Last change on this file was 98218, checked in by vboxsync, 16 months ago

Add/VbglR3: Applied same VERR_WRONG_PARAMETER_TYPE and always setting the return value logic to VbglHGCMParmUInt32Get and VbglHGCMParmUInt64Get. bugref:10348

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/* $Id: VBoxGuestR3LibInternal.h 98218 2023-01-22 23:01:17Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 support library for the guest additions, Internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef GA_INCLUDED_SRC_common_VBoxGuest_lib_VBoxGuestR3LibInternal_h
38#define GA_INCLUDED_SRC_common_VBoxGuest_lib_VBoxGuestR3LibInternal_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <VBox/VMMDev.h>
44#include <VBox/VBoxGuest.h>
45#include <VBox/VBoxGuestLib.h>
46
47#ifdef VBOX_VBGLR3_XFREE86
48/* Rather than try to resolve all the header file conflicts, I will just
49 prototype what we need here. */
50typedef unsigned long xf86size_t;
51extern "C" xf86size_t xf86strlen(const char*);
52# undef strlen
53# define strlen xf86strlen
54#endif /* VBOX_VBGLR3_XFREE86 */
55
56RT_C_DECLS_BEGIN
57
58int vbglR3DoIOCtl(uintptr_t uFunction, PVBGLREQHDR pReq, size_t cbReq);
59int vbglR3DoIOCtlRaw(uintptr_t uFunction, PVBGLREQHDR pReq, size_t cbReq);
60int vbglR3GRAlloc(VMMDevRequestHeader **ppReq, size_t cb, VMMDevRequestType enmReqType);
61int vbglR3GRPerform(VMMDevRequestHeader *pReq);
62void vbglR3GRFree(VMMDevRequestHeader *pReq);
63
64
65
66DECLINLINE(void) VbglHGCMParmUInt32Set(HGCMFunctionParameter *pParm, uint32_t u32)
67{
68 pParm->type = VMMDevHGCMParmType_32bit;
69 pParm->u.value64 = 0; /* init unused bits to 0 */
70 pParm->u.value32 = u32;
71}
72
73
74DECLINLINE(int) VbglHGCMParmUInt32Get(HGCMFunctionParameter *pParm, uint32_t *pu32)
75{
76 if (pParm->type == VMMDevHGCMParmType_32bit)
77 {
78 *pu32 = pParm->u.value32;
79 return VINF_SUCCESS;
80 }
81 *pu32 = UINT32_MAX; /* shut up gcc */
82 return VERR_WRONG_PARAMETER_TYPE;
83}
84
85
86DECLINLINE(void) VbglHGCMParmUInt64Set(HGCMFunctionParameter *pParm, uint64_t u64)
87{
88 pParm->type = VMMDevHGCMParmType_64bit;
89 pParm->u.value64 = u64;
90}
91
92
93DECLINLINE(int) VbglHGCMParmUInt64Get(HGCMFunctionParameter *pParm, uint64_t *pu64)
94{
95 if (pParm->type == VMMDevHGCMParmType_64bit)
96 {
97 *pu64 = pParm->u.value64;
98 return VINF_SUCCESS;
99 }
100 *pu64 = UINT64_MAX; /* shut up gcc */
101 return VERR_WRONG_PARAMETER_TYPE;
102}
103
104
105DECLINLINE(void) VbglHGCMParmPtrSet(HGCMFunctionParameter *pParm, void *pv, uint32_t cb)
106{
107 pParm->type = VMMDevHGCMParmType_LinAddr;
108 pParm->u.Pointer.size = cb;
109 pParm->u.Pointer.u.linearAddr = (uintptr_t)pv;
110}
111
112
113#ifdef IPRT_INCLUDED_string_h
114
115DECLINLINE(void) VbglHGCMParmPtrSetString(HGCMFunctionParameter *pParm, const char *psz)
116{
117 pParm->type = VMMDevHGCMParmType_LinAddr_In;
118 pParm->u.Pointer.size = (uint32_t)strlen(psz) + 1;
119 pParm->u.Pointer.u.linearAddr = (uintptr_t)psz;
120}
121
122#endif /* IPRT_INCLUDED_string_h */
123
124#ifdef VBOX_VBGLR3_XFREE86
125# undef strlen
126#endif /* VBOX_VBGLR3_XFREE86 */
127
128RT_C_DECLS_END
129
130#endif /* !GA_INCLUDED_SRC_common_VBoxGuest_lib_VBoxGuestR3LibInternal_h */
131
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use