VBoxGuestR3LibInfoSvc.cpp revision 499b762111b674f02f4a747c323d1476d55718ec
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * VBoxGuestR3Lib - Ring-3 Support Library for VirtualBox guest additions, information service.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Copyright (C) 2007 Sun Microsystems, Inc.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * available from http://www.virtualbox.org. This file is free software;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * you can redistribute it and/or modify it under the terms of the GNU
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * General Public License (GPL) as published by the Free Software
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * additional information or have any questions.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync/*******************************************************************************
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync* Header Files *
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync*******************************************************************************/
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync#include <VBox/HostServices/VBoxInfoSvc.h> /* For Save and RetrieveVideoMode */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncusing namespace svcInfo;
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Connects to the information service.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns VBox status code
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pu32ClientId Where to put the client id on success. The client id
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * must be passed to all the other calls to the service.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncVBGLR3DECL(int) VbglR3InfoSvcConnect(uint32_t *pu32ClientId)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Info.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync strcpy(Info.Loc.u.host.achName, "VBoxSharedInfoSvc");
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Info.u32ClientID = UINT32_MAX; /* try make valgrid shut up. */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CONNECT, &Info, sizeof(Info));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Disconnect from the information service.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns VBox status code.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param u32ClientId The client id returned by VbglR3InfoSvcConnect().
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncVBGLR3DECL(int) VbglR3InfoSvcDisconnect(uint32_t u32ClientId)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Info.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_DISCONNECT, &Info, sizeof(Info));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Write a key value.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns VBox status code.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param u32ClientId The client id returned by VbglR3InvsSvcConnect().
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pszKey The key to save to. Utf8
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pszValue The value to store. Utf8. If this is NULL then
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * the key will be removed.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncVBGLR3DECL(int) VbglR3InfoSvcWriteKey(uint32_t u32ClientId, char *pszKey, char *pszValue)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Msg.hdr.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync VbglHGCMParmPtrSet(&Msg.key, pszKey, strlen(pszKey) + 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync VbglHGCMParmPtrSet(&Msg.value, pszValue, strlen(pszValue) + 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL, &Msg, sizeof(Msg));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Msg.hdr.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync VbglHGCMParmPtrSet(&Msg.key, pszKey, strlen(pszKey) + 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL, &Msg, sizeof(Msg));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * Retrieve a key value.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @returns VBox status code.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @retval VINF_SUCCESS on success, pszValue and pcbActual containing valid data.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @retval VERR_BUFFER_OVERFLOW if the buffer is too small, pcbActual will contain
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * the require buffer size. Note race condition here when retrying wrt
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * someone updating it.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @retval VERR_NOT_FOUND if the key wasn't found.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param u32ClientId The client id returned by VbglR3ClipboardConnect().
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pszKey The key to read. Utf8
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pszValue Where to store the value retrieved. Utf8.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param cbValue The size of the buffer pszValue points to.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * @param pcbActual Where to store the required buffer size if cbValue
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * is too small. On success this contains the
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync * actual size of the value retrieved. Optional.
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsyncVBGLR3DECL(int) VbglR3InfoSvcReadKey(uint32_t u32ClientId, char *pszKey,
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync char *pszValue, uint32_t cbValue, uint32_t *pcbActual)
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync Msg.hdr.result = (uint32_t)VERR_WRONG_ORDER; /** @todo drop the cast when the result type has been fixed! */
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync VbglHGCMParmPtrSet(&Msg.key, pszKey, strlen(pszKey) + 1);
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL, &Msg, sizeof(Msg));
9dca051a5f8ff457ef1692990f6ecfa280daf265vboxsync if (RT_SUCCESS(rc) || (VERR_BUFFER_OVERFLOW == rc))