亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? excepthandler.cpp

?? CExceptionLogger
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
/*  
Module : EXCEPTHANDLER.CPP
Purpose: Implementation for a class which intercepts and logs details about unhandled exceptions
         such as access violations, stack overflows and division by zero.
         The class is based upon the February 2002 MSDN article called "Under the Hood: Improved
         Error Reporting with DBGHELP 5.1 by Matt Pietrek. 

         To compile the class you need the November 2002 Platform SDK or later installed.
         You can add the ExceptHandler.cpp/h files directly to your C++ project or put the exception
         handler class in a DLL and arrange for your app / dll to get it installed via a LoadLibrary
         call.

         A binary version of the ExceptHandler is provided in the XCPTHLR.DLL which is included
         in this distribution.

         To get this code to work on client machines you will need to arrange for the distribution
         of the DBGHELP 5.1 dll which can be obtained from November 2002 Platform SDK or later. Select
         "Install Debugging Tools for Windows" to get the DLL installed on your machine. Also
         note that the DBGHELP dll is under Windows System File protection on recent versions of Windows, 
         so put the DBGHELP dll in the same directory as your application.

         To provide symbols for your code in release mode, you should modify your projects settings as 
         follows:

         1. Project Settings -> Link -> Debug (Category) , Enable "Debug Info" and pick "Microsoft Format".
         2. Same Place, pick "Separate Types".
         3. In the Project Options edit box on the same page, add "/OPT:REF". This will ensure that 
         unreferrenced functions are removed from the resultant binary.
         4. Project Settings -> C++ -> General (Category) Debug Info Combo -> "Program Database"
         5. Sample Place, you may need to set "Optimizations" to "Disable (Debug)" if your are getting
         call stacks which do not make sense.

         Also remember to ship the resultant pdb files with your code (or arrange for them to be somehow
         available) so that CExceptionLogger can give the source and line information in the resultant
         log.

         By default the CExceptionLogger class will generate a log file with the name "name of exe.exception".
         In this file (which is ASCII if the CExceptionLogger is build as ASCII and UNICODE if the 
         CExceptionLogger is build as a UNICODE) is the following information:

         1.  Date and Time when the exception occurred.
         2.  Exception Code
         3.  Details about exception if an access violation
         4.  Details about exception address including linear address, section, offset and module path
         5.  Full path of the process
         6.  Current Win32 working directory
         7.  Command line for the process
         8.  Process ID
         9.  Thread ID where the exception occurred.
         10. Enumeration of all the threads in the process (assuming Toolhelp32 is available) including
              i)   Thread ID
              ii)  Priority and Delta priority
              iii) References
              iv)  Creation Time
              v)   Kernel and User Time
         11. Enumeration of the Modules in the process (again only if Toolhelp32 is available) including
              i)   Name and full path
              ii)  Global and per Process reference count
              iii) module handle
              iv)  size
              v)   All symbols for that module fully expanded (see details later)
         12. All the x86 registers
         13. Call Stack where exception occured, including section, offset, module, function and line 
             information. 
         14. At each stack frame as well as for all modules, all variables and parameters all also logged. 
             All basic types such as voids, chars, shorts, words, ints, DWORDS, floats, doubles and longs 
             are logged. UDT's including structs, unions and classes are also fully recursed into to 
             display their members. Info for each type includes its name, address, type and value. 
             In addition if the variable is a array, each value in the array is fully logged.

         Please note that due to all the symbols which even a very small appp has, each log of an exception
         can generate upwards of 100K of data or more. My opinion on this is that disk space is cheap while 
         developers time looking for an intermittent release only bug is not!!!!!.             

         References:

         Bugslayer,      MSJ,  August 1998 by John Robbins, http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0898/bugslayer0898.htm
         Under the Hood, MSDN, March 2002 by Matt Pietrek,  http://msdn.microsoft.com/msdnmag/issues/02/03/Hood/Hood0203.asp



Created: PJN / 14-03-2002
History: None


Copyright (c) 2002 by PJ Naughter.  (Web: www.naughter.com, Email: pjna@naughter.com)

All rights reserved.

Copyright / Usage Details:

You are allowed to include the source code in any product (commercial, shareware, freeware or otherwise) 
when your product is released in binary form. You are allowed to modify the source code in any way you want 
except you cannot modify the copyright details at the top of each module. If you want to distribute source 
code with your application, then you are only allowed to distribute versions released by the author. This is 
to maintain a single distribution point for the source code. 

*/



