dbghelp.hpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Copyright 2015 Klemens Morgenstern
  3. * Copyright 2016 Jorge Lodos
  4. * Copyright 2016 Andrey Semashev
  5. *
  6. * Distributed under the Boost Software License, Version 1.0.
  7. * See http://www.boost.org/LICENSE_1_0.txt
  8. */
  9. #ifndef BOOST_WINAPI_DBGHELP_HPP_INCLUDED_
  10. #define BOOST_WINAPI_DBGHELP_HPP_INCLUDED_
  11. #include <boost/winapi/basic_types.hpp>
  12. #if defined( BOOST_USE_WINDOWS_H )
  13. #if !defined( BOOST_WINAPI_IS_MINGW )
  14. #include <dbghelp.h>
  15. #else
  16. // In MinGW there is no dbghelp.h but an older imagehlp.h header defines some of the symbols from it.
  17. // Note that the user has to link with libimagehlp.a instead of libdbghelp.a for it to work.
  18. #include <imagehlp.h>
  19. #endif
  20. #endif
  21. #ifdef BOOST_HAS_PRAGMA_ONCE
  22. #pragma once
  23. #endif
  24. #if BOOST_WINAPI_PARTITION_DESKTOP
  25. // Some symbols declared below are not present in all versions of Windows SDK, MinGW and MinGW-w64.
  26. // dbghelp.h/imagehlp.h define the API_VERSION_NUMBER macro which we use to detect its version.
  27. // When the macro is not available we can only guess based on the compiler version or SDK type.
  28. #if defined(API_VERSION_NUMBER)
  29. #if API_VERSION_NUMBER >= 11
  30. // UnDecorateSymbolNameW available since Windows SDK 6.0A and MinGW-w64 (as of 2016-02-14)
  31. #define BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW
  32. #endif
  33. #elif defined(_MSC_VER) && _MSC_VER >= 1500
  34. // Until MSVC 9.0 Windows SDK was bundled in Visual Studio and didn't have UnDecorateSymbolNameW.
  35. // Supposedly, Windows SDK 6.0A was the first standalone one and it is used with MSVC 9.0.
  36. #define BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW
  37. #elif !defined(BOOST_WINAPI_IS_MINGW)
  38. // MinGW does not provide UnDecorateSymbolNameW (as of 2016-02-14)
  39. #define BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW
  40. #endif
  41. #if !defined( BOOST_USE_WINDOWS_H )
  42. extern "C" {
  43. struct API_VERSION;
  44. BOOST_SYMBOL_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
  45. UnDecorateSymbolName(
  46. boost::winapi::LPCSTR_ DecoratedName,
  47. boost::winapi::LPSTR_ UnDecoratedName,
  48. boost::winapi::DWORD_ UndecoratedLength,
  49. boost::winapi::DWORD_ Flags);
  50. #if defined( BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW )
  51. BOOST_SYMBOL_IMPORT boost::winapi::DWORD_ BOOST_WINAPI_WINAPI_CC
  52. UnDecorateSymbolNameW(
  53. boost::winapi::LPCWSTR_ DecoratedName,
  54. boost::winapi::LPWSTR_ UnDecoratedName,
  55. boost::winapi::DWORD_ UndecoratedLength,
  56. boost::winapi::DWORD_ Flags);
  57. #endif
  58. BOOST_SYMBOL_IMPORT API_VERSION* BOOST_WINAPI_WINAPI_CC
  59. ImagehlpApiVersion(BOOST_WINAPI_DETAIL_VOID);
  60. } // extern "C"
  61. #endif
  62. namespace boost {
  63. namespace winapi {
  64. #if defined( BOOST_USE_WINDOWS_H )
  65. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_COMPLETE_ = UNDNAME_COMPLETE;
  66. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_LEADING_UNDERSCORES_ = UNDNAME_NO_LEADING_UNDERSCORES;
  67. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MS_KEYWORDS_ = UNDNAME_NO_MS_KEYWORDS;
  68. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_FUNCTION_RETURNS_ = UNDNAME_NO_FUNCTION_RETURNS;
  69. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ALLOCATION_MODEL_ = UNDNAME_NO_ALLOCATION_MODEL;
  70. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ALLOCATION_LANGUAGE_ = UNDNAME_NO_ALLOCATION_LANGUAGE;
  71. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MS_THISTYPE_ = UNDNAME_NO_MS_THISTYPE;
  72. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_CV_THISTYPE_ = UNDNAME_NO_CV_THISTYPE;
  73. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_THISTYPE_ = UNDNAME_NO_THISTYPE;
  74. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ACCESS_SPECIFIERS_ = UNDNAME_NO_ACCESS_SPECIFIERS;
  75. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_THROW_SIGNATURES_ = UNDNAME_NO_THROW_SIGNATURES;
  76. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MEMBER_TYPE_ = UNDNAME_NO_MEMBER_TYPE;
  77. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_RETURN_UDT_MODEL_ = UNDNAME_NO_RETURN_UDT_MODEL;
  78. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_32_BIT_DECODE_ = UNDNAME_32_BIT_DECODE;
  79. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NAME_ONLY_ = UNDNAME_NAME_ONLY;
  80. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ARGUMENTS_ = UNDNAME_NO_ARGUMENTS;
  81. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_SPECIAL_SYMS_ = UNDNAME_NO_SPECIAL_SYMS;
  82. #else // defined( BOOST_USE_WINDOWS_H )
  83. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_COMPLETE_ = 0x00000000;
  84. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_LEADING_UNDERSCORES_ = 0x00000001;
  85. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MS_KEYWORDS_ = 0x00000002;
  86. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_FUNCTION_RETURNS_ = 0x00000004;
  87. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ALLOCATION_MODEL_ = 0x00000008;
  88. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ALLOCATION_LANGUAGE_ = 0x00000010;
  89. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MS_THISTYPE_ = 0x00000020;
  90. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_CV_THISTYPE_ = 0x00000040;
  91. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_THISTYPE_ = 0x00000060;
  92. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ACCESS_SPECIFIERS_ = 0x00000080;
  93. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_THROW_SIGNATURES_ = 0x00000100;
  94. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_MEMBER_TYPE_ = 0x00000200;
  95. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_RETURN_UDT_MODEL_ = 0x00000400;
  96. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_32_BIT_DECODE_ = 0x00000800;
  97. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NAME_ONLY_ = 0x00001000;
  98. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_ARGUMENTS_ = 0x00002000;
  99. BOOST_CONSTEXPR_OR_CONST DWORD_ UNDNAME_NO_SPECIAL_SYMS_ = 0x00004000;
  100. #endif // defined( BOOST_USE_WINDOWS_H )
  101. using ::UnDecorateSymbolName;
  102. #if defined( BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW )
  103. using ::UnDecorateSymbolNameW;
  104. #endif
  105. typedef struct BOOST_MAY_ALIAS API_VERSION {
  106. USHORT_ MajorVersion;
  107. USHORT_ MinorVersion;
  108. USHORT_ Revision;
  109. USHORT_ Reserved;
  110. } API_VERSION_, *LPAPI_VERSION_;
  111. BOOST_FORCEINLINE LPAPI_VERSION_ ImagehlpApiVersion()
  112. {
  113. return reinterpret_cast<LPAPI_VERSION_>(::ImagehlpApiVersion());
  114. }
  115. BOOST_FORCEINLINE DWORD_ undecorate_symbol_name(
  116. LPCSTR_ DecoratedName,
  117. LPSTR_ UnDecoratedName,
  118. DWORD_ UndecoratedLength,
  119. DWORD_ Flags)
  120. {
  121. return ::UnDecorateSymbolName(
  122. DecoratedName,
  123. UnDecoratedName,
  124. UndecoratedLength,
  125. Flags);
  126. }
  127. #if defined( BOOST_WINAPI_DETAIL_HAS_UNDECORATESYMBOLNAMEW )
  128. BOOST_FORCEINLINE DWORD_ undecorate_symbol_name(
  129. LPCWSTR_ DecoratedName,
  130. LPWSTR_ UnDecoratedName,
  131. DWORD_ UndecoratedLength,
  132. DWORD_ Flags)
  133. {
  134. return ::UnDecorateSymbolNameW(
  135. DecoratedName,
  136. UnDecoratedName,
  137. UndecoratedLength,
  138. Flags);
  139. }
  140. #endif
  141. }
  142. }
  143. #endif // BOOST_WINAPI_PARTITION_DESKTOP
  144. #endif // BOOST_WINAPI_DBGHELP_HPP_INCLUDED_