Pol  Revision:cb584c9
msjexhnd.h
Go to the documentation of this file.
1 
7 #ifndef CLIB_MSJEXHND_H
8 #define CLIB_MSJEXHND_H
9 
10 #include "Header_Windows.h"
11 #include <imagehlp.h>
12 namespace Pol
13 {
14 namespace Clib
15 {
17 {
18 public:
21 
22  void SetLogFileName( PTSTR pszLogFileName );
23 
24  // where report info is extracted and generated
25  static void GenerateExceptionReport( PEXCEPTION_POINTERS pExceptionInfo );
26  // entry point where control comes on an unhandled exception
27  static LONG WINAPI MSJUnhandledExceptionFilter( PEXCEPTION_POINTERS pExceptionInfo );
28 
29 private:
30  // Helper functions
31  static LPTSTR GetExceptionString( DWORD dwCode );
32  static BOOL GetLogicalAddress( PVOID addr, PTSTR szModule, DWORD len, DWORD& section,
33  DWORD& offset );
34 #ifndef _M_X64
35  static void IntelStackWalk( PCONTEXT pContext );
36 #endif
37 #ifndef _M_X64
38  static void ImagehlpStackWalk( PCONTEXT pContext );
39 #endif
40  static int __cdecl _tprintf( const TCHAR* format, ... );
41 
42 #if 1
43  static BOOL InitImagehlpFunctions( void );
44 #endif
45 
46  // Variables used by the class
47  static TCHAR m_szLogFileName[MAX_PATH];
48  static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter;
50 
51 #if 1
52  // Make typedefs for some IMAGEHLP.DLL functions so that we can use them
53  // with GetProcAddress
54  typedef BOOL( __stdcall* SYMINITIALIZEPROC )( HANDLE, LPSTR, BOOL );
55  typedef BOOL( __stdcall* SYMCLEANUPPROC )( HANDLE );
56 
57  typedef BOOL( __stdcall* STACKWALKPROC )( DWORD, HANDLE, HANDLE, LPSTACKFRAME, LPVOID,
61 
62  typedef LPVOID( __stdcall* SYMFUNCTIONTABLEACCESSPROC )( HANDLE, DWORD );
63 
64  typedef DWORD( __stdcall* SYMGETMODULEBASEPROC )( HANDLE, DWORD );
65 
66  typedef BOOL( __stdcall* SYMGETSYMFROMADDRPROC )( HANDLE, DWORD, PDWORD, PIMAGEHLP_SYMBOL );
67 
68  static SYMINITIALIZEPROC _SymInitialize;
69  static SYMCLEANUPPROC _SymCleanup;
70  static STACKWALKPROC _StackWalk;
71  static SYMFUNCTIONTABLEACCESSPROC _SymFunctionTableAccess;
72  static SYMGETMODULEBASEPROC _SymGetModuleBase;
73  static SYMGETSYMFROMADDRPROC _SymGetSymFromAddr;
74 
75 #endif
76 };
77 
78 extern MSJExceptionHandler g_MSJExceptionHandler; // global instance of class
79 }
80 }
81 #endif // CLIB_MSJEXHND_H
static TCHAR m_szLogFileName[MAX_PATH]
Definition: msjexhnd.h:47
static LPTOP_LEVEL_EXCEPTION_FILTER m_previousFilter
Definition: msjexhnd.h:48
static int __cdecl _tprintf(const TCHAR *format,...)
Definition: msjexhnd.cpp:397
static SYMFUNCTIONTABLEACCESSPROC _SymFunctionTableAccess
Definition: msjexhnd.h:71
MSJExceptionHandler g_MSJExceptionHandler
Definition: msjexhnd.cpp:48
static LONG WINAPI MSJUnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionInfo)
Definition: msjexhnd.cpp:97
static SYMGETMODULEBASEPROC _SymGetModuleBase
Definition: msjexhnd.h:72
static LPTSTR GetExceptionString(DWORD dwCode)
Definition: msjexhnd.cpp:185
static STACKWALKPROC _StackWalk
Definition: msjexhnd.h:70
void SetLogFileName(PTSTR pszLogFileName)
Definition: msjexhnd.cpp:86
static HANDLE m_hReportFile
Definition: msjexhnd.h:49
static void IntelStackWalk(PCONTEXT pContext)
Definition: msjexhnd.cpp:285
static SYMGETSYMFROMADDRPROC _SymGetSymFromAddr
Definition: msjexhnd.h:73
static SYMINITIALIZEPROC _SymInitialize
Definition: msjexhnd.h:68
typedef PFUNCTION_TABLE_ACCESS_ROUTINE
Definition: msjexhnd.h:57
static void ImagehlpStackWalk(PCONTEXT pContext)
Definition: msjexhnd.cpp:329
static void GenerateExceptionReport(PEXCEPTION_POINTERS pExceptionInfo)
Definition: msjexhnd.cpp:122
static BOOL InitImagehlpFunctions(void)
Definition: msjexhnd.cpp:418
Definition: berror.cpp:12
static BOOL GetLogicalAddress(PVOID addr, PTSTR szModule, DWORD len, DWORD &section, DWORD &offset)
Definition: msjexhnd.cpp:235
static SYMCLEANUPPROC _SymCleanup
Definition: msjexhnd.h:69