Changeset 64


Ignore:
Timestamp:
May 12, 2012, 10:23:26 AM (11 years ago)
Author:
roman
Message:
  • skip initial exception on re-attaching to process
  • email notification code (hardcoded)
  • cosmetic
Location:
trunk/Utilities/LogProcessExceptions
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/LogProcessExceptions/LogProcessExceptions.cpp

    r61 r64  
    11////////////////////////////////////////////////////////////
    2 // Copyright (C) Roman Ryltsov, 2008-2011
     2// Copyright (C) Roman Ryltsov, 2008-2012
    33// Created by Roman Ryltsov roman@alax.info
    44//
  • trunk/Utilities/LogProcessExceptions/LogProcessExceptions.rc

    r61 r64  
    8383    LTEXT           "Email:",IDC_ABOUT_EMAILTITLE,60,72,20,8
    8484    LTEXT           "<A HREF=""mailto:support@alax.info"">support@alax.info</A>",IDC_ABOUT_EMAIL,108,72,162,8,NOT WS_GROUP | WS_TABSTOP
    85     LTEXT           "Copyright © Alax.Info, Roman Ryltsov, 2008-2011",IDC_ABOUT_COPYRIGHT,60,84,210,8,SS_NOPREFIX
     85    LTEXT           "Copyright © Alax.Info, Roman Ryltsov, 2008-2012",IDC_ABOUT_COPYRIGHT,60,84,210,8,SS_NOPREFIX
    8686    DEFPUSHBUTTON   "OK",1,220,102,50,14
    8787    CONTROL         "",IDC_STATIC,"Static",SS_ETCHEDHORZ,6,122,267,1
     
    215215
    216216VS_VERSION_INFO VERSIONINFO
    217  FILEVERSION  1, 0, 0, 204
     217 FILEVERSION  1, 0, 0, 226
    218218 PRODUCTVERSION 1,0,0,1
    219219 FILEFLAGSMASK 0x3fL
     
    234234            VALUE "Created By", "Roman Ryltsov <roman@alax.info>"
    235235            VALUE "FileDescription", "Log Process Exceptions Utility"
    236             VALUE "FileVersion",  "1, 0, 0, 204\0"
     236            VALUE "FileVersion",  "1, 0, 0, 226\0"
    237237            VALUE "InternalName", "LogProcessExceptions"
    238             VALUE "LegalCopyright", "Copyright © Alax.Info, Roman Ryltsov, 2008-2011"
     238            VALUE "LegalCopyright", "Copyright © Alax.Info, Roman Ryltsov, 2008-2012"
    239239            VALUE "OriginalFilename", "LogProcessExceptions.exe"
    240240            VALUE "ProductName", "Log Process Exceptions Utility"
  • trunk/Utilities/LogProcessExceptions/MainWizard.h

    r61 r64  
    11////////////////////////////////////////////////////////////
    2 // Copyright (C) Roman Ryltsov, 2008-2011
     2// Copyright (C) Roman Ryltsov, 2008-2012
    33// Created by Roman Ryltsov roman@alax.info
    44//
     
    1111#include <atlsecurity.h>
    1212#include "AboutDialog.h"
     13#include "..\..\..\Repository-Private\Utilities\EmailTools\Message.h"
    1314
    1415#if PSAPI_VERSION == 1
     
    869870                CObjectPtr<CThread> m_pDebugThread;
    870871                UINT m_nExceptionIndex;
     872                BOOL m_bSkipInitialException;
    871873                UINT m_nUserIndex;
     874                CObjectPtr<CMessageQueue> m_pMessageQueue;
    872875
    873876                VOID UpdateButtons() throw()
     
    940943                                                        _Z4(atlTraceGeneral, 4, _T(".ExceptionCode %d, .ExceptionFlags %d, .dwFirstChance %d\n"), DebugInformation.ExceptionRecord.ExceptionCode, DebugInformation.ExceptionRecord.ExceptionFlags, DebugInformation.dwFirstChance);
    941944                                                        #pragma region Skip Initial Debugger Attachment Exception
    942                                                         if(DebugInformation.ExceptionRecord.ExceptionCode == 0x80000003 && !m_nExceptionIndex)
     945                                                        if(DebugInformation.ExceptionRecord.ExceptionCode == 0x80000003 && m_bSkipInitialException)
    943946                                                        {
    944                                                                 AppendLog(AtlFormatString(_T("Skipping initial debugger attachment exception (0x%08x)\r\n"), DebugInformation.ExceptionRecord.ExceptionCode));
     947                                                                AppendLog(AtlFormatString(_T("Skipping initial debugger attachment exception (0x%08X)\r\n"), DebugInformation.ExceptionRecord.ExceptionCode));
     948                                                                m_bSkipInitialException = FALSE;
    945949                                                                break;
    946950                                                        }
     
    950954                                                        if(DebugInformation.ExceptionRecord.ExceptionCode == 0x406D1388)
    951955                                                        {
    952                                                                 AppendLog(AtlFormatString(_T("Skipping thread name setting exception (0x%08x)\r\n"), DebugInformation.ExceptionRecord.ExceptionCode));
     956                                                                AppendLog(AtlFormatString(_T("Skipping thread name setting exception (0x%08X)\r\n"), DebugInformation.ExceptionRecord.ExceptionCode));
    953957                                                                break;
    954958                                                        }
    955959                                                        #pragma endregion
    956960                                                        #pragma region Skip C++ Exceptions (Debug)
    957                                                         #if _DEVELOPMENT && FALSE
     961                                                        #if _DEVELOPMENT //&& FALSE
     962                                                        #if !defined(_WIN64)
    958963                                                        COMPILER_MESSAGE("Debug: Skip C++ Exceptions")
    959964                                                        if(DebugInformation.ExceptionRecord.ExceptionCode == 0xE06D7363)
    960965                                                        {
    961                                                                 AppendLog(AtlFormatString(_T("Skipping C++ exception (0x%08x)\r\n"), DebugInformation.ExceptionRecord.ExceptionCode));
    962                                                                 break;
     966                                                                BOOL bSkip = TRUE;
     967                                                                if(DebugInformation.ExceptionRecord.NumberParameters >= 2)
     968                                                                {
     969                                                                        HRESULT nNativeExceptionCode = S_OK;
     970                                                                        SIZE_T nReadDataSize = 0;
     971                                                                        if(ReadProcessMemory(Process, (const VOID*) DebugInformation.ExceptionRecord.ExceptionInformation[1], &nNativeExceptionCode, sizeof nNativeExceptionCode, &nReadDataSize))
     972                                                                                if(nReadDataSize == sizeof nNativeExceptionCode)
     973                                                                                {
     974                                                                                        if((nNativeExceptionCode & 0x0FFF0000) != 0x01390000) // DVRServerStretch
     975                                                                                        {
     976                                                                                                AppendLog(AtlFormatString(_T("Skipping C++ exception (0x%08X, 0x%08X)\r\n"), DebugInformation.ExceptionRecord.ExceptionCode, nNativeExceptionCode));
     977                                                                                                break;
     978                                                                                        } else
     979                                                                                                bSkip = FALSE;
     980                                                                                }
     981                                                                }
     982                                                                if(bSkip)
     983                                                                {
     984                                                                        AppendLog(AtlFormatString(_T("Skipping C++ exception (0x%08X)\r\n"), DebugInformation.ExceptionRecord.ExceptionCode));
     985                                                                        break;
     986                                                                }
    963987                                                        }
     988                                                        #endif // !defined(_WIN64)
    964989                                                        #endif // _DEVELOPMENT
    965990                                                        #pragma endregion
     
    9821007                                                                sName.AppendFormat(_T("%s-%d-%03d"), pszProcessFileName, nProcessIdentifier, m_nExceptionIndex++);
    9831008                                                                sName.AppendFormat(_T("-%08x"), DebugInformation.ExceptionRecord.ExceptionCode);
     1009                                                                HRESULT nNativeExceptionCode = S_OK;
    9841010                                                                if(DebugInformation.ExceptionRecord.ExceptionCode == 0xE06D7363 && DebugInformation.ExceptionRecord.NumberParameters >= 2)
    9851011                                                                {
    986                                                                         HRESULT nNativeExceptionCode = 0;
    9871012                                                                        SIZE_T nReadDataSize = 0;
    9881013                                                                        if(ReadProcessMemory(Process, (const VOID*) DebugInformation.ExceptionRecord.ExceptionInformation[1], &nNativeExceptionCode, sizeof nNativeExceptionCode, &nReadDataSize))
     
    9981023                                                                __E(MiniDumpWriteDump(Process, nProcessIdentifier, File, Type, ExceptionPointers.ContextRecord ? &ExceptionInformation : NULL, NULL, NULL));
    9991024                                                                AppendLog(AtlFormatString(_T("Written exception minidump into file %s\r\n"), sName));
     1025                                                                #pragma region Message Notification
     1026                                                                _ATLTRY
     1027                                                                {
     1028                                                                        if(!m_pMessageQueue)
     1029                                                                                m_pMessageQueue.Construct();
     1030                                                                        CObjectPtr<CMessage> pMessage;
     1031                                                                        pMessage.Construct();
     1032                                                                        #pragma region Fixed Initialization
     1033                                                                        __C(pMessage->put_ServerHost(CComBSTR(_T("smtp.gmail.com"))));
     1034                                                                        __C(pMessage->put_Sender(CComBSTR(_T("Roman Ryltsov <ryltsov@gmail.com>"))));
     1035                                                                        __C(pMessage->put_ToRecipients(CComBSTR(_T("Roman Ryltsov <ryltsov@gmail.com>"))));
     1036                                                                        __C(pMessage->put_TransportLayerSecurity(ATL_VARIANT_TRUE));
     1037                                                                        __C(pMessage->put_AuthMethods(CComBSTR(_T("login"))));
     1038                                                                        __C(pMessage->put_AuthName(CComBSTR(_T("ryltsov@gmail.com"))));
     1039                                                                        __C(pMessage->put_AuthPassword(CComBSTR(_T(""))));
     1040                                                                        #pragma endregion
     1041                                                                        TCHAR pszComputerName[MAX_COMPUTERNAME_LENGTH] = { 0 };
     1042                                                                        DWORD nComputerNameLength = DIM(pszComputerName);
     1043                                                                        _W(GetComputerName(pszComputerName, &nComputerNameLength));
     1044                                                                        CString sSubject = AtlFormatString(_T("Exception 0x%08X in %s on %s"), DebugInformation.ExceptionRecord.ExceptionCode, pszProcessFileName, pszComputerName);
     1045                                                                        CString sBody;
     1046                                                                        sBody += _T("Hi,") _T("\r\n")
     1047                                                                                _T("\r\n");
     1048                                                                        sBody += AtlFormatString(_T("This is Log Process Exception notifying on exception occurred:") _T("\r\n")
     1049                                                                                _T("\r\n"),
     1050                                                                                pszComputerName);
     1051                                                                        sBody += AtlFormatString(_T(" * ") _T("Code: 0x%08X") _T("\r\n"), DebugInformation.ExceptionRecord.ExceptionCode);
     1052                                                                        if(nNativeExceptionCode != S_OK)
     1053                                                                                sBody += AtlFormatString(_T(" * ") _T("Native ATL Code: 0x%08X") _T("\r\n"), nNativeExceptionCode);
     1054                                                                        sBody += AtlFormatString(_T(" * ") _T("Local Time: %s") _T("\r\n"), _StringHelper::FormatDateTime());
     1055                                                                        sBody += AtlFormatString(_T(" * ") _T("Computer Name: %s") _T("\r\n"), pszComputerName);
     1056                                                                        // WARN: Attaching a minidump file requires it being closed by API (should we do ContinueDebugEvent and/or wait?)
     1057                                                                        //sBody += _T("\r\n")
     1058                                                                        //      _T("Minidump attached.") _T("\r\n");
     1059                                                                        __C(pMessage->put_Subject(CComBSTR(sSubject)));
     1060                                                                        __C(pMessage->put_Body(CComBSTR(sBody)));
     1061                                                                        //CObjectPtr<CMessage::CComAttachment> pAttachment = pMessage->GetAttachments()->Add();
     1062                                                                        //__C(pAttachment->put_Name(CComBSTR(sName)));
     1063                                                                        //__C(pAttachment->LoadFromFile(CComBSTR(sPath)));
     1064                                                                        m_pMessageQueue->Add(pMessage);
     1065                                                                }
     1066                                                                _ATLCATCHALL()
     1067                                                                {
     1068                                                                        _Z_EXCEPTION();
     1069                                                                }
     1070                                                                #pragma endregion
    10001071                                                        }
    10011072                                                        _ATLCATCHALL()
     
    10991170                                                AppendLog(AtlFormatString(_T("Attaching to process %d (%s)...\r\n"), ProcessData.m_nIdentifier, ProcessData.GetFileName()));
    11001171                                                EnableTokenDebugPrivilege();
     1172                                                m_bSkipInitialException = TRUE;
    11011173                                                AttachDebug();
    11021174                                        }
  • trunk/Utilities/LogProcessExceptions/stdafx.cpp

    r61 r64  
    11////////////////////////////////////////////////////////////
    2 // Copyright (C) Roman Ryltsov, 2008-2011
     2// Copyright (C) Roman Ryltsov, 2008-2012
    33// Created by Roman Ryltsov roman@alax.info
    44//
  • trunk/Utilities/LogProcessExceptions/stdafx.h

    r61 r64  
    11////////////////////////////////////////////////////////////
    2 // Copyright (C) Roman Ryltsov, 2008-2011
     2// Copyright (C) Roman Ryltsov, 2008-2012
    33// Created by Roman Ryltsov roman@alax.info
    44//
Note: See TracChangeset for help on using the changeset viewer.