예제 #1
0
RTR0DECL(int) RTR0DbgKrnlInfoOpen(PRTDBGKRNLINFO phKrnlInfo, uint32_t fFlags)
{
    AssertReturn(fFlags == 0, VERR_INVALID_PARAMETER);
    AssertPtrReturn(phKrnlInfo, VERR_INVALID_POINTER);
    RT_ASSERT_PREEMPTIBLE();

    *phKrnlInfo = NIL_RTDBGKRNLINFO;
    PRTDBGKRNLINFOINT pThis = (PRTDBGKRNLINFOINT)RTMemAllocZ(sizeof(*pThis));
    if (!pThis)
        return VERR_NO_MEMORY;

    char szGenUnixModName[] = "genunix";
    int rc = rtR0DbgKrnlInfoModRetain(szGenUnixModName, &pThis->pGenUnixMod, &pThis->pGenUnixCTF);
    if (RT_SUCCESS(rc))
    {
        pThis->u32Magic       = RTDBGKRNLINFO_MAGIC;
        pThis->cRefs          = 1;

        *phKrnlInfo = pThis;
        return VINF_SUCCESS;
    }

    LogRel(("RTR0DbgKrnlInfoOpen: rtR0DbgKrnlInfoModRetain failed rc=%d.\n", rc));
    RTMemFree(pThis);
    return rc;
}
/**
 * Helper for opening the specified kernel module.
 *
 * @param pszModule         The name of the module.
 * @param ppMod             Where to store the module handle.
 * @param ppCtf             Where to store the module's CTF handle.
 *
 * @returns Pointer to the CTF structure for the module.
 */
static int rtR0DbgKrnlInfoModRetainEx(const char *pszModule, modctl_t **ppMod, ctf_file_t **ppCtf)
{
    char *pszMod = RTStrDup(pszModule);
    if (RT_LIKELY(pszMod))
    {
        int rc = rtR0DbgKrnlInfoModRetain(pszMod, ppMod, ppCtf);
        RTStrFree(pszMod);
        if (RT_SUCCESS(rc))
        {
            AssertPtrReturn(*ppMod, VERR_INTERNAL_ERROR_2);
            AssertPtrReturn(*ppCtf, VERR_INTERNAL_ERROR_3);
        }
        return rc;
    }
    return VERR_NO_MEMORY;
}