/////////////////////// Includes //////////////////////////////
#include "stdafx.h"
#include "ExceptHandler.h"
#ifndef _INC_TCHAR
#pragma message("To avoid this message, put tchar.h in your PCH")
#include <tchar.h>
#endif
#ifndef _INC_TOOLHELP32
#pragma message("To avoid this message, put tlhelp32.h in your PCH")
#include <tlhelp32.h>
#endif
#ifndef _INC_STDIO
#pragma message("To avoid this message, put stdio.h in your PCH")
#include <stdio.h>
#endif



/////////////////////// Macros / Defines  / Locals //////////////////////

#pragma comment(lib, "dbghelp.lib")
#pragma comment(lib, "oleaut32.lib")

//Class which looks after pulling in ToolHelp32 and OpenThread dynamically. 
//That way the CExceptionlogger class will work on NT 4 (without of course the Thread
//and module lists) and Win95 which does not have OpenThread (but does
//have Toolhelp32!!!!)
class _EXCEPTION_LOGGER_DATA
{
public:
//Constructors /Destructors
  _EXCEPTION_LOGGER_DATA();

  typedef HANDLE (WINAPI CREATETOOLHELP32SNAPSHOT)(DWORD, DWORD);
  typedef CREATETOOLHELP32SNAPSHOT* LPCREATETOOLHELP32SNAPSHOT;

  typedef BOOL (WINAPI THREAD32FIRST)(HANDLE, LPTHREADENTRY32);
  typedef THREAD32FIRST* LPTHREAD32FIRST;

  typedef BOOL (WINAPI THREAD32NEXT)(HANDLE, LPTHREADENTRY32);
  typedef THREAD32NEXT* LPTHREAD32NEXT;

  typedef BOOL (WINAPI MODULE32FIRST)(HANDLE, LPMODULEENTRY32);
  typedef MODULE32FIRST* LPMODULE32FIRST;

  typedef BOOL (WINAPI MODULE32NEXT)(HANDLE, LPMODULEENTRY32);
  typedef MODULE32NEXT* LPMODULE32NEXT;

  typedef HANDLE (WINAPI OPENTHREAD)(DWORD, BOOL, DWORD);
  typedef OPENTHREAD* LPOPENTHREAD;

  LPCREATETOOLHELP32SNAPSHOT m_lpfnCreateToolhelp32Snapshot;
  LPTHREAD32FIRST            m_lpfnThread32First;
  LPTHREAD32NEXT             m_lpfnThread32Next;
  LPMODULE32FIRST            m_lpfnModule32First;
  LPMODULE32NEXT             m_lpfnModule32Next;
  LPOPENTHREAD               m_lpfnOpenThread;
  HMODULE                    m_hKernel32;

  void ResetFunctionPointers();
};

_EXCEPTION_LOGGER_DATA::_EXCEPTION_LOGGER_DATA()
{
  m_hKernel32 = LoadLibrary(_T("KERNEL32.DLL"));
  if (m_hKernel32)
  {
    m_lpfnOpenThread               = (LPOPENTHREAD) GetProcAddress(m_hKernel32, "OpenThread");
    m_lpfnCreateToolhelp32Snapshot = (LPCREATETOOLHELP32SNAPSHOT) GetProcAddress(m_hKernel32, "CreateToolhelp32Snapshot");
    m_lpfnThread32First            = (LPTHREAD32FIRST) GetProcAddress(m_hKernel32, "Thread32First");
    m_lpfnThread32Next             = (LPTHREAD32NEXT) GetProcAddress(m_hKernel32, "Thread32Next");
#ifdef _UNICODE
    m_lpfnModule32First = (LPMODULE32FIRST) GetProcAddress(m_hKernel32, "Module32FirstW");
    m_lpfnModule32Next  = (LPMODULE32NEXT) GetProcAddress(m_hKernel32, "Module32NextW");
#else
    m_lpfnModule32First = (LPMODULE32FIRST) GetProcAddress(m_hKernel32, "Module32First");
    m_lpfnModule32Next  = (LPMODULE32NEXT) GetProcAddress(m_hKernel32, "Module32Next");
#endif
  }
  
  //Any function pointer NULL, then set them all to NULL. Helps simplify the code which 
  //uses the function pointers
  if (m_lpfnCreateToolhelp32Snapshot == NULL || m_lpfnThread32First == NULL || 
      m_lpfnThread32Next == NULL || m_lpfnModule32First == NULL || m_lpfnModule32Next == NULL)
    ResetFunctionPointers();
}

void _EXCEPTION_LOGGER_DATA::ResetFunctionPointers()
{
  m_lpfnCreateToolhelp32Snapshot = NULL;
  m_lpfnThread32First = NULL;
  m_lpfnThread32Next = NULL;
  m_lpfnModule32First = NULL;
  m_lpfnModule32Next = NULL;
  if (m_hKernel32)
  {
    FreeLibrary(m_hKernel32);
    m_hKernel32 = NULL;
  }
}

//Statics used by the CExceptionLogger class
TCHAR                        CExceptionLogger::m_pszLogFilename[_MAX_PATH];
LPTOP_LEVEL_EXCEPTION_FILTER CExceptionLogger::m_pPreviousFilter = NULL;
HANDLE                       CExceptionLogger::m_hLogFile = INVALID_HANDLE_VALUE;
TCHAR                        CExceptionLogger::m_szTempLogLine[4096];
TCHAR                        CExceptionLogger::m_szTempFileName[_MAX_PATH];
BYTE                         CExceptionLogger::m_bySymbolInfo[sizeof(SYMBOL_INFO) + 1024];


//The one and only instance of the crash handler
CExceptionLogger g_CrashHandlerLogger;

//The local variable which handle the function pointers
_EXCEPTION_LOGGER_DATA _ExceptionLoggerData;



/////////////////////// Implementation ////////////////////////

CExceptionLogger::CExceptionLogger()
{
  //Install our exception handler
  m_pPreviousFilter = SetUnhandledExceptionFilter(UnHandledExceptionFilter);

  //The name of the Crash handler log file will by default
  //be "name of exe.crash.log"
  GetModuleFileName(NULL, m_pszLogFilename, _MAX_PATH);
  
  //Note we use the C Runtime here as the exception has not occured yet, so we
  //can be confident that the CRT is ok at this time
  _tcscat(m_pszLogFilename, _T(".exception"));
}

CExceptionLogger::~CExceptionLogger()
{
  //Restore the old exception handler
  SetUnhandledExceptionFilter(m_pPreviousFilter);
}

long CExceptionLogger::UnHandledExceptionFilter(_EXCEPTION_POINTERS* pExceptionInfo)
{
  //Open up the log file, Notice we use FILE_FLAG_WRITE_THROUGHT to 
  //avoid caching of writes. That way if our code goes belly up, we will
  //at least have all the data up to then safely written to disk
  m_hLogFile = CreateFile(m_pszLogFilename, GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_FLAG_WRITE_THROUGH, 0);
  if (m_hLogFile != INVALID_HANDLE_VALUE)
  {
    //Seek to the end of the Log file so that we always append to the crash log file
    SetFilePointer(m_hLogFile, 0, 0, FILE_END);

    //Let the helper function do its job
    GenerateCrashLog(pExceptionInfo);

    //Close the file now that we are finished with it
    CloseHandle(m_hLogFile);
    m_hLogFile = INVALID_HANDLE_VALUE;
  }

  //Chain to the previous exception if there is one
  if (m_pPreviousFilter)
    return m_pPreviousFilter(pExceptionInfo);
  else
    return EXCEPTION_CONTINUE_SEARCH;
}

