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

static int kldrModLXGetImport ( PKLDRMOD  pMod,
const void *  pvBits,
KU32  iImport,
char *  pszName,
KSIZE  cchName 
) [static]

Get the name of an import module by ordinal number.

Returns:
0 and name in pszName on success. On buffer overruns KERR_BUFFER_OVERFLOW will be returned. On other failures and appropriate error code is returned.
Parameters:
pMod The module.
pvBits Optional pointer to bits returned by kLdrModGetBits(). This can be used by some module interpreters to reduce memory consumption.
iImport The import module ordinal number.
pszName Where to store the name.
cchName The size of the name buffer.

Definition at line 1195 of file kLdrModLX.c.

References e32_exe::e32_impmodcnt, KLDRMODLX::Hdr, KERR_BUFFER_OVERFLOW, KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS, kldrModLXDoLoadFixupSection(), KLDRMODLX::pbImportMods, and KLDRMOD::pvData.

{
    PKLDRMODLX  pModLX = (PKLDRMODLX)pMod->pvData;
    const KU8  *pb;
    int         rc;

    /*
     * Validate
     */
    if (iImport >= pModLX->Hdr.e32_impmodcnt)
        return KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS;

    /*
     * Lazy loading the fixup section.
     */
    if (!pModLX->pbImportMods)
    {
        rc = kldrModLXDoLoadFixupSection(pModLX);
        if (rc)
            return rc;
    }

    /*
     * Iterate the module import table until we reach the requested import ordinal.
     */
    pb = pModLX->pbImportMods;
    while (iImport-- > 0)
        pb += *pb + 1;

    /*
     * Copy out the result.
     */
    if (*pb < cchName)
    {
        kHlpMemCopy(pszName, pb + 1, *pb);
        pszName[*pb] = '\0';
        rc = 0;
    }
    else
    {
        kHlpMemCopy(pszName, pb + 1, cchName);
        if (cchName)
            pszName[cchName - 1] = '\0';
        rc = KERR_BUFFER_OVERFLOW;
    }

    return rc;
}


Generated by  Doxygen 1.6.0   Back to index