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

static int kldrModNativeGetImport ( 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.

Todo:
implement import enumeration on OS/2.

Definition at line 732 of file kLdrModNative.c.

References KLDRMODNATIVE::hmod, K_OS_OS2, KERR_BUFFER_OVERFLOW, KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS, KLDR_ERR_TODO, KLDRMODNATIVE_RVA2TYPE, kldrModNativeNumberOfImports(), KSIZE, and KLDRMOD::pvData.

{
    PKLDRMODNATIVE                  pModNative = (PKLDRMODNATIVE)pMod->pvData;
#if K_OS == K_OS_OS2

    /** @todo implement import enumeration on OS/2. */
    (void)pModNative;
    return ERROR_NOT_SUPPORTED;

#elif K_OS == K_OS_WINDOWS || defined(__NT__)
    const IMAGE_IMPORT_DESCRIPTOR  *pImpDesc;
    const char                     *pszImportName;
    KSIZE                           cchImportName;
    int                             rc;

    /*
     * Simple bounds check.
     */
    if (iImport >= (KU32)kldrModNativeNumberOfImports(pMod, pvBits))
        return KLDR_ERR_IMPORT_ORDINAL_OUT_OF_BOUNDS;

    /*
     * Get the name.
     */
    pImpDesc = KLDRMODNATIVE_RVA2TYPE(pModNative->hmod,
                                      pModNative->pNtHdrs->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress
                                      + sizeof(IMAGE_IMPORT_DESCRIPTOR) * iImport,
                                      const IMAGE_IMPORT_DESCRIPTOR *);
    pszImportName = KLDRMODNATIVE_RVA2TYPE(pModNative->hmod, pImpDesc->Name, const char *);
    cchImportName = kHlpStrLen(pszImportName);
    if (cchImportName < cchName)
    {
        kHlpMemCopy(pszName, pszImportName, cchImportName + 1);
        rc = 0;
    }
    else
    {
        kHlpMemCopy(pszName, pszImportName, cchName);
        if (cchName)
            pszName[cchName - 1] = '\0';
        rc = KERR_BUFFER_OVERFLOW;
    }

    return rc;

#elif K_OS == K_OS_DARWIN
    /** @todo Implement import enumeration on darwin. */
    (void)pModNative;
    return KLDR_ERR_TODO;

#else
# error "Port me"
#endif
}


Generated by  Doxygen 1.6.0   Back to index