Source code of Windows XP (NT5)
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.

119 lines
2.9 KiB

  1. #ifndef DBG
  2. #define NETCFG_TRY try {
  3. #define NETCFG_CATCH(hr) ; } \
  4. catch (bad_alloc a) \
  5. { \
  6. hr = E_OUTOFMEMORY; \
  7. } \
  8. catch (HRESULT hrCaught) \
  9. { \
  10. hr = hrCaught; \
  11. } \
  12. catch (...) \
  13. { \
  14. hr = E_FAIL; \
  15. }
  16. #define NETCFG_CATCH_NOHR ; } \
  17. catch (bad_alloc a) \
  18. { \
  19. } \
  20. catch (HRESULT hrCaught) \
  21. { \
  22. }
  23. #define NETCFG_CATCH_AND_RETHROW ; } \
  24. catch (...) \
  25. { \
  26. throw; \
  27. }
  28. #else // #ifndef DBG
  29. #define NETCFG_TRY {
  30. #define NETCFG_CATCH(hr) ; }
  31. #define NETCFG_CATCH_NOHR ; }
  32. #define NETCFG_CATCH_AND_RETHROW ; }
  33. /*
  34. #define NETCFG_CATCH(hr) ; } \
  35. catch (bad_alloc a) \
  36. { \
  37. hr = E_OUTOFMEMORY; \
  38. TraceException(hr, "bad_alloc"); \
  39. AssertSzWithDbgPromptIgnore(FALSE, "A bad_alloc exception occurred"); \
  40. throw; \
  41. } \
  42. catch (HRESULT hrCaught) \
  43. { \
  44. TraceException(hr, "HRESULT"); \
  45. hr = hrCaught; \
  46. CHAR szTemp[MAX_PATH]; \
  47. sprintf(szTemp, "An HRESULT exception occurred (0x%08x)", hr); \
  48. AssertSzWithDbgPromptIgnore(FALSE, szTemp); \
  49. throw; \
  50. } \
  51. catch (...) \
  52. { \
  53. TraceException(E_FAIL, "HRESULT"); \
  54. hr = E_FAIL; \
  55. AssertSzWithDbgPromptIgnore(FALSE, "A general exception occurred."); \
  56. throw; \
  57. }
  58. #define NETCFG_CATCH_NOHR ; } \
  59. catch (bad_alloc a) \
  60. { \
  61. TraceException(E_OUTOFMEMORY, "bad_alloc"); \
  62. AssertSzWithDbgPromptIgnore(FALSE, "A bad_alloc exception occurred"); \
  63. throw; \
  64. } \
  65. catch (HRESULT hrCaught) \
  66. { \
  67. TraceException(hrCaught, "HRESULT"); \
  68. CHAR szTemp[MAX_PATH]; \
  69. sprintf(szTemp, "An HRESULT exception occurred (0x%08x)", hrCaught); \
  70. AssertSzWithDbgPromptIgnore(FALSE, szTemp); \
  71. throw; \
  72. }
  73. #define NETCFG_CATCH_AND_RETHROW } \
  74. catch (bad_alloc a) \
  75. { \
  76. TraceException(E_OUTOFMEMORY, "bad_alloc"); \
  77. AssertSzWithDbgPromptIgnore(FALSE, "A bad_alloc exception occurred"); \
  78. throw; \
  79. } \
  80. catch (HRESULT hrCaught) \
  81. { \
  82. TraceException(hrCaught, "HRESULT"); \
  83. CHAR szTemp[MAX_PATH]; \
  84. sprintf(szTemp, "An HRESULT exception occurred (0x%08x)", hrCaught); \
  85. AssertSzWithDbgPromptIgnore(FALSE, szTemp); \
  86. throw; \
  87. } \
  88. catch (...) \
  89. { \
  90. TraceException(E_FAIL, "Unknown"); \
  91. AssertSzWithDbgPromptIgnore(FALSE, "A bad_alloc exception occurred"); \
  92. throw; \
  93. }
  94. */
  95. #endif // ifndef DBG
  96. class NC_SEH_Exception
  97. {
  98. private:
  99. unsigned int m_uSECode;
  100. public:
  101. NC_SEH_Exception(unsigned int uSECode) : m_uSECode(uSECode) {}
  102. NC_SEH_Exception() {}
  103. ~NC_SEH_Exception() {}
  104. unsigned int getSeHNumber() { return m_uSECode; }
  105. };
  106. void __cdecl nc_trans_func( unsigned int uSECode, EXCEPTION_POINTERS* pExp );
  107. void EnableCPPExceptionHandling();
  108. void DisableCPPExceptionHandling();