THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. ***************************************************************************/
// This method is to write mini dump of current process to // CppExceptionHandling.dmp file. LONG WINAPI WriteMiniDump(struct _EXCEPTION_POINTERS *ExceptionInfo) { // EXCEPTION_CONTINUE_SEARCH means it continue to // execute subsequent exception handlers. LONG rc = EXCEPTION_CONTINUE_SEARCH;
// Write the information into the dump if (MiniDumpWriteDump( GetCurrentProcess(), // Handle of process GetCurrentProcessId(), // Process Id hDumpFile, // Handle of dump file MiniDumpNormal, // Dump Level: Mini &ExInfo, // Exception information NULL, // User stream parameter NULL)) // Callback Parameter { rc = EXCEPTION_CONTINUE_SEARCH; } else { _tprintf(_T("MiniDumpWriteDump failed w/err 0x%08lxn"), GetLastError()); }
// Raise a fake exception for demo __try { printf("RaiseException: Raise an exceptionn"); RaiseException(1,0,0,NULL); } __except(EXCEPTION_EXECUTE_HANDLER) { printf("This is a exception handlern"); }
// Remove the vectored exception handler RemoveVectoredExceptionHandler(handler); }
#pragma endregion
int _tmain(int argc, _TCHAR* argv[]) { ThrowAndHandleVectoredException();