VirtualBox

Changeset 43462 in vbox


Ignore:
Timestamp:
Sep 28, 2012 10:46:41 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
80995
Message:

HGCM Host Channel service: implemented a generic Query function.

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/HostServices/VBoxHostChannel.h

    r43347 r43462  
    4545#define VBOX_HOST_CHANNEL_FN_SEND         3 /* Send data to the host. */
    4646#define VBOX_HOST_CHANNEL_FN_RECV         4 /* Receive data from the host. */
    47 #define VBOX_HOST_CHANNEL_FN_CONTROL      5 /* Generic data exchange. */
     47#define VBOX_HOST_CHANNEL_FN_CONTROL      5 /* Generic data exchange using a channel instance. */
    4848#define VBOX_HOST_CHANNEL_FN_EVENT_WAIT   6 /* Blocking wait for a host event. */
    4949#define VBOX_HOST_CHANNEL_FN_EVENT_CANCEL 7 /* Cancel the blocking wait. */
     50#define VBOX_HOST_CHANNEL_FN_QUERY        8 /* Generic data exchange using a channel name. */
    5051
    5152/*
     
    5657#define VBOX_HOST_CHANNEL_EVENT_RECV         2    /* Data is available for receiving. */
    5758#define VBOX_HOST_CHANNEL_EVENT_USER         1000 /* Base of channel specific events. */
     59
     60/*
     61 * The common control code ids for the VBOX_HOST_CHANNEL_FN_[CONTROL|QUERY]
     62 */
     63#define VBOX_HOST_CHANNEL_CTRL_EXISTS     0    /* Whether the channel instance or provider exists. */
     64#define VBOX_HOST_CHANNEL_CTRL_USER       1000 /* Base of channel specific events. */
    5865
    5966#pragma pack(1)
     
    122129    VBoxGuestHGCMCallInfo hdr;
    123130} VBoxHostChannelEventCancel;
     131
     132typedef struct VBoxHostChannelQuery
     133{
     134    VBoxGuestHGCMCallInfo hdr;
     135    HGCMFunctionParameter name;   /* IN linear ptr: Channel name utf8 nul terminated. */
     136    HGCMFunctionParameter code;   /* IN uint32_t: The control code. */
     137    HGCMFunctionParameter parm;   /* IN linear pointer: Parameters of the function. */
     138    HGCMFunctionParameter data;   /* OUT linear pointer: Buffer for results. */
     139    HGCMFunctionParameter sizeDataReturned; /* OUT uint32_t: Bytes returned in the 'data' buffer. */
     140} VBoxHostChannelQuery;
    124141
    125142
     
    180197                                                   uint32_t *pcbReceived, uint32_t *pcbRemaining));
    181198
    182     /* The guest talks to the provider of the channel. */
     199    /* The guest talks to the provider of the channel.
     200     * @param pvChannel The channel instance. NULL if the target is the provider, rather than a channel.
     201     */
    183202    DECLR3CALLBACKMEMBER(int, HostChannelControl, (void *pvChannel, uint32_t u32Code,
    184203                                                   const void *pvParm, uint32_t cbParm,
  • trunk/include/VBox/VBoxGuestLib.h

    r43346 r43462  
    737737                                            uint32_t *pu32SizeReturned);
    738738VBGLR3DECL(int)  VbglR3HostChannelEventCancel(uint32_t u32ChannelHandle, uint32_t u32HGCMClientId);
     739VBGLR3DECL(int)  VbglR3HostChannelQuery(const char *pszName, uint32_t u32HGCMClientId, uint32_t u32Code,
     740                                        void *pvParm, uint32_t cbParm, void *pvData, uint32_t cbData,
     741                                        uint32_t *pu32SizeDataReturned);
    739742
    740743#endif /* IN_RING3 */
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibHostChannel.cpp

    r43346 r43462  
    276276    return rc;
    277277}
     278
     279VBGLR3DECL(int) VbglR3HostChannelQuery(const char *pszName,
     280                                       uint32_t u32HGCMClientId,
     281                                       uint32_t u32Code,
     282                                       void *pvParm,
     283                                       uint32_t cbParm,
     284                                       void *pvData,
     285                                       uint32_t cbData,
     286                                       uint32_t *pu32SizeDataReturned)
     287{
     288    /* Make a heap copy of the name, because HGCM can not use some of other memory types. */
     289    size_t cbName = strlen(pszName) + 1;
     290    char *pszCopy = (char *)RTMemAlloc(cbName);
     291    if (pszCopy == NULL)
     292    {
     293        return VERR_NO_MEMORY;
     294    }
     295
     296    memcpy(pszCopy, pszName, cbName);
     297
     298    VBoxHostChannelQuery parms;
     299
     300    parms.hdr.result = VERR_WRONG_ORDER;
     301    parms.hdr.u32ClientID = u32HGCMClientId;
     302    parms.hdr.u32Function = VBOX_HOST_CHANNEL_FN_QUERY;
     303    parms.hdr.cParms = 5;
     304
     305    VbglHGCMParmPtrSet(&parms.name, pszCopy, (uint32_t)cbName);
     306    VbglHGCMParmUInt32Set(&parms.code, u32Code);
     307    VbglHGCMParmPtrSet(&parms.parm, pvParm, cbParm);
     308    VbglHGCMParmPtrSet(&parms.data, pvData, cbData);
     309    VbglHGCMParmUInt32Set(&parms.sizeDataReturned, 0);
     310
     311    int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(parms)), &parms, sizeof(parms));
     312
     313    if (RT_SUCCESS(rc))
     314    {
     315        rc = parms.hdr.result;
     316
     317        if (RT_SUCCESS(rc))
     318        {
     319            *pu32SizeDataReturned = parms.sizeDataReturned.u.value32;
     320        }
     321    }
     322
     323    RTMemFree(pszCopy);
     324
     325    return rc;
     326}
  • trunk/src/VBox/HostServices/HostChannel/HostChannel.cpp

    r43385 r43462  
    699699}
    700700
     701int vboxHostChannelQuery(VBOXHOSTCHCLIENT *pClient,
     702                         const char *pszName,
     703                         uint32_t u32Code,
     704                         void *pvParm,
     705                         uint32_t cbParm,
     706                         void *pvData,
     707                         uint32_t cbData,
     708                         uint32_t *pu32SizeDataReturned)
     709{
     710    HOSTCHLOG(("HostChannel: Query: (%d) name [%s], cbData %d\n", pClient->u32ClientID, pszName, cbData));
     711
     712    int rc = VINF_SUCCESS;
     713
     714    /* Look if there is a provider. */
     715    VBOXHOSTCHPROVIDER *pProvider = vhcProviderFind(pClient->pCtx, pszName);
     716
     717    if (pProvider)
     718    {
     719        pProvider->iface.HostChannelControl(NULL, u32Code,
     720                                            pvParm, cbParm,
     721                                            pvData, cbData, pu32SizeDataReturned);
     722
     723        vhcProviderRelease(pProvider);
     724    }
     725    else
     726    {
     727        rc = VERR_NOT_SUPPORTED;
     728    }
     729
     730    return rc;
     731}
     732
    701733int vboxHostChannelRegister(const char *pszName,
    702734                            const VBOXHOSTCHANNELINTERFACE *pInterface,
  • trunk/src/VBox/HostServices/HostChannel/HostChannel.h

    r43352 r43462  
    104104                              uint32_t *pcbParmOut);
    105105
     106int vboxHostChannelQuery(VBOXHOSTCHCLIENT *pClient,
     107                         const char *pszName,
     108                         uint32_t u32Code,
     109                         void *pvParm,
     110                         uint32_t cbParm,
     111                         void *pvData,
     112                         uint32_t cbData,
     113                         uint32_t *pu32SizeDataReturned);
     114
    106115int vboxHostChannelRegister(const char *pszName,
    107116                            const VBOXHOSTCHANNELINTERFACE *pInterface,
  • trunk/src/VBox/HostServices/HostChannel/service.cpp

    r43352 r43462  
    243243                        uint32_t u32Handle = 0;
    244244
     245                        /* @todo make sure that pvName is a nul terminated */
    245246                        rc = vboxHostChannelAttach(pClient, &u32Handle, (const char *)pvName, u32Flags);
    246247
     
    516517
    517518                    vboxHostChannelUnlock();
     519                }
     520            }
     521        } break;
     522
     523        case VBOX_HOST_CHANNEL_FN_QUERY:
     524        {
     525            LogRel2(("svcCall: VBOX_HOST_CHANNEL_FN_QUERY\n"));
     526
     527            if (cParms != 5)
     528            {
     529                rc = VERR_INVALID_PARAMETER;
     530            }
     531            else if (   paParms[0].type != VBOX_HGCM_SVC_PARM_PTR     /* channel name */
     532                     || paParms[1].type != VBOX_HGCM_SVC_PARM_32BIT   /* code */
     533                     || paParms[2].type != VBOX_HGCM_SVC_PARM_PTR     /* parm */
     534                     || paParms[3].type != VBOX_HGCM_SVC_PARM_PTR     /* data */
     535                     || paParms[4].type != VBOX_HGCM_SVC_PARM_32BIT   /* sizeDataReturned */
     536                    )
     537            {
     538                rc = VERR_INVALID_PARAMETER;
     539            }
     540            else
     541            {
     542                void *pvName;
     543                uint32_t cbName;
     544                uint32_t u32Code;
     545                void *pvParm;
     546                uint32_t cbParm;
     547                void *pvData;
     548                uint32_t cbData;
     549
     550                rc = VBoxHGCMParmPtrGet(&paParms[0], &pvName, &cbName);
     551
     552                if (RT_SUCCESS (rc))
     553                {
     554                    rc = VBoxHGCMParmUInt32Get (&paParms[1], &u32Code);
     555
     556                    if (RT_SUCCESS (rc))
     557                    {
     558                        rc = VBoxHGCMParmPtrGet (&paParms[2], &pvParm, &cbParm);
     559
     560                        if (RT_SUCCESS (rc))
     561                        {
     562                            rc = VBoxHGCMParmPtrGet (&paParms[3], &pvData, &cbData);
     563
     564                            if (RT_SUCCESS (rc))
     565                            {
     566                                uint32_t u32SizeDataReturned = 0;
     567
     568                                /* @todo make sure that pvName is a nul terminated */
     569                                rc = vboxHostChannelQuery(pClient, (const char *)pvName, u32Code,
     570                                                          pvParm, cbParm,
     571                                                          pvData, cbData, &u32SizeDataReturned);
     572                                if (RT_SUCCESS(rc))
     573                                {
     574                                    VBoxHGCMParmUInt32Set(&paParms[4], u32SizeDataReturned);
     575                                }
     576                            }
     577                        }
     578                    }
    518579                }
    519580            }
  • trunk/src/VBox/Main/src-client/ConsoleVRDPServer.cpp

    r43446 r43462  
    22142214{
    22152215    LogFlowFunc(("\n"));
     2216    if (!pvChannel)
     2217    {
     2218        /* Special case, the provider must answer rather than a channel instance. */
     2219        if (u32Code == VBOX_HOST_CHANNEL_CTRL_EXISTS)
     2220        {
     2221            *pcbDataReturned = 0;
     2222            return VINF_SUCCESS;
     2223        }
     2224
     2225        return VERR_NOT_IMPLEMENTED;
     2226    }
     2227
     2228    /* Channels do not support this. */
    22162229    return VERR_NOT_IMPLEMENTED;
    22172230}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette