27 LRESULT CALLBACK
cbtproc(INT code, WPARAM wParam, LPARAM lParam)
29 HWND
window = (HWND)wParam;
30 if (code == HCBT_ACTIVATE)
32 if (GetDlgItem(window, IDCANCEL) !=
NULL)
34 SetDlgItemText(window, IDCANCEL, L
"Report");
36 UnhookWindowsHookEx(
hhk);
38 else CallNextHookEx(
hhk, code, wParam, lParam);
44 if (code == EXCEPTION_BREAKPOINT || code == EXCEPTION_SINGLE_STEP)
return false;
50 if (code == EXCEPTION_ACCESS_VIOLATION)
return "Access Violation!";
51 else if (code == EXCEPTION_ARRAY_BOUNDS_EXCEEDED)
return "Array out of bounds access error!";
52 else if (code == EXCEPTION_DATATYPE_MISALIGNMENT)
return "Read / write of misaligned data!";
53 else if (code == EXCEPTION_FLT_DENORMAL_OPERAND)
return "Denormal floating point operation!";
54 else if (code == EXCEPTION_FLT_DIVIDE_BY_ZERO)
return "Unhandled floating point division by zero!";
55 else if (code == EXCEPTION_FLT_INEXACT_RESULT)
return "Inexact floating point result!";
56 else if (code == EXCEPTION_FLT_INVALID_OPERATION)
return "Invalid floating point operation!";
57 else if (code == EXCEPTION_FLT_OVERFLOW)
return "Floating point overflow!";
58 else if (code == EXCEPTION_FLT_STACK_CHECK)
return "Floating point stack overflow / underflow!";
59 else if (code == EXCEPTION_FLT_UNDERFLOW)
return "Floating point underflow!";
60 else if (code == EXCEPTION_ILLEGAL_INSTRUCTION)
return "Illegal CPU instruction!\nPossibly newer CPU architecture is required";
61 else if (code == EXCEPTION_IN_PAGE_ERROR)
return "In page error!\nPossibly network connection error when running the program over network";
62 else if (code == EXCEPTION_INT_DIVIDE_BY_ZERO)
return "Unhandled integer division by zero!";
63 else if (code == EXCEPTION_INT_OVERFLOW)
return "Integer overflow!";
64 else if (code == EXCEPTION_INVALID_DISPOSITION)
return "Invalid disposition error!";
65 else if (code == EXCEPTION_NONCONTINUABLE_EXCEPTION)
return "Noncontinuable exception occured!";
66 else if (code == EXCEPTION_PRIV_INSTRUCTION)
return "Error due to invalid call to priviledged instruction!";
67 else if (code == EXCEPTION_STACK_OVERFLOW)
return "Stack overflow error!";
68 else if (code == VcppException(ERROR_SEVERITY_ERROR, ERROR_MOD_NOT_FOUND)) {
69 auto details = (DelayLoadInfo*)ep->ExceptionRecord->ExceptionInformation[0];
72 return rs2::to_string() <<
"Could not find " << dll_name <<
" library required for " <<
fname <<
".\nMake sure all program dependencies are reachable or download standalone version of the App from our GitHub";
81 std::wstring ws(error.begin(), error.end());
82 SetWindowsHookEx(WH_CBT, &
cbtproc, 0, GetCurrentThreadId());
83 auto button = MessageBox(
NULL, ws.c_str(), L
"Something went wrong...", MB_ICONERROR | MB_OKCANCEL);
84 if (button == IDCANCEL)
93 ss <<
"Intel RealSense Viewer / Depth Quality Tool has crashed with the following error message:\n";
106 auto code = ep->ExceptionRecord->ExceptionCode;
110 std::string error =
"Unhandled exception escaping from a worker thread!\nError type: ";
115 return EXCEPTION_CONTINUE_SEARCH;
119 int main(
int argv,
const char** argc);
121 int filter(
unsigned int code,
struct _EXCEPTION_POINTERS *ep)
126 std::cerr <<
"Program terminated due to an unrecoverable SEH exception:\n" <<
error;
127 return EXCEPTION_EXECUTE_HANDLER;
129 else return EXCEPTION_CONTINUE_SEARCH;
140 res =
main(argv, argc);
142 __except (
filter(GetExceptionCode(), GetExceptionInformation()))
150 _In_ HINSTANCE hInstance,
151 _In_ HINSTANCE hPrevInstance,
152 _In_ LPSTR lpCmdLine,
158 std::shared_ptr<LPWSTR> szArgList(CommandLineToArgvW(GetCommandLine(), &argCount), LocalFree);
159 if (szArgList ==
NULL)
return main(0,
nullptr);
161 std::vector<std::string>
args;
162 for (
int i = 0;
i < argCount;
i++)
164 std::wstring ws = szArgList.get()[
i];
174 catch (...) {
exit(-1); }
180 std::vector<const char*> argc;
184 std::stringstream ss;
187 int res =
run_main(static_cast<int>(argc.size()), argc.data());
189 if (res == EXIT_FAILURE)
std::string exception_code_to_string(int code, struct _EXCEPTION_POINTERS *ep)
int rs2_get_api_version(rs2_error **error)
int filter(unsigned int code, struct _EXCEPTION_POINTERS *ep)
GLsizei const GLchar *const * string
static const textual_icon link
void open_url(const char *url)
std::string url_encode(const std::string &value)
bool should_intercept(int code)
int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nCmdShow)
static const textual_icon exit
LONG WINAPI CrashHandler(EXCEPTION_POINTERS *ep)
LRESULT CALLBACK cbtproc(INT code, WPARAM wParam, LPARAM lParam)
void report_error(std::string error)
std::string api_version_to_string(int version)
int main(int argv, const char **argc)
GLuint GLenum GLenum transform
int run_main(int argv, const char **argc)
std::string get_os_name()
std::string to_string(T value)