Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.8 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include <windows.h>
  8. #include "tier0/minidump.h"
  9. #include "tools_minidump.h"
  10. static bool g_bToolsWriteFullMinidumps = false;
  11. static ToolsExceptionHandler g_pCustomExceptionHandler = NULL;
  12. // --------------------------------------------------------------------------------- //
  13. // Internal helpers.
  14. // --------------------------------------------------------------------------------- //
  15. static void ToolsExceptionFilter( uint uStructuredExceptionCode, ExceptionInfo_t * pExceptionInfo, const char *pszFilenameSuffix )
  16. {
  17. // Non VMPI workers write a minidump and show a crash dialog like normal.
  18. uint32 iType = MINIDUMP_Normal;
  19. if ( g_bToolsWriteFullMinidumps )
  20. {
  21. iType |= MINIDUMP_WithDataSegs | MINIDUMP_WithIndirectlyReferencedMemory;
  22. }
  23. WriteMiniDumpUsingExceptionInfo( uStructuredExceptionCode, pExceptionInfo, iType, pszFilenameSuffix );
  24. }
  25. static void ToolsExceptionFilter_Custom( uint uStructuredExceptionCode, ExceptionInfo_t * pExceptionInfo, const char *pszFilenameSuffix )
  26. {
  27. // Run their custom handler.
  28. g_pCustomExceptionHandler( uStructuredExceptionCode, pExceptionInfo );
  29. }
  30. // --------------------------------------------------------------------------------- //
  31. // Interface functions.
  32. // --------------------------------------------------------------------------------- //
  33. void EnableFullMinidumps( bool bFull )
  34. {
  35. g_bToolsWriteFullMinidumps = bFull;
  36. }
  37. void SetupDefaultToolsMinidumpHandler()
  38. {
  39. MinidumpSetUnhandledExceptionFunction( ToolsExceptionFilter );
  40. }
  41. void SetupToolsMinidumpHandler( ToolsExceptionHandler fn )
  42. {
  43. g_pCustomExceptionHandler = fn;
  44. MinidumpSetUnhandledExceptionFunction( ToolsExceptionFilter_Custom );
  45. }