VirtualBox

Ignore:
Timestamp:
Jun 23, 2008 3:02:47 PM (16 years ago)
Author:
vboxsync
Message:

Main: add the Main part of the guest/host configuration registry

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r9809 r9883  
    24862486    return S_OK;
    24872487}
     2488
     2489STDMETHODIMP Console::GetConfigRegistryValue (INPTR BSTR aKey, BSTR *aValue)
     2490{
     2491    if (!VALID_PTR(aValue))
     2492        return E_POINTER;
     2493
     2494#ifndef VBOX_WITH_INFO_SVC
     2495    HRESULT hrc = E_NOTIMPL;
     2496#else
     2497    HRESULT hrc = E_FAIL;
     2498    using namespace svcInfo;
     2499
     2500    VBOXHGCMSVCPARM parm[3];
     2501    Utf8Str Utf8Key = aKey;
     2502    Utf8Str Utf8Value(KEY_MAX_VALUE_LEN);
     2503
     2504    parm[0].type = VBOX_HGCM_SVC_PARM_PTR;
     2505    /* To save doing a const cast, we use the mutableRaw() member. */
     2506    parm[0].u.pointer.addr = Utf8Key.mutableRaw();
     2507    /* The + 1 is the null terminator */
     2508    parm[0].u.pointer.size = Utf8Key.length() + 1;
     2509    parm[1].type = VBOX_HGCM_SVC_PARM_PTR;
     2510    parm[1].u.pointer.addr = Utf8Value.mutableRaw();
     2511    parm[1].u.pointer.size = KEY_MAX_VALUE_LEN;
     2512    int rc = mVMMDev->hgcmHostCall ("VBoxSharedInfoSvc", GET_CONFIG_KEY_HOST, 3, &parm[0]);
     2513    /* The returned string should never be able to be greater than our buffer */
     2514    AssertLogRel(rc != VINF_BUFFER_OVERFLOW);
     2515    if (RT_SUCCESS(rc) && (rc != VINF_BUFFER_OVERFLOW))
     2516    {
     2517        hrc = S_OK;
     2518        if (parm[2].u.uint32 != 0)
     2519            Utf8Value.cloneTo(aValue);
     2520        else
     2521            aValue = NULL;
     2522    }
     2523    else
     2524        hrc = setError (E_FAIL, tr ("hgcmHostCall to VBoxSharedInfoSvc failed: %Rrc"), rc);
     2525#endif
     2526    return hrc;
     2527}
     2528
     2529STDMETHODIMP Console::SetConfigRegistryValue (INPTR BSTR aKey, INPTR BSTR aValue)
     2530{
     2531#ifndef VBOX_WITH_INFO_SVC
     2532    HRESULT hrc = E_NOTIMPL;
     2533#else
     2534    HRESULT hrc = E_FAIL;
     2535    using namespace svcInfo;
     2536
     2537    VBOXHGCMSVCPARM parm[2];
     2538    Utf8Str Utf8Key = aKey;
     2539    Utf8Str Utf8Value = aValue;
     2540
     2541    parm[0].type = VBOX_HGCM_SVC_PARM_PTR;
     2542    /* To save doing a const cast, we use the mutableRaw() member. */
     2543    parm[0].u.pointer.addr = Utf8Key.mutableRaw();
     2544    /* The + 1 is the null terminator */
     2545    parm[0].u.pointer.size = Utf8Key.length() + 1;
     2546    parm[1].type = VBOX_HGCM_SVC_PARM_PTR;
     2547    /* To save doing a const cast, we use the mutableRaw() member. */
     2548    parm[1].u.pointer.addr = Utf8Value.mutableRaw();
     2549    if (parm[1].u.pointer.addr != NULL)
     2550        /* The + 1 is the null terminator */
     2551        parm[1].u.pointer.size = Utf8Value.length() + 1;
     2552    else
     2553        parm[1].u.pointer.size = 0;
     2554    int rc = mVMMDev->hgcmHostCall ("VBoxSharedInfoSvc", SET_CONFIG_KEY_HOST, 2, &parm[0]);
     2555    if (RT_SUCCESS(rc))
     2556        hrc = S_OK;
     2557    else
     2558        hrc = setError (E_FAIL, tr ("hgcmHostCall to VBoxSharedInfoSvc failed: %Rrc"), rc);
     2559#endif
     2560    return hrc;
     2561}
     2562
    24882563
    24892564// Non-interface public methods
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