VirtualBox

Ignore:
Timestamp:
May 14, 2013 11:39:28 PM (12 years ago)
Author:
vboxsync
Message:

Made it possible to find symbols for windows nt using a image-in-guest-memory loader fallback.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/dbg/dbgmodldr.cpp

    r46025 r46083  
    4141#include <iprt/string.h>
    4242#include "internal/dbgmod.h"
     43#include "internal/ldr.h"
    4344#include "internal/magics.h"
    4445
     
    5455    /** The loader handle. */
    5556    RTLDRMOD        hLdrMod;
    56     /** File handle for the image. */
    57     RTFILE          hFile;
    5857} RTDBGMODLDR;
    5958/** Pointer to instance data NM map reader. */
     
    8079        return VERR_NO_MEMORY;
    8180
    82     int rc = RTFileReadAt(pThis->hFile, off, pvMap, cb, NULL);
     81    int rc = rtLdrReadAt(pThis->hLdrMod, pvMap, off, cb);
    8382    if (RT_SUCCESS(rc))
    8483        *ppvMap = pvMap;
     
    134133    pThis->hLdrMod = NIL_RTLDRMOD;
    135134
    136     rc = RTFileClose(pThis->hFile); AssertRC(rc);
    137     pThis->hFile = NIL_RTFILE;
    138 
    139135    RTMemFree(pThis);
    140136
     
    146142static DECLCALLBACK(int) rtDbgModLdr_TryOpen(PRTDBGMODINT pMod)
    147143{
    148     RTFILE hFile;
    149     int rc = RTFileOpen(&hFile, pMod->pszImgFile, RTFILE_O_READ | RTFILE_O_DENY_WRITE | RTFILE_O_OPEN);
     144    RTLDRMOD hLdrMod;
     145    int rc = RTLdrOpen(pMod->pszImgFile, RTLDR_O_FOR_DEBUG, RTLDRARCH_WHATEVER, &hLdrMod);
    150146    if (RT_SUCCESS(rc))
    151147    {
    152         RTLDRMOD hLdrMod;
    153         rc = RTLdrOpen(pMod->pszImgFile, RTLDR_O_FOR_DEBUG, RTLDRARCH_WHATEVER, &hLdrMod);
    154         if (RT_SUCCESS(rc))
    155         {
    156             PRTDBGMODLDR pThis = (PRTDBGMODLDR)RTMemAllocZ(sizeof(RTDBGMODLDR));
    157             if (pThis)
    158             {
    159                 pThis->hLdrMod  = hLdrMod;
    160                 pThis->hFile    = hFile;
    161                 pMod->pvImgPriv = pThis;
    162                 return VINF_SUCCESS;
    163             }
    164 
    165             rc = VERR_NO_MEMORY;
     148        rc = rtDbgModLdrOpenFromHandle(pMod, hLdrMod);
     149        if (RT_FAILURE(rc))
    166150            RTLdrClose(hLdrMod);
    167         }
    168 
    169         RTFileClose(hFile);
    170151    }
    171152    return rc;
     
    191172};
    192173
     174
     175/**
     176 * Open PE-image trick.
     177 *
     178 * @returns IPRT status code
     179 * @param   pDbgMod             The debug module instance.
     180 * @param   hLdrMod             The module to open a image debug backend for.
     181 */
     182DECLHIDDEN(int) rtDbgModLdrOpenFromHandle(PRTDBGMODINT pDbgMod, RTLDRMOD hLdrMod)
     183{
     184    PRTDBGMODLDR pThis = (PRTDBGMODLDR)RTMemAllocZ(sizeof(RTDBGMODLDR));
     185    if (!pThis)
     186        return VERR_NO_MEMORY;
     187
     188    pThis->hLdrMod     = hLdrMod;
     189    pDbgMod->pvImgPriv = pThis;
     190    return VINF_SUCCESS;
     191}
     192
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette