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

static int kldrModPEEnumDbgInfo ( PKLDRMOD  pMod,
const void *  pvBits,
PFNKLDRENUMDBG  pfnCallback,
void *  pvUser 
) [static]

Enumerate the debug info formats contained in the executable image.

Returns:
0 on success, non-zero OS or kLdr status code on failure, or non-zero callback status.
Parameters:
pMod The module.
pvBits Optional pointer to bits returned by kLdrModGetBits(). This can be used by some module interpreters to reduce memory consumption.
pfnCallback The callback function.
pvUser The user argument.
See also:
pg_kDbg for the debug info reader.

Definition at line 1143 of file kLdrModPE.c.

References KLDRMODPE::Hdrs, KLDRDBGINFOTYPE_CODEVIEW, KLDRDBGINFOTYPE_UNKNOWN, KLDRMODPE_RVA2TYPE, kldrModPEBitsAndBaseAddress(), NIL_KLDRADDR, NULL, and KLDRMOD::pvData.

{
    PKLDRMODPE                      pModPE = (PKLDRMODPE)pMod->pvData;
    const IMAGE_DEBUG_DIRECTORY    *pDbgDir;
    KU32                            iDbgInfo;
    KU32                            cb;
    int                             rc;

    /*
     * Check that there is a debug directory first.
     */
    cb = pModPE->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].Size;
    if (    cb < sizeof(IMAGE_DEBUG_DIRECTORY) /* screw borland linkers */
        ||  !pModPE->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress)
        return 0;

    /*
     * Make sure we've got mapped bits.
     */
    rc = kldrModPEBitsAndBaseAddress(pModPE, &pvBits, NULL);
    if (rc)
        return rc;

    /*
     * Enumerate the debug directory.
     */
    pDbgDir = KLDRMODPE_RVA2TYPE(pvBits,
                                 pModPE->Hdrs.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress,
                                 const IMAGE_DEBUG_DIRECTORY *);
    for (iDbgInfo = 0;; iDbgInfo++, pDbgDir++, cb -= sizeof(IMAGE_DEBUG_DIRECTORY))
    {
        KLDRDBGINFOTYPE     enmDbgInfoType;

        /* convert the type. */
        switch (pDbgDir->Type)
        {
            case IMAGE_DEBUG_TYPE_UNKNOWN:
            case IMAGE_DEBUG_TYPE_FPO:
            case IMAGE_DEBUG_TYPE_COFF: /*stabs dialect??*/
            case IMAGE_DEBUG_TYPE_MISC:
            case IMAGE_DEBUG_TYPE_EXCEPTION:
            case IMAGE_DEBUG_TYPE_FIXUP:
            case IMAGE_DEBUG_TYPE_BORLAND:
            default:
                enmDbgInfoType = KLDRDBGINFOTYPE_UNKNOWN;
                break;
            case IMAGE_DEBUG_TYPE_CODEVIEW:
                enmDbgInfoType = KLDRDBGINFOTYPE_CODEVIEW;
                break;
        }

        rc = pfnCallback(pMod, iDbgInfo,
                         enmDbgInfoType, pDbgDir->MajorVersion, pDbgDir->MinorVersion,
                         pDbgDir->PointerToRawData ? (KLDRFOFF)pDbgDir->PointerToRawData : -1,
                         pDbgDir->AddressOfRawData ? pDbgDir->AddressOfRawData : NIL_KLDRADDR,
                         pDbgDir->SizeOfData,
                         NULL,
                         pvUser);
        if (rc)
            break;

        /* next */
        if (cb <= sizeof(IMAGE_DEBUG_DIRECTORY))
            break;
    }

    return rc;
}


Generated by  Doxygen 1.6.0   Back to index