VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibHGCM.cpp@ 82528

Last change on this file since 82528 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1/* $Id: VBoxGuestR3LibHGCM.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions,
4 * generic HGCM.
5 */
6
7/*
8 * Copyright (C) 2015-2019 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * The contents of this file may alternatively be used under the terms
19 * of the Common Development and Distribution License Version 1.0
20 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
21 * VirtualBox OSE distribution, in which case the provisions of the
22 * CDDL are applicable instead of those of the GPL.
23 *
24 * You may elect to license modified versions of this file under the
25 * terms and conditions of either the GPL or the CDDL or both.
26 */
27
28
29/*********************************************************************************************************************************
30* Header Files *
31*********************************************************************************************************************************/
32#include "VBoxGuestR3LibInternal.h"
33#include <VBox/VBoxGuestLib.h>
34#include <iprt/string.h>
35
36
37/**
38 * Connects to an HGCM service.
39 *
40 * @returns VBox status code
41 * @param pszServiceName Name of the host service.
42 * @param pidClient Where to put the client ID on success. The client ID
43 * must be passed to all the other calls to the service.
44 */
45VBGLR3DECL(int) VbglR3HGCMConnect(const char *pszServiceName, HGCMCLIENTID *pidClient)
46{
47 VBGLIOCHGCMCONNECT Info;
48 RT_ZERO(Info);
49 VBGLREQHDR_INIT(&Info.Hdr, HGCM_CONNECT);
50 Info.u.In.Loc.type = VMMDevHGCMLoc_LocalHost_Existing;
51 strcpy(Info.u.In.Loc.u.host.achName, pszServiceName);
52
53 int rc = vbglR3DoIOCtl(VBGL_IOCTL_HGCM_CONNECT, &Info.Hdr, sizeof(Info));
54 if (RT_SUCCESS(rc))
55 *pidClient = Info.u.Out.idClient;
56 return rc;
57}
58
59
60/**
61 * Disconnect from an HGCM service.
62 *
63 * @returns VBox status code.
64 * @param idClient The client id returned by VbglR3InfoSvcConnect().
65 */
66VBGLR3DECL(int) VbglR3HGCMDisconnect(HGCMCLIENTID idClient)
67{
68 VBGLIOCHGCMDISCONNECT Info;
69 VBGLREQHDR_INIT(&Info.Hdr, HGCM_DISCONNECT);
70 Info.u.In.idClient = idClient;
71
72 return vbglR3DoIOCtl(VBGL_IOCTL_HGCM_DISCONNECT, &Info.Hdr, sizeof(Info));
73}
74
75
76/**
77 * Makes a fully prepared HGCM call.
78 *
79 * @returns VBox status code.
80 * @param pInfo Fully prepared HGCM call info.
81 * @param cbInfo Size of the info. This may sometimes be larger than
82 * what the parameter count indicates because of
83 * parameter changes between versions and such.
84 */
85VBGLR3DECL(int) VbglR3HGCMCall(PVBGLIOCHGCMCALL pInfo, size_t cbInfo)
86{
87 /* Expect caller to have filled in pInfo. */
88 AssertMsg(pInfo->Hdr.cbIn == cbInfo, ("cbIn=%#x cbInfo=%#zx\n", pInfo->Hdr.cbIn, cbInfo));
89 AssertMsg(pInfo->Hdr.cbOut == cbInfo, ("cbOut=%#x cbInfo=%#zx\n", pInfo->Hdr.cbOut, cbInfo));
90 Assert(sizeof(*pInfo) + pInfo->cParms * sizeof(HGCMFunctionParameter) <= cbInfo);
91 Assert(pInfo->u32ClientID != 0);
92
93 return vbglR3DoIOCtl(VBGL_IOCTL_HGCM_CALL(cbInfo), &pInfo->Hdr, cbInfo);
94}
95
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