VirtualBox

Changeset 8797

Show
Ignore:
Timestamp:
05/14/08 01:16:03 (8 months ago)
Author:
vboxsync
Message:

New DBGF interface for digging into the guts of the guest OS kernel.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/dbgf.h

    r8155 r8797  
    15501550DBGFR3DECL(int) DBGFR3MemScan(PVM pVM, PCDBGFADDRESS pAddress, RTGCUINTPTR cbRange, const uint8_t *pabNeedle, size_t cbNeedle, PDBGFADDRESS pHitAddress); 
    15511551 
     1552 
     1553/** 
     1554 * Guest OS digger interface identifier. 
     1555 * 
     1556 * This is for use together with PDBGFR3QueryInterface and is used to 
     1557 * obtain access to optional interfaces. 
     1558 */ 
     1559typedef enum DBGFOSINTERFACE 
     1560{ 
     1561    /** The usual invalid entry. */ 
     1562    DBGFOSINTERFACE_INVALID = 0, 
     1563    /** Process info. */ 
     1564    DBGFOSINTERFACE_PROCESS, 
     1565    /** Thread info. */ 
     1566    DBGFOSINTERFACE_THREAD, 
     1567    /** The end of the valid entries. */ 
     1568    DBGFOSINTERFACE_END, 
     1569    /** The usual 32-bit type blowup. */ 
     1570    DBGFOSINTERFACE_32BIT_HACK = 0x7fffffff 
     1571} DBGFOSINTERFACE; 
     1572/** Pointer to a Guest OS digger interface identifier. */ 
     1573typedef DBGFOSINTERFACE *PDBGFOSINTERFACE; 
     1574/** Pointer to a const Guest OS digger interface identifier. */ 
     1575typedef DBGFOSINTERFACE const *PCDBGFOSINTERFACE; 
     1576 
     1577 
     1578/** 
     1579 * Guest OS Digger Registration Record. 
     1580 * 
     1581 * This is used with the DBGFR3OSRegister() API. 
     1582 */ 
     1583typedef struct DBGFOSREG 
     1584{ 
     1585    /** Magic value (DBGFOSREG_MAGIC). */ 
     1586    uint32_t u32Magic; 
     1587    /** Flags. Reserved. */ 
     1588    uint32_t fFlags; 
     1589    /** The size of the instance data. */ 
     1590    uint32_t cbData; 
     1591    /** Operative System name. */ 
     1592    char szName[24]; 
     1593 
     1594    /** 
     1595     * Constructs the instance. 
     1596     * 
     1597     * @returns VBox status code. 
     1598     * @param   pVM     Pointer to the shared VM structure. 
     1599     * @param   pvData  Pointer to the instance data. 
     1600     */ 
     1601    DECLCALLBACKMEMBER(int, pfnConstruct)(PVM pVM, void *pvData); 
     1602 
     1603    /** 
     1604     * Destroys the instance. 
     1605     * 
     1606     * @param   pVM     Pointer to the shared VM structure. 
     1607     * @param   pvData  Pointer to the instance data. 
     1608     */ 
     1609    DECLCALLBACKMEMBER(void, pfnDestruct)(PVM pVM, void *pvData); 
     1610 
     1611    /** 
     1612     * Probes the guest memory for OS finger prints. 
     1613     * 
     1614     * No setup or so is performed, it will be followed by a call to pfnInit 
     1615     * or pfnRefresh that should take care of that. 
     1616     * 
     1617     * @returns true if is an OS handled by this module, otherwise false. 
     1618     * @param   pVM     Pointer to the shared VM structure. 
     1619     * @param   pvData  Pointer to the instance data. 
     1620     */ 
     1621    DECLCALLBACKMEMBER(bool, pfnProbe)(PVM pVM, void *pvData); 
     1622 
     1623    /** 
     1624     * Initializes a fresly detected guest, loading symbols and such useful stuff. 
     1625     * 
     1626     * This is called after pfnProbe. 
     1627     * 
     1628     * @returns VBox status code. 
     1629     * @param   pVM     Pointer to the shared VM structure. 
     1630     * @param   pvData  Pointer to the instance data. 
     1631     */ 
     1632    DECLCALLBACKMEMBER(int, pfnInit)(PVM pVM, void *pvData); 
     1633 
     1634    /** 
     1635     * Refreshes symbols and stuff following a redetection of the same OS. 
     1636     * 
     1637     * This is called after pfnProbe. 
     1638     * 
     1639     * @returns VBox status code. 
     1640     * @param   pVM     Pointer to the shared VM structure. 
     1641     * @param   pvData  Pointer to the instance data. 
     1642     */ 
     1643    DECLCALLBACKMEMBER(int, pfnRefresh)(PVM pVM, void *pvData); 
     1644 
     1645    /** 
     1646     * Terminates an OS when a new (or none) OS has been detected, 
     1647     * and before destruction. 
     1648     * 
     1649     * This is called after pfnProbe and if needed before pfnDestruct. 
     1650     * 
     1651     * @param   pVM     Pointer to the shared VM structure. 
     1652     * @param   pvData  Pointer to the instance data. 
     1653     */ 
     1654    DECLCALLBACKMEMBER(void, pfnTerm)(PVM pVM, void *pvData); 
     1655 
     1656    /** 
     1657     * Queries the version of the running OS. 
     1658     * 
     1659     * This is only called after pfnInit(). 
     1660     * 
     1661     * @returns VBox status code. 
     1662     * @param   pVM         Pointer to the shared VM structure. 
     1663     * @param   pvData      Pointer to the instance data. 
     1664     * @param   pszVersion  Where to store the version string. 
     1665     * @param   cchVersion  The size of the version string buffer. 
     1666     */ 
     1667    DECLCALLBACKMEMBER(int, pfnQueryVersion)(PVM pVM, void *pvData, char *pszVersion, size_t cchVersion); 
     1668 
     1669    /** 
     1670     * Queries the pointer to a interface. 
     1671     * 
     1672     * This is called after pfnProbe. 
     1673     * 
     1674     * @returns Pointer to the interface if available, NULL if not available. 
     1675     * @param   pVM     Pointer to the shared VM structure. 
     1676     * @param   pvData  Pointer to the instance data. 
     1677     * @param   enmIf   The interface identifier. 
     1678     */ 
     1679    DECLCALLBACKMEMBER(void *, pfnQueryInterface)(PVM pVM, void *pvData, DBGFOSINTERFACE enmIf); 
     1680 
     1681    /** Trailing magic (DBGFOSREG_MAGIC). */ 
     1682    uint32_t u32EndMagic; 
     1683} DBGFOSREG; 
     1684/** Pointer to a Guest OS digger registration record. */ 
     1685typedef DBGFOSREG *PDBGFOSREG; 
     1686/** Pointer to a const Guest OS digger registration record. */ 
     1687typedef DBGFOSREG const *PCDBGFOSREG; 
     1688 
     1689/** Magic value for DBGFOSREG::u32Magic and DBGFOSREG::u32EndMagic. (Hitomi Kanehara) */ 
     1690#define DBGFOSREG_MAGIC     0x19830808 
     1691 
     1692DBGFR3DECL(int)     DBGFR3OSRegister(PVM pVM, PDBGFOSREG pReg); 
     1693DBGFR3DECL(int)     DBGFR3OSDeregister(PVM pVM, PDBGFOSREG pReg); 
     1694DBGFR3DECL(int)     DBGFR3OSDetect(PVM pVM, char *pszName, size_t cchName); 
     1695DBGFR3DECL(int)     DBGFR3OSNameAndVersion(PVM pVM, char *pszName, size_t cchName, char *pszVersion, size_t cchVersion); 
     1696DBGFR3DECL(void *)  DBGFR3OSQueryInterface(PVM pVM, DBGFOSINTERFACE enmIf); 
     1697 
    15521698/** @} */ 
    15531699 
     1700 
    15541701__END_DECLS 
    15551702 
  • trunk/include/VBox/err.h

    r8543 r8797  
    239239/** The byte string was not found. */ 
    240240#define VERR_DBGF_MEM_NOT_FOUND             (-1208) 
     241/** The OS was not detected. */ 
     242#define VERR_DBGF_OS_NOT_DETCTED            (-1209) 
     243/** The OS was not detected. */ 
     244#define VINF_DBGF_OS_NOT_DETCTED            1209 
    241245/** @} */ 
    242246 
  • trunk/include/VBox/mm.h

    r8155 r8797  
    145145    MM_TAG_DBGF_LINE, 
    146146    MM_TAG_DBGF_LINE_DUP, 
     147    MM_TAG_DBGF_MODULE, 
     148    MM_TAG_DBGF_OS, 
    147149    MM_TAG_DBGF_STACK, 
    148150    MM_TAG_DBGF_SYMBOL, 
    149151    MM_TAG_DBGF_SYMBOL_DUP, 
    150     MM_TAG_DBGF_MODULE, 
    151152 
    152153    MM_TAG_EM, 
  • trunk/src/VBox/VMM/DBGF.cpp

    r8155 r8797  
    203203     * Terminate the other bits. 
    204204     */ 
     205    dbgfR3OSTerm(pVM); 
    205206    dbgfR3InfoTerm(pVM); 
    206207    return VINF_SUCCESS; 
  • trunk/src/VBox/VMM/DBGFInternal.h

    r8155 r8797  
    169169 
    170170/** 
     171 * Guest OS digger instance. 
     172 */ 
     173typedef struct DBGFOS 
     174{ 
     175    /** Pointer to the registration record. */ 
     176    PCDBGFOSREG pReg; 
     177    /** Pointer to the next OS we've registered. */ 
     178    struct DBGFOS *pNext; 
     179    /** The instance data (variable size). */ 
     180    uint8_t abData[16]; 
     181} DBGFOS; 
     182/** Pointer to guest OS digger instance. */ 
     183typedef DBGFOS *PDBGFOS; 
     184/** Pointer to const guest OS digger instance. */ 
     185typedef DBGFOS const *PCDBGFOS; 
     186 
     187 
     188/** 
    171189 * Converts a DBGF pointer into a VM pointer. 
    172190 * @returns Pointer to the VM structure the CPUM is part of. 
     
    253271     * This is checked and cleared in the \#DB handler. */ 
    254272    bool                    fSingleSteppingRaw; 
     273 
     274    /** The current Guest OS digger. */ 
     275    PDBGFOS                 pCurOS; 
     276    /** The head of the Guest OS digger instances. */ 
     277    PDBGFOS                 pOSHead; 
    255278} DBGF; 
    256279/** Pointer to DBGF Data. */ 
     
    260283extern int  dbgfR3InfoInit(PVM pVM); 
    261284extern int  dbgfR3InfoTerm(PVM pVM); 
     285extern void dbgfR3OSTerm(PVM pVM); 
    262286extern int  dbgfR3SymInit(PVM pVM); 
    263287extern int  dbgfR3SymTerm(PVM pVM); 
  • trunk/src/VBox/VMM/MMHeap.cpp

    r8155 r8797  
    656656        TAG2STR(DBGF_LINE); 
    657657        TAG2STR(DBGF_LINE_DUP); 
     658        TAG2STR(DBGF_MODULE); 
     659        TAG2STR(DBGF_OS); 
    658660        TAG2STR(DBGF_STACK); 
    659661        TAG2STR(DBGF_SYMBOL); 
    660662        TAG2STR(DBGF_SYMBOL_DUP); 
    661         TAG2STR(DBGF_MODULE); 
    662663 
    663664        TAG2STR(EM); 
  • trunk/src/VBox/VMM/Makefile.kmk

    r8760 r8797  
    6565        DBGFLog.cpp \ 
    6666        DBGFMem.cpp \ 
     67        DBGFOS.cpp \ 
    6768        DBGFStack.cpp \ 
    6869        DBGFSym.cpp \ 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy