⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commonroutines.cpp

📁 可以用于.net2005或.net2003中的vc调试
💻 CPP
📖 第 1 页 / 共 2 页
字号:

    cBitmap.DeleteObject ( ) ;

    m_pTree->SetImageList ( pImageList , TVSIL_NORMAL ) ;

    return ( TRUE ) ;
}

BOOL CrashFinderTreeDisplay ::
            InsertImageStatsIntoTree ( HTREEITEM       hParent  ,
                                       CBinaryImage *  pImage    )
{
    CString strText ;
    HTREEITEM hRet ;

    strText.Format ( IDS_IMAGEBASE , pImage->GetLoadAddress ( ) ) ;
    hRet = m_pTree->InsertItem ( strText    ,
                                 STATE_INFO ,
                                 STATE_INFO ,
                                 hParent     ) ;
    ASSERT ( NULL != hRet ) ;
    if ( NULL != hRet )
    {
        // Convert the time into a readable format and get rid of the
        // annoying '\n'.
        TCHAR szTime [ 30 ] ;
        DWORD64 dwTime = pImage->GetTimeStamp( ) ;
        _tcscpy ( szTime , _tctime ( (time_t*)&dwTime ) ) ;
        szTime[ 24 ] = '\0' ;

        strText.Format ( IDS_TIMESTAMP , szTime ) ;
        hRet = m_pTree->InsertItem ( strText    ,
                                     STATE_INFO ,
                                     STATE_INFO ,
                                     hParent     ) ;
        ASSERT ( NULL != hRet ) ;
        if ( NULL != hRet )
        {
            strText.LoadString ( IDS_SYMBOLTYPE ) ;
            switch ( pImage->GetSymType ( ) )
            {
                case SymNone            :
                    strText += _T ( "SymNone" ) ;
                    break;

                case SymCoff            :
                    strText += _T ( "SymCoff" ) ;
                    break;

                case SymCv              :
                    strText += _T ( "SymCv" ) ;
                    break;

                case SymPdb             :
                    strText += _T ( "SymPdb" ) ;
                    break;

                case SymExport          :
                    strText += _T ( "SymExport" ) ;
                    break;

                case SymDeferred        :
                    strText += _T ( "SymDeferred" ) ;
                    break;

                case SymSym             :
                    strText += _T ( "SymSym" ) ;
                    break;

                case SymDia             :
                    strText += _T ( "SymDia" ) ;
                    break ;

                default :
                    ASSERT ( FALSE ) ;
                    strText += _T ( "**UNKNOWN!!!!!\r\n" );
                    break;
            }
            hRet = m_pTree->InsertItem ( strText    ,
                                         STATE_INFO ,
                                         STATE_INFO ,
                                         hParent     ) ;
            ASSERT ( NULL != hRet ) ;
            if ( NULL != hRet )
            {
                strText.Format ( IDS_IMAGENAME                  ,
                                 pImage->GetSymbolImageName ( )  );
                hRet = m_pTree->InsertItem ( strText    ,
                                             STATE_INFO ,
                                             STATE_INFO ,
                                             hParent     ) ;
                ASSERT ( NULL != hRet ) ;
                if ( NULL != hRet )
                {
                    strText.Format (IDS_LOADEDIMAGE          ,
                                    pImage->GetLoadedSymbolImageName());
                    hRet = m_pTree->InsertItem ( strText    ,
                                                 STATE_INFO ,
                                                 STATE_INFO ,
                                                 hParent     ) ;
                    ASSERT ( NULL != hRet ) ;
                }
            }
        }
    }
    return ( NULL != hRet ) ;
}

