8#ifndef ErrLib_H_INCLUDED
9#define ErrLib_H_INCLUDED
23#define ERRLIB_REFERENCE
24#define ERRLIB_INLINE inline
26#define ERRLIB_REFERENCE &
27#define ERRLIB_INLINE __inline
30#pragma comment(lib, "advapi32.lib")
31#pragma comment(lib, "Dbghelp.lib")
33#define ErrLib_MaxNameLen 300
38#define ErrLib_MessageLen 1024
43#define ErrLib_StackLen 10000
46#define ERRLIB_API __declspec(dllexport)
48#define ERRLIB_API __declspec(dllimport)
49#pragma comment(lib, "ErrLib.lib")
57#define MSG_ERROR ((DWORD)0xC0020100L)
62#define MSG_WARNING ((DWORD)0x80020101L)
67#define MSG_INFORMATION ((DWORD)0x40020102L)
75#define ERRLIB_OUTPUT_LOGFILE 1
81#define ERRLIB_OUTPUT_STDERR 2
87#define ERRLIB_OUTPUT_MBOX 3
93#define ERRLIB_OUTPUT_EVENT_LOG 4
100#define ERRLIB_OUTPUT_CUSTOM 5
102#define ERRLIB_PARAM_VISUALCPPVERSION 100
103#define ERRLIB_PARAM_ISDEBUGBUILD 101
108#define ERRLIB_SYMBOL_NAME 1
113#define ERRLIB_SYMBOL_MODULE 2
118#define ERRLIB_SYMBOL_SOURCE 3
123typedef LONG (WINAPI * ERRLIB_EXCEPTION_CALLBACK) (
struct _EXCEPTION_POINTERS *,LPCWSTR,LPCWSTR);
126typedef void (WINAPI * ERRLIB_LOGGING_CALLBACK) (LPCWSTR,
void*);
135 uint64_t displacement;
136 WCHAR symbol[MAX_SYM_NAME];
137 WCHAR module[MAX_PATH];
138 WCHAR src_file[MAX_PATH];
157#define ERRLIB_WIN32_EXCEPTION 0xC0400000
160#define ERRLIB_COM_EXCEPTION 0xC0400001
163#define ERRLIB_APP_EXCEPTION 0xC0400002
180ERRLIB_API DWORD __stdcall ErrLib_GetWinapiErrorMessage(DWORD dwCode, BOOL localized, WCHAR* pOutput,
int cch);
183ERRLIB_API WCHAR* __stdcall ErrLib_FileNameFromPathW(WCHAR* path);
241ERRLIB_API BOOL __stdcall ErrLib_InitializeInternal();
250 BOOL ret = ErrLib_InitializeInternal();
262ERRLIB_API BOOL __stdcall ErrLib_InitTLS();
263ERRLIB_API BOOL __stdcall ErrLib_InitThread();
264ERRLIB_API
void __stdcall ErrLib_FreeThread();
412ERRLIB_API
void __stdcall
ErrLib_LogMessage(LPCWSTR lpwsMessage, BOOL visible, DWORD type, BOOL bIncludeStack );
444ERRLIB_API LONG __stdcall ErrLib_CatchCode(
struct _EXCEPTION_POINTERS * ex, DWORD FilteredCode);
445ERRLIB_API LONG __stdcall ErrLib_CatchAll(
struct _EXCEPTION_POINTERS * ex);
447ERRLIB_API LPVOID __stdcall ErrLib_StrBuf_GetPointer();
448ERRLIB_API LPVOID __stdcall ErrLib_ExArgs_GetPointer();
451ERRLIB_API
void __stdcall ErrLib_HResultToString(HRESULT hr,LPTSTR lpszFunction,WCHAR* buf);
452ERRLIB_API
void __stdcall ErrLib_GetHResultMessage(HRESULT hr,WCHAR* lpOutput,
int cch);
464#define ERRLIB_THROW(mes) {((ULONG_PTR*)ErrLib_ExArgs_GetPointer())[0]=(ULONG_PTR)mes;\
465RaiseException(ERRLIB_APP_EXCEPTION,0,1,((ULONG_PTR*)ErrLib_ExArgs_GetPointer()));}
477#define ERRLIB_THROW_IF_EQUAL(var,value,func) if((var)==(value)){DWORD ErrLibLocal_LastError=GetLastError();\
478ErrLib_ErrorMes(L#func,ErrLibLocal_LastError,(WCHAR*)ErrLib_StrBuf_GetPointer());((ULONG_PTR*)ErrLib_ExArgs_GetPointer())[0]=(ULONG_PTR)ErrLibLocal_LastError;\
479((ULONG_PTR*)ErrLib_ExArgs_GetPointer())[1]=(ULONG_PTR)ErrLib_StrBuf_GetPointer();RaiseException(ERRLIB_WIN32_EXCEPTION,0,2,(ULONG_PTR*)ErrLib_ExArgs_GetPointer());}
490#define ERRLIB_THROW_IF_FAILED(var,func) if(FAILED(var)){ErrLib_HResultToString((DWORD)var,L#func,(WCHAR*)ErrLib_StrBuf_GetPointer());\
491((ULONG_PTR*)ErrLib_ExArgs_GetPointer())[0]=(ULONG_PTR)var;((ULONG_PTR*)ErrLib_ExArgs_GetPointer())[1]=(ULONG_PTR)ErrLib_StrBuf_GetPointer();RaiseException(ERRLIB_COM_EXCEPTION,0,2,((ULONG_PTR*)ErrLib_ExArgs_GetPointer()));}
502#define ERRLIB_INVOKEAPI(func, ...) if(FALSE == func( ##__VA_ARGS__ )){DWORD ErrLibLocal_LastError=GetLastError();\
503ErrLib_ErrorMes((L#func),ErrLibLocal_LastError,(WCHAR*)ErrLib_StrBuf_GetPointer());\
504((ULONG_PTR*)ErrLib_ExArgs_GetPointer())[0]=(ULONG_PTR)ErrLibLocal_LastError;((ULONG_PTR*)ErrLib_ExArgs_GetPointer())[1]=(ULONG_PTR)ErrLib_StrBuf_GetPointer();\
505RaiseException(ERRLIB_WIN32_EXCEPTION,0,2,((ULONG_PTR*)ErrLib_ExArgs_GetPointer()));}
510#define ERRLIB_CATCH_ALL __except(ErrLib_CatchAll(GetExceptionInformation()))
515#define ERRLIB_CATCH(code) __except(ErrLib_CatchCode(GetExceptionInformation(),code))
ERRLIB_API BOOL __stdcall ErrLib_SetParameter(UINT param, UINT_PTR value)
ERRLIB_API LPWSTR __stdcall ErrLib_Except_GetStackTrace()
ERRLIB_API void __stdcall ErrLib_SetLogFilePath(LPCWSTR path)
ERRLIB_API ERRLIB_STACK_TRACE __stdcall ErrLib_GetStackTrace(CONTEXT *ctx)
BOOL ERRLIB_INLINE ErrLib_Initialize()
Definition: ErrLib.h:249
ERRLIB_API void __stdcall ErrLib_LogMessage(LPCWSTR lpwsMessage, BOOL visible, DWORD type, BOOL bIncludeStack)
ERRLIB_API BOOL __stdcall ErrLib_RegisterEventSource()
struct structERRLIB_STACK_FRAME ERRLIB_STACK_FRAME
ERRLIB_API const ERRLIB_STACK_FRAME *__stdcall ErrLib_ST_GetFrame(const ERRLIB_STACK_TRACE *pStack, int n)
ERRLIB_API void __stdcall ErrLib_PrintStack(CONTEXT *ctx, WCHAR *dest, size_t cch)
ERRLIB_API void __stdcall ErrLib_FreeStackTrace(ERRLIB_STACK_TRACE *pStack)
ERRLIB_API void __stdcall ErrLib_ErrorMes(LPTSTR lpszFunction, DWORD dw, WCHAR *buf)
ERRLIB_API DWORD __stdcall ErrLib_Except_GetCode()
ERRLIB_API void __stdcall ErrLib_SetLoggingCallback(ERRLIB_LOGGING_CALLBACK pCallback)
struct structERRLIB_STACK_TRACE ERRLIB_STACK_TRACE
ERRLIB_API void __stdcall ErrLib_LogExceptionInfo(DWORD dwExcCode, LPCWSTR lpwsMessage, LPCWSTR lpwsStackTrace, BOOL visible)
ERRLIB_API int __stdcall ErrLib_ST_GetFramesCount(const ERRLIB_STACK_TRACE *pStack)
ERRLIB_API uint64_t __stdcall ErrLib_ST_GetAddress(const ERRLIB_STACK_FRAME *pFrame)
ERRLIB_API DWORD __stdcall ErrLib_ST_GetSymLine(const ERRLIB_STACK_FRAME *pFrame)
ERRLIB_API void __stdcall ErrLib_SetExceptionCallback(ERRLIB_EXCEPTION_CALLBACK pCallback)
ERRLIB_API void __stdcall ErrLib_GetExceptionMessage(struct _EXCEPTION_POINTERS *ExceptionInfo, LPWSTR dest, size_t cch)
ERRLIB_API BOOL __stdcall ErrLib_UnregisterEventSource()
ERRLIB_API LPWSTR __stdcall ErrLib_Except_GetMessage()
ERRLIB_API uint64_t __stdcall ErrLib_ST_GetDisplacement(const ERRLIB_STACK_FRAME *pFrame)
ERRLIB_API ERRLIB_STACK_TRACE __stdcall ErrLib_Except_GetStackTraceData()
ERRLIB_API const WCHAR *__stdcall ErrLib_ST_GetStringProperty(const ERRLIB_STACK_FRAME *pFrame, int propId)