VirtualBox

Changeset 93444 in vbox for trunk/src/VBox/HostServices


Ignore:
Timestamp:
Jan 26, 2022 6:01:15 PM (3 years ago)
Author:
vboxsync
Message:

VMM,Main,HostServices: Use a function table for accessing the VBoxVMM.dll/so/dylib functionality, and load it dynamically when the Console object is initialized. Also converted a few drivers in Main to use device helpers to get config values and such. bugref:10074

Location:
trunk/src/VBox/HostServices
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/DragAndDrop/Makefile.kmk

    r93115 r93444  
    4747
    4848VBoxDragAndDropSvc_LIBS = \
    49         $(LIB_VMM) \
    5049        $(LIB_RUNTIME) \
    51         $(LIB_REM) \
    5250        $(PATH_STAGE_LIB)/VBoxDnDHostR3Lib$(VBOX_SUFF_LIB)
    5351
  • trunk/src/VBox/HostServices/GuestControl/Makefile.kmk

    r93115 r93444  
    4040
    4141VBoxGuestControlSvc_LIBS = \
    42         $(LIB_VMM) \
    43         $(LIB_RUNTIME) \
    44         $(LIB_REM)
     42        $(LIB_RUNTIME)
    4543
    4644VBoxGuestControlSvc_LDFLAGS.darwin = \
  • trunk/src/VBox/HostServices/GuestControl/VBoxGuestControlSvc.cpp

    r93115 r93444  
    6969#include <VBox/VMMDev.h>
    7070#include <VBox/vmm/ssm.h>
     71#include <VBox/vmm/vmmr3vtable.h>
    7172#include <iprt/assert.h>
    7273#include <iprt/cpp/autores.h>
     
    905906                                      uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[], uint64_t tsArrival);
    906907    static DECLCALLBACK(int)  svcHostCall(void *pvService, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[]);
    907     static DECLCALLBACK(int)  svcSaveState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM);
    908     static DECLCALLBACK(int)  svcLoadState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion);
     908    static DECLCALLBACK(int)  svcSaveState(void *pvService, uint32_t idClient, void *pvClient,
     909                                           PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM);
     910    static DECLCALLBACK(int)  svcLoadState(void *pvService, uint32_t idClient, void *pvClient,
     911                                           PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion);
    909912    static DECLCALLBACK(int)  svcRegisterExtension(void *pvService, PFNHGCMSVCEXT pfnExtension, void *pvExtension);
    910913
     
    24232426 */
    24242427/*static*/ DECLCALLBACK(int)
    2425 GstCtrlService::svcSaveState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM)
     2428GstCtrlService::svcSaveState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
    24262429{
    24272430    RT_NOREF(pvClient);
     
    24342437             Only the root service survives, so remember who that is and its mode. */
    24352438
    2436     SSMR3PutU32(pSSM, 1);
    2437     SSMR3PutBool(pSSM, pThis->m_fLegacyMode);
    2438     return SSMR3PutBool(pSSM, idClient == pThis->m_idMasterClient);
     2439    pVMM->pfnSSMR3PutU32(pSSM, 1);
     2440    pVMM->pfnSSMR3PutBool(pSSM, pThis->m_fLegacyMode);
     2441    return pVMM->pfnSSMR3PutBool(pSSM, idClient == pThis->m_idMasterClient);
    24392442}
    24402443
     
    24442447 */
    24452448/*static*/ DECLCALLBACK(int)
    2446 GstCtrlService::svcLoadState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
     2449GstCtrlService::svcLoadState(void *pvService, uint32_t idClient, void *pvClient,
     2450                             PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
    24472451{
    24482452    SELF *pThis = reinterpret_cast<SELF *>(pvService);
     
    24552459    {
    24562460        uint32_t uSubVersion;
    2457         int rc = SSMR3GetU32(pSSM, &uSubVersion);
     2461        int rc = pVMM->pfnSSMR3GetU32(pSSM, &uSubVersion);
    24582462        AssertRCReturn(rc, rc);
    24592463        if (uSubVersion != 1)
    2460             return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     2464            return pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    24612465                                     "sub version %u, expected 1\n", uSubVersion);
    24622466        bool fLegacyMode;
    2463         rc = SSMR3GetBool(pSSM, &fLegacyMode);
     2467        rc = pVMM->pfnSSMR3GetBool(pSSM, &fLegacyMode);
    24642468        AssertRCReturn(rc, rc);
    24652469        pThis->m_fLegacyMode = fLegacyMode;
    24662470
    24672471        bool fIsMaster;
    2468         rc = SSMR3GetBool(pSSM, &fIsMaster);
     2472        rc = pVMM->pfnSSMR3GetBool(pSSM, &fIsMaster);
    24692473        AssertRCReturn(rc, rc);
    24702474
  • trunk/src/VBox/HostServices/GuestControl/testcase/Makefile.kmk

    r93115 r93444  
    3535        ../VBoxGuestControlSvc.cpp \
    3636        tstGuestControlSvc.cpp
    37  tstGuestControlSvc_LIBS     = $(LIB_RUNTIME) $(LIB_VMM)
     37 tstGuestControlSvc_LIBS     = $(LIB_RUNTIME)
    3838
    3939$$(tstGuestControlSvc_0_OUTDIR)/tstGuestControlSvc.run: $$(tstGuestControlSvc_1_STAGE_TARGET)
  • trunk/src/VBox/HostServices/GuestProperties/Makefile.kmk

    r93115 r93444  
    4040
    4141VBoxGuestPropSvc_LIBS = \
    42         $(LIB_VMM) \
    43         $(LIB_RUNTIME) \
    44         $(LIB_REM)
     42        $(LIB_RUNTIME)
    4543
    4644VBoxGuestPropSvc_LDFLAGS.darwin = \
  • trunk/src/VBox/HostServices/HostChannel/Makefile.kmk

    r93115 r93444  
    3636
    3737VBoxHostChannel_LIBS = \
    38         $(LIB_VMM) \
    3938        $(LIB_RUNTIME)
    4039
  • trunk/src/VBox/HostServices/SharedClipboard/Makefile.kmk

    r93115 r93444  
    7373
    7474VBoxSharedClipboard_LIBS = \
    75         $(LIB_VMM) \
    76         $(LIB_RUNTIME) \
    77         $(LIB_REM)
     75        $(LIB_RUNTIME)
    7876if1of ($(KBUILD_TARGET), linux solaris freebsd)
    7977 ifndef VBOX_HEADLESS
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxSharedClipboardSvc.cpp

    r93316 r93444  
    184184#define LOG_GROUP LOG_GROUP_SHARED_CLIPBOARD
    185185#include <VBox/log.h>
     186#include <VBox/vmm/vmmr3vtable.h> /* must be included before hgcmsvc.h */
    186187
    187188#include <VBox/GuestHost/clipboard-helper.h>
     
    24572458#endif /* !UNIT_TEST */
    24582459
    2459 static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
     2460static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
    24602461{
    24612462    LogFlowFuncEnter();
     
    24752476
    24762477    /* Write Shared Clipboard saved state version. */
    2477     SSMR3PutU32(pSSM, VBOX_SHCL_SAVED_STATE_VER_CURRENT);
    2478 
    2479     int rc = SSMR3PutStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /*fFlags*/, &s_aShClSSMClientState[0], NULL);
     2478    pVMM->pfnSSMR3PutU32(pSSM, VBOX_SHCL_SAVED_STATE_VER_CURRENT);
     2479
     2480    int rc = pVMM->pfnSSMR3PutStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /*fFlags*/, &s_aShClSSMClientState[0], NULL);
    24802481    AssertRCReturn(rc, rc);
    24812482
    2482     rc = SSMR3PutStructEx(pSSM, &pClient->State.POD, sizeof(pClient->State.POD), 0 /*fFlags*/, &s_aShClSSMClientPODState[0], NULL);
     2483    rc = pVMM->pfnSSMR3PutStructEx(pSSM, &pClient->State.POD, sizeof(pClient->State.POD), 0 /*fFlags*/, &s_aShClSSMClientPODState[0], NULL);
    24832484    AssertRCReturn(rc, rc);
    24842485
    2485     rc = SSMR3PutStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /*fFlags*/, &s_aShClSSMClientTransferState[0], NULL);
     2486    rc = pVMM->pfnSSMR3PutStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /*fFlags*/, &s_aShClSSMClientTransferState[0], NULL);
    24862487    AssertRCReturn(rc, rc);
    24872488
    24882489    /* Serialize the client's internal message queue. */
    2489     rc = SSMR3PutU64(pSSM, pClient->cMsgAllocated);
     2490    rc = pVMM->pfnSSMR3PutU64(pSSM, pClient->cMsgAllocated);
    24902491    AssertRCReturn(rc, rc);
    24912492
     
    24932494    RTListForEach(&pClient->MsgQueue, pMsg, SHCLCLIENTMSG, ListEntry)
    24942495    {
    2495         SSMR3PutStructEx(pSSM, pMsg, sizeof(SHCLCLIENTMSG), 0 /*fFlags*/, &s_aShClSSMClientMsgHdr[0], NULL);
    2496         SSMR3PutStructEx(pSSM, pMsg, sizeof(SHCLCLIENTMSG), 0 /*fFlags*/, &s_aShClSSMClientMsgCtx[0], NULL);
     2496        pVMM->pfnSSMR3PutStructEx(pSSM, pMsg, sizeof(SHCLCLIENTMSG), 0 /*fFlags*/, &s_aShClSSMClientMsgHdr[0], NULL);
     2497        pVMM->pfnSSMR3PutStructEx(pSSM, pMsg, sizeof(SHCLCLIENTMSG), 0 /*fFlags*/, &s_aShClSSMClientMsgCtx[0], NULL);
    24972498
    24982499        for (uint32_t iParm = 0; iParm < pMsg->cParms; iParm++)
    2499             HGCMSvcSSMR3Put(&pMsg->aParms[iParm], pSSM);
    2500     }
    2501 
    2502     rc = SSMR3PutU64(pSSM, pClient->Legacy.cCID);
     2500            HGCMSvcSSMR3Put(&pMsg->aParms[iParm], pSSM, pVMM);
     2501    }
     2502
     2503    rc = pVMM->pfnSSMR3PutU64(pSSM, pClient->Legacy.cCID);
    25032504    AssertRCReturn(rc, rc);
    25042505
     
    25062507    RTListForEach(&pClient->Legacy.lstCID, pCID, SHCLCLIENTLEGACYCID, Node)
    25072508    {
    2508         rc = SSMR3PutStructEx(pSSM, pCID, sizeof(SHCLCLIENTLEGACYCID), 0 /*fFlags*/, &s_aShClSSMClientLegacyCID[0], NULL);
     2509        rc = pVMM->pfnSSMR3PutStructEx(pSSM, pCID, sizeof(SHCLCLIENTLEGACYCID), 0 /*fFlags*/, &s_aShClSSMClientLegacyCID[0], NULL);
    25092510        AssertRCReturn(rc, rc);
    25102511    }
    25112512#else  /* UNIT_TEST */
    2512     RT_NOREF3(u32ClientID, pvClient, pSSM);
     2513    RT_NOREF(u32ClientID, pvClient, pSSM, pVMM);
    25132514#endif /* UNIT_TEST */
    25142515    return VINF_SUCCESS;
     
    25162517
    25172518#ifndef UNIT_TEST
    2518 static int svcLoadStateV0(uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
     2519static int svcLoadStateV0(uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
    25192520{
    25202521    RT_NOREF(u32ClientID, pvClient, pSSM, uVersion);
    25212522
    25222523    uint32_t uMarker;
    2523     int rc = SSMR3GetU32(pSSM, &uMarker);   /* Begin marker. */
     2524    int rc = pVMM->pfnSSMR3GetU32(pSSM, &uMarker);   /* Begin marker. */
    25242525    AssertRC(rc);
    25252526    Assert(uMarker == UINT32_C(0x19200102)  /* SSMR3STRUCT_BEGIN */);
    25262527
    2527     rc = SSMR3Skip(pSSM, sizeof(uint32_t)); /* Client ID */
     2528    rc = pVMM->pfnSSMR3Skip(pSSM, sizeof(uint32_t)); /* Client ID */
    25282529    AssertRCReturn(rc, rc);
    25292530
    25302531    bool fValue;
    2531     rc = SSMR3GetBool(pSSM, &fValue);       /* fHostMsgQuit */
     2532    rc = pVMM->pfnSSMR3GetBool(pSSM, &fValue);       /* fHostMsgQuit */
    25322533    AssertRCReturn(rc, rc);
    25332534
    2534     rc = SSMR3GetBool(pSSM, &fValue);       /* fHostMsgReadData */
     2535    rc = pVMM->pfnSSMR3GetBool(pSSM, &fValue);       /* fHostMsgReadData */
    25352536    AssertRCReturn(rc, rc);
    25362537
    2537     rc = SSMR3GetBool(pSSM, &fValue);       /* fHostMsgFormats */
     2538    rc = pVMM->pfnSSMR3GetBool(pSSM, &fValue);       /* fHostMsgFormats */
    25382539    AssertRCReturn(rc, rc);
    25392540
    25402541    uint32_t fFormats;
    2541     rc = SSMR3GetU32(pSSM, &fFormats);      /* u32RequestedFormat */
     2542    rc = pVMM->pfnSSMR3GetU32(pSSM, &fFormats);      /* u32RequestedFormat */
    25422543    AssertRCReturn(rc, rc);
    25432544
    2544     rc = SSMR3GetU32(pSSM, &uMarker);       /* End marker. */
     2545    rc = pVMM->pfnSSMR3GetU32(pSSM, &uMarker);       /* End marker. */
    25452546    AssertRCReturn(rc, rc);
    25462547    Assert(uMarker == UINT32_C(0x19920406) /* SSMR3STRUCT_END */);
     
    25502551#endif /* UNIT_TEST */
    25512552
    2552 static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
     2553static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient,
     2554                                      PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
    25532555{
    25542556    LogFlowFuncEnter();
     
    25632565    /* Restore the client data. */
    25642566    uint32_t lenOrVer;
    2565     int rc = SSMR3GetU32(pSSM, &lenOrVer);
     2567    int rc = pVMM->pfnSSMR3GetU32(pSSM, &lenOrVer);
    25662568    AssertRCReturn(rc, rc);
    25672569
     
    25692571
    25702572    if (lenOrVer == VBOX_SHCL_SAVED_STATE_VER_3_1)
    2571         return svcLoadStateV0(u32ClientID, pvClient, pSSM, uVersion);
     2573        return svcLoadStateV0(u32ClientID, pvClient, pSSM, pVMM, uVersion);
    25722574
    25732575    if (   lenOrVer >= VBOX_SHCL_SAVED_STATE_VER_6_1B2
     
    25762578        if (lenOrVer >= VBOX_SHCL_SAVED_STATE_VER_6_1RC1)
    25772579        {
    2578             SSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */, &s_aShClSSMClientState[0], NULL);
    2579             SSMR3GetStructEx(pSSM, &pClient->State.POD, sizeof(pClient->State.POD), 0 /* fFlags */,
    2580                              &s_aShClSSMClientPODState[0], NULL);
     2580            pVMM->pfnSSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */,
     2581                                      &s_aShClSSMClientState[0], NULL);
     2582            pVMM->pfnSSMR3GetStructEx(pSSM, &pClient->State.POD, sizeof(pClient->State.POD), 0 /* fFlags */,
     2583                                      &s_aShClSSMClientPODState[0], NULL);
    25812584        }
    25822585        else
    2583             SSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */, &s_aShClSSMClientState61B1[0], NULL);
    2584         rc = SSMR3GetStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /* fFlags */,
    2585                               &s_aShClSSMClientTransferState[0], NULL);
     2586            pVMM->pfnSSMR3GetStructEx(pSSM, &pClient->State, sizeof(pClient->State), 0 /* fFlags */,
     2587                                      &s_aShClSSMClientState61B1[0], NULL);
     2588        rc = pVMM->pfnSSMR3GetStructEx(pSSM, &pClient->State.Transfers, sizeof(pClient->State.Transfers), 0 /* fFlags */,
     2589                                       &s_aShClSSMClientTransferState[0], NULL);
    25862590        AssertRCReturn(rc, rc);
    25872591
    25882592        /* Load the client's internal message queue. */
    25892593        uint64_t cMsgs;
    2590         rc = SSMR3GetU64(pSSM, &cMsgs);
     2594        rc = pVMM->pfnSSMR3GetU64(pSSM, &cMsgs);
    25912595        AssertRCReturn(rc, rc);
    25922596        AssertLogRelMsgReturn(cMsgs < _16K, ("Too many messages: %u (%x)\n", cMsgs, cMsgs), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
     
    26002604            } u;
    26012605
    2602             SSMR3GetStructEx(pSSM, &u.Msg, RT_UOFFSETOF(SHCLCLIENTMSG, aParms), 0 /*fFlags*/, &s_aShClSSMClientMsgHdr[0], NULL);
    2603             rc = SSMR3GetStructEx(pSSM, &u.Msg, RT_UOFFSETOF(SHCLCLIENTMSG, aParms), 0 /*fFlags*/, &s_aShClSSMClientMsgCtx[0], NULL);
     2606            pVMM->pfnSSMR3GetStructEx(pSSM, &u.Msg, RT_UOFFSETOF(SHCLCLIENTMSG, aParms), 0 /*fFlags*/,
     2607                                      &s_aShClSSMClientMsgHdr[0], NULL);
     2608            rc = pVMM->pfnSSMR3GetStructEx(pSSM, &u.Msg, RT_UOFFSETOF(SHCLCLIENTMSG, aParms), 0 /*fFlags*/,
     2609                                           &s_aShClSSMClientMsgCtx[0], NULL);
    26042610            AssertRCReturn(rc, rc);
    26052611
     
    26142620            for (uint32_t p = 0; p < pMsg->cParms; p++)
    26152621            {
    2616                 rc = HGCMSvcSSMR3Get(&pMsg->aParms[p], pSSM);
     2622                rc = HGCMSvcSSMR3Get(&pMsg->aParms[p], pSSM, pVMM);
    26172623                AssertRCReturnStmt(rc, shClSvcMsgFree(pClient, pMsg), rc);
    26182624            }
     
    26262632        {
    26272633            uint64_t cCID;
    2628             rc = SSMR3GetU64(pSSM, &cCID);
     2634            rc = pVMM->pfnSSMR3GetU64(pSSM, &cCID);
    26292635            AssertRCReturn(rc, rc);
    26302636            AssertLogRelMsgReturn(cCID < _16K, ("Too many context IDs: %u (%x)\n", cCID, cCID), VERR_SSM_DATA_UNIT_FORMAT_CHANGED);
     
    26352641                AssertPtrReturn(pCID, VERR_NO_MEMORY);
    26362642
    2637                 SSMR3GetStructEx(pSSM, pCID, sizeof(SHCLCLIENTLEGACYCID), 0 /* fFlags */, &s_aShClSSMClientLegacyCID[0], NULL);
     2643                pVMM->pfnSSMR3GetStructEx(pSSM, pCID, sizeof(SHCLCLIENTLEGACYCID), 0 /* fFlags */,
     2644                                          &s_aShClSSMClientLegacyCID[0], NULL);
    26382645                RTListAppend(&pClient->Legacy.lstCID, &pCID->Node);
    26392646            }
     
    26502657
    26512658#else  /* UNIT_TEST */
    2652     RT_NOREF(u32ClientID, pvClient, pSSM, uVersion);
     2659    RT_NOREF(u32ClientID, pvClient, pSSM, pVMM, uVersion);
    26532660#endif /* UNIT_TEST */
    26542661    return VINF_SUCCESS;
  • trunk/src/VBox/HostServices/SharedFolders/Makefile.kmk

    r93115 r93444  
    4747
    4848VBoxSharedFolders_LIBS = \
    49         $(LIB_VMM) \
    50         $(LIB_RUNTIME) \
    51         $(LIB_REM)
     49        $(LIB_RUNTIME)
    5250
    5351include $(FILE_KBUILD_SUB_FOOTER)
  • trunk/src/VBox/HostServices/SharedFolders/VBoxSharedFoldersSvc.cpp

    r93115 r93444  
    3333#include <VBox/vmm/ssm.h>
    3434#include <VBox/vmm/pdmifs.h>
     35#include <VBox/vmm/vmmr3vtable.h>
    3536
    3637
     
    194195 *        as the contents of a shared folder might change in between save and restore.
    195196 */
    196 static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
     197static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM)
    197198{
    198199#ifndef UNITTEST  /* Read this as not yet tested */
     
    202203    Log(("SharedFolders host service: saving state, u32ClientID = %u\n", u32ClientID));
    203204
    204     int rc = SSMR3PutU32(pSSM, SHFL_SAVED_STATE_VERSION);
     205    int rc = pVMM->pfnSSMR3PutU32(pSSM, SHFL_SAVED_STATE_VERSION);
    205206    AssertRCReturn(rc, rc);
    206207
    207     rc = SSMR3PutU32(pSSM, SHFL_MAX_MAPPINGS);
     208    rc = pVMM->pfnSSMR3PutU32(pSSM, SHFL_MAX_MAPPINGS);
    208209    AssertRCReturn(rc, rc);
    209210
    210211    /* Save client structure length & contents */
    211     rc = SSMR3PutU32(pSSM, sizeof(*pClient));
     212    rc = pVMM->pfnSSMR3PutU32(pSSM, sizeof(*pClient));
    212213    AssertRCReturn(rc, rc);
    213214
    214     rc = SSMR3PutMem(pSSM, pClient, sizeof(*pClient));
     215    rc = pVMM->pfnSSMR3PutMem(pSSM, pClient, sizeof(*pClient));
    215216    AssertRCReturn(rc, rc);
    216217
     
    221222        MAPPING *pFolderMapping = vbsfMappingGetByRoot(i);
    222223
    223         rc = SSMR3PutU32(pSSM, pFolderMapping? pFolderMapping->cMappings: 0);
     224        rc = pVMM->pfnSSMR3PutU32(pSSM, pFolderMapping? pFolderMapping->cMappings: 0);
    224225        AssertRCReturn(rc, rc);
    225226
    226         rc = SSMR3PutBool(pSSM, pFolderMapping? pFolderMapping->fValid: false);
     227        rc = pVMM->pfnSSMR3PutBool(pSSM, pFolderMapping? pFolderMapping->fValid: false);
    227228        AssertRCReturn(rc, rc);
    228229
     
    230231        {
    231232            uint32_t len = (uint32_t)strlen(pFolderMapping->pszFolderName);
    232             SSMR3PutU32(pSSM, len);
    233             SSMR3PutStrZ(pSSM, pFolderMapping->pszFolderName);
     233            pVMM->pfnSSMR3PutU32(pSSM, len);
     234            pVMM->pfnSSMR3PutStrZ(pSSM, pFolderMapping->pszFolderName);
    234235
    235236            len = ShflStringSizeOfBuffer(pFolderMapping->pMapName);
    236             SSMR3PutU32(pSSM, len);
    237             SSMR3PutMem(pSSM, pFolderMapping->pMapName, len);
    238 
    239             SSMR3PutBool(pSSM, pFolderMapping->fHostCaseSensitive);
    240 
    241             SSMR3PutBool(pSSM, pFolderMapping->fGuestCaseSensitive);
     237            pVMM->pfnSSMR3PutU32(pSSM, len);
     238            pVMM->pfnSSMR3PutMem(pSSM, pFolderMapping->pMapName, len);
     239
     240            pVMM->pfnSSMR3PutBool(pSSM, pFolderMapping->fHostCaseSensitive);
     241
     242            pVMM->pfnSSMR3PutBool(pSSM, pFolderMapping->fGuestCaseSensitive);
    242243
    243244            len = ShflStringSizeOfBuffer(pFolderMapping->pAutoMountPoint);
    244             SSMR3PutU32(pSSM, len);
    245             rc = SSMR3PutMem(pSSM, pFolderMapping->pAutoMountPoint, len);
     245            pVMM->pfnSSMR3PutU32(pSSM, len);
     246            rc = pVMM->pfnSSMR3PutMem(pSSM, pFolderMapping->pAutoMountPoint, len);
    246247            AssertRCReturn(rc, rc);
    247248        }
     
    249250
    250251#else
    251     RT_NOREF3(u32ClientID, pvClient, pSSM);
     252    RT_NOREF(u32ClientID, pvClient, pSSM, pVMM);
    252253#endif
    253254    return VINF_SUCCESS;
    254255}
    255256
    256 static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
     257static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient,
     258                                      PSSMHANDLE pSSM, PCVMMR3VTABLE pVMM, uint32_t uVersion)
    257259{
    258260#ifndef UNITTEST  /* Read this as not yet tested */
     
    265267
    266268    uint32_t uShfVersion = 0;
    267     int rc = SSMR3GetU32(pSSM, &uShfVersion);
     269    int rc = pVMM->pfnSSMR3GetU32(pSSM, &uShfVersion);
    268270    AssertRCReturn(rc, rc);
    269271
    270272    if (   uShfVersion > SHFL_SAVED_STATE_VERSION
    271273        || uShfVersion < SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)
    272         return SSMR3SetLoadError(pSSM, VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION, RT_SRC_POS,
    273                                  "Unknown shared folders state version %u!", uShfVersion);
    274 
    275     rc = SSMR3GetU32(pSSM, &nrMappings);
     274        return pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION, RT_SRC_POS,
     275                                          "Unknown shared folders state version %u!", uShfVersion);
     276
     277    rc = pVMM->pfnSSMR3GetU32(pSSM, &nrMappings);
    276278    AssertRCReturn(rc, rc);
    277279    if (nrMappings != SHFL_MAX_MAPPINGS)
     
    279281
    280282    /* Restore the client data (flags + path delimiter + mapping counts (new) at the moment) */
    281     rc = SSMR3GetU32(pSSM, &len);
     283    rc = pVMM->pfnSSMR3GetU32(pSSM, &len);
    282284    AssertRCReturn(rc, rc);
    283285
     
    285287        pClient->fHasMappingCounts = false;
    286288    else if (len != sizeof(*pClient))
    287         return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    288                                  "Saved SHFLCLIENTDATA size %u differs from current %u!", len, sizeof(*pClient));
    289 
    290     rc = SSMR3GetMem(pSSM, pClient, len);
     289        return pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     290                                          "Saved SHFLCLIENTDATA size %u differs from current %u!", len, sizeof(*pClient));
     291
     292    rc = pVMM->pfnSSMR3GetMem(pSSM, pClient, len);
    291293    AssertRCReturn(rc, rc);
    292294
     
    297299    else if (   pClient->enmErrorStyle <= kShflErrorStyle_Invalid
    298300             || pClient->enmErrorStyle >= kShflErrorStyle_End)
    299         return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    300                                  "Saved SHFLCLIENTDATA enmErrorStyle value %d is not known/valid!", pClient->enmErrorStyle);
     301        return pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     302                                          "Saved SHFLCLIENTDATA enmErrorStyle value %d is not known/valid!", pClient->enmErrorStyle);
    301303
    302304    /* Drop the root IDs of all configured mappings before restoring: */
     
    311313
    312314        /* restore the folder mapping counter. */
    313         rc = SSMR3GetU32(pSSM, &mapping.cMappings);
     315        rc = pVMM->pfnSSMR3GetU32(pSSM, &mapping.cMappings);
    314316        AssertRCReturn(rc, rc);
    315317
    316         rc = SSMR3GetBool(pSSM, &mapping.fValid);
     318        rc = pVMM->pfnSSMR3GetBool(pSSM, &mapping.fValid);
    317319        AssertRCReturn(rc, rc);
    318320
     
    321323            /* Load the host path name. */
    322324            uint32_t cb;
    323             rc = SSMR3GetU32(pSSM, &cb);
     325            rc = pVMM->pfnSSMR3GetU32(pSSM, &cb);
    324326            AssertRCReturn(rc, rc);
    325327
     
    328330            {
    329331                AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
    330                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad folder name size: %#x", cb));
     332                             pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     333                                                        "Bad folder name size: %#x", cb));
    331334                PSHFLSTRING pFolderName = (PSHFLSTRING)RTMemAlloc(cb);
    332335                AssertReturn(pFolderName != NULL, VERR_NO_MEMORY);
    333336
    334                 rc = SSMR3GetMem(pSSM, pFolderName, cb);
     337                rc = pVMM->pfnSSMR3GetMem(pSSM, pFolderName, cb);
    335338                AssertRCReturn(rc, rc);
    336339                AssertReturn(pFolderName->u16Size < cb && pFolderName->u16Length < pFolderName->u16Size,
    337                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    338                                                "Bad folder name string: %#x/%#x cb=%#x",
    339                                                pFolderName->u16Size, pFolderName->u16Length, cb));
     340                             pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     341                                                        "Bad folder name string: %#x/%#x cb=%#x",
     342                                                        pFolderName->u16Size, pFolderName->u16Length, cb));
    340343
    341344                rc = RTUtf16ToUtf8(pFolderName->String.ucs2, &pszFolderName);
     
    348351                AssertReturn(pszFolderName, VERR_NO_MEMORY);
    349352
    350                 rc = SSMR3GetStrZ(pSSM, pszFolderName, cb + 1);
     353                rc = pVMM->pfnSSMR3GetStrZ(pSSM, pszFolderName, cb + 1);
    351354                AssertRCReturn(rc, rc);
    352355                mapping.pszFolderName = pszFolderName;
     
    354357
    355358            /* Load the map name. */
    356             rc = SSMR3GetU32(pSSM, &cb);
     359            rc = pVMM->pfnSSMR3GetU32(pSSM, &cb);
    357360            AssertRCReturn(rc, rc);
    358361            AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
    359                          SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad map name size: %#x", cb));
     362                         pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     363                                                    "Bad map name size: %#x", cb));
    360364
    361365            PSHFLSTRING pMapName = (PSHFLSTRING)RTMemAlloc(cb);
    362366            AssertReturn(pMapName != NULL, VERR_NO_MEMORY);
    363367
    364             rc = SSMR3GetMem(pSSM, pMapName, cb);
     368            rc = pVMM->pfnSSMR3GetMem(pSSM, pMapName, cb);
    365369            AssertRCReturn(rc, rc);
    366370            AssertReturn(pMapName->u16Size < cb && pMapName->u16Length < pMapName->u16Size,
    367                          SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    368                                            "Bad map name string: %#x/%#x cb=%#x",
    369                                            pMapName->u16Size, pMapName->u16Length, cb));
     371                         pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     372                                                    "Bad map name string: %#x/%#x cb=%#x",
     373                                                    pMapName->u16Size, pMapName->u16Length, cb));
    370374
    371375            /* Load case sensitivity config. */
    372             rc = SSMR3GetBool(pSSM, &mapping.fHostCaseSensitive);
     376            rc = pVMM->pfnSSMR3GetBool(pSSM, &mapping.fHostCaseSensitive);
    373377            AssertRCReturn(rc, rc);
    374378
    375             rc = SSMR3GetBool(pSSM, &mapping.fGuestCaseSensitive);
     379            rc = pVMM->pfnSSMR3GetBool(pSSM, &mapping.fGuestCaseSensitive);
    376380            AssertRCReturn(rc, rc);
    377381
     
    380384            if (uShfVersion > SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT)
    381385            {
    382                 rc = SSMR3GetU32(pSSM, &cb);
     386                rc = pVMM->pfnSSMR3GetU32(pSSM, &cb);
    383387                AssertRCReturn(rc, rc);
    384388                AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
    385                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad auto mount point size: %#x", cb));
     389                             pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     390                                                        "Bad auto mount point size: %#x", cb));
    386391
    387392                pAutoMountPoint = (PSHFLSTRING)RTMemAlloc(cb);
    388393                AssertReturn(pAutoMountPoint != NULL, VERR_NO_MEMORY);
    389394
    390                 rc = SSMR3GetMem(pSSM, pAutoMountPoint, cb);
     395                rc = pVMM->pfnSSMR3GetMem(pSSM, pAutoMountPoint, cb);
    391396                AssertRCReturn(rc, rc);
    392397                AssertReturn(pAutoMountPoint->u16Size < cb && pAutoMountPoint->u16Length < pAutoMountPoint->u16Size,
    393                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
    394                                                "Bad auto mount point string: %#x/%#x cb=%#x",
    395                                                pAutoMountPoint->u16Size, pAutoMountPoint->u16Length, cb));
     398                             pVMM->pfnSSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
     399                                                        "Bad auto mount point string: %#x/%#x cb=%#x",
     400                                                        pAutoMountPoint->u16Size, pAutoMountPoint->u16Length, cb));
    396401
    397402            }
     
    428433    Log(("SharedFolders host service: successfully loaded state\n"));
    429434#else
    430     RT_NOREF(u32ClientID, pvClient, pSSM, uVersion);
     435    RT_NOREF(u32ClientID, pvClient, pSSM, pVMM, uVersion);
    431436#endif
    432437    return VINF_SUCCESS;
Note: See TracChangeset for help on using the changeset viewer.

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