BOOL CrashFinderTreeDisplay ::
                    InsertImageInTree ( CBinaryImage *  pImage     ,
                                        int             iState     ,
                                        HTREEITEM       hItemAfter )
{
    // The return value.
    BOOL bRet = FALSE ;

    // Get the application.
    CCrashFinderApp * pApp = (CCrashFinderApp*)AfxGetApp ( ) ;
    ASSERT ( NULL != pApp ) ;
    if ( NULL == pApp )
    {
        return ( FALSE ) ;
    }

    // Put the string into the tree.
    HTREEITEM hParentItem =
                    m_pTree->InsertItem ( pApp->ShowFullPaths ( )
                                            ? pImage->GetFullName ( )
                                            : pImage->GetName ( )    ,
                                          iState                     ,
                                          iState                     ,
                                          TVI_ROOT                   ,
                                          hItemAfter                  );
    ASSERT ( NULL != hParentItem ) ;
    if ( NULL != hParentItem )
    {
        // Put a pointer to the image in the item data. The pointer
        // makes it easy to update the module symbol information
        // whenever the view changes.
        bRet = m_pTree->SetItemData ( hParentItem , (DWORD)pImage ) ;
        ASSERT ( bRet ) ;

        // Only if the item was inserted and was deemed valid can I
        // do the child node stats.
        CString strString ;
        if ( ( TRUE == bRet ) && ( STATE_VALIDATED == iState ) )
        {
            bRet = InsertImageStatsIntoTree ( hParentItem , pImage ) ;
            ASSERT ( TRUE == bRet ) ;
            // Force the item to be selected.
            bRet = m_pTree->SelectItem ( hParentItem ) ;
            ASSERT ( bRet ) ;
        }
        else
        {
            DWORD dwStringID ;
            switch ( pImage->GetBinaryError ( ) )
            {
                case eNotFound  :
                    dwStringID = IDS_ERR_NOTFOUND ;
                    break ;
                case eAddressConflict :
                    dwStringID = IDS_ERR_LOADCONFLICT ;
                    break ;
                case eNoPEImage :
                    dwStringID = IDS_ERR_NOTAPEFILE ;
                    break ;
                case eNoSymbolsAtAll :
                    dwStringID = IDS_ERR_NOSYMBOLS ;
                    break ;
                case eNoPDBSymbols :
                    dwStringID = IDS_ERR_NOPDBSYMBOLS ;
                    break ;
                default :
                    dwStringID = IDS_ERR_UNKNOWNERROR ;
                    break ;

            }
            strString.FormatMessage ( dwStringID , pImage->GetName ( ));
            // Show this message as the item's data.
            m_pTree->InsertItem ( strString   ,
                                  STATE_INFO  ,
                                  STATE_INFO  ,
                                  hParentItem  ) ;
            // Expand the tree to show the error.
            m_pTree->Expand ( hParentItem , TVE_EXPAND ) ;
        }
    }
    else
    {
        // I couldn't add it.
        bRet = FALSE ;
    }
    return ( bRet ) ;
}

BOOL CrashFinderTreeDisplay ::
                         DeleteImageStatsFromTree ( HTREEITEM  hParent )
{
    HTREEITEM hCurrChildItem = m_pTree->GetChildItem ( hParent ) ;
    while ( NULL != hCurrChildItem )
    {
        // Get the next item.
        HTREEITEM hNextChildItem = m_pTree->GetNextItem(hCurrChildItem ,
                                                        TVGN_NEXT     );
        // Delete the current item.
        BOOL bRet = m_pTree->DeleteItem ( hCurrChildItem ) ;
        ASSERT ( TRUE == bRet ) ;
        hCurrChildItem = hNextChildItem ;
    }
    return ( TRUE ) ;
}

BOOL CrashFinderTreeDisplay ::
                UpdateImageStats ( HTREEITEM       hParent          ,
                                   CBinaryImage *  pImage           ,
                                   BOOL            bPrevWasGoodLoad  )
{
    BOOL bRet = FALSE ;

    // Check that the item has properly loaded previously.
    if ( TRUE == bPrevWasGoodLoad )
    {
        // The image had a good load previously so all I need to do is
        // update the load address, which is the first child.
        HTREEITEM hChild = m_pTree->GetChildItem ( hParent ) ;
        ASSERT ( NULL != hChild ) ;
        if ( NULL != hChild )
        {
            CString strText ;

            strText.Format ( IDS_IMAGEBASE              ,
                             pImage->GetLoadAddress ( )  ) ;

            bRet = m_pTree->SetItemText ( hChild , strText ) ;
        }
    }
    else
    {
        // This is a node that had only the warning message as a child
        // node.

        // Remove all child nodes.
        DeleteImageStatsFromTree ( hParent ) ;

        // Get all the module information.
        // The module information.
        CImageHlp_Module cModInfo ;

        CString strString ;

        // Look up this module's information.
        // Try and get the symbol information for this module.
        bRet = m_pSymEng->SymGetModuleInfo(pImage->GetLoadAddress(),
                                           &cModInfo              );

        ASSERT ( FALSE != bRet ) ;
        if ( TRUE == bRet )
        {
            bRet = InsertImageStatsIntoTree ( hParent , pImage) ;
            ASSERT ( TRUE == bRet ) ;
        }
        else
        {
            strString.FormatMessage ( IDS_SYMMODULENOTLOADED ,
                                      pImage->GetName ( )     );
            // Show this message as the item's data.
            m_pTree->InsertItem ( strString   ,
                                  STATE_INFO  ,
                                  STATE_INFO  ,
                                  hParent      ) ;
        }
    }
    return ( bRet ) ;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -