VirtualBox

Changeset 15320 in vbox for trunk/src/recompiler_new


Ignore:
Timestamp:
Dec 11, 2008 5:30:31 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
40747
Message:

VBoxREMWrapper.cpp: Use SUPR3HardenedLdrLoadAppPriv. Cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/recompiler_new/VBoxREMWrapper.cpp

    r15305 r15320  
    179179# define USE_REM_IMPORT_JUMP_GLUE
    180180#endif
     181
    181182
    182183/*******************************************************************************
     
    19411942# endif
    19421943}
    1943 #endif
    1944 
     1944
     1945#endif /* USE_REM_STUBS */
    19451946#ifdef VBOX_USE_BITNESS_SELECTOR
    1946 static bool isRem64Needed(PVM pVM)
    1947 {
    1948     PCFGMNODE pRoot = CFGMR3GetRoot(pVM);
    1949     uint64_t u64Value = 0;
    1950 
    1951     CFGMR3QueryIntegerDef(pRoot, "Rem64Enabled", &u64Value, 0);
    1952 
    1953     return u64Value == 1;
    1954 }
     1947
     1948/**
     1949 * Checks if 64-bit support is enabled.
     1950 *
     1951 * @returns true / false.
     1952 * @param   pVM         Pointer to the shared VM structure.
     1953 */
     1954static bool remIs64bitEnabled(PVM pVM)
     1955{
     1956    bool f;
     1957    int rc = CFGMR3QueryBoolDef(CFGMR3GetRoot(pVM), "Rem64Enabled", &f, false);
     1958    AssertRCReturn(rc, false);
     1959    return f;
     1960}
     1961
    19551962
    19561963/**
     
    19611968static int remLoadProperObj(PVM pVM)
    19621969{
    1963     size_t  offFilename;
    1964     char    szPath[RTPATH_MAX];
    1965     int     rc = RTPathAppPrivateArch(szPath, sizeof(szPath) - 32);
    1966     AssertRCReturn(rc, rc);
    1967     offFilename = strlen(szPath);
    1968 
    19691970    /*
    19701971     * Load the VBoxREM32/64 object/DLL.
    19711972     */
    1972     strcpy(&szPath[offFilename], isRem64Needed(pVM) ? "/VBoxREM64" : "/VBoxREM32");
    1973     rc = RTLdrLoad(szPath, &g_ModREM2);
     1973    int rc = SUPR3HardenedLdrLoadAppPriv(remIs64bitEnabled(pVM) ? "VBoxREM64" : "VBoxREM32", &g_ModREM2);
    19741974    if (RT_SUCCESS(rc))
    19751975    {
    1976         if (RT_SUCCESS(rc))
     1976        /*
     1977         * Resolve exports.
     1978         */
     1979        unsigned i;
     1980        for (i = 0; i < RT_ELEMENTS(g_aExports); i++)
    19771981        {
    1978             /*
    1979              * Resolve exports.
    1980              */
    1981             unsigned i;
    1982             for (i = 0; i < RT_ELEMENTS(g_aExports); i++)
    1983             {
    1984                 void* Value;
    1985                 rc = RTLdrGetSymbol(g_ModREM2, g_aExports[i].pszName, &Value);
    1986                 AssertMsgRC(rc, ("%s rc=%Rrc\n", g_aExports[i].pszName, rc));
    1987                 if (RT_FAILURE(rc))
    1988                     break;
    1989                 *(void **)g_aExports[i].pv = Value;
    1990             }
     1982            void *pvValue;
     1983            rc = RTLdrGetSymbol(g_ModREM2, g_aExports[i].pszName, &pvValue);
     1984            AssertLogRelMsgRCBreak(rc, ("%s rc=%Rrc\n", g_aExports[i].pszName, rc));
     1985            *(void **)g_aExports[i].pv = pvValue;
    19911986        }
    19921987    }
    1993    
     1988
    19941989    return rc;
    19951990}
     1991
    19961992
    19971993/**
     
    20001996static void remUnloadProperObj(void)
    20011997{
    2002     unsigned i;
    2003 
    20041998    /* close module. */
    20051999    RTLdrClose(g_ModREM2);
    20062000    g_ModREM2 = NIL_RTLDRMOD;
    20072001}
    2008 #endif
    2009 
     2002
     2003#endif /* VBOX_USE_BITNESS_SELECTOR */
    20102004
    20112005REMR3DECL(int) REMR3Init(PVM pVM)
     
    20132007#ifdef USE_REM_STUBS
    20142008    return VINF_SUCCESS;
    2015 #elif VBOX_USE_BITNESS_SELECTOR
     2009
     2010#elif defined(VBOX_USE_BITNESS_SELECTOR)
    20162011    if (!pfnREMR3Init)
    20172012    {
     
    20212016    }
    20222017    return pfnREMR3Init(pVM);
     2018
    20232019#else
    20242020    if (!pfnREMR3Init)
     
    20362032#ifdef USE_REM_STUBS
    20372033    return VINF_SUCCESS;
    2038 #elif VBOX_USE_BITNESS_SELECTOR
     2034
     2035#elif defined(VBOX_USE_BITNESS_SELECTOR)
    20392036    int rc;
    20402037    Assert(VALID_PTR(pfnREMR3Term));
     
    20422039    remUnloadProperObj();
    20432040    return rc;
     2041
    20442042#else
    20452043    int rc;
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