VirtualBox

Changeset 105988 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 9, 2024 4:08:22 PM (7 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
164732
Message:

DBGF: Extended OS/2 digger to understand OS/2 2.1/2.11 MTE format.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Debugger/DBGPlugInOS2.cpp

    r104607 r105988  
    9090
    9191/**
    92  * 32-bit OS/2 loader module table entry.
     92 * 32-bit OS/2 loader module table entry (V3.0 and later).
    9393 */
    9494typedef struct LDRMTE
     
    106106    uint32_t    mte_modver;     /**< added even later. */
    107107} LDRMTE;
     108AssertCompileSize(LDRMTE, 40);
     109
     110/**
     111 * 32-bit OS/2 loader module table entry (V2.11).
     112 */
     113typedef struct LDRMTE2
     114{
     115    uint16_t    mte_flags2;
     116    uint16_t    mte_handle;
     117    uint32_t    mte_swapmte;    /**< Pointer to LDRSMTE. */
     118    uint32_t    mte_modname;    /**< Pointer to module name. */
     119    uint32_t    mte_link;       /**< Pointer to next LDRMTE2. */
     120    uint32_t    mte_flags1;
     121    uint32_t    mte_impmodcnt;
     122    uint16_t    mte_sfn;
     123    uint16_t    mte_usecnt;
     124} LDRMTE2;
     125AssertCompileSize(LDRMTE2, 28);
     126
    108127/** @name LDRMTE::mte_flag2 values
    109128 * @{ */
     
    874893
    875894
     895static void dbgdiggerOS2FixupMTE(PUVM pUVM, PCVMMR3VTABLE pVMM, PDBGDIGGEROS2 pThis, DBGDIGGEROS2BUF *pBuf)
     896{
     897    /** @todo OS/2 2.0 used a different format of SAS and likely MTE as well; not supported */
     898    if (pThis->OS2MajorVersion == 20 && pThis->OS2MinorVersion < 30)
     899    {
     900        /*
     901         * The MTE was laid out differently in OS/2 2.11, but contained the
     902         * same information as in 3.0. After reading the MTE from guest memory,
     903         * we can just shuffle things around.
     904         * NB: The OS/2 Debugging Handbook doesn't exactly explain that in the
     905         * old MTE format, mte_modname is actually a pointer to the ASCII string,
     906         * preceded by a length byte.
     907         * Must be called before dbgdiggerOS2ProcessModule().
     908         */
     909        LDRMTE2 OldMte;
     910        char    achNameBuf[9];
     911
     912        memcpy(&OldMte, &pBuf->mte, sizeof(OldMte));
     913
     914        pBuf->mte.mte_flags2    = OldMte.mte_flags2;
     915        pBuf->mte.mte_handle    = OldMte.mte_handle;
     916        pBuf->mte.mte_swapmte   = OldMte.mte_swapmte;
     917        pBuf->mte.mte_link      = OldMte.mte_link;
     918        pBuf->mte.mte_flags1    = OldMte.mte_flags1;
     919        pBuf->mte.mte_impmodcnt = OldMte.mte_impmodcnt;
     920        pBuf->mte.mte_sfn       = OldMte.mte_sfn;
     921        pBuf->mte.mte_usecnt    = OldMte.mte_usecnt;
     922
     923        /*
     924         * Deal with the module name. We assume that in OS/2 V2.x the module name was in
     925         * practice restricted to 8 chars, just like it is in V3.0 (pretty safe assumption).
     926         */
     927        DBGFADDRESS     Addr;
     928        int rc = pVMM->pfnDBGFR3MemRead(pUVM, 0 /*idCpu*/, pVMM->pfnDBGFR3AddrFromFlat(pUVM, &Addr, OldMte.mte_modname),
     929                                        &achNameBuf, sizeof(achNameBuf));
     930        if (RT_SUCCESS(rc))
     931        {
     932            memset(pBuf->mte.mte_modname, 0, 8);
     933            if((uint8_t)achNameBuf[0] <= 8)
     934                memcpy(pBuf->mte.mte_modname, &achNameBuf[1], achNameBuf[0]);
     935            else
     936                memcpy(pBuf->mte.mte_modname, "!NameErr", 8);
     937        }
     938        else
     939        {
     940            memcpy(pBuf->mte.mte_modname, "!RdErr", 6);
     941        }
     942    }
     943}
     944
     945
    876946static void dbgdiggerOS2ProcessModule(PUVM pUVM, PCVMMR3VTABLE pVMM, PDBGDIGGEROS2 pThis, DBGDIGGEROS2BUF *pBuf,
    877947                                      const char *pszCacheSubDir, RTDBGAS hAs, RTDBGCFG hDbgCfg)
     
    11241194                        if (RT_FAILURE(rc))
    11251195                            break;
     1196                        dbgdiggerOS2FixupMTE(pUVM, pVMM, pThis, &uBuf);
    11261197                        LogRel(("DbgDiggerOs2: Module @ %#010RX32: %.8s %#x %#x\n", (uint32_t)Addr.FlatPtr,
    11271198                                uBuf.mte.mte_modname, uBuf.mte.mte_flags1, uBuf.mte.mte_flags2));
     
    11411212                        if (RT_SUCCESS(rc))
    11421213                        {
     1214                            dbgdiggerOS2FixupMTE(pUVM, pVMM, pThis, &uBuf);
    11431215                            LogRel(("DbgDiggerOs2: Module @ %#010RX32: %.8s %#x %#x [again]\n", (uint32_t)Addr.FlatPtr,
    11441216                                    uBuf.mte.mte_modname, uBuf.mte.mte_flags1, uBuf.mte.mte_flags2));
Note: See TracChangeset for help on using the changeset viewer.

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