VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR3LibDrmClient.cpp@ 93115

Last change on this file since 93115 was 93115, checked in by vboxsync, 3 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.5 KB
Line 
1/* $Id: VBoxGuestR3LibDrmClient.cpp 93115 2022-01-01 11:31:46Z vboxsync $ */
2/** @file
3 * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, DRM client handling.
4 */
5
6/*
7 * Copyright (C) 2020-2022 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/*********************************************************************************************************************************
29* Header Files *
30*********************************************************************************************************************************/
31#include "VBoxGuestR3LibInternal.h"
32
33#include <iprt/env.h>
34#include <iprt/path.h>
35#include <iprt/process.h>
36
37/** Defines the DRM client executable (image). */
38#define VBOX_DRMCLIENT_EXECUTABLE "VBoxDRMClient"
39/** Defines the guest property that defines if the DRM resizing client needs to be active or not. */
40#define VBOX_DRMCLIENT_GUEST_PROP_RESIZE "/VirtualBox/GuestAdd/DRMResize"
41
42/**
43 * Returns if the DRM resizing client is needed.
44 * This is achieved by querying existence of a guest property.
45 *
46 * @returns \c true if the DRM resizing client is needed, \c false if not.
47 */
48VBGLR3DECL(bool) VbglR3DrmClientIsNeeded(void)
49{
50 bool fStartClient = false;
51
52#ifdef VBOX_WITH_GUEST_PROPS
53 uint32_t idClient;
54 int rc = VbglR3GuestPropConnect(&idClient);
55 if (RT_SUCCESS(rc))
56 {
57 fStartClient = VbglR3GuestPropExist(idClient, VBOX_DRMCLIENT_GUEST_PROP_RESIZE /*pszPropName*/);
58 VbglR3GuestPropDisconnect(idClient);
59 }
60#endif
61
62 return fStartClient;
63}
64
65/**
66 * Returns if the DRM resizing client already is running.
67 * This is achieved by querying existence of a guest property.
68 *
69 * @returns \c true if the DRM resizing client is running, \c false if not.
70 */
71VBGLR3DECL(bool) VbglR3DrmClientIsRunning(void)
72{
73 return VbglR3DrmClientIsNeeded();
74}
75
76/**
77 * Starts (executes) the DRM resizing client process ("VBoxDRMClient").
78 *
79 * @returns VBox status code.
80 */
81VBGLR3DECL(int) VbglR3DrmClientStart(void)
82{
83 char szDRMClientPath[RTPATH_MAX];
84 int rc = RTPathExecDir(szDRMClientPath, RTPATH_MAX);
85 if (RT_SUCCESS(rc))
86 {
87 RTPathStripSuffix(szDRMClientPath);
88 rc = RTPathAppend(szDRMClientPath, RTPATH_MAX, VBOX_DRMCLIENT_EXECUTABLE);
89 if (RT_SUCCESS(rc))
90 {
91 const char *apszArgs[1] = { NULL }; /** @todo r=andy Pass path + process name as argv0? */
92 rc = RTProcCreate(VBOX_DRMCLIENT_EXECUTABLE, apszArgs, RTENV_DEFAULT,
93 RTPROC_FLAGS_DETACHED | RTPROC_FLAGS_SEARCH_PATH, NULL);
94 }
95 }
96
97 return rc;
98}
99
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