VirtualBox

Changeset 45109 in vbox for trunk/src


Ignore:
Timestamp:
Mar 20, 2013 4:41:00 PM (12 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
84401
Message:

GuestCtrl: More stuff for IGuestFile and IGuestSession handling (work in progress).

Location:
trunk/src/VBox
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestCtrl.cpp

    r45018 r45109  
    186186
    187187
    188 VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify(uint32_t uClientId, uint32_t uContext,
     188VBGLR3DECL(int) VbglR3GuestCtrlSessionNotify(PVBGLR3GUESTCTRLCMDCTX pCtx,
    189189                                             uint32_t uType, uint32_t uResult)
    190190{
     191    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     192
    191193    HGCMMsgSessionNotify Msg;
    192194
    193195    Msg.hdr.result      = VERR_WRONG_ORDER;
    194     Msg.hdr.u32ClientID = uClientId;
     196    Msg.hdr.u32ClientID = pCtx->uClientID;
    195197    Msg.hdr.u32Function = GUEST_SESSION_NOTIFY;
    196198    Msg.hdr.cParms      = 3;
    197199
    198     VbglHGCMParmUInt32Set(&Msg.context, uContext);
     200    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
    199201    VbglHGCMParmUInt32Set(&Msg.type, uType);
    200202    VbglHGCMParmUInt32Set(&Msg.result, uResult);
     
    215217 *
    216218 * @return  IPRT status code.
    217  * @param   pHostCtx                    Host context.
     219 * @param   pCtx                    Host context.
    218220 ** @todo Docs!
    219221 */
    220 VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     222VBGLR3DECL(int) VbglR3GuestCtrlSessionGetOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
    221223                                              uint32_t *puProtocol,
    222224                                              char     *pszUser,     uint32_t  cbUser,
     
    225227                                              uint32_t *puFlags,     uint32_t *puSessionID)
    226228{
    227     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    228     AssertReturn(pHostCtx->uNumParms == 6, VERR_INVALID_PARAMETER);
     229    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     230    AssertReturn(pCtx->uNumParms == 6, VERR_INVALID_PARAMETER);
    229231
    230232    AssertPtrReturn(puProtocol, VERR_INVALID_POINTER);
     
    237239
    238240    Msg.hdr.result      = VERR_WRONG_ORDER;
    239     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    240     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    241     Msg.hdr.cParms      = pHostCtx->uNumParms;
     241    Msg.hdr.u32ClientID = pCtx->uClientID;
     242    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     243    Msg.hdr.cParms      = pCtx->uNumParms;
    242244
    243245    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    258260        else
    259261        {
    260             Msg.context.GetUInt32(&pHostCtx->uContextID);
     262            Msg.context.GetUInt32(&pCtx->uContextID);
    261263            Msg.protocol.GetUInt32(puProtocol);
    262264            Msg.flags.GetUInt32(puFlags);
    263265
    264266            if (puSessionID)
    265                 *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHostCtx->uContextID);
     267                *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
    266268        }
    267269    }
     
    275277 *
    276278 * @return  IPRT status code.
    277  * @param   pHostCtx                    Host context.
     279 * @param   pCtx                    Host context.
    278280 ** @todo Docs!
    279281 */
    280 VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLHOSTCTX pHostCtx, uint32_t *puFlags, uint32_t *puSessionID)
    281 {
    282     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    283     AssertReturn(pHostCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
     282VBGLR3DECL(int) VbglR3GuestCtrlSessionGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puFlags, uint32_t *puSessionID)
     283{
     284    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     285    AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
    284286
    285287    AssertPtrReturn(puFlags, VERR_INVALID_POINTER);
     
    288290
    289291    Msg.hdr.result      = VERR_WRONG_ORDER;
    290     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    291     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    292     Msg.hdr.cParms      = pHostCtx->uNumParms;
     292    Msg.hdr.u32ClientID = pCtx->uClientID;
     293    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     294    Msg.hdr.cParms      = pCtx->uNumParms;
    293295
    294296    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    305307        else
    306308        {
    307             Msg.context.GetUInt32(&pHostCtx->uContextID);
     309            Msg.context.GetUInt32(&pCtx->uContextID);
    308310            Msg.flags.GetUInt32(puFlags);
    309311
    310312            if (puSessionID)
    311                 *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHostCtx->uContextID);
     313                *puSessionID = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pCtx->uContextID);
    312314        }
    313315    }
     
    326328 ** @todo Move the parameters in an own struct!
    327329 */
    328 VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRLHOSTCTX   pHostCtx,
     330VBGLR3DECL(int) VbglR3GuestCtrlProcGetStart(PVBGLR3GUESTCTRLCMDCTX   pCtx,
    329331                                            char     *pszCmd,         uint32_t  cbCmd,
    330332                                            uint32_t *puFlags,
     
    337339                                            uint64_t *puAffinity,     uint32_t  cbAffinity, uint32_t *pcAffinity)
    338340{
    339     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
     341    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
    340342
    341343    AssertPtrReturn(pszCmd, VERR_INVALID_POINTER);
     
    351353
    352354    Msg.hdr.result      = VERR_WRONG_ORDER;
    353     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    354     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    355     Msg.hdr.cParms      = pHostCtx->uNumParms;
     355    Msg.hdr.u32ClientID = pCtx->uClientID;
     356    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     357    Msg.hdr.cParms      = pCtx->uNumParms;
    356358
    357359    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    363365    VbglHGCMParmUInt32Set(&Msg.cb_env, 0);
    364366    VbglHGCMParmPtrSet(&Msg.env, pszEnv, *pcbEnv);
    365     if (pHostCtx->uProtocol < 2)
     367    if (pCtx->uProtocol < 2)
    366368    {
    367369        AssertPtrReturn(pszUser, VERR_INVALID_POINTER);
     
    395397        else
    396398        {
    397             Msg.context.GetUInt32(&pHostCtx->uContextID);
     399            Msg.context.GetUInt32(&pCtx->uContextID);
    398400            Msg.flags.GetUInt32(puFlags);
    399401            Msg.num_args.GetUInt32(pcArgs);
    400402            Msg.num_env.GetUInt32(pcEnvVars);
    401403            Msg.cb_env.GetUInt32(pcbEnv);
    402             if (pHostCtx->uProtocol < 2)
     404            if (pCtx->uProtocol < 2)
    403405            {
    404406                Msg.u.v1.timeout.GetUInt32(puTimeoutMS);
     
    424426 ** @todo Docs!
    425427 */
    426 VBGLR3DECL(int) VbglR3GuestCtrlProcGetOutput(PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     428VBGLR3DECL(int) VbglR3GuestCtrlProcGetOutput(PVBGLR3GUESTCTRLCMDCTX pCtx,
    427429                                             uint32_t *puPID, uint32_t *puHandle, uint32_t *puFlags)
    428430{
    429     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    430     AssertReturn(pHostCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
     431    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     432    AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
    431433
    432434    AssertPtrReturn(puPID, VERR_INVALID_POINTER);
     
    437439
    438440    Msg.hdr.result = VERR_WRONG_ORDER;
    439     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    440     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    441     Msg.hdr.cParms      = pHostCtx->uNumParms;
     441    Msg.hdr.u32ClientID = pCtx->uClientID;
     442    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     443    Msg.hdr.cParms      = pCtx->uNumParms;
    442444
    443445    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    456458        else
    457459        {
    458             Msg.context.GetUInt32(&pHostCtx->uContextID);
     460            Msg.context.GetUInt32(&pCtx->uContextID);
    459461            Msg.pid.GetUInt32(puPID);
    460462            Msg.handle.GetUInt32(puHandle);
     
    475477 ** @todo Docs!
    476478 */
    477 VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     479VBGLR3DECL(int) VbglR3GuestCtrlProcGetInput(PVBGLR3GUESTCTRLCMDCTX pCtx,
    478480                                            uint32_t  *puPID,       uint32_t *puFlags,
    479481                                            void      *pvData,      uint32_t  cbData,
    480482                                            uint32_t  *pcbSize)
    481483{
    482     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    483     AssertReturn(pHostCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
     484    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     485    AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
    484486
    485487    AssertPtrReturn(puPID, VERR_INVALID_POINTER);
     
    491493
    492494    Msg.hdr.result      = VERR_WRONG_ORDER;
    493     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    494     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    495     Msg.hdr.cParms      = pHostCtx->uNumParms;
     495    Msg.hdr.u32ClientID = pCtx->uClientID;
     496    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     497    Msg.hdr.cParms      = pCtx->uNumParms;
    496498
    497499    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    511513        else
    512514        {
    513             Msg.context.GetUInt32(&pHostCtx->uContextID);
     515            Msg.context.GetUInt32(&pCtx->uContextID);
    514516            Msg.pid.GetUInt32(puPID);
    515517            Msg.flags.GetUInt32(puFlags);
     
    521523
    522524
    523 VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLHOSTCTX      pHostCtx,
     525VBGLR3DECL(int) VbglR3GuestCtrlFileGetOpen(PVBGLR3GUESTCTRLCMDCTX      pCtx,
    524526                                           char     *pszFileName,       uint32_t cbFileName,
    525527                                           char     *pszOpenMode,       uint32_t cbOpenMode,
     
    528530                                           uint64_t *puOffset)
    529531{
    530     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    531     AssertReturn(pHostCtx->uNumParms == 6, VERR_INVALID_PARAMETER);
     532    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     533    AssertReturn(pCtx->uNumParms == 6, VERR_INVALID_PARAMETER);
    532534
    533535    AssertPtrReturn(pszFileName, VERR_INVALID_POINTER);
     
    543545
    544546    Msg.hdr.result      = VERR_WRONG_ORDER;
    545     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    546     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    547     Msg.hdr.cParms      = pHostCtx->uNumParms;
     547    Msg.hdr.u32ClientID = pCtx->uClientID;
     548    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     549    Msg.hdr.cParms      = pCtx->uNumParms;
    548550
    549551    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    564566        else
    565567        {
    566             Msg.context.GetUInt32(&pHostCtx->uContextID);
     568            Msg.context.GetUInt32(&pCtx->uContextID);
    567569            Msg.creationmode.GetUInt32(puCreationMode);
    568570            Msg.offset.GetUInt64(puOffset);
     
    573575
    574576
    575 VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLHOSTCTX pHostCtx, uint32_t *puHandle)
    576 {
    577     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    578 
    579     AssertReturn(pHostCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
     577VBGLR3DECL(int) VbglR3GuestCtrlFileGetClose(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle)
     578{
     579    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     580
     581    AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
    580582    AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
    581583
     
    583585
    584586    Msg.hdr.result      = VERR_WRONG_ORDER;
    585     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    586     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    587     Msg.hdr.cParms      = pHostCtx->uNumParms;
     587    Msg.hdr.u32ClientID = pCtx->uClientID;
     588    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     589    Msg.hdr.cParms      = pCtx->uNumParms;
    588590
    589591    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    600602        else
    601603        {
    602             Msg.context.GetUInt32(&pHostCtx->uContextID);
     604            Msg.context.GetUInt32(&pCtx->uContextID);
    603605            Msg.handle.GetUInt32(puHandle);
    604606        }
     
    608610
    609611
    610 VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     612VBGLR3DECL(int) VbglR3GuestCtrlFileGetRead(PVBGLR3GUESTCTRLCMDCTX pCtx,
    611613                                           uint32_t *puHandle, uint32_t *puToRead)
    612614{
    613     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    614 
    615     AssertReturn(pHostCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
     615    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     616
     617    AssertReturn(pCtx->uNumParms == 3, VERR_INVALID_PARAMETER);
    616618    AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
    617619    AssertPtrReturn(puToRead, VERR_INVALID_POINTER);
     
    620622
    621623    Msg.hdr.result      = VERR_WRONG_ORDER;
    622     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    623     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    624     Msg.hdr.cParms      = pHostCtx->uNumParms;
     624    Msg.hdr.u32ClientID = pCtx->uClientID;
     625    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     626    Msg.hdr.cParms      = pCtx->uNumParms;
    625627
    626628    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    638640        else
    639641        {
    640             Msg.context.GetUInt32(&pHostCtx->uContextID);
     642            Msg.context.GetUInt32(&pCtx->uContextID);
    641643            Msg.handle.GetUInt32(puHandle);
    642644            Msg.size.GetUInt32(puToRead);
     
    647649
    648650
    649 VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     651VBGLR3DECL(int) VbglR3GuestCtrlFileGetReadAt(PVBGLR3GUESTCTRLCMDCTX pCtx,
    650652                                             uint32_t *puHandle, uint32_t *puToRead, uint64_t *puOffset)
    651653{
    652     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    653 
    654     AssertReturn(pHostCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
     654    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     655
     656    AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
    655657    AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
    656658    AssertPtrReturn(puToRead, VERR_INVALID_POINTER);
    657659
    658     HGCMMsgFileRead Msg;
    659 
    660     Msg.hdr.result      = VERR_WRONG_ORDER;
    661     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    662     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    663     Msg.hdr.cParms      = pHostCtx->uNumParms;
     660    HGCMMsgFileReadAt Msg;
     661
     662    Msg.hdr.result      = VERR_WRONG_ORDER;
     663    Msg.hdr.u32ClientID = pCtx->uClientID;
     664    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     665    Msg.hdr.cParms      = pCtx->uNumParms;
    664666
    665667    VbglHGCMParmUInt32Set(&Msg.context, 0);
    666668    VbglHGCMParmUInt32Set(&Msg.handle, 0);
     669    VbglHGCMParmUInt32Set(&Msg.offset, 0);
    667670    VbglHGCMParmUInt32Set(&Msg.size, 0);
    668671
     
    677680        else
    678681        {
    679             Msg.context.GetUInt32(&pHostCtx->uContextID);
     682            Msg.context.GetUInt32(&pCtx->uContextID);
    680683            Msg.handle.GetUInt32(puHandle);
     684            Msg.offset.GetUInt64(puOffset);
    681685            Msg.size.GetUInt32(puToRead);
    682686        }
     
    686690
    687691
    688 VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRLHOSTCTX pHostCtx, uint32_t *puHandle,
     692VBGLR3DECL(int) VbglR3GuestCtrlFileGetWrite(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
    689693                                            void *pvData, uint32_t cbData, uint32_t *pcbSize)
    690694{
    691     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    692 
    693     AssertReturn(pHostCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
     695    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     696
     697    AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
    694698    AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
    695699    AssertPtrReturn(pvData, VERR_INVALID_POINTER);
     
    700704
    701705    Msg.hdr.result      = VERR_WRONG_ORDER;
    702     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    703     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    704     Msg.hdr.cParms      = pHostCtx->uNumParms;
     706    Msg.hdr.u32ClientID = pCtx->uClientID;
     707    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     708    Msg.hdr.cParms      = pCtx->uNumParms;
    705709
    706710    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    719723        else
    720724        {
    721             Msg.context.GetUInt32(&pHostCtx->uContextID);
     725            Msg.context.GetUInt32(&pCtx->uContextID);
    722726            Msg.handle.GetUInt32(puHandle);
    723727            Msg.size.GetUInt32(pcbSize);
     
    728732
    729733
    730 VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRLHOSTCTX pHostCtx, uint32_t *puHandle,
     734VBGLR3DECL(int) VbglR3GuestCtrlFileGetWriteAt(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle,
    731735                                              void *pvData, uint32_t cbData, uint32_t *pcbSize, uint64_t *puOffset)
    732736{
    733     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    734 
    735     AssertReturn(pHostCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
     737    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     738
     739    AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
    736740    AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
    737741    AssertPtrReturn(pvData, VERR_INVALID_POINTER);
     
    742746
    743747    Msg.hdr.result      = VERR_WRONG_ORDER;
    744     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    745     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    746     Msg.hdr.cParms      = pHostCtx->uNumParms;
     748    Msg.hdr.u32ClientID = pCtx->uClientID;
     749    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     750    Msg.hdr.cParms      = pCtx->uNumParms;
    747751
    748752    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    762766        else
    763767        {
    764             Msg.context.GetUInt32(&pHostCtx->uContextID);
     768            Msg.context.GetUInt32(&pCtx->uContextID);
    765769            Msg.handle.GetUInt32(puHandle);
    766770            Msg.size.GetUInt32(pcbSize);
     
    771775
    772776
    773 VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     777VBGLR3DECL(int) VbglR3GuestCtrlFileGetSeek(PVBGLR3GUESTCTRLCMDCTX pCtx,
    774778                                           uint32_t *puHandle, uint32_t *puSeekMethod, uint64_t *puOffset)
    775779{
    776     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    777 
    778     AssertReturn(pHostCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
     780    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     781
     782    AssertReturn(pCtx->uNumParms == 4, VERR_INVALID_PARAMETER);
    779783    AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
    780784    AssertPtrReturn(puSeekMethod, VERR_INVALID_POINTER);
     
    784788
    785789    Msg.hdr.result      = VERR_WRONG_ORDER;
    786     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    787     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    788     Msg.hdr.cParms      = pHostCtx->uNumParms;
     790    Msg.hdr.u32ClientID = pCtx->uClientID;
     791    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     792    Msg.hdr.cParms      = pCtx->uNumParms;
    789793
    790794    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    803807        else
    804808        {
    805             Msg.context.GetUInt32(&pHostCtx->uContextID);
     809            Msg.context.GetUInt32(&pCtx->uContextID);
    806810            Msg.handle.GetUInt32(puHandle);
    807811            Msg.method.GetUInt32(puSeekMethod);
     
    813817
    814818
    815 VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRLHOSTCTX pHostCtx, uint32_t *puHandle)
    816 {
    817     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    818 
    819     AssertReturn(pHostCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
     819VBGLR3DECL(int) VbglR3GuestCtrlFileGetTell(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puHandle)
     820{
     821    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     822
     823    AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
    820824    AssertPtrReturn(puHandle, VERR_INVALID_POINTER);
    821825
     
    823827
    824828    Msg.hdr.result      = VERR_WRONG_ORDER;
    825     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    826     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    827     Msg.hdr.cParms      = pHostCtx->uNumParms;
     829    Msg.hdr.u32ClientID = pCtx->uClientID;
     830    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     831    Msg.hdr.cParms      = pCtx->uNumParms;
    828832
    829833    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    840844        else
    841845        {
    842             Msg.context.GetUInt32(&pHostCtx->uContextID);
     846            Msg.context.GetUInt32(&pCtx->uContextID);
    843847            Msg.handle.GetUInt32(puHandle);
    844848        }
     
    848852
    849853
    850 VBGLR3DECL(int) VbglR3GuestCtrlProcGetTerminate(PVBGLR3GUESTCTRLHOSTCTX pHostCtx, uint32_t *puPID)
    851 {
    852     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    853 
    854     AssertReturn(pHostCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
     854VBGLR3DECL(int) VbglR3GuestCtrlProcGetTerminate(PVBGLR3GUESTCTRLCMDCTX pCtx, uint32_t *puPID)
     855{
     856    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     857
     858    AssertReturn(pCtx->uNumParms == 2, VERR_INVALID_PARAMETER);
    855859    AssertPtrReturn(puPID, VERR_INVALID_POINTER);
    856860
     
    858862
    859863    Msg.hdr.result      = VERR_WRONG_ORDER;
    860     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    861     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    862     Msg.hdr.cParms      = pHostCtx->uNumParms;
     864    Msg.hdr.u32ClientID = pCtx->uClientID;
     865    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     866    Msg.hdr.cParms      = pCtx->uNumParms;
    863867
    864868    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    875879        else
    876880        {
    877             Msg.context.GetUInt32(&pHostCtx->uContextID);
     881            Msg.context.GetUInt32(&pCtx->uContextID);
    878882            Msg.pid.GetUInt32(puPID);
    879883        }
     
    883887
    884888
    885 VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLHOSTCTX pHostCtx, uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS)
    886 {
    887     AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    888 
    889     AssertReturn(pHostCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
     889VBGLR3DECL(int) VbglR3GuestCtrlProcGetWaitFor(PVBGLR3GUESTCTRLCMDCTX pCtx,
     890                                              uint32_t *puPID, uint32_t *puWaitFlags, uint32_t *puTimeoutMS)
     891{
     892    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     893
     894    AssertReturn(pCtx->uNumParms == 5, VERR_INVALID_PARAMETER);
    890895    AssertPtrReturn(puPID, VERR_INVALID_POINTER);
    891896
     
    893898
    894899    Msg.hdr.result      = VERR_WRONG_ORDER;
    895     Msg.hdr.u32ClientID = pHostCtx->uClientID;
    896     Msg.hdr.u32Function = GUEST_MSG_WAIT;
    897     Msg.hdr.cParms      = pHostCtx->uNumParms;
     900    Msg.hdr.u32ClientID = pCtx->uClientID;
     901    Msg.hdr.u32Function = GUEST_MSG_WAIT;
     902    Msg.hdr.cParms      = pCtx->uNumParms;
    898903
    899904    VbglHGCMParmUInt32Set(&Msg.context, 0);
     
    912917        else
    913918        {
    914             Msg.context.GetUInt32(&pHostCtx->uContextID);
     919            Msg.context.GetUInt32(&pCtx->uContextID);
    915920            Msg.pid.GetUInt32(puPID);
    916921            Msg.flags.GetUInt32(puWaitFlags);
     
    922927
    923928
    924 VBGLR3DECL(int) VbglR3GuestCtrlFileNotify(uint32_t     uClientId,    uint32_t     uContext,
    925                                           uint32_t     uType,
    926                                           void        *pvPayload,    uint32_t     cbPayload)
    927 {
    928     AssertPtrReturn(pvPayload, VERR_INVALID_POINTER);
    929     AssertReturn(cbPayload, VERR_INVALID_PARAMETER);
    930 
    931     HGCMMsgFileNotify Msg;
    932 
    933     Msg.hdr.result      = VERR_WRONG_ORDER;
    934     Msg.hdr.u32ClientID = uClientId;
    935     //Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
     929VBGLR3DECL(int) VbglR3GuestCtrlFileCbOpen(PVBGLR3GUESTCTRLCMDCTX pCtx,
     930                                          uint32_t uRc, uint32_t uFileHandle)
     931{
     932    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     933
     934    HGCMReplyFileNotify Msg;
     935
     936    Msg.hdr.result      = VERR_WRONG_ORDER;
     937    Msg.hdr.u32ClientID = pCtx->uClientID;
     938    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
     939    Msg.hdr.cParms      = 4;
     940
     941    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     942    VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_OPEN);
     943    VbglHGCMParmUInt32Set(&Msg.rc, uRc);
     944
     945    VbglHGCMParmUInt32Set(&Msg.u.open.handle, uFileHandle);
     946
     947    int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
     948    if (RT_SUCCESS(rc))
     949    {
     950        int rc2 = Msg.hdr.result;
     951        if (RT_FAILURE(rc2))
     952            rc = rc2;
     953    }
     954    return rc;
     955}
     956
     957
     958VBGLR3DECL(int) VbglR3GuestCtrlFileCbClose(PVBGLR3GUESTCTRLCMDCTX pCtx,
     959                                           uint32_t uRc)
     960{
     961    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     962
     963    HGCMReplyFileNotify Msg;
     964
     965    Msg.hdr.result      = VERR_WRONG_ORDER;
     966    Msg.hdr.u32ClientID = pCtx->uClientID;
     967    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
    936968    Msg.hdr.cParms      = 3;
    937969
    938     VbglHGCMParmUInt32Set(&Msg.context, uContext);
    939     VbglHGCMParmUInt32Set(&Msg.type, uType);
    940     VbglHGCMParmPtrSet(&Msg.payload, pvPayload, cbPayload);
     970    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     971    VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_CLOSE);
     972    VbglHGCMParmUInt32Set(&Msg.rc, uRc);
     973
     974    int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
     975    if (RT_SUCCESS(rc))
     976    {
     977        int rc2 = Msg.hdr.result;
     978        if (RT_FAILURE(rc2))
     979            rc = rc2;
     980    }
     981    return rc;
     982}
     983
     984
     985VBGLR3DECL(int) VbglR3GuestCtrlFileCbRead(PVBGLR3GUESTCTRLCMDCTX pCtx,
     986                                          uint32_t uRc,
     987                                          void *pvData, uint32_t cbData)
     988{
     989    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     990
     991    HGCMReplyFileNotify Msg;
     992
     993    Msg.hdr.result      = VERR_WRONG_ORDER;
     994    Msg.hdr.u32ClientID = pCtx->uClientID;
     995    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
     996    Msg.hdr.cParms      = 4;
     997
     998    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     999    VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_READ);
     1000    VbglHGCMParmUInt32Set(&Msg.rc, uRc);
     1001
     1002    VbglHGCMParmPtrSet(&Msg.u.read.data, pvData, cbData);
     1003
     1004    int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
     1005    if (RT_SUCCESS(rc))
     1006    {
     1007        int rc2 = Msg.hdr.result;
     1008        if (RT_FAILURE(rc2))
     1009            rc = rc2;
     1010    }
     1011    return rc;
     1012}
     1013
     1014
     1015VBGLR3DECL(int) VbglR3GuestCtrlFileCbWrite(PVBGLR3GUESTCTRLCMDCTX pCtx,
     1016                                           uint32_t uRc, uint32_t uWritten)
     1017{
     1018    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     1019
     1020    HGCMReplyFileNotify Msg;
     1021
     1022    Msg.hdr.result      = VERR_WRONG_ORDER;
     1023    Msg.hdr.u32ClientID = pCtx->uClientID;
     1024    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
     1025    Msg.hdr.cParms      = 4;
     1026
     1027    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     1028    VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_WRITE);
     1029    VbglHGCMParmUInt32Set(&Msg.rc, uRc);
     1030
     1031    VbglHGCMParmUInt32Set(&Msg.u.write.written, uWritten);
     1032
     1033    int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
     1034    if (RT_SUCCESS(rc))
     1035    {
     1036        int rc2 = Msg.hdr.result;
     1037        if (RT_FAILURE(rc2))
     1038            rc = rc2;
     1039    }
     1040    return rc;
     1041}
     1042
     1043
     1044VBGLR3DECL(int) VbglR3GuestCtrlFileCbSeek(PVBGLR3GUESTCTRLCMDCTX pCtx,
     1045                                          uint32_t uRc, uint64_t uOffActual)
     1046{
     1047    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     1048
     1049    HGCMReplyFileNotify Msg;
     1050
     1051    Msg.hdr.result      = VERR_WRONG_ORDER;
     1052    Msg.hdr.u32ClientID = pCtx->uClientID;
     1053    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
     1054    Msg.hdr.cParms      = 4;
     1055
     1056    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     1057    VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_SEEK);
     1058    VbglHGCMParmUInt32Set(&Msg.rc, uRc);
     1059
     1060    VbglHGCMParmUInt64Set(&Msg.u.seek.offset, uOffActual);
     1061
     1062    int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
     1063    if (RT_SUCCESS(rc))
     1064    {
     1065        int rc2 = Msg.hdr.result;
     1066        if (RT_FAILURE(rc2))
     1067            rc = rc2;
     1068    }
     1069    return rc;
     1070}
     1071
     1072
     1073VBGLR3DECL(int) VbglR3GuestCtrlFileCbTell(PVBGLR3GUESTCTRLCMDCTX pCtx,
     1074                                          uint32_t uRc, uint64_t uOffActual)
     1075{
     1076    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     1077
     1078    HGCMReplyFileNotify Msg;
     1079
     1080    Msg.hdr.result      = VERR_WRONG_ORDER;
     1081    Msg.hdr.u32ClientID = pCtx->uClientID;
     1082    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
     1083    Msg.hdr.cParms      = 4;
     1084
     1085    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     1086    VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_TELL);
     1087    VbglHGCMParmUInt32Set(&Msg.rc, uRc);
     1088
     1089    VbglHGCMParmUInt64Set(&Msg.u.tell.offset, uOffActual);
    9411090
    9421091    int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
     
    9571106 ** @todo Docs!
    9581107 */
    959 VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(uint32_t     u32ClientID,
    960                                             uint32_t     u32Context,
    961                                             uint32_t     u32PID,
    962                                             uint32_t     u32Status,
    963                                             uint32_t     u32Flags,
    964                                             void        *pvData,
    965                                             uint32_t     cbData)
    966 {
     1108VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatus(PVBGLR3GUESTCTRLCMDCTX pCtx,
     1109                                            uint32_t uPID, uint32_t uStatus, uint32_t uFlags,
     1110                                            void  *pvData, uint32_t cbData)
     1111{
     1112    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     1113
    9671114    HGCMMsgProcStatus Msg;
    9681115
    9691116    Msg.hdr.result = VERR_WRONG_ORDER;
    970     Msg.hdr.u32ClientID = u32ClientID;
     1117    Msg.hdr.u32ClientID = pCtx->uClientID;
    9711118    Msg.hdr.u32Function = GUEST_EXEC_STATUS;
    9721119    Msg.hdr.cParms = 5;
    9731120
    974     VbglHGCMParmUInt32Set(&Msg.context, u32Context);
    975     VbglHGCMParmUInt32Set(&Msg.pid, u32PID);
    976     VbglHGCMParmUInt32Set(&Msg.status, u32Status);
    977     VbglHGCMParmUInt32Set(&Msg.flags, u32Flags);
     1121    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     1122    VbglHGCMParmUInt32Set(&Msg.pid, uPID);
     1123    VbglHGCMParmUInt32Set(&Msg.status, uStatus);
     1124    VbglHGCMParmUInt32Set(&Msg.flags, uFlags);
    9781125    VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
    9791126
     
    9951142 ** @todo Docs!
    9961143 */
    997 VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(uint32_t     u32ClientID,
    998                                             uint32_t     u32Context,
    999                                             uint32_t     u32PID,
    1000                                             uint32_t     u32Handle,
    1001                                             uint32_t     u32Flags,
    1002                                             void        *pvData,
    1003                                             uint32_t     cbData)
    1004 {
     1144VBGLR3DECL(int) VbglR3GuestCtrlProcCbOutput(PVBGLR3GUESTCTRLCMDCTX pCtx,
     1145                                            uint32_t uPID,uint32_t uHandle, uint32_t uFlags,
     1146                                            void *pvData, uint32_t cbData)
     1147{
     1148    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     1149
    10051150    HGCMMsgProcOutput Msg;
    10061151
    10071152    Msg.hdr.result = VERR_WRONG_ORDER;
    1008     Msg.hdr.u32ClientID = u32ClientID;
     1153    Msg.hdr.u32ClientID = pCtx->uClientID;
    10091154    Msg.hdr.u32Function = GUEST_EXEC_OUTPUT;
    10101155    Msg.hdr.cParms = 5;
    10111156
    1012     VbglHGCMParmUInt32Set(&Msg.context, u32Context);
    1013     VbglHGCMParmUInt32Set(&Msg.pid, u32PID);
    1014     VbglHGCMParmUInt32Set(&Msg.handle, u32Handle);
    1015     VbglHGCMParmUInt32Set(&Msg.flags, u32Flags);
     1157    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     1158    VbglHGCMParmUInt32Set(&Msg.pid, uPID);
     1159    VbglHGCMParmUInt32Set(&Msg.handle, uHandle);
     1160    VbglHGCMParmUInt32Set(&Msg.flags, uFlags);
    10161161    VbglHGCMParmPtrSet(&Msg.data, pvData, cbData);
    10171162
     
    10331178 ** @todo Docs!
    10341179 */
    1035 VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(uint32_t     u32ClientID,
    1036                                                  uint32_t     u32Context,
    1037                                                  uint32_t     u32PID,
    1038                                                  uint32_t     u32Status,
    1039                                                  uint32_t     u32Flags,
    1040                                                  uint32_t     cbWritten)
    1041 {
     1180VBGLR3DECL(int) VbglR3GuestCtrlProcCbStatusInput(PVBGLR3GUESTCTRLCMDCTX pCtx,
     1181                                                 uint32_t uPID, uint32_t uStatus,
     1182                                                 uint32_t uFlags, uint32_t cbWritten)
     1183{
     1184    AssertPtrReturn(pCtx, VERR_INVALID_POINTER);
     1185
    10421186    HGCMMsgProcStatusInput Msg;
    10431187
    10441188    Msg.hdr.result = VERR_WRONG_ORDER;
    1045     Msg.hdr.u32ClientID = u32ClientID;
     1189    Msg.hdr.u32ClientID = pCtx->uClientID;
    10461190    Msg.hdr.u32Function = GUEST_EXEC_INPUT_STATUS;
    10471191    Msg.hdr.cParms = 5;
    10481192
    1049     VbglHGCMParmUInt32Set(&Msg.context, u32Context);
    1050     VbglHGCMParmUInt32Set(&Msg.pid, u32PID);
    1051     VbglHGCMParmUInt32Set(&Msg.status, u32Status);
    1052     VbglHGCMParmUInt32Set(&Msg.flags, u32Flags);
     1193    VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     1194    VbglHGCMParmUInt32Set(&Msg.pid, uPID);
     1195    VbglHGCMParmUInt32Set(&Msg.status, uStatus);
     1196    VbglHGCMParmUInt32Set(&Msg.flags, uFlags);
    10531197    VbglHGCMParmUInt32Set(&Msg.written, cbWritten);
    10541198
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp

    r45010 r45109  
    6868*   Internal Functions                                                         *
    6969*******************************************************************************/
    70 static int  gstcntlHandleSessionOpen(PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
    71 static int  gstcntlHandleSessionClose(PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
     70static int  gstcntlHandleSessionOpen(PVBGLR3GUESTCTRLCMDCTX pHostCtx);
     71static int  gstcntlHandleSessionClose(PVBGLR3GUESTCTRLCMDCTX pHostCtx);
    7272static void VBoxServiceControlShutdown(void);
    7373
     
    198198    AssertPtrReturn(pvScratchBuf, VERR_NO_MEMORY);
    199199
    200     VBGLR3GUESTCTRLHOSTCTX ctxHost = { g_uControlSvcClientID,
    201                                        1 /* Default protocol version */ };
     200    VBGLR3GUESTCTRLCMDCTX ctxHost = { g_uControlSvcClientID };
     201    /* Set default protocol version to 1. */
     202    ctxHost.uProtocol = 1;
     203
    202204    for (;;)
    203205    {
     
    301303
    302304
    303 static int gstcntlHandleSessionOpen(PVBGLR3GUESTCTRLHOSTCTX pHostCtx)
     305static int gstcntlHandleSessionOpen(PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    304306{
    305307    AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
     
    329331        /* Report back on failure. On success this will be done
    330332         * by the forked session thread. */
    331         int rc2 = VbglR3GuestCtrlSessionNotify(pHostCtx->uClientID, pHostCtx->uContextID,
     333        int rc2 = VbglR3GuestCtrlSessionNotify(pHostCtx,
    332334                                               GUEST_SESSION_NOTIFYTYPE_ERROR, rc /* uint32_t vs. int */);
    333335        if (RT_FAILURE(rc2))
     
    343345
    344346
    345 static int gstcntlHandleSessionClose(PVBGLR3GUESTCTRLHOSTCTX pHostCtx)
     347static int gstcntlHandleSessionClose(PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    346348{
    347349    AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
     
    368370            /* Report back on failure. On success this will be done
    369371             * by the forked session thread. */
    370             int rc2 = VbglR3GuestCtrlSessionNotify(pHostCtx->uClientID, pHostCtx->uContextID,
     372            int rc2 = VbglR3GuestCtrlSessionNotify(pHostCtx,
    371373                                                   GUEST_SESSION_NOTIFYTYPE_ERROR, rc);
    372374            if (RT_FAILURE(rc2))
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.h

    r45010 r45109  
    385385extern int                      GstCntlSessionDestroy(PVBOXSERVICECTRLSESSION pSession);
    386386extern int                      GstCntlSessionInit(PVBOXSERVICECTRLSESSION pSession, uint32_t uFlags);
    387 extern int                      GstCntlSessionHandler(PVBOXSERVICECTRLSESSION pSession, uint32_t uMsg, PVBGLR3GUESTCTRLHOSTCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf, volatile bool *pfShutdown);
     387extern int                      GstCntlSessionHandler(PVBOXSERVICECTRLSESSION pSession, uint32_t uMsg, PVBGLR3GUESTCTRLCMDCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf, volatile bool *pfShutdown);
    388388extern int                      GstCntlSessionListSet(PVBOXSERVICECTRLSESSION pSession, PVBOXSERVICECTRLPROCESS pThread, VBOXSERVICECTRLTHREADLISTTYPE enmList);
    389389extern int                      GstCntlSessionProcessStartAllowed(const PVBOXSERVICECTRLSESSION pSession, bool *pbAllowed);
     
    401401extern void                     GstCntlProcessRequestFree(PVBOXSERVICECTRLREQUEST pReq);
    402402/* Per-session functions. */
    403 extern int gstcntlHandleFileOpen(uint32_t idClient, uint32_t cParms);
    404 extern int gstcntlHandleFileClose(uint32_t idClient, uint32_t cParms);
    405 extern int gstcntlHandleFileRead(uint32_t idClient, uint32_t cParms, void *pvScratchBuf, size_t cbScratchBuf);
    406 extern int gstcntlHandleFileReadAt(uint32_t idClient, uint32_t cParms, void *pvScratchBuf, size_t cbScratchBuf);
    407 extern int gstcntlHandleFileWrite(uint32_t idClient, uint32_t cParms, void *pvScratchBuf, size_t cbScratchBuf);
    408 extern int gstcntlHandleFileWriteAt(uint32_t idClient, uint32_t cParms, void *pvScratchBuf, size_t cbScratchBuf);
    409 extern int gstcntlHandleFileSeek(uint32_t idClient, uint32_t cParms);
    410 extern int gstcntlHandleFileTell(uint32_t idClient, uint32_t cParms);
    411 extern int                      GstCntlSessionHandleProcExec(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
    412 extern int                      GstCntlSessionHandleProcInput(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf);
    413 extern int                      GstCntlSessionHandleProcOutput(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
    414 extern int                      GstCntlSessionHandleProcTerminate(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
    415 extern int                      GstCntlSessionHandleProcWaitFor(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
     403extern int                      GstCntlSessionHandleProcExec(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx);
     404extern int                      GstCntlSessionHandleProcInput(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf);
     405extern int                      GstCntlSessionHandleProcOutput(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx);
     406extern int                      GstCntlSessionHandleProcTerminate(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx);
     407extern int                      GstCntlSessionHandleProcWaitFor(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx);
    416408
    417409RT_C_DECLS_END
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp

    r45017 r45109  
    650650    VBoxServiceVerbose(2, "[PID %u]: Process \"%s\" started, CID=%u, User=%s\n",
    651651                       pThread->uPID, pThread->pszCmd, pThread->uContextID, pThread->pszUser);
    652     rc = VbglR3GuestCtrlProcCbStatus(pThread->uClientID, pThread->uContextID,
     652    VBGLR3GUESTCTRLCMDCTX ctx = { pThread->uClientID, pThread->uContextID };
     653    rc = VbglR3GuestCtrlProcCbStatus(&ctx,
    653654                                     pThread->uPID, PROC_STS_STARTED, 0 /* u32Flags */,
    654655                                     NULL /* pvData */, 0 /* cbData */);
     
    925926        if (!(pThread->uFlags & EXECUTEPROCESSFLAG_WAIT_START))
    926927        {
    927             rc2 = VbglR3GuestCtrlProcCbStatus(pThread->uClientID, pThread->uContextID,
     928            VBGLR3GUESTCTRLCMDCTX ctx = { pThread->uClientID, pThread->uContextID };
     929            rc2 = VbglR3GuestCtrlProcCbStatus(&ctx,
    928930                                              pThread->uPID, uStatus, uFlags,
    929931                                              NULL /* pvData */, 0 /* cbData */);
     
    17461748        if (RT_FAILURE(rc))
    17471749        {
    1748             rc2 = VbglR3GuestCtrlProcCbStatus(pProcess->uClientID, pProcess->uContextID, pProcess->uPID,
    1749                                               PROC_STS_ERROR, rc,
     1750            VBGLR3GUESTCTRLCMDCTX ctx = { pProcess->uClientID, pProcess->uContextID };
     1751            rc2 = VbglR3GuestCtrlProcCbStatus(&ctx,
     1752                                              pProcess->uPID, PROC_STS_ERROR, rc,
    17501753                                              NULL /* pvData */, 0 /* cbData */);
    17511754            if (RT_FAILURE(rc2))
  • trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r45076 r45109  
    5555static PVBOXSERVICECTRLFILE gstcntlSessionGetFile(const PVBOXSERVICECTRLSESSION pSession, uint32_t uHandle);
    5656static int                  gstcntlSessionGetOutput(const PVBOXSERVICECTRLSESSION pSession, uint32_t uPID, uint32_t uCID, uint32_t uHandleId, uint32_t cMsTimeout, void *pvBuf, uint32_t cbBuf, uint32_t *pcbRead);
    57 static int                  gstcntlSessionHandleFileOpen(PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
    58 static int                  gstcntlSessionHandleFileClose(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
    59 static int                  gstcntlSessionHandleFileRead(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
    60 static int                  gstcntlSessionHandleFileWrite(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf);
    61 static int                  gstcntlSessionHandleFileSeek(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
    62 static int                  gstcntlSessionHandleFileTell(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLHOSTCTX pHostCtx);
     57static int                  gstcntlSessionHandleFileOpen(PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx);
     58static int                  gstcntlSessionHandleFileClose(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx);
     59static int                  gstcntlSessionHandleFileRead(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx);
     60static int                  gstcntlSessionHandleFileWrite(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx, void *pvScratchBuf, size_t cbScratchBuf);
     61static int                  gstcntlSessionHandleFileSeek(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx);
     62static int                  gstcntlSessionHandleFileTell(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx);
    6363static int                  gstcntlSessionSetInput(const PVBOXSERVICECTRLSESSION pSession, uint32_t uPID, uint32_t uCID, bool fPendingClose, void *pvBuf, uint32_t cbBuf, uint32_t *pcbWritten);
    6464static DECLCALLBACK(int)    gstcntlSessionThread(RTTHREAD ThreadSelf, void *pvUser);
     
    142142
    143143static int gstcntlSessionHandleFileOpen(PVBOXSERVICECTRLSESSION pSession,
    144                                         PVBGLR3GUESTCTRLHOSTCTX pHostCtx)
     144                                        PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    145145{
    146146    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     
    208208
    209209        /* Report back in any case. */
    210         CALLBACKPAYLOAD_FILE_NOTIFY_OPEN cplOpen = { rc, uHandle };
    211         int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID,
    212                                             GUEST_FILE_NOTIFYTYPE_OPEN, &cplOpen, sizeof(cplOpen));
     210        int rc2 = VbglR3GuestCtrlFileCbOpen(pHostCtx, rc, uHandle);
    213211        if (RT_FAILURE(rc2))
    214212            VBoxServiceError("[File %s]: Failed to report file open status, rc=%Rrc\n",
     
    223221
    224222static int gstcntlSessionHandleFileClose(const PVBOXSERVICECTRLSESSION pSession,
    225                                          PVBGLR3GUESTCTRLHOSTCTX pHostCtx)
     223                                         PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    226224{
    227225    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     
    242240
    243241        /* Report back in any case. */
    244         CALLBACKPAYLOAD_FILE_NOTIFY_CLOSE cplClose = { rc };
    245         int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID,
    246                                             GUEST_FILE_NOTIFYTYPE_CLOSE, &cplClose, sizeof(cplClose));
     242        int rc2 = VbglR3GuestCtrlFileCbClose(pHostCtx, rc);
    247243        if (RT_FAILURE(rc2))
    248244            VBoxServiceError("Failed to report file close status, rc=%Rrc\n", rc2);
     
    255251
    256252static int gstcntlSessionHandleFileRead(const PVBOXSERVICECTRLSESSION pSession,
    257                                         PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     253                                        PVBGLR3GUESTCTRLCMDCTX pHostCtx,
    258254                                        void *pvScratchBuf, size_t cbScratchBuf)
    259255{
     
    292288
    293289        /* Report back in any case. */
    294         CALLBACKPAYLOAD_FILE_NOTIFY_READ cplRead = { rc, (uint32_t)cbRead, pvDataRead };
    295         int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID,
    296                                             GUEST_FILE_NOTIFYTYPE_READ, &cplRead, sizeof(cplRead));
     290        int rc2 = VbglR3GuestCtrlFileCbRead(pHostCtx, rc, pvDataRead, (uint32_t)cbRead);
    297291        if (   cbToRead > cbScratchBuf
    298292            && pvDataRead)
     
    309303
    310304static int gstcntlSessionHandleFileReadAt(const PVBOXSERVICECTRLSESSION pSession,
    311                                           PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     305                                          PVBGLR3GUESTCTRLCMDCTX pHostCtx,
    312306                                          void *pvScratchBuf, size_t cbScratchBuf)
    313307{
     
    347341
    348342        /* Report back in any case. */
    349         CALLBACKPAYLOAD_FILE_NOTIFY_READ cplRead = { rc, (uint32_t)cbRead, pvDataRead };
    350         int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID,
    351                                             GUEST_FILE_NOTIFYTYPE_READ, &cplRead, sizeof(cplRead));
     343        int rc2 = VbglR3GuestCtrlFileCbRead(pHostCtx, rc, pvDataRead, (uint32_t)cbRead);
    352344        if (   cbToRead > cbScratchBuf
    353345            && pvDataRead)
     
    364356
    365357static int gstcntlSessionHandleFileWrite(const PVBOXSERVICECTRLSESSION pSession,
    366                                          PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     358                                         PVBGLR3GUESTCTRLCMDCTX pHostCtx,
    367359                                         void *pvScratchBuf, size_t cbScratchBuf)
    368360{
     
    390382
    391383        /* Report back in any case. */
    392         CALLBACKPAYLOAD_FILE_NOTIFY_WRITE cplWrite = { rc, (uint32_t)cbWritten };
    393         int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID,
    394                                             GUEST_FILE_NOTIFYTYPE_WRITE, &cplWrite, sizeof(cplWrite));
     384        int rc2 = VbglR3GuestCtrlFileCbWrite(pHostCtx, rc, (uint32_t)cbWritten);
    395385        if (RT_FAILURE(rc2))
    396386            VBoxServiceError("Failed to report file write status, rc=%Rrc\n", rc2);
     
    403393
    404394static int gstcntlSessionHandleFileWriteAt(const PVBOXSERVICECTRLSESSION pSession,
    405                                            PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     395                                           PVBGLR3GUESTCTRLCMDCTX pHostCtx,
    406396                                           void *pvScratchBuf, size_t cbScratchBuf)
    407397{
     
    430420
    431421        /* Report back in any case. */
    432         CALLBACKPAYLOAD_FILE_NOTIFY_WRITE cplWrite = { rc, (uint32_t)cbWritten };
    433         int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID,
    434                                             GUEST_FILE_NOTIFYTYPE_WRITE, &cplWrite, sizeof(cplWrite));
     422        int rc2 = VbglR3GuestCtrlFileCbWrite(pHostCtx, rc, (uint32_t)cbWritten);
    435423        if (RT_FAILURE(rc2))
    436424            VBoxServiceError("Failed to report file write status, rc=%Rrc\n", rc2);
     
    443431
    444432static int gstcntlSessionHandleFileSeek(const PVBOXSERVICECTRLSESSION pSession,
    445                                         PVBGLR3GUESTCTRLHOSTCTX pHostCtx)
     433                                        PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    446434{
    447435    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     
    489477
    490478        /* Report back in any case. */
    491         CALLBACKPAYLOAD_FILE_NOTFIY_SEEK cplSeek = { rc, uOffsetActual };
    492         int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID,
    493                                             GUEST_FILE_NOTIFYTYPE_SEEK, &cplSeek, sizeof(cplSeek));
     479        int rc2 = VbglR3GuestCtrlFileCbSeek(pHostCtx, rc, uOffsetActual);
    494480        if (RT_FAILURE(rc2))
    495481            VBoxServiceError("Failed to report file seek status, rc=%Rrc\n", rc2);
     
    502488
    503489static int gstcntlSessionHandleFileTell(const PVBOXSERVICECTRLSESSION pSession,
    504                                         PVBGLR3GUESTCTRLHOSTCTX pHostCtx)
     490                                        PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    505491{
    506492    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     
    522508
    523509        /* Report back in any case. */
    524         CALLBACKPAYLOAD_FILE_NOTFIY_TELL cplTell = { rc, uOffsetActual };
    525         int rc2 = VbglR3GuestCtrlFileNotify(pHostCtx->uClientID, pHostCtx->uContextID,
    526                                             GUEST_FILE_NOTIFYTYPE_TELL, &cplTell, sizeof(cplTell));
     510        int rc2 = VbglR3GuestCtrlFileCbTell(pHostCtx, rc, uOffsetActual);
    527511        if (RT_FAILURE(rc2))
    528512            VBoxServiceError("Failed to report file tell status, rc=%Rrc\n", rc2);
     
    542526 */
    543527int GstCntlSessionHandleProcExec(PVBOXSERVICECTRLSESSION pSession,
    544                                  PVBGLR3GUESTCTRLHOSTCTX pHostCtx)
     528                                 PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    545529{
    546530    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     
    626610         *       from the host. The host in case has to deal with that!
    627611         */
    628         int rc2 = VbglR3GuestCtrlProcCbStatus(pHostCtx->uClientID, pHostCtx->uContextID,
    629                                               0 /* PID, invalid */,
     612        int rc2 = VbglR3GuestCtrlProcCbStatus(pHostCtx, 0 /* PID, invalid */,
    630613                                              PROC_STS_ERROR, rc,
    631614                                              NULL /* pvData */, 0 /* cbData */);
     
    651634 */
    652635int GstCntlSessionHandleProcInput(PVBOXSERVICECTRLSESSION pSession,
    653                                   PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     636                                  PVBGLR3GUESTCTRLCMDCTX pHostCtx,
    654637                                  void *pvScratchBuf, size_t cbScratchBuf)
    655638{
     
    732715     *       regardless whether we got data or not! Otherwise the progress object
    733716     *       on the host never will get completed! */
    734     rc = VbglR3GuestCtrlProcCbStatusInput(pHostCtx->uClientID, pHostCtx->uContextID, uPID,
     717    rc = VbglR3GuestCtrlProcCbStatusInput(pHostCtx, uPID,
    735718                                          uStatus, uFlags, (uint32_t)cbWritten);
    736719
     
    748731 */
    749732int GstCntlSessionHandleProcOutput(PVBOXSERVICECTRLSESSION pSession,
    750                                    PVBGLR3GUESTCTRLHOSTCTX pHostCtx)
     733                                   PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    751734{
    752735    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     
    800783             *       regardless whether we got data or not! Otherwise the progress object
    801784             *       on the host never will get completed! */
    802             int rc2 = VbglR3GuestCtrlProcCbOutput(pHostCtx->uClientID, pHostCtx->uContextID, uPID, uHandleID, uFlags,
     785            int rc2 = VbglR3GuestCtrlProcCbOutput(pHostCtx, uPID, uHandleID, uFlags,
    803786                                                  pBuf, cbRead);
    804787            if (RT_SUCCESS(rc))
     
    821804
    822805int GstCntlSessionHandleProcTerminate(const PVBOXSERVICECTRLSESSION pSession,
    823                                       PVBGLR3GUESTCTRLHOSTCTX pHostCtx)
     806                                      PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    824807{
    825808    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     
    853836
    854837int GstCntlSessionHandleProcWaitFor(const PVBOXSERVICECTRLSESSION pSession,
    855                                     PVBGLR3GUESTCTRLHOSTCTX pHostCtx)
     838                                    PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    856839{
    857840    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     
    888871
    889872int GstCntlSessionHandler(PVBOXSERVICECTRLSESSION pSession,
    890                           uint32_t uMsg, PVBGLR3GUESTCTRLHOSTCTX pHostCtx,
     873                          uint32_t uMsg, PVBGLR3GUESTCTRLCMDCTX pHostCtx,
    891874                          void *pvScratchBuf, size_t cbScratchBuf,
    892875                          volatile bool *pfShutdown)
     
    11361119    /* Report final status. */
    11371120    Assert(uSessionStatus != GUEST_SESSION_NOTIFYTYPE_UNDEFINED);
    1138     rc2 = VbglR3GuestCtrlSessionNotify(uClientID,
    1139                                        VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSessionID),
     1121    VBGLR3GUESTCTRLCMDCTX ctx = { uClientID, VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(uSessionID) };
     1122    rc2 = VbglR3GuestCtrlSessionNotify(&ctx,
    11401123                                       uSessionStatus, uSessionRc);
    11411124    if (RT_FAILURE(rc2))
     
    11871170
    11881171    /* Report started status. */
    1189     int rc2 = VbglR3GuestCtrlSessionNotify(uClientID,
    1190                                            VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(pSession->StartupInfo.uSessionID),
     1172    VBGLR3GUESTCTRLCMDCTX ctx = { uClientID, VBOX_GUESTCTRL_CONTEXTID_MAKE_SESSION(pSession->StartupInfo.uSessionID) };
     1173    int rc2 = VbglR3GuestCtrlSessionNotify(&ctx,
    11911174                                           GUEST_SESSION_NOTIFYTYPE_STARTED, VINF_SUCCESS);
    11921175    if (RT_FAILURE(rc2))
     
    12111194        bool fShutdown = false;
    12121195
    1213         VBGLR3GUESTCTRLHOSTCTX ctxHost = { uClientID,
    1214                                            pSession->StartupInfo.uProtocol };
     1196        VBGLR3GUESTCTRLCMDCTX ctxHost = { uClientID, 0 /* Context ID, zeroed */,
     1197                                          pSession->StartupInfo.uProtocol };
    12151198        for (;;)
    12161199        {
  • trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h

    r45010 r45109  
    107107    /** Guest process input notification. */
    108108    CALLBACKTYPE_PROC_INPUT = 106,
    109     /** @todo Docs! */
    110     CALLBACKTYPE_FILE_OPEN = 210,
    111     CALLBACKTYPE_FILE_CLOSE = 215,
    112     CALLBACKTYPE_FILE_READ = 230,
    113     CALLBACKTYPE_FILE_WRITE = 240,
    114     CALLBACKTYPE_FILE_SEEK = 250,
    115     CALLBACKTYPE_FILE_TELL = 260
     109    /** Guest file notification. */
     110    CALLBACKTYPE_FILE_NOTIFY = 210
    116111};
    117112
     
    593588    int bindToSession(Console *pConsole, GuestSession *pSession, uint32_t uObjectID);
    594589    int callbackAdd(GuestCtrlCallback *pCallback, uint32_t *puContextID);
     590    void callbackDelete(GuestCtrlCallback *pCallback);
    595591    bool callbackExists(uint32_t uContextID);
    596592    int callbackRemove(uint32_t uContextID);
  • trunk/src/VBox/Main/include/GuestFileImpl.h

    r44863 r45109  
    7878     * @{ */
    7979    int             callbackDispatcher(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
     80    int             closeFile(int *pGuestRc);
    8081    static uint32_t getDispositionFromString(const Utf8Str &strDisposition);
    8182    static uint32_t getOpenModeFromString(const Utf8Str &strOpenMode);
    82     int             onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
    83     int             onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData);
     83    static Utf8Str  guestErrorToString(int guestRc);
     84    int             onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData, GuestCtrlCallback *pCallback);
     85    int             onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData, GuestCtrlCallback *pCallback);
    8486    int             openFile(int *pGuestRc);
     87    int             readData(uint32_t uSize, uint32_t uTimeoutMS, void *pvData, size_t cbData, size_t *pcbRead, int *pGuestRc);
     88    int             readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS, void *pvData, size_t cbData, size_t *pcbRead, int *pGuestRc);
     89    int             seekAt(uint64_t uOffset, GUEST_FILE_SEEKTYPE eSeekType, uint32_t uTimeoutMS, int *pGuestRc);
     90    int             sendFileCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms, uint32_t uTimeoutMS, int *pGuestRc, GuestCtrlCallback **ppCallback);
     91    static HRESULT  setErrorExternal(VirtualBoxBase *pInterface, int guestRc);
     92    int             writeData(uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbWritten, int *pGuestRc);
     93    int             writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS, void *pvData, size_t cbData, uint32_t *pcbWritten, int *pGuestRc);
    8594    /** @}  */
    8695
     
    99108        /** The file's initial size on open. */
    100109        uint64_t                mInitialSize;
     110        /** The file's internal ID. */
     111        uint32_t                mID;
    101112        /** The file's current offset. */
    102113        uint64_t                mOffCurrent;
  • trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp

    r45076 r45109  
    189189        }
    190190
     191        case CALLBACKTYPE_FILE_NOTIFY:
     192        {
     193            pvData = (PCALLBACKDATA_FILE_NOTIFY)RTMemAllocZ(sizeof(CALLBACKDATA_FILE_NOTIFY));
     194            AssertPtrReturn(pvData, VERR_NO_MEMORY);
     195            cbData = sizeof(CALLBACKDATA_FILE_NOTIFY);
     196            break;
     197        }
     198
    191199        default:
    192200            AssertMsgFailed(("Unknown callback type specified (%ld)\n", enmType));
     
    220228        }
    221229
    222         case CALLBACKTYPE_FILE_READ:
    223         {
    224             PCALLBACKPAYLOAD_FILE_NOTIFY_READ pThis = (PCALLBACKPAYLOAD_FILE_NOTIFY_READ)pvData;
     230        case CALLBACKTYPE_FILE_NOTIFY:
     231        {
     232            PCALLBACKDATA_FILE_NOTIFY pThis = (PCALLBACKDATA_FILE_NOTIFY)pvData;
    225233            AssertPtr(pThis);
    226             if (pThis->pvData)
    227                 RTMemFree(pThis->pvData);
    228             break;
     234            switch (pThis->uType)
     235            {
     236                case GUEST_FILE_NOTIFYTYPE_READ:
     237                {
     238                    if (pThis->u.read.pvData)
     239                    {
     240                        RTMemFree(pThis->u.read.pvData);
     241                        pThis->u.read.pvData = NULL;
     242                    }
     243
     244                    break;
     245                }
     246
     247                default:
     248                    break;
     249            }
    229250        }
    230251
     
    264285            Assert(cbCallback == sizeof(CALLBACKDATA_SESSION_NOTIFY));
    265286
    266             pThis->uType   = pCB->uType;
    267             pThis->uResult = pCB->uResult;
     287            memcpy(pThis, pCB, sizeof(CALLBACKDATA_SESSION_NOTIFY));
    268288            break;
    269289        }
     
    275295            Assert(cbCallback == sizeof(CALLBACKDATA_PROC_STATUS));
    276296
    277             pThis->uFlags  = pCB->uFlags;
    278             pThis->uPID    = pCB->uPID;
    279             pThis->uStatus = pCB->uStatus;
     297            memcpy(pThis, pCB, sizeof(CALLBACKDATA_PROC_STATUS));
    280298            break;
    281299        }
     
    305323            Assert(cbCallback == sizeof(CALLBACKDATA_PROC_INPUT));
    306324
    307             pThis->uProcessed = pCB->uProcessed;
    308             pThis->uFlags     = pCB->uFlags;
    309             pThis->uPID       = pCB->uPID;
    310             pThis->uStatus    = pCB->uStatus;
    311             break;
    312         }
    313 
     325            memcpy(pThis, pCB, sizeof(CALLBACKDATA_PROC_INPUT));
     326            break;
     327        }
     328
     329        case CALLBACKTYPE_FILE_NOTIFY:
     330        {
     331            PCALLBACKDATA_FILE_NOTIFY pThis = (PCALLBACKDATA_FILE_NOTIFY)pvData;
     332            PCALLBACKDATA_FILE_NOTIFY pCB = (PCALLBACKDATA_FILE_NOTIFY)pvCallback;
     333            Assert(cbCallback == sizeof(CALLBACKDATA_FILE_NOTIFY));
     334
     335            memcpy(pThis, pCB, sizeof(CALLBACKDATA_FILE_NOTIFY));
     336
     337            switch (pThis->uType)
     338            {
     339                case GUEST_FILE_NOTIFYTYPE_READ:
     340                {
     341                    pThis->u.read.pvData   = RTMemAlloc(pCB->u.read.cbData);
     342                    AssertPtrReturn(pThis->u.read.pvData, VERR_NO_MEMORY);
     343                    memcpy(pThis->u.read.pvData, pCB->u.read.pvData, pCB->u.read.cbData);
     344                    pThis->u.read.cbData   = pCB->u.read.cbData;
     345                    break;
     346                }
     347
     348                default:
     349                    break;
     350            }
     351            break;
     352        }
     353
     354#if 0
    314355        case CALLBACKTYPE_FILE_OPEN:
    315356        {
     
    382423            break;
    383424        }
    384 
     425#endif
    385426        default:
    386427            AssertMsgFailed(("Callback type not supported (%ld)\n", mType));
     
    12871328}
    12881329
     1330void GuestObject::callbackDelete(GuestCtrlCallback *pCallback)
     1331{
     1332    if (pCallback)
     1333    {
     1334        delete pCallback;
     1335        pCallback = NULL;
     1336    }
     1337}
     1338
    12891339bool GuestObject::callbackExists(uint32_t uContextID)
    12901340{
     
    13061356    if (it != mObject.mCallbacks.end())
    13071357    {
    1308         delete it->second;
    13091358        mObject.mCallbacks.erase(it);
    13101359
  • trunk/src/VBox/Main/src-client/GuestFileImpl.cpp

    r44863 r45109  
    6161/////////////////////////////////////////////////////////////////////////////
    6262
     63/**
     64 * Initializes a file object but does *not* open the file on the guest
     65 * yet. This is done in the dedidcated openFile call.
     66 *
     67 * @return  IPRT status code.
     68 * @param   pConsole                Pointer to console object.
     69 * @param   pSession                Pointer to session object.
     70 * @param   uFileID                 Host-based file ID (part of the context ID).
     71 * @param   openInfo                File opening information.
     72 */
    6373int GuestFile::init(Console *pConsole, GuestSession *pSession, ULONG uFileID, const GuestFileOpenInfo &openInfo)
    6474{
     
    7686    if (RT_SUCCESS(vrc))
    7787    {
     88        mData.mID = 0;
    7889        mData.mInitialSize = 0;
    7990
     
    257268    {
    258269        case GUEST_DISCONNECTED:
    259             vrc = onGuestDisconnected(pCbCtx, pCallback, pSvcCb); /* Affects all callbacks. */
     270            vrc = onGuestDisconnected(pCbCtx, pSvcCb, pCallback); /* Affects all callbacks. */
    260271            break;
    261272
    262273        case GUEST_FILE_NOTIFY:
    263             vrc = onFileNotify(pCbCtx, pCallback, pSvcCb);
     274            vrc = onFileNotify(pCbCtx, pSvcCb, pCallback);
    264275            break;
    265276
     
    273284    LogFlowFuncLeaveRC(vrc);
    274285#endif
     286    return vrc;
     287}
     288
     289int GuestFile::closeFile(int *pGuestRc)
     290{
     291    LogFlowThisFunc(("strFile=%s\n", mData.mOpenInfo.mFileName.c_str()));
     292
     293    /* Prepare HGCM call. */
     294    VBOXHGCMSVCPARM paParms[4];
     295    int i = 1; /* Context ID will be set in sendFileComannd(). */
     296    paParms[i++].setUInt32(mData.mID /* Guest file ID */);
     297
     298    int guestRc;
     299    int vrc = sendFileCommand(HOST_FILE_CLOSE, i, paParms, 30 * 1000 /* 30s timeout */,
     300                              &guestRc, NULL /* ppCallback */);
     301    if (pGuestRc)
     302        *pGuestRc = guestRc;
     303
     304    LogFlowFuncLeaveRC(vrc);
    275305    return vrc;
    276306}
     
    309339}
    310340
    311 int GuestFile::onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData)
    312 {
    313     AssertPtrReturn(pCallback, VERR_INVALID_POINTER);
     341/* static */
     342Utf8Str GuestFile::guestErrorToString(int guestRc)
     343{
     344    Utf8Str strError;
     345
     346    /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */
     347    switch (guestRc)
     348    {
     349        case VERR_INVALID_VM_HANDLE:
     350            strError += Utf8StrFmt(tr("VMM device is not available (is the VM running?)"));
     351            break;
     352
     353        case VERR_HGCM_SERVICE_NOT_FOUND:
     354            strError += Utf8StrFmt(tr("The guest execution service is not available"));
     355            break;
     356
     357        case VERR_TIMEOUT:
     358            strError += Utf8StrFmt(tr("The guest did not respond within time"));
     359            break;
     360
     361        case VERR_CANCELLED:
     362            strError += Utf8StrFmt(tr("The session operation was canceled"));
     363            break;
     364
     365        case VERR_MAX_PROCS_REACHED:
     366            strError += Utf8StrFmt(tr("Maximum number of concurrent guest files has been reached"));
     367            break;
     368
     369        case VERR_NOT_EQUAL: /** @todo Imprecise to the user; can mean anything and all. */
     370            strError += Utf8StrFmt(tr("Unable to retrieve requested information"));
     371            break;
     372
     373        case VERR_NOT_FOUND:
     374            strError += Utf8StrFmt(tr("The guest execution service is not ready (yet)"));
     375            break;
     376
     377        default:
     378            strError += Utf8StrFmt("%Rrc", guestRc);
     379            break;
     380    }
     381
     382    return strError;
     383}
     384
     385int GuestFile::onFileNotify(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData,
     386                            GuestCtrlCallback *pCallback)
     387{
     388    AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER);
    314389    AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER);
     390    /* pCallback is optional. */
    315391
    316392    if (pSvcCbData->mParms < 3)
    317393        return VERR_INVALID_PARAMETER;
    318394
    319     uint32_t uType;
    320     void *pvData; uint32_t cbData;
     395    int vrc = VINF_SUCCESS;
     396
     397    int idx = 0; /* Current parameter index. */
     398    CALLBACKDATA_FILE_NOTIFY dataCb;
    321399    /* pSvcCb->mpaParms[0] always contains the context ID. */
    322     pSvcCbData->mpaParms[1].getUInt32(&uType);
    323     pSvcCbData->mpaParms[2].getPointer(&pvData, &cbData);
    324 
    325     LogFlowThisFunc(("strName=%s, uType=%RU32, pvData=%p, cbData=%RU32, pCallback=%p\n",
    326                      mData.mOpenInfo.mFileName.c_str(), uType, pvData, cbData, pCallback));
     400    pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.uType);
     401    pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.rc);
     402
     403    switch (dataCb.uType)
     404    {
     405        case GUEST_FILE_NOTIFYTYPE_ERROR:
     406            /* No extra data. */
     407            break;
     408
     409        case GUEST_FILE_NOTIFYTYPE_OPEN:
     410            if (pSvcCbData->mParms == 4)
     411            {
     412                pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.u.open.uHandle);
     413
     414                AssertMsg(mData.mID == 0, ("File ID already set to %RU32\n", mData.mID));
     415                mData.mID = dataCb.u.open.uHandle;
     416                AssertMsg(mData.mID == VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(pCbCtx->uContextID),
     417                          ("File ID %RU32 does not match context ID %RU32\n", mData.mID,
     418                           VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(pCbCtx->uContextID)));
     419            }
     420            else
     421                vrc = VERR_NOT_SUPPORTED;
     422            break;
     423
     424        case GUEST_FILE_NOTIFYTYPE_CLOSE:
     425            /* No extra data. */
     426            break;
     427
     428        case GUEST_FILE_NOTIFYTYPE_READ:
     429            if (pSvcCbData->mParms == 4)
     430            {
     431                pSvcCbData->mpaParms[idx++].getPointer(&dataCb.u.read.pvData,
     432                                                       &dataCb.u.read.cbData);
     433
     434                mData.mOffCurrent += dataCb.u.read.cbData;
     435            }
     436            else
     437                vrc = VERR_NOT_SUPPORTED;
     438            break;
     439
     440        case GUEST_FILE_NOTIFYTYPE_WRITE:
     441            if (pSvcCbData->mParms == 4)
     442            {
     443                pSvcCbData->mpaParms[idx++].getUInt32(&dataCb.u.write.cbWritten);
     444
     445                mData.mOffCurrent += dataCb.u.write.cbWritten;
     446            }
     447            else
     448                vrc = VERR_NOT_SUPPORTED;
     449            break;
     450
     451        case GUEST_FILE_NOTIFYTYPE_SEEK:
     452            if (pSvcCbData->mParms == 4)
     453            {
     454                pSvcCbData->mpaParms[idx++].getUInt64(&dataCb.u.seek.uOffActual);
     455
     456                mData.mOffCurrent = dataCb.u.seek.uOffActual;
     457            }
     458            else
     459                vrc = VERR_NOT_SUPPORTED;
     460            break;
     461
     462        case GUEST_FILE_NOTIFYTYPE_TELL:
     463            if (pSvcCbData->mParms == 4)
     464            {
     465                pSvcCbData->mpaParms[idx++].getUInt64(&dataCb.u.tell.uOffActual);
     466
     467                mData.mOffCurrent = dataCb.u.tell.uOffActual;
     468            }
     469            else
     470                vrc = VERR_NOT_SUPPORTED;
     471            break;
     472
     473        default:
     474            vrc = VERR_NOT_SUPPORTED;
     475            break;
     476    }
     477
     478    LogFlowThisFunc(("strName=%s, uType=%RU32, rc=%Rrc, pCallback=%p\n",
     479                     mData.mOpenInfo.mFileName.c_str(), dataCb.uType, dataCb.rc, pCallback));
     480
     481    int guestRc = (int)dataCb.rc; /* uint32_t vs. int. */
     482    if (RT_SUCCESS(vrc))
     483    {
     484        /* Nothing to do here yet. */
     485    }
     486    else if (vrc == VERR_NOT_SUPPORTED)
     487    {
     488        /* Also let the callback know. */
     489        guestRc = VERR_NOT_SUPPORTED;
     490    }
    327491
    328492    /* Signal callback in every case (if available). */
    329     int vrc = VINF_SUCCESS;
    330493    if (pCallback)
    331494    {
    332         vrc = pCallback->SetData(pvData, cbData);
    333 
    334         int rc2 = pCallback->Signal();
     495        int rc2 = pCallback->SetData(&dataCb, sizeof(dataCb));
    335496        if (RT_SUCCESS(vrc))
    336497            vrc = rc2;
     498        rc2 = pCallback->Signal(guestRc);
     499        if (RT_SUCCESS(vrc))
     500            vrc = rc2;
    337501    }
    338502
     
    341505}
    342506
    343 int GuestFile::onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, GuestCtrlCallback *pCallback, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData)
    344 {
    345     AssertPtrReturn(pCallback, VERR_INVALID_POINTER);
    346 
    347     LogFlowThisFunc(("strFile=%s, pCallback=%p\n", mData.mOpenInfo.mFileName.c_str(), pCallback));
     507int GuestFile::onGuestDisconnected(PVBOXGUESTCTRLHOSTCBCTX pCbCtx, PVBOXGUESTCTRLHOSTCALLBACK pSvcCbData,
     508                                   GuestCtrlCallback *pCallback)
     509{
     510    AssertPtrReturn(pCbCtx, VERR_INVALID_POINTER);
     511    AssertPtrReturn(pSvcCbData, VERR_INVALID_POINTER);
     512    /* pCallback is optional. */
     513
     514    LogFlowThisFunc(("strFile=%s, pCallback=%p\n",
     515                     mData.mOpenInfo.mFileName.c_str(), pCallback));
    348516
    349517    /* First, signal callback in every case. */
     
    364532                     mData.mOpenInfo.mDisposition.c_str(), mData.mOpenInfo.mCreationMode));
    365533
    366     /* Wait until the caller function (if kicked off by a thread)
    367      * has returned and continue operation. */
     534    /* Prepare HGCM call. */
     535    VBOXHGCMSVCPARM paParms[8];
     536    int i = 1; /* Context ID will be set in sendFileComannd(). */
     537    paParms[i++].setPointer((void*)mData.mOpenInfo.mFileName.c_str(),
     538                            (ULONG)mData.mOpenInfo.mFileName.length() + 1);
     539    paParms[i++].setPointer((void*)mData.mOpenInfo.mOpenMode.c_str(),
     540                            (ULONG)mData.mOpenInfo.mOpenMode.length() + 1);
     541    paParms[i++].setPointer((void*)mData.mOpenInfo.mDisposition.c_str(),
     542                            (ULONG)mData.mOpenInfo.mDisposition.length() + 1);
     543    paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode);
     544    paParms[i++].setUInt64(mData.mOpenInfo.mInitialOffset);
     545
     546    int vrc = sendFileCommand(HOST_FILE_OPEN, i, paParms, 30 * 1000 /* 30s timeout */,
     547                              pGuestRc, NULL /* ppCallback */);
     548
     549    LogFlowFuncLeaveRC(vrc);
     550    return vrc;
     551}
     552
     553int GuestFile::readData(uint32_t uSize, uint32_t uTimeoutMS, void *pvData, size_t cbData,
     554                        size_t *pcbRead, int *pGuestRc)
     555{
     556    LogFlowThisFunc(("uSize=%RU32, uTimeoutMS=%RU32, pvData=%p, cbData=%zu\n",
     557                     uSize, uTimeoutMS, pvData, cbData));
     558
     559    /* Prepare HGCM call. */
     560    VBOXHGCMSVCPARM paParms[4];
     561    int i = 1; /* Context ID will be set in sendFileComannd(). */
     562    paParms[i++].setUInt32(mData.mID /* File handle */);
     563    paParms[i++].setUInt32(uSize /* Size (in bytes) to read */);
     564
     565    GuestCtrlCallback *pCallback = NULL; int guestRc;
     566    int vrc = sendFileCommand(HOST_FILE_READ, i, paParms, uTimeoutMS,
     567                              &guestRc, &pCallback);
     568
     569    if (RT_SUCCESS(vrc))
     570    {
     571        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     572
     573        Assert(pCallback->GetDataSize() == sizeof(CALLBACKDATA_FILE_NOTIFY));
     574        PCALLBACKDATA_FILE_NOTIFY pData = (PCALLBACKDATA_FILE_NOTIFY)pCallback->GetDataRaw();
     575        AssertPtr(pData);
     576        Assert(pData->uType == GUEST_FILE_NOTIFYTYPE_READ);
     577
     578        size_t cbRead = pData->u.read.cbData;
     579        if (cbRead)
     580        {
     581            Assert(cbData >= cbRead);
     582            memcpy(pvData, pData->u.read.pvData, cbRead);
     583        }
     584
     585        LogFlowThisFunc(("cbRead=%RU32\n", cbRead));
     586
     587        if (pcbRead)
     588            *pcbRead = cbRead;
     589    }
     590
     591    callbackDelete(pCallback);
     592
     593    if (pGuestRc)
     594        *pGuestRc = guestRc;
     595
     596    LogFlowFuncLeaveRC(vrc);
     597    return vrc;
     598}
     599
     600int GuestFile::readDataAt(uint64_t uOffset, uint32_t uSize, uint32_t uTimeoutMS,
     601                          void *pvData, size_t cbData,
     602                          size_t *pcbRead, int *pGuestRc)
     603{
     604    LogFlowThisFunc(("uOffset=%RU64, uSize=%RU32, uTimeoutMS=%RU32, pvData=%p, cbData=%zu\n",
     605                     uOffset, uSize, uTimeoutMS, pvData, cbData));
     606
     607    /* Prepare HGCM call. */
     608    VBOXHGCMSVCPARM paParms[4];
     609    int i = 1; /* Context ID will be set in sendFileComannd(). */
     610    paParms[i++].setUInt32(mData.mID /* File handle */);
     611    paParms[i++].setUInt64(uOffset /* Offset (in bytes) to start reading */);
     612    paParms[i++].setUInt32(uSize /* Size (in bytes) to read */);
     613
     614    GuestCtrlCallback *pCallback = NULL; int guestRc;
     615    int vrc = sendFileCommand(HOST_FILE_READ_AT, i, paParms, uTimeoutMS,
     616                              &guestRc, &pCallback);
     617
     618    if (RT_SUCCESS(vrc))
     619    {
     620        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     621
     622        Assert(pCallback->GetDataSize() == sizeof(CALLBACKDATA_FILE_NOTIFY));
     623        PCALLBACKDATA_FILE_NOTIFY pData = (PCALLBACKDATA_FILE_NOTIFY)pCallback->GetDataRaw();
     624        AssertPtr(pData);
     625        Assert(pData->uType == GUEST_FILE_NOTIFYTYPE_READ);
     626
     627        size_t cbRead = pData->u.read.cbData;
     628        if (cbRead)
     629        {
     630            Assert(cbData >= cbRead);
     631            memcpy(pvData, pData->u.read.pvData, cbRead);
     632        }
     633
     634        LogFlowThisFunc(("cbRead=%RU32\n", cbRead));
     635
     636        if (pcbRead)
     637            *pcbRead = cbRead;
     638    }
     639
     640    callbackDelete(pCallback);
     641
     642    if (pGuestRc)
     643        *pGuestRc = guestRc;
     644
     645    LogFlowFuncLeaveRC(vrc);
     646    return vrc;
     647}
     648
     649int GuestFile::seekAt(uint64_t uOffset, GUEST_FILE_SEEKTYPE eSeekType,
     650                      uint32_t uTimeoutMS, int *pGuestRc)
     651{
     652    LogFlowThisFunc(("uOffset=%RU64, uTimeoutMS=%RU32\n",
     653                     uOffset, uTimeoutMS));
     654
     655    /* Prepare HGCM call. */
     656    VBOXHGCMSVCPARM paParms[4];
     657    int i = 1; /* Context ID will be set in sendFileComannd(). */
     658    paParms[i++].setUInt32(mData.mID /* File handle */);
     659    paParms[i++].setUInt32(eSeekType /* Seek method */);
     660    paParms[i++].setUInt64(uOffset /* Offset (in bytes) to start reading */);
     661
     662    int guestRc;
     663    int vrc = sendFileCommand(HOST_FILE_SEEK, i, paParms, uTimeoutMS,
     664                              &guestRc, NULL /* ppCallback */);
     665    if (pGuestRc)
     666        *pGuestRc = guestRc;
     667
     668    LogFlowFuncLeaveRC(vrc);
     669    return vrc;
     670}
     671
     672/**
     673 * Handles the common parts of sending a file command to the guest.
     674 * If ppCallback is returned it must be removed via callbackRemove()
     675 * by the caller in any case.
     676 *
     677 * @return  IPRT status code.
     678 * @param   uFunction               HGCM function of command to send.
     679 * @param   uParms                  Number of HGCM parameters to send.
     680 *                                  At least one parameter must be present.
     681 * @param   paParms                 Array of HGCM parameters to send.
     682 *                                  Index [0] must not be used and will be
     683 *                                  filled out by the function.
     684 * @param   uTimeoutMS              Timeout (in ms).
     685 * @param   pGuestRc                Guest result. Optional.
     686 * @param   ppCallback              Pointer which will receive the callback for
     687 *                                  further processing by the caller. Must
     688 *                                  be deleted with callbackDelete() when done. Optional.
     689 */
     690int GuestFile::sendFileCommand(uint32_t uFunction, uint32_t uParms, PVBOXHGCMSVCPARM paParms,
     691                               uint32_t uTimeoutMS, int *pGuestRc, GuestCtrlCallback **ppCallback)
     692{
     693    AssertReturn(uParms, VERR_INVALID_PARAMETER);
     694    AssertPtrReturn(paParms, VERR_INVALID_POINTER);
     695    /** pGuestRc is optional. */
     696    /** ppCallback is optional. */
     697
     698    LogFlowThisFunc(("strFile=%s, uFunction=%RU32, uParms=%RU32\n",
     699                     mData.mOpenInfo.mFileName.c_str(), uFunction, uParms));
     700
    368701    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    369702
     
    376709    uint32_t uContextID = 0;
    377710
    378     GuestCtrlCallback *pCallbackOpen;
     711    GuestCtrlCallback *pCallback;
    379712    try
    380713    {
    381         pCallbackOpen = new GuestCtrlCallback();
     714        pCallback = new GuestCtrlCallback();
    382715    }
    383716    catch(std::bad_alloc &)
     
    389722    {
    390723        /* Create callback and add it to the map. */
    391         vrc = pCallbackOpen->Init(CALLBACKTYPE_FILE_OPEN);
     724        vrc = pCallback->Init(CALLBACKTYPE_FILE_NOTIFY);
    392725        if (RT_SUCCESS(vrc))
    393             vrc = callbackAdd(pCallbackOpen, &uContextID);
     726            vrc = callbackAdd(pCallback, &uContextID);
    394727    }
    395728
    396729    if (RT_SUCCESS(vrc))
    397730    {
     731        /* Assign context ID. */
     732        paParms[0].setUInt32(uContextID);
     733
    398734        GuestSession *pSession = mData.mSession;
    399735        AssertPtr(pSession);
    400736
    401         const GuestCredentials &sessionCreds = pSession->getCredentials();
    402 
    403         if (RT_SUCCESS(vrc))
    404         {
    405             /* Prepare HGCM call. */
    406             VBOXHGCMSVCPARM paParms[8];
    407             int i = 0;
    408             paParms[i++].setUInt32(uContextID);
    409             paParms[i++].setPointer((void*)mData.mOpenInfo.mFileName.c_str(),
    410                                     (ULONG)mData.mOpenInfo.mFileName.length() + 1);
    411             paParms[i++].setPointer((void*)mData.mOpenInfo.mOpenMode.c_str(),
    412                                     (ULONG)mData.mOpenInfo.mOpenMode.length() + 1);
    413             paParms[i++].setPointer((void*)mData.mOpenInfo.mDisposition.c_str(),
    414                                     (ULONG)mData.mOpenInfo.mDisposition.length() + 1);
    415             paParms[i++].setUInt32(mData.mOpenInfo.mCreationMode);
    416             paParms[i++].setUInt64(mData.mOpenInfo.mInitialOffset);
    417 
    418             /* Note: Don't hold the write lock in here. */
    419             vrc = sendCommand(HOST_FILE_OPEN, i, paParms);
    420         }
    421 
    422         /* Drop the write lock again before waiting. */
    423         alock.release();
     737        alock.release(); /* Drop the write lock again. */
     738
     739        /* Note: Don't hold the write lock in here. */
     740        vrc = sendCommand(uFunction, uParms, paParms);
    424741
    425742        if (RT_SUCCESS(vrc))
     
    429746             * Note: Be sure not keeping a AutoRead/WriteLock here.
    430747             */
    431             LogFlowThisFunc(("Waiting for callback (30s) ...\n"));
    432             vrc = pCallbackOpen->Wait(30 *  1000 /* Wait 30s max. */);
     748            LogFlowThisFunc(("Waiting for callback (%RU32ms) ...\n",
     749                             uTimeoutMS));
     750            vrc = pCallback->Wait(uTimeoutMS);
    433751            if (RT_SUCCESS(vrc)) /* Wait was successful, check for supplied information. */
    434752            {
    435                 int guestRc = pCallbackOpen->GetResultCode();
     753                int guestRc = pCallback->GetResultCode();
    436754                if (RT_SUCCESS(guestRc))
    437755                {
    438 
     756                    /* Nothing to do here yet. */
    439757                }
     758                else
     759                    vrc = VERR_GSTCTL_GUEST_ERROR;
    440760
    441761                if (pGuestRc)
     
    443763                LogFlowThisFunc(("Callback returned rc=%Rrc\n", guestRc));
    444764            }
    445             else
    446                 vrc = VERR_TIMEOUT;
    447765        }
    448766
    449         AutoWriteLock awlock(this COMMA_LOCKVAL_SRC_POS);
    450 
    451         AssertPtr(pCallbackOpen);
     767        alock.acquire(); /* Get write lock again. */
     768
     769        AssertPtr(pCallback);
    452770        int rc2 = callbackRemove(uContextID);
    453771        if (RT_SUCCESS(vrc))
    454772            vrc = rc2;
    455     }
     773
     774        if (ppCallback)
     775        {
     776            /* Return callback to the caller which then will be
     777             * responsible for removing it. Don't forget to lock write
     778             * access before using this callback then! */
     779            *ppCallback = pCallback;
     780        }
     781        else
     782        {
     783            delete pCallback;
     784        }
     785    }
     786
     787    LogFlowFuncLeaveRC(vrc);
     788    return vrc;
     789}
     790
     791/* static */
     792HRESULT GuestFile::setErrorExternal(VirtualBoxBase *pInterface, int guestRc)
     793{
     794    AssertPtr(pInterface);
     795    AssertMsg(RT_FAILURE(guestRc), ("Guest rc does not indicate a failure when setting error\n"));
     796
     797    return pInterface->setError(VBOX_E_IPRT_ERROR, GuestFile::guestErrorToString(guestRc).c_str());
     798}
     799
     800int GuestFile::writeData(uint32_t uTimeoutMS, void *pvData, size_t cbData,
     801                         uint32_t *pcbWritten, int *pGuestRc)
     802{
     803    AssertPtrReturn(pvData, VERR_INVALID_POINTER);
     804    AssertReturn(cbData, VERR_INVALID_PARAMETER);
     805
     806    LogFlowThisFunc(("uTimeoutMS=%RU32, pvData=%p, cbData=%zu\n",
     807                     uTimeoutMS, pvData, cbData));
     808
     809    /* Prepare HGCM call. */
     810    VBOXHGCMSVCPARM paParms[4];
     811    int i = 1; /* Context ID will be set in sendFileComannd(). */
     812    paParms[i++].setUInt32(mData.mID /* File handle */);
     813    paParms[i++].setUInt32(cbData /* Size (in bytes) to write */);
     814    paParms[i++].setPointer(pvData, cbData);
     815
     816    GuestCtrlCallback *pCallback = NULL; int guestRc;
     817    int vrc = sendFileCommand(HOST_FILE_WRITE, i, paParms, uTimeoutMS,
     818                              &guestRc, &pCallback);
     819
     820    if (RT_SUCCESS(vrc))
     821    {
     822        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     823
     824        Assert(pCallback->GetDataSize() == sizeof(CALLBACKDATA_FILE_NOTIFY));
     825        PCALLBACKDATA_FILE_NOTIFY pData = (PCALLBACKDATA_FILE_NOTIFY)pCallback->GetDataRaw();
     826        AssertPtr(pData);
     827        Assert(pData->uType == GUEST_FILE_NOTIFYTYPE_WRITE);
     828
     829        size_t cbWritten = pData->u.write.cbWritten;
     830        LogFlowThisFunc(("cbWritten=%RU32\n", cbWritten));
     831
     832        if (pcbWritten)
     833            *pcbWritten = cbWritten;
     834    }
     835
     836    callbackDelete(pCallback);
     837
     838    if (pGuestRc)
     839        *pGuestRc = guestRc;
     840
     841    LogFlowFuncLeaveRC(vrc);
     842    return vrc;
     843}
     844
     845int GuestFile::writeDataAt(uint64_t uOffset, uint32_t uTimeoutMS,
     846                           void *pvData, size_t cbData,
     847                           uint32_t *pcbWritten, int *pGuestRc)
     848{
     849    AssertPtrReturn(pvData, VERR_INVALID_POINTER);
     850    AssertReturn(cbData, VERR_INVALID_PARAMETER);
     851
     852    LogFlowThisFunc(("uOffset=%RU64, uTimeoutMS=%RU32, pvData=%p, cbData=%zu\n",
     853                     uOffset, uTimeoutMS, pvData, cbData));
     854
     855    /* Prepare HGCM call. */
     856    VBOXHGCMSVCPARM paParms[4];
     857    int i = 1; /* Context ID will be set in sendFileComannd(). */
     858    paParms[i++].setUInt32(mData.mID /* File handle */);
     859    paParms[i++].setUInt64(uOffset /* Offset where to starting writing */);
     860    paParms[i++].setUInt32(cbData /* Size (in bytes) to write */);
     861    paParms[i++].setPointer(pvData, cbData);
     862
     863    GuestCtrlCallback *pCallback = NULL; int guestRc;
     864    int vrc = sendFileCommand(HOST_FILE_WRITE_AT, i, paParms, uTimeoutMS,
     865                              &guestRc, &pCallback);
     866
     867    if (RT_SUCCESS(vrc))
     868    {
     869        AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     870
     871        Assert(pCallback->GetDataSize() == sizeof(CALLBACKDATA_FILE_NOTIFY));
     872        PCALLBACKDATA_FILE_NOTIFY pData = (PCALLBACKDATA_FILE_NOTIFY)pCallback->GetDataRaw();
     873        AssertPtr(pData);
     874        Assert(pData->uType == GUEST_FILE_NOTIFYTYPE_WRITE);
     875
     876        size_t cbWritten = pData->u.write.cbWritten;
     877        LogFlowThisFunc(("cbWritten=%RU32\n", cbWritten));
     878
     879        if (pcbWritten)
     880            *pcbWritten = cbWritten;
     881    }
     882
     883    callbackDelete(pCallback);
     884
     885    if (pGuestRc)
     886        *pGuestRc = guestRc;
    456887
    457888    LogFlowFuncLeaveRC(vrc);
     
    472903    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    473904
     905    /* Close file on guest. */
     906    int guestRc;
     907    int rc = closeFile(&guestRc);
     908    /* On failure don't return here, instead do all the cleanup
     909     * work first and then return an error. */
     910
    474911    AssertPtr(mData.mSession);
    475     int rc = mData.mSession->fileRemoveFromList(this);
     912    int rc2 = mData.mSession->fileRemoveFromList(this);
     913    if (RT_SUCCESS(rc))
     914        rc = rc2;
    476915
    477916    /*
     
    483922
    484923    LogFlowFuncLeaveRC(rc);
     924    if (RT_FAILURE(rc))
     925    {
     926        if (rc == VERR_GSTCTL_GUEST_ERROR)
     927            return GuestFile::setErrorExternal(this, guestRc);
     928
     929        return setError(VBOX_E_IPRT_ERROR,
     930                        tr("Closing guest file failed with %Rrc\n"), rc);
     931    }
     932
    485933    return S_OK;
    486934#endif /* VBOX_WITH_GUEST_CONTROL */
     
    504952    ReturnComNotImplemented();
    505953#else
    506     AutoCaller autoCaller(this);
    507     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    508 
    509     ReturnComNotImplemented();
     954    if (aToRead == 0)
     955        return setError(E_INVALIDARG, tr("The size to read is zero"));
     956    CheckComArgOutSafeArrayPointerValid(aData);
     957
     958    AutoCaller autoCaller(this);
     959    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     960
     961    com::SafeArray<BYTE> data((size_t)aToRead);
     962    Assert(data.size() >= aToRead);
     963
     964    HRESULT hr = S_OK;
     965
     966    size_t cbRead; int guestRc;
     967    int vrc = readData(aToRead, aTimeoutMS,
     968                       data.raw(), aToRead, &cbRead, &guestRc);
     969    if (RT_SUCCESS(vrc))
     970    {
     971        if (data.size() != cbRead)
     972            data.resize(cbRead);
     973        data.detachTo(ComSafeArrayOutArg(aData));
     974    }
     975    else
     976    {
     977        switch (vrc)
     978        {
     979            case VERR_GSTCTL_GUEST_ERROR:
     980                hr = GuestFile::setErrorExternal(this, guestRc);
     981                break;
     982
     983            default:
     984                hr = setError(VBOX_E_IPRT_ERROR,
     985                              tr("Reading from file \"%s\" failed: %Rrc"),
     986                              mData.mOpenInfo.mFileName.c_str(), vrc);
     987                break;
     988        }
     989    }
     990
     991    LogFlowThisFunc(("rc=%Rrc, cbRead=%RU64\n", vrc, cbRead));
     992
     993    LogFlowFuncLeaveRC(vrc);
     994    return hr;
    510995#endif /* VBOX_WITH_GUEST_CONTROL */
    511996}
     
    5161001    ReturnComNotImplemented();
    5171002#else
    518     AutoCaller autoCaller(this);
    519     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    520 
    521     ReturnComNotImplemented();
     1003    if (aToRead == 0)
     1004        return setError(E_INVALIDARG, tr("The size to read is zero"));
     1005    CheckComArgOutSafeArrayPointerValid(aData);
     1006
     1007    AutoCaller autoCaller(this);
     1008    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1009
     1010    com::SafeArray<BYTE> data((size_t)aToRead);
     1011    Assert(data.size() >= aToRead);
     1012
     1013    HRESULT hr = S_OK;
     1014
     1015    size_t cbRead; int guestRc;
     1016    int vrc = readDataAt(aOffset, aToRead, aTimeoutMS,
     1017                         data.raw(), aToRead, &cbRead, &guestRc);
     1018    if (RT_SUCCESS(vrc))
     1019    {
     1020        if (data.size() != cbRead)
     1021            data.resize(cbRead);
     1022        data.detachTo(ComSafeArrayOutArg(aData));
     1023    }
     1024    else
     1025    {
     1026        switch (vrc)
     1027        {
     1028            case VERR_GSTCTL_GUEST_ERROR:
     1029                hr = GuestFile::setErrorExternal(this, guestRc);
     1030                break;
     1031
     1032            default:
     1033                hr = setError(VBOX_E_IPRT_ERROR,
     1034                              tr("Reading from file \"%s\" (at offset %RU64) failed: %Rrc"),
     1035                              mData.mOpenInfo.mFileName.c_str(), aOffset, vrc);
     1036                break;
     1037        }
     1038    }
     1039
     1040    LogFlowThisFunc(("rc=%Rrc, cbRead=%RU64\n", vrc, cbRead));
     1041
     1042    LogFlowFuncLeaveRC(vrc);
     1043    return hr;
    5221044#endif /* VBOX_WITH_GUEST_CONTROL */
    5231045}
     
    5281050    ReturnComNotImplemented();
    5291051#else
    530     AutoCaller autoCaller(this);
    531     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    532 
    533     ReturnComNotImplemented();
     1052    LogFlowThisFuncEnter();
     1053
     1054    AutoCaller autoCaller(this);
     1055    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1056
     1057    HRESULT hr = S_OK;
     1058
     1059    GUEST_FILE_SEEKTYPE eSeekType;
     1060    switch (aType)
     1061    {
     1062        case FileSeekType_Set:
     1063            eSeekType = GUEST_FILE_SEEKTYPE_BEGIN;
     1064            break;
     1065
     1066        case FileSeekType_Current:
     1067            eSeekType = GUEST_FILE_SEEKTYPE_CURRENT;
     1068            break;
     1069
     1070        default:
     1071            return setError(E_INVALIDARG, tr("Invalid seek type specified"));
     1072            break;
     1073    }
     1074
     1075    int guestRc;
     1076    int vrc = seekAt(aOffset, eSeekType,
     1077                     30 * 1000 /* 30s timeout */, &guestRc);
     1078    if (RT_FAILURE(vrc))
     1079    {
     1080        switch (vrc)
     1081        {
     1082            case VERR_GSTCTL_GUEST_ERROR:
     1083                hr = GuestFile::setErrorExternal(this, guestRc);
     1084                break;
     1085
     1086            default:
     1087                hr = setError(VBOX_E_IPRT_ERROR,
     1088                              tr("Seeking file \"%s\" (to offset %RU64) failed: %Rrc"),
     1089                              mData.mOpenInfo.mFileName.c_str(), aOffset, vrc);
     1090                break;
     1091        }
     1092    }
     1093
     1094    LogFlowFuncLeaveRC(vrc);
     1095    return hr;
    5341096#endif /* VBOX_WITH_GUEST_CONTROL */
    5351097}
     
    5521114    ReturnComNotImplemented();
    5531115#else
    554     AutoCaller autoCaller(this);
    555     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    556 
    557     ReturnComNotImplemented();
     1116    LogFlowThisFuncEnter();
     1117
     1118    CheckComArgOutPointerValid(aWritten);
     1119
     1120    AutoCaller autoCaller(this);
     1121    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1122
     1123    HRESULT hr = S_OK;
     1124
     1125    com::SafeArray<BYTE> data(ComSafeArrayInArg(aData)); int guestRc;
     1126    int vrc = writeData(aTimeoutMS, data.raw(), data.size(), (uint32_t*)aWritten, &guestRc);
     1127    if (RT_FAILURE(vrc))
     1128    {
     1129        switch (vrc)
     1130        {
     1131            case VERR_GSTCTL_GUEST_ERROR:
     1132                hr = GuestFile::setErrorExternal(this, guestRc);
     1133                break;
     1134
     1135            default:
     1136                hr = setError(VBOX_E_IPRT_ERROR,
     1137                              tr("Writing to file \"%s\" failed: %Rrc"),
     1138                              mData.mOpenInfo.mFileName.c_str(), vrc);
     1139                break;
     1140        }
     1141    }
     1142
     1143    LogFlowThisFunc(("rc=%Rrc, aWritten=%RU32\n", vrc, aWritten));
     1144
     1145    LogFlowFuncLeaveRC(vrc);
     1146    return hr;
    5581147#endif /* VBOX_WITH_GUEST_CONTROL */
    5591148}
     
    5641153    ReturnComNotImplemented();
    5651154#else
    566     AutoCaller autoCaller(this);
    567     if (FAILED(autoCaller.rc())) return autoCaller.rc();
    568 
    569     ReturnComNotImplemented();
    570 #endif /* VBOX_WITH_GUEST_CONTROL */
    571 }
    572 
     1155    LogFlowThisFuncEnter();
     1156
     1157    CheckComArgOutPointerValid(aWritten);
     1158
     1159    AutoCaller autoCaller(this);
     1160    if (FAILED(autoCaller.rc())) return autoCaller.rc();
     1161
     1162    HRESULT hr = S_OK;
     1163
     1164    com::SafeArray<BYTE> data(ComSafeArrayInArg(aData)); int guestRc;
     1165    int vrc = writeData(aTimeoutMS, data.raw(), data.size(), (uint32_t*)aWritten, &guestRc);
     1166    if (RT_FAILURE(vrc))
     1167    {
     1168        switch (vrc)
     1169        {
     1170            case VERR_GSTCTL_GUEST_ERROR:
     1171                hr = GuestFile::setErrorExternal(this, guestRc);
     1172                break;
     1173
     1174            default:
     1175                hr = setError(VBOX_E_IPRT_ERROR,
     1176                              tr("Writing to file \"%s\" (at offset %RU64) failed: %Rrc"),
     1177                              mData.mOpenInfo.mFileName.c_str(), aOffset, vrc);
     1178                break;
     1179        }
     1180    }
     1181
     1182    LogFlowThisFunc(("rc=%Rrc, aWritten=%RU32\n", vrc, aWritten));
     1183
     1184    LogFlowFuncLeaveRC(vrc);
     1185    return hr;
     1186#endif /* VBOX_WITH_GUEST_CONTROL */
     1187}
     1188
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r45078 r45109  
    949949    alock.acquire();
    950950
    951     AssertPtr(pCallbackRead);
    952951    int rc2 = callbackRemove(uContextID);
    953952    if (RT_SUCCESS(vrc))
    954953        vrc = rc2;
     954
     955    callbackDelete(pCallbackRead);
    955956
    956957    LogFlowFuncLeaveRC(vrc);
     
    10151016    uint32_t uContextID = 0;
    10161017
    1017     GuestCtrlCallback *pCallbackStart;
     1018    GuestCtrlCallback *pCallbackStart = NULL;
    10181019    try
    10191020    {
     
    11741175        AutoWriteLock awlock(this COMMA_LOCKVAL_SRC_POS);
    11751176
    1176         AssertPtr(pCallbackStart);
    11771177        int rc2 = callbackRemove(uContextID);
    11781178        if (RT_SUCCESS(vrc))
    11791179            vrc = rc2;
    11801180    }
     1181
     1182    callbackDelete(pCallbackStart);
    11811183
    11821184    LogFlowFuncLeaveRC(vrc);
     
    13051307    alock.acquire();
    13061308
    1307     AssertPtr(pCallbackTerminate);
    13081309    int rc2 = callbackRemove(uContextID);
    13091310    if (RT_SUCCESS(vrc))
    13101311        vrc = rc2;
     1312
     1313    callbackDelete(pCallbackTerminate);
    13111314
    13121315    LogFlowFuncLeaveRC(vrc);
     
    16171620        vrc = rc2;
    16181621
     1622    callbackDelete(pCallbackWrite);
     1623
    16191624    LogFlowFuncLeaveRC(vrc);
    16201625    return vrc;
     
    18071812    AutoCaller autoCaller(this);
    18081813    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    1809 
    1810     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
    18111814
    18121815    HRESULT hr = S_OK;
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r45078 r45109  
    968968        return rc;
    969969
    970     /* Add the created file to our vector. */
    971     mData.mFiles[uNewFileID] = pFile;
    972     mData.mNumObjects++;
    973     Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS);
    974 
    975     LogFlowFunc(("Added new file \"%s\" (Session: %RU32) (now total %ld files, %ld objects)\n",
    976                  openInfo.mFileName.c_str(), mData.mSession.mID, mData.mFiles.size(), mData.mNumObjects));
     970    int guestRc;
     971    rc = pFile->openFile(&guestRc);
     972    if (RT_SUCCESS(rc))
     973    {
     974        /* Add the created file to our vector. */
     975        mData.mFiles[uNewFileID] = pFile;
     976        mData.mNumObjects++;
     977        Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS);
     978
     979        LogFlowFunc(("Added new file \"%s\" (Session: %RU32) (now total %ld files, %ld objects)\n",
     980                     openInfo.mFileName.c_str(), mData.mSession.mID, mData.mFiles.size(), mData.mNumObjects));
     981    }
     982
     983    if (pGuestRc)
     984        *pGuestRc = guestRc;
    977985
    978986    LogFlowFuncLeaveRC(rc);
     
    17941802    if (FAILED(autoCaller.rc())) return autoCaller.rc();
    17951803
    1796     /* Close session on guest session. */
     1804    /* Close session on guest. */
    17971805    int guestRc;
    17981806    int rc = closeSession(0 /* Flags */, 30 * 1000 /* Timeout */,
     
    18161824    if (RT_FAILURE(rc))
    18171825    {
    1818         /** @todo Handle guestRc! */
     1826        if (rc == VERR_GSTCTL_GUEST_ERROR)
     1827            return GuestSession::setErrorExternal(this, guestRc);
     1828
    18191829        return setError(VBOX_E_IPRT_ERROR,
    18201830                        tr("Closing guest session failed with %Rrc\n"), rc);
     
    24832493        {
    24842494            case VERR_GSTCTL_GUEST_ERROR:
    2485                 hr = GuestProcess::setErrorExternal(this, guestRc);
     2495                hr = GuestFile::setErrorExternal(this, guestRc);
    24862496                break;
    24872497
    24882498            default:
    2489                 hr = setError(VBOX_E_IPRT_ERROR, tr("Opening file \"%s\" failed: %Rrc"),
     2499                hr = setError(VBOX_E_IPRT_ERROR, tr("Opening guest file \"%s\" failed: %Rrc"),
    24902500                              Utf8Str(aPath).c_str(), vrc);
    24912501                break;
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