third_party/virtualbox/src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
/**
 * Construct the path to the DLL/SO/DYLIB containing the actual program.
 *
 * @returns VBox status code.
 * @param   pszProgName     The program name.
 * @param   fMainFlags      The flags passed to SUPR3HardenedMain.
 * @param   pszPath         The output buffer.
 * @param   cbPath          The size of the output buffer, in bytes.  Must be at
 *                          least 128 bytes!
 */
Construct the path to the DLL/SO/DYLIB containing the actual program.
@returns VBox status code.
@param   pszProgName     The program name.
@param   fMainFlags      The flags passed to SUPR3HardenedMain.
@param   pszPath         The output buffer.
@param   cbPath          The size of the output buffer, in bytes.  Must be at
least 128 bytes!
Construct the path to the DLL / SO / DYLIB containing the actual program . @returns VBox status code . @param pszProgName The program name . @param fMainFlags The flags passed to SUPR3HardenedMain . @param pszPath The output buffer . @param cbPath The size of the output buffer in bytes . Must be at least 128 bytes!
static int supR3HardenedMainGetTrustedLib(const char *pszProgName, uint32_t fMainFlags, char *pszPath, size_t cbPath)
{
    supR3HardenedPathAppPrivateArch(pszPath, sizeof(cbPath) - 10);
    const char *pszSubDirSlash;
    switch (g_fSupHardenedMain & SUPSECMAIN_FLAGS_LOC_MASK)
    {
        case SUPSECMAIN_FLAGS_LOC_APP_BIN:
#ifdef RT_OS_DARWIN
        case SUPSECMAIN_FLAGS_LOC_OSX_HLP_APP:
#endif
            pszSubDirSlash = "/";
            break;
        case SUPSECMAIN_FLAGS_LOC_TESTCASE:
            pszSubDirSlash = "/testcase/";
            break;
        default:
            pszSubDirSlash = "/";
            supR3HardenedFatal("supR3HardenedMainGetTrustedMain: Unknown program binary location: %#x\n", g_fSupHardenedMain);
    }
#ifdef RT_OS_DARWIN
    if (fMainFlags & SUPSECMAIN_FLAGS_OSX_VM_APP)
        pszProgName = "VirtualBox";
#else
    RT_NOREF1(fMainFlags);
#endif
    size_t cch = suplibHardenedStrLen(pszPath);
    return suplibHardenedStrCopyEx(&pszPath[cch], cbPath - cch, pszSubDirSlash, pszProgName, SUPLIB_DLL_SUFF, NULL);
}
static int supR3HardenedMainGetTrustedLib ( const char * pszProgName , uint32_t fMainFlags , char * pszPath , size_t cbPath ) { supR3HardenedPathAppPrivateArch ( pszPath , sizeof ( cbPath ) - 10 ) ; const char * pszSubDirSlash ; switch ( g_fSupHardenedMain & SUPSECMAIN_FLAGS_LOC_MASK ) { case SUPSECMAIN_FLAGS_LOC_APP_BIN : #ifdef RT_OS_DARWIN case SUPSECMAIN_FLAGS_LOC_OSX_HLP_APP : #endif pszSubDirSlash = " " ; break ; case SUPSECMAIN_FLAGS_LOC_TESTCASE : pszSubDirSlash = " " ; break ; default : pszSubDirSlash = " " ; supR3HardenedFatal ( " \n " , g_fSupHardenedMain ) ; } #ifdef RT_OS_DARWIN if ( fMainFlags & SUPSECMAIN_FLAGS_OSX_VM_APP ) pszProgName = " " ; #else RT_NOREF1 ( fMainFlags ) ; #endif size_t cch = suplibHardenedStrLen ( pszPath ) ; return suplibHardenedStrCopyEx ( & pszPath [ cch ] , cbPath - cch , pszSubDirSlash , pszProgName , SUPLIB_DLL_SUFF , NULL ) ; }
Construct the path to the DLL/SO/DYLIB containing the actual program.
Construct the path to the DLL / SO / DYLIB containing the actual program .