void CExceptionLogger::GenerateCrashLog(_EXCEPTION_POINTERS* pExceptionInfo)
{
  //Write out a banner first to separate multiple log entries
  Log(_T("-----------------------------------------------------\r\n"));

  //get the current time so that it goes into the file
  SYSTEMTIME st;
  GetLocalTime(&st);
  Log(_T("Time of Exception: %02d:%02d:%02d.%03d %d/%d/%d (D/M/Y)\r\n"), st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, st.wDay, st.wMonth, st.wYear);

  //Log the type of unhandled exception
  Log(_T("Exception Code: 0x%08x\r\n"), pExceptionInfo->ExceptionRecord->ExceptionCode);

  //Display extra info if an Access Violation
  if (pExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION)
  {
    if (pExceptionInfo->ExceptionRecord->NumberParameters > 0)
    {
      if (pExceptionInfo->ExceptionRecord->ExceptionInformation[0] == 0)
        Log(_T("Access Violation Exception: Due to the thread attempting to read from an inaccessible address\r\n"));
      else
        Log(_T("Access Violation Exception: Due to the thread attempting to write to an inaccessible address\r\n"));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
色香色香欲天天天影视综合网| 亚洲精品一区二区三区福利| 一区视频在线播放| 不卡一区二区三区四区| 一区二区日韩电影| 欧美三级视频在线| 午夜精品久久久久久久99樱桃| 欧美日韩三级一区| 免费亚洲电影在线| 久久久久久久电影| 色综合天天狠狠| 午夜精品久久久久| 日韩欧美国产系列| 懂色av一区二区三区免费看| 亚洲精品va在线观看| 在线播放/欧美激情| 国产乱码精品一区二区三区忘忧草| 亚洲国产成人在线| 欧美午夜一区二区三区| 精品一区二区综合| 国产精品免费免费| 欧美日韩精品欧美日韩精品一| 美女精品一区二区| 国产精品伦理一区二区| 在线观看亚洲成人| 国产一区二区三区免费播放| 自拍偷在线精品自拍偷无码专区| 色综合一个色综合| 韩国精品免费视频| 亚洲欧美激情小说另类| 日韩欧美二区三区| 91在线视频网址| 极品少妇xxxx精品少妇| 日韩美女精品在线| 欧美大尺度电影在线| 色综合久久六月婷婷中文字幕| 美女视频一区在线观看| 洋洋成人永久网站入口| 日韩一区二区三区观看| 99久久精品国产一区| 欧美aaaaaa午夜精品| 一区二区三区日韩精品视频| 久久影院电视剧免费观看| 91福利小视频| 高清av一区二区| 麻豆91在线播放| 亚洲精品日韩综合观看成人91| 久久理论电影网| 91麻豆精品国产综合久久久久久| 92精品国产成人观看免费| 国内精品免费在线观看| 午夜欧美一区二区三区在线播放| 国产精品伦理一区二区| 国产丝袜在线精品| 欧美成人精品福利| 欧美日韩国产首页| 在线区一区二视频| 成人av第一页| 国产91在线看| 国产精品一二二区| 九色综合狠狠综合久久| 日本午夜精品视频在线观看 | 欧美日韩高清一区二区| 99久久精品免费看国产| 成人精品鲁一区一区二区| 成人黄色软件下载| 日本美女视频一区二区| 一区在线中文字幕| 成人午夜视频在线观看| 日本亚洲一区二区| 日韩电影网1区2区| 午夜伦理一区二区| 亚洲国产sm捆绑调教视频| 亚洲精品国产品国语在线app| 国产精品女同一区二区三区| 国产欧美日韩一区二区三区在线观看| 亚洲精品在线网站| www国产成人免费观看视频 深夜成人网| 欧美精品乱码久久久久久按摩| 欧美日韩不卡一区| 欧美日韩在线一区二区| 欧美疯狂性受xxxxx喷水图片| 欧美日韩高清不卡| 日韩欧美国产电影| 26uuu国产电影一区二区| 久久综合九色欧美综合狠狠 | 欧美tickling挠脚心丨vk| 日韩欧美国产午夜精品| 精品成人免费观看| 国产亚洲综合色| √…a在线天堂一区| 亚洲激情第一区| 午夜久久电影网| 美女视频一区在线观看| 国产精品996| 成人av在线电影| 91精品办公室少妇高潮对白| 欧美亚洲禁片免费| 日韩欧美一二区| 国产日韩欧美一区二区三区乱码| 国产精品久久久久久久久图文区| 一区二区视频在线| 蜜臀久久久久久久| 国产aⅴ精品一区二区三区色成熟| 北条麻妃一区二区三区| 欧美日韩在线观看一区二区 | 欧美亚洲动漫另类| 精品久久国产字幕高潮| 92国产精品观看| 欧美在线一区二区| 欧美一区二区视频免费观看| 精品久久人人做人人爰| 国产精品福利av| 视频一区视频二区中文字幕| 国产一区二区三区四区在线观看| 91在线视频在线| 日韩免费视频一区二区| 国产精品三级av| 日本中文字幕一区二区视频 | 在线电影一区二区三区| 精品美女在线观看| 自拍视频在线观看一区二区| 天堂蜜桃91精品| av激情综合网| 日韩欧美亚洲另类制服综合在线| 亚洲欧美在线视频| 美女网站一区二区| 欧美一区二区三区喷汁尤物| 久久久午夜精品| 污片在线观看一区二区| 成人av在线播放网址| 日韩欧美www| 亚洲一区二区偷拍精品| 国产91精品欧美| 日韩美女天天操| 亚洲午夜在线观看视频在线| 成人黄色在线视频| 精品国产露脸精彩对白| 亚洲国产美国国产综合一区二区| 国产.欧美.日韩| 日韩欧美一区电影| 午夜精品一区二区三区免费视频| 99综合影院在线| 国产欧美精品一区二区色综合朱莉| 三级影片在线观看欧美日韩一区二区| av午夜精品一区二区三区| 国产午夜精品一区二区三区嫩草 | 欧美日本在线播放| 亚洲人成人一区二区在线观看| 国产乱码精品一品二品| 日韩一区二区三区精品视频| 亚洲6080在线| 91黄色免费看| 亚洲精选一二三| 99在线精品观看| 国产精品美女久久久久aⅴ| 国产乱子伦一区二区三区国色天香| 欧美精品1区2区3区| 亚洲成人午夜影院| 色久综合一二码| 亚洲男女毛片无遮挡| 色综合天天综合给合国产| 国产精品欧美久久久久无广告| 国产乱码字幕精品高清av| 精品国产一二三| 国产综合成人久久大片91| 精品国产第一区二区三区观看体验| 五月天一区二区| 欧美怡红院视频| 精品av久久707| 国产高清成人在线| 精品处破学生在线二十三| 亚洲一区二区不卡免费| 欧美日韩国产片| 日本视频免费一区| 国产精品女人毛片| 欧美日韩激情一区二区| 国产综合久久久久影院| 亚洲精品视频免费观看| 久久综合色鬼综合色| 欧美最猛黑人xxxxx猛交| 国产在线播放一区二区三区| 亚洲视频一区二区在线观看| 精品久久久久av影院| av一区二区三区在线| 欧美蜜桃一区二区三区| 亚洲在线中文字幕| 欧美日韩国产不卡| 美女视频黄久久| 日本一区二区三区在线不卡| 福利一区在线观看| 一级中文字幕一区二区| 91精品国产高清一区二区三区蜜臀| 麻豆国产精品官网| 一区二区三区四区高清精品免费观看| 一本一道综合狠狠老| 偷拍一区二区三区| 久久综合色播五月| 一本色道久久加勒比精品| 天天做天天摸天天爽国产一区|