Logo Search packages:      
Sourcecode: virtualbox-ose version File versions  Download package

static int kldrDyldFindDoDllSearch ( const char *  pszName,
const char *  pszPrefix,
const char *  pszSuffix,
KLDRDYLDSEARCH  enmSearch,
unsigned  fFlags,
PPKRDR  ppRdr 
) [static]

Todo:
Deal with DT_RUNPATH and DT_RPATH.
Todo:
ld.so.cache?
Searches for a DLL file using the specified method.

Returns:
0 on success and *ppMod pointing to the new module.

KLDR_ERR_MODULE_NOT_FOUND if the specified file couldn't be opened.

non-zero kLdr or OS specific status code on other failures.

Parameters:
pszName The name.
pszPrefix The prefix, optional.
pszSuffix The suffix, optional.
enmSearch The search method.
fFlags The load/search flags.
ppRdr Where to store the pointer to the file provider instance on success.

Todo:
get rid of the strlen() on the various paths here!

Definition at line 461 of file kLdrDyldFind.c.

References KLDRDYLDFINDARGS::cchMaxLength, KLDRDYLDFINDARGS::cchName, KLDRDYLDFINDARGS::cchPrefix, KLDRDYLDFINDARGS::cchSuffix, KLDRDYLDFINDARGS::enmSearch, KLDRDYLDFINDARGS::fFlags, KLDR_ERR_MODULE_NOT_FOUND, KLDRDYLD_SEARCH_KLDR, KLDRDYLD_SEARCH_OS2, KLDRDYLD_SEARCH_UNIX_COMMON, KLDRDYLD_SEARCH_WINDOWS, KLDRDYLD_SEARCH_WINDOWS_ALTERED, kLdrDyldAppDir, kldrDyldFindEnumeratePath(), kldrDyldFindGetDefaults(), kldrDyldFindLazyInitAppDir(), kldrDyldFindTryOpenPath(), kLdrDyldLibraryPath, kLdrDyldOS2BeginLibpath, kLdrDyldOS2EndLibpath, kLdrDyldOS2Libpath, kLdrDyldUnixLibraryPath, kLdrDyldUnixSystemLibraryPath, kLdrDyldWindowsAppDir, kLdrDyldWindowsDir, kLdrDyldWindowsPath, kLdrDyldWindowsSystemDir, KLDRDYLDFINDARGS::ppRdr, KLDRDYLDFINDARGS::pszName, KLDRDYLDFINDARGS::pszPrefix, and KLDRDYLDFINDARGS::pszSuffix.

Referenced by kldrDyldFindExistingModule(), and kldrDyldFindNewModule().

{
    int rc;
    KLDRDYLDFINDARGS Args;

    /*
     * Initialize the argument structure and resolve defaults.
     */
    Args.enmSearch = enmSearch;
    Args.pszPrefix = pszPrefix;
    Args.pszSuffix = pszSuffix;
    rc = kldrDyldFindGetDefaults(&Args.enmSearch, &Args.pszPrefix, &Args.pszSuffix, pszName, fFlags);
    if (rc)
        return rc;
    Args.pszName = pszName;
    Args.cchName = kHlpStrLen(pszName);
    Args.cchPrefix = Args.pszPrefix ? kHlpStrLen(Args.pszPrefix) : 0;
    Args.cchSuffix = Args.pszSuffix ? kHlpStrLen(Args.pszSuffix) : 0;
    Args.cchMaxLength = Args.cchName + Args.cchSuffix + Args.cchPrefix;
    Args.fFlags = fFlags;
    Args.ppRdr = ppRdr;

    /*
     * Apply the specified search method.
     */
/** @todo get rid of the strlen() on the various paths here! */
    switch (Args.enmSearch)
    {
        case KLDRDYLD_SEARCH_KLDR:
        {
            kldrDyldFindLazyInitAppDir();
            if (kLdrDyldAppDir[0] != '\0')
            {
                rc = kldrDyldFindTryOpenPath(kLdrDyldAppDir, kHlpStrLen(kLdrDyldAppDir), &Args);
                if (rc != KLDR_ERR_MODULE_NOT_FOUND)
                    break;
            }
            rc = kldrDyldFindTryOpenPath(".", 1, &Args);
            if (rc != KLDR_ERR_MODULE_NOT_FOUND)
                break;
            rc = kldrDyldFindEnumeratePath(kLdrDyldLibraryPath, &Args);
            break;
        }

        case KLDRDYLD_SEARCH_OS2:
        {
            rc = kldrDyldFindEnumeratePath(kLdrDyldOS2BeginLibpath, &Args);
            if (rc != KLDR_ERR_MODULE_NOT_FOUND)
                break;
            rc = kldrDyldFindEnumeratePath(kLdrDyldOS2Libpath, &Args);
            if (rc != KLDR_ERR_MODULE_NOT_FOUND)
                break;
            rc = kldrDyldFindEnumeratePath(kLdrDyldOS2EndLibpath, &Args);
            break;
        }

        case KLDRDYLD_SEARCH_WINDOWS:
        case KLDRDYLD_SEARCH_WINDOWS_ALTERED:
        {
            kldrDyldFindLazyInitAppDir();
            rc = kldrDyldFindTryOpenPath(kLdrDyldWindowsAppDir, kHlpStrLen(kLdrDyldWindowsAppDir), &Args);
            if (rc != KLDR_ERR_MODULE_NOT_FOUND)
                break;
            if (Args.enmSearch == KLDRDYLD_SEARCH_WINDOWS_ALTERED)
            {
                rc = kldrDyldFindTryOpenPath(".", 1, &Args);
                if (rc != KLDR_ERR_MODULE_NOT_FOUND)
                    break;
            }
            rc = kldrDyldFindTryOpenPath(kLdrDyldWindowsSystemDir, kHlpStrLen(kLdrDyldWindowsSystemDir), &Args);
            if (rc != KLDR_ERR_MODULE_NOT_FOUND)
                break;
            rc = kldrDyldFindTryOpenPath(kLdrDyldWindowsDir, kHlpStrLen(kLdrDyldWindowsDir), &Args);
            if (rc != KLDR_ERR_MODULE_NOT_FOUND)
                break;
            if (Args.enmSearch == KLDRDYLD_SEARCH_WINDOWS)
            {
                rc = kldrDyldFindTryOpenPath(".", 1, &Args);
                if (rc != KLDR_ERR_MODULE_NOT_FOUND)
                    break;
            }
            rc = kldrDyldFindEnumeratePath(kLdrDyldWindowsPath, &Args);
            break;
        }

        case KLDRDYLD_SEARCH_UNIX_COMMON:
        {
            rc = kldrDyldFindEnumeratePath(kLdrDyldUnixLibraryPath, &Args);
            if (rc == KLDR_ERR_MODULE_NOT_FOUND)
                break;
            rc = kldrDyldFindEnumeratePath(kLdrDyldUnixSystemLibraryPath, &Args);
            break;
        }

        default: kHlpAssert(!"internal error"); return -1;
    }
    return rc;
}


Generated by  Doxygen 1.6.0   Back to index